[pLog-svn] r779 - in plugins/trunk: . nofollow nofollow/class
nofollow/class/action nofollow/locale nofollow/templates
recentcomments recentcomments/class recentcomments/class/action
recentcomments/locale recentcomments/templates recenttrackbacks
recenttrackbacks/class recenttrackbacks/class/action
recenttrackbacks/locale recenttrackbacks/templates
topcommentposts topcommentposts/class
topcommentposts/class/action topcommentposts/locale
topcommentposts/templates topcommentvisitors
topcommentvisitors/class topcommentvisitors/class/action
topcommentvisitors/locale topcommentvisitors/templates
topreadposts topreadposts/class topreadposts/class/action
topreadposts/locale topreadposts/templates toptrackbackposts
toptrackbackposts/class toptrackbackposts/class/action
toptrackbackposts/locale toptrackbackposts/templates
Oscar Renalias
oscar at renalias.net
Thu Jan 20 16:27:19 GMT 2005
great work! :)
Oscar
On 20 Jan 2005, at 18:06, mark at devel.plogworld.net wrote:
> Author: mark
> Date: 2005-01-20 16:06:26 +0000 (Thu, 20 Jan 2005)
> New Revision: 779
>
> Added:
> plugins/trunk/nofollow/
> plugins/trunk/nofollow/class/
> plugins/trunk/nofollow/class/action/
>
> plugins/trunk/nofollow/class/action/
> pluginnofollowconfigaction.class.php
>
> plugins/trunk/nofollow/class/action/
> pluginnofollowupdateconfigaction.class.php
> plugins/trunk/nofollow/locale/
> plugins/trunk/nofollow/locale/locale_en_UK.php
> plugins/trunk/nofollow/locale/locale_zh_TW.php
> plugins/trunk/nofollow/pluginnofollow.class.php
> plugins/trunk/nofollow/templates/
> plugins/trunk/nofollow/templates/nofollow.template
> plugins/trunk/recentcomments/
> plugins/trunk/recentcomments/class/
> plugins/trunk/recentcomments/class/action/
>
> plugins/trunk/recentcomments/class/action/
> pluginrecentcommentsconfigaction.class.php
>
> plugins/trunk/recentcomments/class/action/
> pluginrecentcommentsupdateconfigaction.class.php
> plugins/trunk/recentcomments/locale/
> plugins/trunk/recentcomments/locale/locale_en_UK.php
> plugins/trunk/recentcomments/locale/locale_zh_TW.php
> plugins/trunk/recentcomments/pluginrecentcomments.class.php
> plugins/trunk/recentcomments/templates/
> plugins/trunk/recentcomments/templates/recentcomments.template
> plugins/trunk/recenttrackbacks/
> plugins/trunk/recenttrackbacks/class/
> plugins/trunk/recenttrackbacks/class/action/
>
> plugins/trunk/recenttrackbacks/class/action/
> pluginrecenttrackbacksconfigaction.class.php
>
> plugins/trunk/recenttrackbacks/class/action/
> pluginrecenttrackbacksupdateconfigaction.class.php
> plugins/trunk/recenttrackbacks/locale/
> plugins/trunk/recenttrackbacks/locale/locale_en_UK.php
> plugins/trunk/recenttrackbacks/locale/locale_zh_TW.php
> plugins/trunk/recenttrackbacks/pluginrecenttrackbacks.class.php
> plugins/trunk/recenttrackbacks/templates/
> plugins/trunk/recenttrackbacks/templates/recenttrackbacks.template
> plugins/trunk/topcommentposts/
> plugins/trunk/topcommentposts/class/
> plugins/trunk/topcommentposts/class/action/
>
> plugins/trunk/topcommentposts/class/action/
> plugintopcommentpostsconfigaction.class.php
>
> plugins/trunk/topcommentposts/class/action/
> plugintopcommentpostsupdateconfigaction.class.php
> plugins/trunk/topcommentposts/locale/
> plugins/trunk/topcommentposts/locale/locale_en_UK.php
> plugins/trunk/topcommentposts/locale/locale_zh_TW.php
> plugins/trunk/topcommentposts/plugintopcommentposts.class.php
> plugins/trunk/topcommentposts/templates/
> plugins/trunk/topcommentposts/templates/topcommentposts.template
> plugins/trunk/topcommentvisitors/
> plugins/trunk/topcommentvisitors/class/
> plugins/trunk/topcommentvisitors/class/action/
>
> plugins/trunk/topcommentvisitors/class/action/
> plugintopcommentvisitorsconfigaction.class.php
>
> plugins/trunk/topcommentvisitors/class/action/
> plugintopcommentvisitorsupdateconfigaction.class.php
> plugins/trunk/topcommentvisitors/locale/
> plugins/trunk/topcommentvisitors/locale/locale_en_UK.php
> plugins/trunk/topcommentvisitors/locale/locale_zh_TW.php
> plugins/trunk/topcommentvisitors/plugintopcommentvisitors.class.php
> plugins/trunk/topcommentvisitors/templates/
>
> plugins/trunk/topcommentvisitors/templates/topcommentvisitors.template
> plugins/trunk/topreadposts/
> plugins/trunk/topreadposts/class/
> plugins/trunk/topreadposts/class/action/
>
> plugins/trunk/topreadposts/class/action/
> plugintopreadpostsconfigaction.class.php
>
> plugins/trunk/topreadposts/class/action/
> plugintopreadpostsupdateconfigaction.class.php
> plugins/trunk/topreadposts/locale/
> plugins/trunk/topreadposts/locale/locale_en_UK.php
> plugins/trunk/topreadposts/locale/locale_zh_TW.php
> plugins/trunk/topreadposts/plugintopreadposts.class.php
> plugins/trunk/topreadposts/templates/
> plugins/trunk/topreadposts/templates/topreadposts.template
> plugins/trunk/toptrackbackposts/
> plugins/trunk/toptrackbackposts/class/
> plugins/trunk/toptrackbackposts/class/action/
>
> plugins/trunk/toptrackbackposts/class/action/
> plugintoptrackbackpostsconfigaction.class.php
>
> plugins/trunk/toptrackbackposts/class/action/
> plugintoptrackbackpostsupdateconfigaction.class.php
> plugins/trunk/toptrackbackposts/locale/
> plugins/trunk/toptrackbackposts/locale/locale_en_UK.php
> plugins/trunk/toptrackbackposts/locale/locale_zh_TW.php
> plugins/trunk/toptrackbackposts/plugintoptrackbackposts.class.php
> plugins/trunk/toptrackbackposts/templates/
> plugins/trunk/toptrackbackposts/templates/toptrackbackposts.template
> Log:
> Plugins for 1.0
>
> Added:
> plugins/trunk/nofollow/class/action/
> pluginnofollowconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/nofollow/class/action/
> pluginnofollowconfigaction.class.php 2005-01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/nofollow/class/action/
> pluginnofollowconfigaction.class.php 2005-01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,32 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php"
> );
> +
> + /**
> + * shows a form with the current configuration
> + */
> + class PluginNoFollowConfigAction extends AdminAction
> + {
> +
> + function PluginNoFollowConfigAction( $actionInfo, $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function perform()
> + {
> + // load some configuration settings
> + $blogSettings = $this->_blogInfo->getSettings();
> + $pluginEnabled = $blogSettings->getValue(
> "plugin_nofollow_enabled" );
> +
> + // create a view and export the settings to the template
> + $this->_view = new AdminPluginTemplatedView( $this->_blogInfo,
> "nofollow", "nofollow", true );
> + $this->_view->setValue( "pluginEnabled", $pluginEnabled );
> +
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/nofollow/class/action/
> pluginnofollowupdateconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/nofollow/class/action/
> pluginnofollowupdateconfigaction.class.php 2005-01-20 16:04:28 UTC
> (rev 778)
> +++
> plugins/trunk/nofollow/class/action/
> pluginnofollowupdateconfigaction.class.php 2005-01-20 16:06:26 UTC
> (rev 779)
> @@ -0,0 +1,56 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
> +
> + /**
> + * updates the plugin configuration
> + */
> + class PluginNoFollowUpdateConfigAction extends AdminAction
> + {
> + var $_pluginEnabled;
> +
> + function PluginNoFollowUpdateConfigAction( $actionInfo, $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function validate()
> + {
> + $this->_pluginEnabled = $this->_request->getValue(
> "pluginEnabled" );
> + $this->_pluginEnabled = ($this->_pluginEnabled != "" );
> +
> + return true;
> + }
> +
> + function perform()
> + {
> + // and check which smiley set we should be using, or if
> none, then the default one
> + $blogSettings = $this->_blogInfo->getSettings();
> + $blogSettings->setValue( "plugin_nofollow_enabled",
> $this->_pluginEnabled );
> + $this->_blogInfo->setSettings( $blogSettings );
> +
> + // save the blogs settings
> + $blogs = new Blogs();
> + if( !$blogs->updateBlog( $this->_blogInfo->getId(),
> $this->_blogInfo )) {
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("error_updating_settings"));
> + $this->setCommonData();
> +
> + return false;
> + }
> +
> + // if everything went ok...
> + $this->_blogInfo->setSettings( $blogSettings );
> + $this->_session->setValue( "blogInfo", $this->_blogInfo );
> + $this->saveSession();
> +
> + $this->_view = new AdminMessageView( $this->_blogInfo );
> + $this->_view->setMessage(
> $this->_locale->tr("nofollow_settings_saved_ok"));
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/nofollow/locale/locale_en_UK.php
> ===================================================================
> --- plugins/trunk/nofollow/locale/locale_en_UK.php 2005-01-20 16:04:28
> UTC (rev 778)
> +++ plugins/trunk/nofollow/locale/locale_en_UK.php 2005-01-20 16:06:26
> UTC (rev 779)
> @@ -0,0 +1,6 @@
> +<?php
> +$messages["nofollow_plugin_configuration"] = "Configuration this
> plugin";
> +$messages["nofollow_plugin_enabled"] = "Enable this plugin";
> +$messages["nofollow_plugin"] = "No Follow Plugin";
> +$messages["nofollow_settings_saved_ok"] = "No Follow settings saved
> successfully!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/nofollow/locale/locale_zh_TW.php
> ===================================================================
> --- plugins/trunk/nofollow/locale/locale_zh_TW.php 2005-01-20 16:04:28
> UTC (rev 778)
> +++ plugins/trunk/nofollow/locale/locale_zh_TW.php 2005-01-20 16:06:26
> UTC (rev 779)
> @@ -0,0 +1,6 @@
> +<?php
> +$messages["nofollow_plugin_configuration"] = "夿ç¨å¼è¨å®";
> +$messages["nofollow_plugin_enabled"] = "åå夿ç¨å¼";
> +$messages["nofollow_plugin"] = "No Follow 夿ç¨å¼";
> +$messages["nofollow_settings_saved_ok"] = "No Follow
> è¨å®å²åæåã";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/nofollow/pluginnofollow.class.php
> ===================================================================
> --- plugins/trunk/nofollow/pluginnofollow.class.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/nofollow/pluginnofollow.class.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,88 @@
> +<?php
> + include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
> + include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php"
> );
> + include_once(
> PLOG_CLASS_PATH."class/plugin/eventpluginbase.class.php" );
> +
> + class PluginNoFollow extends PluginBase
> + {
> + function PluginNoFollow()
> + {
> + $this->PluginBase();
> +
> + $this->id = "nofollow";
> + $this->author = "Minstrel Chiu";
> + $this->desc = "Prevents comment spams with 'rel=nofollow'";
> +
> + $this->locales = Array( "en_UK" , "zh_TW" );
> +
> + $this->init();
> + }
> +
> + function init()
> + {
> + $this->registerAdminAction( "nofollow",
> "PluginNoFollowConfigAction" );
> + $this->registerAdminAction( "updateNoFollowConfig",
> "PluginNoFollowUpdateConfigAction" );
> +
> + $menu =& Menu::getMenu();
> + if( !$menu->entryExists(
> "/menu/controlCenter/manageSpamActivities" ))
> + $this->addMenuEntry( "/menu/controlCenter",
> "manageSpamActivities", "", "", true, false );
> + $this->addMenuEntry(
> "/menu/controlCenter/manageSpamActivities", "NoFollow",
> "?op=nofollow", "" );
> +
> + $this->registerNotification( EVENT_PRE_COMMENT_ADD );
> + }
> +
> + function process($eventType, $params)
> + {
> + if ( $eventType != EVENT_PRE_COMMENT_ADD )
> + return true;
> +
> + $blogSettings = $this->blogInfo->getSettings();
> + $pluginEnabled = $blogSettings->getValue(
> "plugin_nofollow_enabled" );
> + if ( $pluginEnabled != 1 )
> + return true;
> +
> + $comment = $params["comment"];
> +
> + $text = $comment->getText();
> + $text = $this->nofollow($text);
> +
> + $comment->setText($text);
> +
> + $params["comment"] = $comment;
> +
> + return true;
> + }
> +
> + function nofollow($text)
> + {
> + if(!isset($text))
> + return $text;
> +
> + return preg_replace_callback('#<a\s([^>]*\s*href\s*=[^>]*)>#i',
> array(&$this, 'nofollow_process'), $text);
> + }
> +
> + function nofollow_process($matches)
> + {
> + $text = $matches[1];
> +
> + preg_match_all('/[^=[:space:]]*\s*=\s*"[^"]*"|[^=[:
> space:]]*\s*=\s*\'[^\']*\'|[^=[:space:]]*\s*=[^[:space:]]*/', $text,
> $attr);
> + $rel_arr = preg_grep('/^rel\s*=/i', $attr[0]);
> +
> + if(count($rel_arr)>0)
> + $rel = array_pop($rel_arr);
> +
> + if($rel)
> + {
> + $rel = preg_replace('/^(rel\s*=\s*[\'"]?)/i', '\1nofollow ',
> $rel);
> + }
> + else
> + {
> + $rel = 'rel="nofollow"';
> + }
> +
> + $attr = preg_grep('/^rel\s*=/i', $attr[0], PREG_GREP_INVERT);
> +
> + return '<a ' . join(' ', $attr) . ' ' . $rel . '>';
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/nofollow/templates/nofollow.template
> ===================================================================
> --- plugins/trunk/nofollow/templates/nofollow.template 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/nofollow/templates/nofollow.template 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,11 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"
> showOpt=NoFollow title=$locale->tr("nofollow_plugin")}
> +<form name="nofollowPluginConfig" method="post">
> + {$locale->tr("nofollow_plugin_enabled")}
> + <input type="checkbox" name="pluginEnabled" {if $pluginEnabled}
> checked="checked" {/if} value="1" /><br/>
> + <br/>
> + <input type="hidden" name="op" value="updateNoFollowConfig" />
> + <input type="submit" name="{$locale->tr("update_settings")}"
> value="{$locale->tr("update")}" />
> +</form>
> +{include file="$admintemplatepath/footernavigation.template"}
> +{include file="$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> Added:
> plugins/trunk/recentcomments/class/action/
> pluginrecentcommentsconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/recentcomments/class/action/
> pluginrecentcommentsconfigaction.class.php 2005-01-20 16:04:28 UTC
> (rev 778)
> +++
> plugins/trunk/recentcomments/class/action/
> pluginrecentcommentsconfigaction.class.php 2005-01-20 16:06:26 UTC
> (rev 779)
> @@ -0,0 +1,35 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php"
> );
> +
> + /**
> + * shows a form with the current configuration
> + */
> + class PluginRecentCommentsConfigAction extends AdminAction
> + {
> +
> + function PluginRecentCommentsConfigAction( $actionInfo, $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function perform()
> + {
> + // load some configuration settings
> + $blogSettings = $this->_blogInfo->getSettings();
> + $pluginEnabled = $blogSettings->getValue(
> "plugin_recentcomments_enabled" );
> + $maxComments = $blogSettings->getValue(
> "plugin_recentcomments_maxcomments" );
> + if ($maxComments == "") $maxComments = 10;
> +
> + // create a view and export the settings to the template
> + $this->_view = new AdminPluginTemplatedView( $this->_blogInfo,
> "recentcomments", "recentcomments", true );
> + $this->_view->setValue( "pluginEnabled", $pluginEnabled );
> + $this->_view->setValue( "maxComments", $maxComments );
> +
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/recentcomments/class/action/
> pluginrecentcommentsupdateconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/recentcomments/class/action/
> pluginrecentcommentsupdateconfigaction.class.php 2005-01-20 16:04:28
> UTC (rev 778)
> +++
> plugins/trunk/recentcomments/class/action/
> pluginrecentcommentsupdateconfigaction.class.php 2005-01-20 16:06:26
> UTC (rev 779)
> @@ -0,0 +1,67 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
> +
> + /**
> + * updates the plugin configuration
> + */
> + class PluginRecentCommentsUpdateConfigAction extends AdminAction
> + {
> + var $_pluginEnabled;
> + var $_maxComments;
> +
> + function PluginRecentCommentsUpdateConfigAction( $actionInfo,
> $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function validate()
> + {
> + $this->_pluginEnabled = $this->_request->getValue(
> "pluginEnabled" );
> + $this->_pluginEnabled = ($this->_pluginEnabled != "" );
> + $this->_maxComments = $this->_request->getValue(
> "maxComments" );
> + if( $this->_maxComments <= 0 ) {
> +
> +
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("recentcomments_error_maxcomments"));
> + $this->setCommonData();
> + return false;
> + }
> +
> + return true;
> + }
> +
> + function perform()
> + {
> + // and check which smiley set we should be using, or if
> none, then the default one
> + $blogSettings = $this->_blogInfo->getSettings();
> + $blogSettings->setValue( "plugin_recentcomments_enabled",
> $this->_pluginEnabled );
> + $blogSettings->setValue(
> "plugin_recentcomments_maxcomments", $this->_maxComments );
> + $this->_blogInfo->setSettings( $blogSettings );
> +
> + // save the blogs settings
> + $blogs = new Blogs();
> + if( !$blogs->updateBlog( $this->_blogInfo->getId(),
> $this->_blogInfo )) {
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("error_updating_settings"));
> + $this->setCommonData();
> +
> + return false;
> + }
> +
> + // if everything went ok...
> + $this->_blogInfo->setSettings( $blogSettings );
> + $this->_session->setValue( "blogInfo", $this->_blogInfo );
> + $this->saveSession();
> +
> + $this->_view = new AdminMessageView( $this->_blogInfo );
> + $this->_view->setMessage(
> $this->_locale->tr("recentcomments_settings_saved_ok"));
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/recentcomments/locale/locale_en_UK.php
> ===================================================================
> --- plugins/trunk/recentcomments/locale/locale_en_UK.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/recentcomments/locale/locale_en_UK.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["recentcomments_maxcomments"] = "Maximum Showed Comments";
> +$messages["recentcomments_plugin_configuration"] = "Configuration
> this plugin";
> +$messages["recentcomments_plugin_enabled"] = "Enable this plugin";
> +$messages["recentcomments_plugin"] = "Recent Comments Plugin";
> +$messages["recentcomments_settings_saved_ok"] = "Recent Comments
> settings saved successfully!";
> +$messages["recentcomments_error_maxcomments"] = "Maximum Showed
> Comments Should >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/recentcomments/locale/locale_zh_TW.php
> ===================================================================
> --- plugins/trunk/recentcomments/locale/locale_zh_TW.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/recentcomments/locale/locale_zh_TW.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["recentcomments_maxcomments"] = "ææ°è¿´é¿é¡¯ç¤ºæ¸é";
> +$messages["recentcomments_plugin_configuration"] =
> "夿ç¨å¼è¨å®";
> +$messages["recentcomments_plugin_enabled"] = "åå夿ç¨å¼";
> +$messages["recentcomments_plugin"] = "æè¿è¿´é¿å¤æç¨å¼";
> +$messages["recentcomments_settings_saved_ok"] =
> "æè¿è¿´é¿è¨å®å²åæåã";
> +$messages["recentcomments_error_maxcomments"] =
> "ææ°è¿´é¿é¡¯ç¤ºæ¸éå¿
> é è¦ >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/recentcomments/pluginrecentcomments.class.php
> ===================================================================
> ---
> plugins/trunk/recentcomments/pluginrecentcomments.class.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/recentcomments/pluginrecentcomments.class.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,125 @@
> +<?php
> +
> + include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php"
> );
> + include_once(
> PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
> + include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
> +
> + /**
> + * Plugin that offers features to return a recent article
> comments from the current blog
> + */
> + class PluginRecentComments extends PluginBase
> + {
> + var $prefix;
> + var $pluginEnabled;
> + var $maxComments;
> +
> + function PluginRecentComments()
> + {
> + $this->PluginBase();
> +
> + $this->id = "recentcomments";
> + $this->author = "Mark Wu";
> + $this->desc = "This plugin offers the most recently
> article comments. Usage as follow:<br /><br />Add the following code
> to header.template<br /><br /><strong><p><br />{assign
> var=comments value=\$recentcomments->getRecentComments()}<br
> />{foreach from=\$comments item=comment}<br />{assign var=postid
> value=\$comment->getArticleId()}<br />{assign var=post
> value=\$recentcomments->getCommentArticle(\$postid)}<br />{if
> \$comment->getUserUrl()}<br /><li><a
> title="{\$comment->getText()|truncate:150:"..."
> |escape}"
> href="{\$comment->getUserUrl()}">{\$comment->
> getUsername()}</a> &gt;&gt; <a
> href="{\$url->postPermalink(\$post)}">{\$post->
> getTopic()}</a></li> <br />{else}<br /><li><a
> title="{\$comment->getText()|truncate:150:"..."
> |escape}"
> href="{\$url->postPermalink(\$post)}">{\$comment->
> getUsername()}</a
> > &gt;&gt; <a
> href="{\$url->postPermalink(\$post)}">{\$post->
> getTopic()}</a></li><br />{/if}<br />{/foreach}<br
> /></p></strong><br /><br />You can use <br /><br
> /><strong>getRecentComments(5)</strong> to get recent 5 comments. The
> default view is BLOG. <br /><strong>getRecentComments(10,
> 'SITE')</strong> to get recent 10 comments from SITE view. It is very
> convenient for pLog Host Provider.<br /><br />";
> +
> + $config =& Config::getConfig();
> + $this->prefix = $config->getValue('db_prefix');
> +
> + $this->locales = Array( "en_UK" , "zh_TW" );
> +
> + $this->init();
> + }
> +
> + function init()
> + {
> + $this->registerAdminAction( "recentcomments",
> "PluginRecentCommentsConfigAction" );
> + $this->registerAdminAction( "updateRecentCommentsConfig",
> "PluginRecentCommentsUpdateConfigAction" );
> +
> + $menu =& Menu::getMenu();
> + if( !$menu->entryExists(
> "/menu/controlCenter/manageRecentActivities" ))
> + $this->addMenuEntry( "/menu/controlCenter",
> "manageRecentActivities", "", "", true, false );
> + $this->addMenuEntry(
> "/menu/controlCenter/manageRecentActivities", "RecentComments",
> "?op=recentcomments", "" );
> + }
> +
> + function register()
> + {
> + $blogSettings = $this->blogInfo->getSettings();
> + $this->pluginEnabled = $blogSettings->getValue(
> "plugin_recentcomments_enabled" );
> + $this->maxComments = $blogSettings->getValue(
> "plugin_recentcomments_maxcomments" );
> + }
> +
> + function isEnabled()
> + {
> + return $this->pluginEnabled;
> + }
> +
> + /**
> + * Returns the recent comments object of current blog
> + */
> + function getRecentComments($maxComments = 0, $based = 'BLOG')
> + {
> + $comments = new ArticleComments();
> + $blogId = $this->blogInfo->getId();
> +
> + if ($based == 'BLOG') {
> + $query = "SELECT ".$this->prefix."articles_comments.*
> FROM ".$this->prefix."articles_comments, ".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."articles_comments.article_id =
> ".$this->prefix."articles.id AND ".$this->prefix."articles.blog_id =
> ".$blogId." AND ".$this->prefix."articles.status=1";
> + $query .= " AND
> ".$this->prefix."articles_comments.status = 0";
> + $query .= " ORDER BY
> ".$this->prefix."articles_comments.date DESC";
> + } elseif ($based == 'SITE') {
> + $query = "SELECT ".$this->prefix."articles_comments.*
> FROM ".$this->prefix."articles_comments, ".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."articles_comments.article_id =
> ".$this->prefix."articles.id AND ".$this->prefix."articles.status=1";
> + $query .= " AND
> ".$this->prefix."articles_comments.status = 0";
> + $query .= " ORDER BY
> ".$this->prefix."articles_comments.date DESC";
> + } else {
> + return false;
> + }
> +
> + if( $maxComments > 0 )
> + {
> + $query .= " LIMIT " . $maxComments;
> + } else {
> + $query .= " LIMIT " . $this->maxComments;
> + }
> +
> + $result = $comments->_db->Execute( $query );
> +
> + if( !$result )
> + return false;
> +
> + $recentcomments = Array();
> + while( $row = $result->FetchRow()) {
> + array_push( $recentcomments,
> $comments->_fillCommentInformation($row));
> + }
> +
> + return $recentcomments;
> + }
> +
> + function getArticle( $artId )
> + {
> + $articles = new Articles();
> + $blogId = $this->blogInfo->getId();
> +
> + $query = "SELECT * FROM ".$this->prefix."articles WHERE
> id = ".$artId;
> +
> + $query .= " AND blog_id = ".$blogId;
> +
> + $query .= ";";
> +
> + // we send the query and then fetch the first array with
> the result
> + $result = $articles->_db->Execute( $query );
> +
> + if( $result == false )
> + return false;
> +
> + if ( $result->RecordCount() == 0)
> + return false;
> +
> + $row = $result->FetchRow( $result );
> +
> + $article = $articles->_fillArticleInformation( $row );
> +
> + return $article;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/recentcomments/templates/recentcomments.template
> ===================================================================
> ---
> plugins/trunk/recentcomments/templates/recentcomments.template 2005
> -01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/recentcomments/templates/recentcomments.template 2005
> -01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,16 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"
> showOpt=RecentComments title=$locale->tr("recentcomments_plugin")}
> +<form name="recentcommentsPluginConfig" method="post">
> + {$locale->tr("recentcomments_plugin_enabled")}
> + <input type="checkbox" name="pluginEnabled" {if $pluginEnabled}
> checked="checked" {/if} value="1" /><br/>
> + <fieldset>
> + <legend>{$locale->tr("recentcomments_plugin_configuration")}</legend>
> + {$locale->tr("recentcomments_maxcomments")}
> + <input type="text" name="maxComments" value="{$maxComments}"
> width="10" />
> + </fieldset>
> + <br/>
> + <input type="hidden" name="op" value="updateRecentCommentsConfig" />
> + <input type="submit" name="{$locale->tr("update_settings")}"
> value="{$locale->tr("update")}" />
> +</form>
> +{include file="$admintemplatepath/footernavigation.template"}
> +{include file="$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> Added:
> plugins/trunk/recenttrackbacks/class/action/
> pluginrecenttrackbacksconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/recenttrackbacks/class/action/
> pluginrecenttrackbacksconfigaction.class.php 2005-01-20 16:04:28 UTC
> (rev 778)
> +++
> plugins/trunk/recenttrackbacks/class/action/
> pluginrecenttrackbacksconfigaction.class.php 2005-01-20 16:06:26 UTC
> (rev 779)
> @@ -0,0 +1,35 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php"
> );
> +
> + /**
> + * shows a form with the current configuration
> + */
> + class PluginRecentTrackbacksConfigAction extends AdminAction
> + {
> +
> + function PluginRecentTrackbacksConfigAction( $actionInfo, $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function perform()
> + {
> + // load some configuration settings
> + $blogSettings = $this->_blogInfo->getSettings();
> + $pluginEnabled = $blogSettings->getValue(
> "plugin_recenttrackbacks_enabled" );
> + $maxTrackbacks = $blogSettings->getValue(
> "plugin_recenttrackbacks_maxtrackbacks" );
> + if ($maxTrackbacks == "") $maxTrackbacks = 10;
> +
> + // create a view and export the settings to the template
> + $this->_view = new AdminPluginTemplatedView( $this->_blogInfo,
> "recenttrackbacks", "recenttrackbacks", true );
> + $this->_view->setValue( "pluginEnabled", $pluginEnabled );
> + $this->_view->setValue( "maxTrackbacks", $maxTrackbacks );
> +
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/recenttrackbacks/class/action/
> pluginrecenttrackbacksupdateconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/recenttrackbacks/class/action/
> pluginrecenttrackbacksupdateconfigaction.class.php 2005-01-20 16:04:28
> UTC (rev 778)
> +++
> plugins/trunk/recenttrackbacks/class/action/
> pluginrecenttrackbacksupdateconfigaction.class.php 2005-01-20 16:06:26
> UTC (rev 779)
> @@ -0,0 +1,67 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
> +
> + /**
> + * updates the plugin configuration
> + */
> + class PluginRecentTrackbacksUpdateConfigAction extends AdminAction
> + {
> + var $_pluginEnabled;
> + var $_maxTrackbacks;
> +
> + function PluginRecentTrackbacksUpdateConfigAction( $actionInfo,
> $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function validate()
> + {
> + $this->_pluginEnabled = $this->_request->getValue(
> "pluginEnabled" );
> + $this->_pluginEnabled = ($this->_pluginEnabled != "" );
> + $this->_maxTrackbacks = $this->_request->getValue(
> "maxTrackbacks" );
> + if( $this->_maxTrackbacks <= 0 ) {
> +
> +
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("recenttrackbacks_error_maxtrackbacks"));
> + $this->setCommonData();
> + return false;
> + }
> +
> + return true;
> + }
> +
> + function perform()
> + {
> + // and check which smiley set we should be using, or if
> none, then the default one
> + $blogSettings = $this->_blogInfo->getSettings();
> + $blogSettings->setValue(
> "plugin_recenttrackbacks_enabled", $this->_pluginEnabled );
> + $blogSettings->setValue(
> "plugin_recenttrackbacks_maxtrackbacks", $this->_maxTrackbacks );
> + $this->_blogInfo->setSettings( $blogSettings );
> +
> + // save the blogs settings
> + $blogs = new Blogs();
> + if( !$blogs->updateBlog( $this->_blogInfo->getId(),
> $this->_blogInfo )) {
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("error_updating_settings"));
> + $this->setCommonData();
> +
> + return false;
> + }
> +
> + // if everything went ok...
> + $this->_blogInfo->setSettings( $blogSettings );
> + $this->_session->setValue( "blogInfo", $this->_blogInfo );
> + $this->saveSession();
> +
> + $this->_view = new AdminMessageView( $this->_blogInfo );
> + $this->_view->setMessage(
> $this->_locale->tr("recenttrackbacks_settings_saved_ok"));
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/recenttrackbacks/locale/locale_en_UK.php
> ===================================================================
> --- plugins/trunk/recenttrackbacks/locale/locale_en_UK.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/recenttrackbacks/locale/locale_en_UK.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["recenttrackbacks_maxtrackbacks"] = "Maximum Showed
> Trackbacks";
> +$messages["recenttrackbacks_plugin_configuration"] = "Configuration
> this plugin";
> +$messages["recenttrackbacks_plugin_enabled"] = "Enable this plugin";
> +$messages["recenttrackbacks_plugin"] = "Recent Trackbacks Plugin";
> +$messages["recenttrackbacks_settings_saved_ok"] = "Recent Trackbacks
> settings saved successfully!";
> +$messages["recenttrackbacks_error_maxtrackbacks"] = "Maximum Showed
> Trackbacks Should >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/recenttrackbacks/locale/locale_zh_TW.php
> ===================================================================
> --- plugins/trunk/recenttrackbacks/locale/locale_zh_TW.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/recenttrackbacks/locale/locale_zh_TW.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["recenttrackbacks_maxtrackbacks"] =
> "æè¿å¼ç¨é¡¯ç¤ºæ¸é";
> +$messages["recenttrackbacks_plugin_configuration"] =
> "夿ç¨å¼è¨å®";
> +$messages["recenttrackbacks_plugin_enabled"] = "åå夿ç¨å¼";
> +$messages["recenttrackbacks_plugin"] = "æè¿å¼ç¨å¤æç¨å¼";
> +$messages["recenttrackbacks_settings_saved_ok"] =
> "æè¿å¼ç¨è¨å®å²åæåã";
> +$messages["recenttrackbacks_error_maxtrackbacks"] =
> "æè¿å¼ç¨é¡¯ç¤ºæ¸éå¿
> é è¦ >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/recenttrackbacks/pluginrecenttrackbacks.class.php
> ===================================================================
> ---
> plugins/trunk/recenttrackbacks/pluginrecenttrackbacks.class.php 2005
> -01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/recenttrackbacks/pluginrecenttrackbacks.class.php 2005
> -01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,123 @@
> +<?php
> +
> + include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php"
> );
> + include_once(
> PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
> + include_once( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
> +
> + /**
> + * Plugin that offers features to return a recent trackbacks from
> the current blog
> + */
> + class PluginRecentTrackbacks extends PluginBase
> + {
> + var $prefix;
> + var $pluginEnabled;
> + var $maxTrackbacks;
> +
> + function PluginRecentTrackbacks()
> + {
> + $this->PluginBase();
> +
> + $this->id = "recenttrackbacks";
> + $this->author = "Mark Wu";
> + $this->desc = "This plugin offers the most recently
> article trackbacks. Usage as follow:<br /><br />Add the following code
> to header.template<br /><br /><strong><p><br />{assign
> var=trackbacks value=\$recenttrackbacks->getRecentTrackbacks()}<br
> />{foreach from=\$trackbacks item=trackback}<br />{assign var=postid
> value=\$trackback->getArticleId()}<br />{assign var=post
> value=\$recenttrackbacks->getTrackbackArticle(\$postid)}<br
> /><li><a title="{\$trackback->getTitle()}"
> href="{\$trackback->getUrl()}">{\$trackback->
> getBlogName()}</a> &gt;&gt; <a
> href="{\$url->postPermalink(\$post)}">{\$post->
> getTopic()}</a></li><br />{/foreach}<br
> /></p></strong><br /><br />You can use <br /><br
> /><strong>getRecentTrackbacks(5)</strong> to get recent 5 trackbacks.
> The default view is BLOG. <br /><strong>getRecentTrackbacks(10,
> 'SITE')</strong> to get recent 10 trackbacks fr
> om SITE view. It is very convenient for pLog Host Provider.<br /><br
> />";
> +
> + $config =& Config::getConfig();
> + $this->prefix = $config->getValue('db_prefix');
> +
> + $this->locales = Array( "en_UK" , "zh_TW" );
> +
> + $this->init();
> +
> + }
> +
> + function init()
> + {
> + $this->registerAdminAction( "recenttrackbacks",
> "PluginRecentTrackbacksConfigAction" );
> + $this->registerAdminAction( "updateRecentTrackbacksConfig",
> "PluginRecentTrackbacksUpdateConfigAction" );
> +
> + $menu =& Menu::getMenu();
> + if( !$menu->entryExists(
> "/menu/controlCenter/manageRecentActivities" ))
> + $this->addMenuEntry( "/menu/controlCenter",
> "manageRecentActivities", "", "", true, false );
> + $this->addMenuEntry(
> "/menu/controlCenter/manageRecentActivities", "RecentTrackbacks",
> "?op=recenttrackbacks", "" );
> + }
> +
> + function register()
> + {
> + $blogSettings = $this->blogInfo->getSettings();
> + $this->pluginEnabled = $blogSettings->getValue(
> "plugin_recenttrackbacks_enabled" );
> + $this->maxTrackbacks = $blogSettings->getValue(
> "plugin_recenttrackbacks_maxtrackbacks" );
> + }
> +
> + function isEnabled()
> + {
> + return $this->pluginEnabled;
> + }
> +
> + /**
> + * Returns the recent trackbacks object of current blog
> + */
> + function getRecentTrackbacks($maxTrackbacks = 0, $based =
> 'BLOG')
> + {
> + $trackbacks = new Trackbacks();
> + $blogId = $this->blogInfo->getId();
> +
> + if ($based == 'BLOG') {
> + $query = "SELECT ".$this->prefix."trackbacks.* FROM
> ".$this->prefix."trackbacks, ".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."trackbacks.article_id = ".$this->prefix."articles.id
> AND ".$this->prefix."articles.blog_id = ".$blogId." AND
> ".$this->prefix."articles.status = 1";
> + $query .= " ORDER BY ".$this->prefix."trackbacks.date
> DESC";
> + } elseif ($based == 'SITE') {
> + $query = "SELECT ".$this->prefix."trackbacks.* FROM
> ".$this->prefix."trackbacks, ".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."trackbacks.article_id = ".$this->prefix."articles.id
> AND ".$this->prefix."articles.status = 1";
> + $query .= " ORDER BY ".$this->prefix."trackbacks.date
> DESC";
> + } else {
> + return false;
> + }
> +
> + if( $maxTrackbacks > 0 )
> + {
> + $query .= " LIMIT " . $maxTrackbacks;
> + } else {
> + $query .= " LIMIT " . $this->maxTrackbacks;
> + }
> +
> + $result = $trackbacks->_db->Execute( $query );
> +
> + if( !$result )
> + return false;
> +
> + $recenttrackbacks = Array();
> + while( $row = $result->FetchRow()) {
> + array_push( $recenttrackbacks,
> $trackbacks->_fillTrackbackInformation($row));
> + }
> +
> + return $recenttrackbacks;
> + }
> +
> + function getArticle( $artId )
> + {
> + $articles = new Articles();
> + $blogId = $this->blogInfo->getId();
> +
> + $query = "SELECT * FROM ".$this->prefix."articles WHERE
> id = ".$artId;
> +
> + $query .= " AND blog_id = ".$blogId;
> +
> + $query .= ";";
> +
> + // we send the query and then fetch the first array with
> the result
> + $result = $articles->_db->Execute( $query );
> +
> + if( $result == false )
> + return false;
> +
> + if ( $result->RecordCount() == 0)
> + return false;
> +
> + $row = $result->FetchRow( $result );
> +
> + $article = $articles->_fillArticleInformation( $row );
> +
> + return $article;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/recenttrackbacks/templates/recenttrackbacks.template
> ===================================================================
> ---
> plugins/trunk/recenttrackbacks/templates/recenttrackbacks.template
> 2005-01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/recenttrackbacks/templates/recenttrackbacks.template
> 2005-01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,16 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"
> showOpt=RecentTrackbacks title=$locale->tr("recenttrackbacks_plugin")}
> +<form name="recenttrackbacksPluginConfig" method="post">
> + {$locale->tr("recenttrackbacks_plugin_enabled")}
> + <input type="checkbox" name="pluginEnabled" {if $pluginEnabled}
> checked="checked" {/if} value="1" /><br/>
> + <fieldset>
> +
> <legend>{$locale->tr("recenttrackbacks_plugin_configuration")}</
> legend>
> + {$locale->tr("recenttrackbacks_maxtrackbacks")}
> + <input type="text" name="maxTrackbacks" value="{$maxTrackbacks}"
> width="10" />
> + </fieldset>
> + <br/>
> + <input type="hidden" name="op" value="updateRecentTrackbacksConfig"
> />
> + <input type="submit" name="{$locale->tr("update_settings")}"
> value="{$locale->tr("update")}" />
> +</form>
> +{include file="$admintemplatepath/footernavigation.template"}
> +{include file="$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> Added:
> plugins/trunk/topcommentposts/class/action/
> plugintopcommentpostsconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/topcommentposts/class/action/
> plugintopcommentpostsconfigaction.class.php 2005-01-20 16:04:28 UTC
> (rev 778)
> +++
> plugins/trunk/topcommentposts/class/action/
> plugintopcommentpostsconfigaction.class.php 2005-01-20 16:06:26 UTC
> (rev 779)
> @@ -0,0 +1,35 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php"
> );
> +
> + /**
> + * shows a form with the current configuration
> + */
> + class PluginTopCommentPostsConfigAction extends AdminAction
> + {
> +
> + function PluginTopCommentPostsConfigAction( $actionInfo, $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function perform()
> + {
> + // load some configuration settings
> + $blogSettings = $this->_blogInfo->getSettings();
> + $pluginEnabled = $blogSettings->getValue(
> "plugin_topcommentposts_enabled" );
> + $maxPosts = $blogSettings->getValue(
> "plugin_topcommentposts_maxposts" );
> + if ($maxPosts == "") $maxPosts = 10;
> +
> + // create a view and export the settings to the template
> + $this->_view = new AdminPluginTemplatedView( $this->_blogInfo,
> "topcommentposts", "topcommentposts", true );
> + $this->_view->setValue( "pluginEnabled", $pluginEnabled );
> + $this->_view->setValue( "maxPosts", $maxPosts );
> +
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/topcommentposts/class/action/
> plugintopcommentpostsupdateconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/topcommentposts/class/action/
> plugintopcommentpostsupdateconfigaction.class.php 2005-01-20 16:04:28
> UTC (rev 778)
> +++
> plugins/trunk/topcommentposts/class/action/
> plugintopcommentpostsupdateconfigaction.class.php 2005-01-20 16:06:26
> UTC (rev 779)
> @@ -0,0 +1,67 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
> +
> + /**
> + * updates the plugin configuration
> + */
> + class PluginTopCommentPostsUpdateConfigAction extends AdminAction
> + {
> + var $_pluginEnabled;
> + var $_maxPosts;
> +
> + function PluginRTopCommentPostsUpdateConfigAction( $actionInfo,
> $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function validate()
> + {
> + $this->_pluginEnabled = $this->_request->getValue(
> "pluginEnabled" );
> + $this->_pluginEnabled = ($this->_pluginEnabled != "" );
> + $this->_maxPosts = $this->_request->getValue( "maxPosts"
> );
> + if( $this->_maxPosts <= 0 ) {
> +
> +
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("topcommentposts_error_maxposts"));
> + $this->setCommonData();
> + return false;
> + }
> +
> + return true;
> + }
> +
> + function perform()
> + {
> + // and check which smiley set we should be using, or if
> none, then the default one
> + $blogSettings = $this->_blogInfo->getSettings();
> + $blogSettings->setValue(
> "plugin_topcommentposts_enabled", $this->_pluginEnabled );
> + $blogSettings->setValue(
> "plugin_topcommentposts_maxposts", $this->_maxPosts );
> + $this->_blogInfo->setSettings( $blogSettings );
> +
> + // save the blogs settings
> + $blogs = new Blogs();
> + if( !$blogs->updateBlog( $this->_blogInfo->getId(),
> $this->_blogInfo )) {
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("error_updating_settings"));
> + $this->setCommonData();
> +
> + return false;
> + }
> +
> + // if everything went ok...
> + $this->_blogInfo->setSettings( $blogSettings );
> + $this->_session->setValue( "blogInfo", $this->_blogInfo );
> + $this->saveSession();
> +
> + $this->_view = new AdminMessageView( $this->_blogInfo );
> + $this->_view->setMessage(
> $this->_locale->tr("topcommentposts_settings_saved_ok"));
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topcommentposts/locale/locale_en_UK.php
> ===================================================================
> --- plugins/trunk/topcommentposts/locale/locale_en_UK.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/topcommentposts/locale/locale_en_UK.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["topcommentposts_maxposts"] = "Maximum Showed Posts";
> +$messages["topcommentposts_plugin_configuration"] = "Configuration
> this plugin";
> +$messages["topcommentposts_plugin_enabled"] = "Enable this plugin";
> +$messages["topcommentposts_plugin"] = "Top Comment Posts Plugin";
> +$messages["topcommentposts_settings_saved_ok"] = "Top Comment Posts
> settings saved successfully!";
> +$messages["topcommentposts_error_maxposts"] = "Maximum Showed Posts
> Should >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topcommentposts/locale/locale_zh_TW.php
> ===================================================================
> --- plugins/trunk/topcommentposts/locale/locale_zh_TW.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/topcommentposts/locale/locale_zh_TW.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["topcommentposts_maxposts"] =
> "æå¤è¿´é¿æç« 顯示æ¸é";
> +$messages["topcommentposts_plugin_configuration"] =
> "夿ç¨å¼è¨å®";
> +$messages["topcommentposts_plugin_enabled"] = "åå夿ç¨å¼";
> +$messages["topcommentposts_plugin"] =
> "æå¤è¿´é¿æç« 夿ç¨å¼";
> +$messages["topcommentposts_settings_saved_ok"] =
> "æå¤è¿´é¿æç« è¨å®å²åæåã";
> +$messages["topcommentposts_error_maxposts"] =
> "æå¤è¿´é¿æç« 顯示æ¸éå¿
> é è¦ >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topcommentposts/plugintopcommentposts.class.php
> ===================================================================
> ---
> plugins/trunk/topcommentposts/plugintopcommentposts.class.php 2005-01
> -20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/topcommentposts/plugintopcommentposts.class.php 2005-01
> -20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,127 @@
> +<?php
> +
> + include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php"
> );
> + include_once(
> PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
> + include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
> +
> + /**
> + * Plugin that offers features to returns the top comment posts
> object of current blog
> + */
> + class PluginTopCommentPosts extends PluginBase
> + {
> + var $prefix;
> + var $pluginEnabled;
> + var $maxPosts;
> +
> + function PluginTopCommentPosts()
> + {
> + $this->PluginBase();
> +
> + $this->id = "topcommentposts";
> + $this->author = "Mark Wu";
> + $this->desc = "This plugin offers the rank list of
> articles by number of comments. Usage as follow:<br /><br />Add the
> following code to footer.template<br /><br /><strong><p><br
> /><strong>Top Comment Post</strong><br /><br
> />{assign var=posts
> value=\$topcommentposts->getTopCommentPosts()}<br />{foreach
> from=\$posts item=post}<br />{assign var=postid
> value=\$post->getId()}<br /><li><a
> title="{\$post->getText()|truncate:150:"..."
> |escape}"
> href="{\$url->postLink(\$post)}">{\$post->
> getTopic()}</a>
> ({\$topcommentposts->getArticleCommentCount(\$postid)}
> ½g)</li><br />{/foreach}<br /></p></strong> <br /><br
> />You can use <br /><br /><strong>getTopCommentPosts(5)</strong> to
> get top 5 comment posts. The default view is BLOG. <br
> /><strong>getTopCommentPosts(10, 'SITE')</strong> to get top 10
> comment posts from SITE view. It is very convenient for pLog Host
> Provider.<br
> /><br />";
> +
> + $config =& Config::getConfig();
> + $this->prefix = $config->getValue('db_prefix');
> +
> + $this->locales = Array( "en_UK" , "zh_TW" );
> +
> + $this->init();
> + }
> +
> + function init()
> + {
> + $this->registerAdminAction( "topcommentposts",
> "PluginTopCommentPostsConfigAction" );
> + $this->registerAdminAction( "updateTopCommentPostsConfig",
> "PluginTopCommentPostsUpdateConfigAction" );
> +
> + $menu =& Menu::getMenu();
> + if( !$menu->entryExists( "/menu/controlCenter/manageTopActivities"
> ))
> + $this->addMenuEntry( "/menu/controlCenter",
> "manageTopActivities", "", "", true, false );
> + $this->addMenuEntry(
> "/menu/controlCenter/manageTopActivities", "TopCommentPosts",
> "?op=topcommentposts", "" );
> + }
> +
> + function register()
> + {
> + $blogSettings = $this->blogInfo->getSettings();
> + $this->pluginEnabled = $blogSettings->getValue(
> "plugin_topcommentposts_enabled" );
> + $this->maxPosts = $blogSettings->getValue(
> "plugin_topcommentposts_maxposts" );
> + }
> +
> + function isEnabled()
> + {
> + return $this->pluginEnabled;
> + }
> +
> + /**
> + * Returns the top comment posts object of current blog
> + */
> + function getTopCommentPosts($maxPosts = 0, $based = 'BLOG')
> + {
> + $comments = new ArticleComments();
> + $blogId = $this->blogInfo->getId();
> +
> + if ($based == 'BLOG') {
> + $query = "SELECT
> ".$this->prefix."articles_comments.article_id,count(".$this-
> >prefix."articles_comments.article_id) as comment_count";
> + $query .= " FROM ".$this->prefix."articles_comments,
> ".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."articles_comments.article_id =
> ".$this->prefix."articles.id AND ".$this->prefix."articles.blog_id =
> ".$blogId." AND ".$this->prefix."articles.status = 1";
> + $query .= " GROUP BY
> ".$this->prefix."articles_comments.article_id ORDER BY comment_count
> DESC";
> + } elseif ($based == 'SITE') {
> + $query = "SELECT
> ".$this->prefix."articles_comments.article_id,count(".$this-
> >prefix."articles_comments.article_id) as comment_count";
> + $query .= " FROM ".$this->prefix."articles_comments,
> ".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."articles_comments.article_id =
> ".$this->prefix."articles.id AND ".$this->prefix."articles.status =
> 1";
> + $query .= " GROUP BY
> ".$this->prefix."articles_comments.article_id ORDER BY comment_count
> DESC";
> + } else {
> + return false;
> + }
> +
> + if( $maxPosts > 0 )
> + {
> + $query .= " LIMIT " . $maxPosts;
> + } else {
> + $query .= " LIMIT " . $this->maxPosts;
> + }
> +
> + $result = $comments->_db->Execute( $query );
> +
> + if( !$result )
> + return false;
> +
> + $topcommentposts = Array();
> + while( $row = $result->FetchRow()) {
> + $article = $this->getArticle($row["article_id"]);
> + array_push( $topcommentposts, $article);
> + }
> +
> + return $topcommentposts;
> + }
> +
> + function getArticle( $artId )
> + {
> + $articles = new Articles();
> + $blogId = $this->blogInfo->getId();
> +
> + $query = "SELECT * FROM ".$this->prefix."articles WHERE
> id = ".$artId;
> +
> + $query .= " AND blog_id = ".$blogId;
> +
> + $query .= ";";
> +
> + // we send the query and then fetch the first array with
> the result
> + $result = $articles->_db->Execute( $query );
> +
> + if( $result == false )
> + return false;
> +
> + if ( $result->RecordCount() == 0)
> + return false;
> +
> + $row = $result->FetchRow( $result );
> +
> + $article = $articles->_fillArticleInformation( $row );
> +
> + return $article;
> + }
> + }
> +
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topcommentposts/templates/topcommentposts.template
> ===================================================================
> ---
> plugins/trunk/topcommentposts/templates/topcommentposts.template 2005
> -01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/topcommentposts/templates/topcommentposts.template 2005
> -01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,16 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"
> showOpt=TopCommentPosts title=$locale->tr("topcommentposts_plugin")}
> +<form name="topcommentpostsPluginConfig" method="post">
> + {$locale->tr("topcommentposts_plugin_enabled")}
> + <input type="checkbox" name="pluginEnabled" {if $pluginEnabled}
> checked="checked" {/if} value="1" /><br/>
> + <fieldset>
> +
> <legend>{$locale->tr("topcommentposts_plugin_configuration")}</legend>
> + {$locale->tr("topcommentposts_maxposts")}
> + <input type="text" name="maxPosts" value="{$maxPosts}" width="10" />
> + </fieldset>
> + <br/>
> + <input type="hidden" name="op" value="updateTopCommentPostsConfig" />
> + <input type="submit" name="{$locale->tr("update_settings")}"
> value="{$locale->tr("update")}" />
> +</form>
> +{include file="$admintemplatepath/footernavigation.template"}
> +{include file="$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> Added:
> plugins/trunk/topcommentvisitors/class/action/
> plugintopcommentvisitorsconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/topcommentvisitors/class/action/
> plugintopcommentvisitorsconfigaction.class.php 2005-01-20 16:04:28 UTC
> (rev 778)
> +++
> plugins/trunk/topcommentvisitors/class/action/
> plugintopcommentvisitorsconfigaction.class.php 2005-01-20 16:06:26 UTC
> (rev 779)
> @@ -0,0 +1,35 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php"
> );
> +
> + /**
> + * shows a form with the current configuration
> + */
> + class PluginTopCommentVisitorsConfigAction extends AdminAction
> + {
> +
> + function PluginTopCommentVisitorsConfigAction( $actionInfo,
> $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function perform()
> + {
> + // load some configuration settings
> + $blogSettings = $this->_blogInfo->getSettings();
> + $pluginEnabled = $blogSettings->getValue(
> "plugin_topcommentvisitors_enabled" );
> + $maxVisitors = $blogSettings->getValue(
> "plugin_topcommentvisitors_maxvisitors" );
> + if ($maxVisitors == "") $maxVisitors = 10;
> +
> + // create a view and export the settings to the template
> + $this->_view = new AdminPluginTemplatedView( $this->_blogInfo,
> "topcommentvisitors", "topcommentvisitors", true );
> + $this->_view->setValue( "pluginEnabled", $pluginEnabled );
> + $this->_view->setValue( "maxVisitors", $maxVisitors );
> +
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/topcommentvisitors/class/action/
> plugintopcommentvisitorsupdateconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/topcommentvisitors/class/action/
> plugintopcommentvisitorsupdateconfigaction.class.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/topcommentvisitors/class/action/
> plugintopcommentvisitorsupdateconfigaction.class.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,67 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
> +
> + /**
> + * updates the plugin configuration
> + */
> + class PluginTopCommentVisitorsUpdateConfigAction extends AdminAction
> + {
> + var $_pluginEnabled;
> + var $_maxVisitors;
> +
> + function PluginRTopCommentVisitorsUpdateConfigAction( $actionInfo,
> $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function validate()
> + {
> + $this->_pluginEnabled = $this->_request->getValue(
> "pluginEnabled" );
> + $this->_pluginEnabled = ($this->_pluginEnabled != "" );
> + $this->_maxVisitors = $this->_request->getValue(
> "maxVisitors" );
> + if( $this->_maxVisitors <= 0 ) {
> +
> +
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("topcommentvisitors_error_maxvisitors"));
> + $this->setCommonData();
> + return false;
> + }
> +
> + return true;
> + }
> +
> + function perform()
> + {
> + // and check which smiley set we should be using, or if
> none, then the default one
> + $blogSettings = $this->_blogInfo->getSettings();
> + $blogSettings->setValue(
> "plugin_topcommentvisitors_enabled", $this->_pluginEnabled );
> + $blogSettings->setValue(
> "plugin_topcommentvisitors_maxvisitors", $this->_maxVisitors );
> + $this->_blogInfo->setSettings( $blogSettings );
> +
> + // save the blogs settings
> + $blogs = new Blogs();
> + if( !$blogs->updateBlog( $this->_blogInfo->getId(),
> $this->_blogInfo )) {
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("error_updating_settings"));
> + $this->setCommonData();
> +
> + return false;
> + }
> +
> + // if everything went ok...
> + $this->_blogInfo->setSettings( $blogSettings );
> + $this->_session->setValue( "blogInfo", $this->_blogInfo );
> + $this->saveSession();
> +
> + $this->_view = new AdminMessageView( $this->_blogInfo );
> + $this->_view->setMessage(
> $this->_locale->tr("topcommentvisitors_settings_saved_ok"));
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topcommentvisitors/locale/locale_en_UK.php
> ===================================================================
> ---
> plugins/trunk/topcommentvisitors/locale/locale_en_UK.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/topcommentvisitors/locale/locale_en_UK.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["topcommentvisitors_maxvisitors"] = "Maximum Showed
> Visitors";
> +$messages["topcommentvisitors_plugin_configuration"] = "Configuration
> this plugin";
> +$messages["topcommentvisitors_plugin_enabled"] = "Enable this plugin";
> +$messages["topcommentvisitors_plugin"] = "Top Comment Visitors
> Plugin";
> +$messages["topcommentvisitors_settings_saved_ok"] = "Top Comment
> Visitors settings saved successfully!";
> +$messages["topcommentvisitors_error_maxvisitors"] = "Maximum Showed
> Visitors Should >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topcommentvisitors/locale/locale_zh_TW.php
> ===================================================================
> ---
> plugins/trunk/topcommentvisitors/locale/locale_zh_TW.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/topcommentvisitors/locale/locale_zh_TW.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["topcommentvisitors_maxvisitors"] =
> "æå¤è¿´é¿è¨ªå®¢é¡¯ç¤ºæ¸é";
> +$messages["topcommentvisitors_plugin_configuration"] =
> "夿ç¨å¼è¨å®";
> +$messages["topcommentvisitors_plugin_enabled"] = "åå夿ç¨å¼";
> +$messages["topcommentvisitors_plugin"] =
> "æå¤è¿´é¿è¨ªå®¢å¤æç¨å¼";
> +$messages["topcommentvisitors_settings_saved_ok"] =
> "æå¤è¿´é¿è¨ªå®¢è¨å®å²åæåã";
> +$messages["topcommentvisitors_error_maxvisitors"] =
> "æå¤è¿´é¿è¨ªå®¢é¡¯ç¤ºæ¸éå¿
> é è¦ >= 0!";
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/topcommentvisitors/plugintopcommentvisitors.class.php
> ===================================================================
> ---
> plugins/trunk/topcommentvisitors/plugintopcommentvisitors.class.php
> 2005-01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/topcommentvisitors/plugintopcommentvisitors.class.php
> 2005-01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,97 @@
> +<?php
> +
> + include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php"
> );
> + include_once(
> PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
> +
> + /**
> + * Plugin that offers features to returns the top comment
> visitors object of current blog
> + */
> + class PluginTopCommentVisitors extends PluginBase
> + {
> + var $prefix;
> + var $pluginEnabled;
> + var $maxVisitors;
> +
> + function PluginTopCommentVisitors()
> + {
> + $this->PluginBase();
> +
> + $this->id = "topcommentvisitors";
> + $this->author = "Mark Wu";
> + $this->desc = "<p>This plugin offers the rank list of
> visitors by number of comments. Usage as follow:<br /><br />Add the
> following code to footer.template<br /><br /><strong><p><br
> /><strong>Top Comment Visitors</strong><br /><br
> />{assign var=visitors
> value=\$topcommentvisitors->getTopCommentVisitors()}<br />{foreach
> from=\$visitors item=visitor}<br /><li
> class="comment-bullet"><a
> title="{\$visitor.user_name}"
> href="{\$visitor.user_url}">{\$visitor.user_name}</
> a> ({\$visitor.user_count})</li><br />{/foreach}<br
> /></p></strong><br /><br />You can use <br /><br
> /><strong>getTopCommentVisitors(5)</strong> to get top 5 comment
> visitors. The default view is BLOG. <br
> /><strong>getTopCommentVisitors(10, 'SITE')</strong> to get top 10
> comment visitors from SITE view. It is very convenient for pLog Host
> Provider.<br /><br /></p><br />";
> +
> + $config =& Config::getConfig();
> + $this->prefix = $config->getValue('db_prefix');
> +
> + $this->db =& Db::getDb();
> +
> + $this->locales = Array( "en_UK" , "zh_TW" );
> +
> + $this->init();
> + }
> +
> + function init()
> + {
> + $this->registerAdminAction( "topcommentvisitors",
> "PluginTopCommentVisitorsConfigAction" );
> + $this->registerAdminAction( "updateTopCommentVisitorsConfig",
> "PluginTopCommentVisitorsUpdateConfigAction" );
> +
> + $menu =& Menu::getMenu();
> + if( !$menu->entryExists( "/menu/controlCenter/manageTopActivities"
> ))
> + $this->addMenuEntry( "/menu/controlCenter",
> "manageTopActivities", "", "", true, false );
> + $this->addMenuEntry(
> "/menu/controlCenter/manageTopActivities", "TopCommentVisitors",
> "?op=topcommentvisitors", "" );
> + }
> +
> + function register()
> + {
> + $blogSettings = $this->blogInfo->getSettings();
> + $this->pluginEnabled = $blogSettings->getValue(
> "plugin_topcommentvisitors_enabled" );
> + $this->maxVisitors = $blogSettings->getValue(
> "plugin_topcommentvisitors_maxvisitors" );
> + }
> +
> + function isEnabled()
> + {
> + return $this->pluginEnabled;
> + }
> +
> + /**
> + * Returns the top comment visitors of current blog
> + */
> + function getTopCommentVisitors($maxVisitors = 0, $based =
> 'BLOG')
> + {
> + $blogId = $this->blogInfo->getId();
> +
> + if ($based == 'BLOG') {
> + $query = "SELECT
> ".$this->prefix."articles_comments.user_name,max(".$this-
> >prefix."articles_comments.user_url) AS
> user_url,count(".$this->prefix."articles_comments.user_name) AS
> user_count";
> + $query .= " FROM
> ".$this->prefix."articles_comments,".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."articles.blog_id=".$blogId." AND
> ".$this->prefix."articles_comments.article_id=".$this-
> >prefix."articles.id AND ".$this->prefix."articles.status=1";
> + $query .= " GROUP BY
> ".$this->prefix."articles_comments.user_name ORDER BY user_count
> DESC";
> + } elseif ($based == 'SITE') {
> + $query = "SELECT
> ".$this->prefix."articles_comments.user_name,max(".$this-
> >prefix."articles_comments.user_url) AS
> user_url,count(".$this->prefix."articles_comments.user_name) AS
> user_count";
> + $query .= " FROM
> ".$this->prefix."articles_comments,".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."articles_comments.article_id=".$this-
> >prefix."articles.id AND ".$this->prefix."articles.status=1";
> + $query .= " GROUP BY
> ".$this->prefix."articles_comments.user_name ORDER BY user_count
> DESC";
> + } else {
> + return false;
> + }
> +
> + if( $maxVisitors > 0 )
> + {
> + $query .= " LIMIT " . $maxVisitors;
> + } else {
> + $query .= " LIMIT " . $this->maxVisitors;
> + }
> +
> + $result = $this->db->Execute( $query );
> +
> + if( !$result )
> + return false;
> +
> + $topcommentvisitors = Array();
> + while( $row = $result->FetchRow()) {
> + array_push( $topcommentvisitors, $row);
> + }
> +
> + return $topcommentvisitors;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/topcommentvisitors/templates/topcommentvisitors.template
> ===================================================================
> ---
> plugins/trunk/topcommentvisitors/templates/topcommentvisitors.template
> 2005-01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/topcommentvisitors/templates/topcommentvisitors.template
> 2005-01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,16 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"
> showOpt=TopCommentVisitors
> title=$locale->tr("topcommentvisitors_plugin")}
> +<form name="topcommentvisitorsPluginConfig" method="post">
> + {$locale->tr("topcommentvisitors_plugin_enabled")}
> + <input type="checkbox" name="pluginEnabled" {if $pluginEnabled}
> checked="checked" {/if} value="1" /><br/>
> + <fieldset>
> +
> <legend>{$locale->tr("topcommentvisitors_plugin_configuration")}</
> legend>
> + {$locale->tr("topcommentvisitors_maxvisitors")}
> + <input type="text" name="maxVisitors" value="{$maxVisitors}"
> width="10" />
> + </fieldset>
> + <br/>
> + <input type="hidden" name="op"
> value="updateTopCommentVisitorsConfig" />
> + <input type="submit" name="{$locale->tr("update_settings")}"
> value="{$locale->tr("update")}" />
> +</form>
> +{include file="$admintemplatepath/footernavigation.template"}
> +{include file="$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> Added:
> plugins/trunk/topreadposts/class/action/
> plugintopreadpostsconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/topreadposts/class/action/
> plugintopreadpostsconfigaction.class.php 2005-01-20 16:04:28 UTC (rev
> 778)
> +++
> plugins/trunk/topreadposts/class/action/
> plugintopreadpostsconfigaction.class.php 2005-01-20 16:06:26 UTC (rev
> 779)
> @@ -0,0 +1,35 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php"
> );
> +
> + /**
> + * shows a form with the current configuration
> + */
> + class PluginTopReadPostsConfigAction extends AdminAction
> + {
> +
> + function PluginTopReadPostsConfigAction( $actionInfo, $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function perform()
> + {
> + // load some configuration settings
> + $blogSettings = $this->_blogInfo->getSettings();
> + $pluginEnabled = $blogSettings->getValue(
> "plugin_topreadposts_enabled" );
> + $maxPosts = $blogSettings->getValue(
> "plugin_topreadposts_maxposts" );
> + if ($maxPosts == "") $maxPosts = 10;
> +
> + // create a view and export the settings to the template
> + $this->_view = new AdminPluginTemplatedView( $this->_blogInfo,
> "topreadposts", "topreadposts", true );
> + $this->_view->setValue( "pluginEnabled", $pluginEnabled );
> + $this->_view->setValue( "maxPosts", $maxPosts );
> +
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/topreadposts/class/action/
> plugintopreadpostsupdateconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/topreadposts/class/action/
> plugintopreadpostsupdateconfigaction.class.php 2005-01-20 16:04:28 UTC
> (rev 778)
> +++
> plugins/trunk/topreadposts/class/action/
> plugintopreadpostsupdateconfigaction.class.php 2005-01-20 16:06:26 UTC
> (rev 779)
> @@ -0,0 +1,67 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
> +
> + /**
> + * updates the plugin configuration
> + */
> + class PluginTopReadPostsUpdateConfigAction extends AdminAction
> + {
> + var $_pluginEnabled;
> + var $_maxPosts;
> +
> + function PluginRTopReadPostsUpdateConfigAction( $actionInfo,
> $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function validate()
> + {
> + $this->_pluginEnabled = $this->_request->getValue(
> "pluginEnabled" );
> + $this->_pluginEnabled = ($this->_pluginEnabled != "" );
> + $this->_maxPosts = $this->_request->getValue( "maxPosts"
> );
> + if( $this->_maxPosts <= 0 ) {
> +
> +
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("topreadposts_error_maxposts"));
> + $this->setCommonData();
> + return false;
> + }
> +
> + return true;
> + }
> +
> + function perform()
> + {
> + // and check which smiley set we should be using, or if
> none, then the default one
> + $blogSettings = $this->_blogInfo->getSettings();
> + $blogSettings->setValue( "plugin_topreadposts_enabled",
> $this->_pluginEnabled );
> + $blogSettings->setValue( "plugin_topreadposts_maxposts",
> $this->_maxPosts );
> + $this->_blogInfo->setSettings( $blogSettings );
> +
> + // save the blogs settings
> + $blogs = new Blogs();
> + if( !$blogs->updateBlog( $this->_blogInfo->getId(),
> $this->_blogInfo )) {
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("error_updating_settings"));
> + $this->setCommonData();
> +
> + return false;
> + }
> +
> + // if everything went ok...
> + $this->_blogInfo->setSettings( $blogSettings );
> + $this->_session->setValue( "blogInfo", $this->_blogInfo );
> + $this->saveSession();
> +
> + $this->_view = new AdminMessageView( $this->_blogInfo );
> + $this->_view->setMessage(
> $this->_locale->tr("topreadposts_settings_saved_ok"));
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topreadposts/locale/locale_en_UK.php
> ===================================================================
> --- plugins/trunk/topreadposts/locale/locale_en_UK.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/topreadposts/locale/locale_en_UK.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["topreadposts_maxposts"] = "Maximum Showed Posts";
> +$messages["topreadposts_plugin_configuration"] = "Configuration this
> plugin";
> +$messages["topreadposts_plugin_enabled"] = "Enable this plugin";
> +$messages["topreadposts_plugin"] = "Top Read Posts Plugin";
> +$messages["topreadposts_settings_saved_ok"] = "Top Read Posts
> settings saved successfully!";
> +$messages["topreadposts_error_maxposts"] = "Maximum Showed Posts
> Should >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topreadposts/locale/locale_zh_TW.php
> ===================================================================
> --- plugins/trunk/topreadposts/locale/locale_zh_TW.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/topreadposts/locale/locale_zh_TW.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["topreadposts_maxposts"] = "æå¤é±è®æç« 顯示æ¸é";
> +$messages["topreadposts_plugin_configuration"] = "夿ç¨å¼è¨å®";
> +$messages["topreadposts_plugin_enabled"] = "åå夿ç¨å¼";
> +$messages["topreadposts_plugin"] = "æå¤é±è®æç« 夿ç¨å¼";
> +$messages["topreadposts_settings_saved_ok"] =
> "æå¤é±è®æç« è¨å®å²åæåã";
> +$messages["topreadposts_error_maxposts"] =
> "æå¤é±è®æç« 顯示æ¸éå¿
> é è¦ >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topreadposts/plugintopreadposts.class.php
> ===================================================================
> --- plugins/trunk/topreadposts/plugintopreadposts.class.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/topreadposts/plugintopreadposts.class.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,96 @@
> +<?php
> +
> + include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php"
> );
> + include_once(
> PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
> + include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
> +
> + /**
> + * Plugin that offers features to returns the top read posts
> object of current blog
> + */
> + class PluginTopReadPosts extends PluginBase
> + {
> +
> + var $prefix;
> + var $pluginEnabled;
> + var $maxPosts;
> +
> + function PluginTopReadPosts()
> + {
> + $this->PluginBase();
> +
> + $this->id = "topreadposts";
> + $this->author = "Mark Wu";
> + $this->desc = "This plugin offers the rank list of
> articles by number of read. Usage as follow:<br /><br />Add the
> following code to footer.template<br /><br /><strong><p><br
> /><strong>Top Read Posts</strong><br /><br />{assign
> var=posts value=\$topreadposts->getTopReadPosts()}<br />{foreach
> from=\$posts item=post}<br /><li><a
> title="{\$post->getText()|truncate:150:"..."
> |escape}"
> href="{\$url->postLink(\$post)}">{\$post->
> getTopic()}</a> ({\$post->getNumReads()} Times)</li><br
> />{/foreach}<br /></p></strong> <br /><br />You can use <br
> /><br /><strong>getTopReadPosts(5)</strong> to get top 5 read posts.
> The default view is BLOG. <br /><strong>getTopReadPosts(10,
> 'SITE')</strong> to get top 10 read posts from SITE view. It is very
> convenient for pLog Host Provider.<br /><br />";
> + $config =& Config::getConfig();
> + $this->prefix = $config->getValue('db_prefix');
> +
> + $this->locales = Array( "en_UK" , "zh_TW" );
> +
> + $this->init();
> + }
> +
> + function init()
> + {
> + $this->registerAdminAction( "topreadposts",
> "PluginTopReadPostsConfigAction" );
> + $this->registerAdminAction( "updateTopReadPostsConfig",
> "PluginTopReadPostsUpdateConfigAction" );
> +
> + $menu =& Menu::getMenu();
> + if( !$menu->entryExists( "/menu/controlCenter/manageTopActivities"
> ))
> + $this->addMenuEntry( "/menu/controlCenter",
> "manageTopActivities", "", "", true, false );
> + $this->addMenuEntry(
> "/menu/controlCenter/manageTopActivities", "TopReadPosts",
> "?op=topreadposts", "" );
> + }
> +
> + function register()
> + {
> + $blogSettings = $this->blogInfo->getSettings();
> + $this->pluginEnabled = $blogSettings->getValue(
> "plugin_topreadposts_enabled" );
> + $this->maxPosts = $blogSettings->getValue(
> "plugin_topreadposts_maxposts" );
> + }
> +
> + function isEnabled()
> + {
> + return $this->pluginEnabled;
> + }
> +
> + /**
> + * Returns the top read posts object of current blog
> + */
> + function getTopReadPosts($maxPosts = 0, $based = 'BLOG')
> + {
> + $articles = new Articles();
> + $blogId = $this->blogInfo->getId();
> +
> + if ($based == 'BLOG') {
> + $query = "SELECT * FROM ".$this->prefix."articles";
> + $query .= " WHERE blog_id = ".$blogId." AND status =
> 1";
> + $query .= " ORDER BY num_reads DESC";
> + } elseif ($based == 'SITE') {
> + $query = "SELECT * FROM ".$this->prefix."articles";
> + $query .= " WHERE status = 1";
> + $query .= " ORDER BY num_reads DESC";
> + } else {
> + return false;
> + }
> +
> + if( $maxPosts > 0 )
> + {
> + $query .= " LIMIT " . $maxPosts;
> + } else {
> + $query .= " LIMIT " . $this->maxPosts;
> + }
> +
> + $result = $articles->_db->Execute( $query );
> +
> + if( !$result )
> + return false;
> +
> + $topreadposts = Array();
> + while( $row = $result->FetchRow()) {
> + $article = $articles->_fillArticleInformation( $row );
> + array_push( $topreadposts, $article);
> + }
> +
> + return $topreadposts;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/topreadposts/templates/topreadposts.template
> ===================================================================
> ---
> plugins/trunk/topreadposts/templates/topreadposts.template 2005-01-20
> 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/topreadposts/templates/topreadposts.template 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,16 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"
> showOpt=TopReadPosts title=$locale->tr("topreadposts_plugin")}
> +<form name="topreadpostsPluginConfig" method="post">
> + {$locale->tr("topreadposts_plugin_enabled")}
> + <input type="checkbox" name="pluginEnabled" {if $pluginEnabled}
> checked="checked" {/if} value="1" /><br/>
> + <fieldset>
> + <legend>{$locale->tr("topreadposts_plugin_configuration")}</legend>
> + {$locale->tr("topreadposts_maxposts")}
> + <input type="text" name="maxPosts" value="{$maxPosts}" width="10" />
> + </fieldset>
> + <br/>
> + <input type="hidden" name="op" value="updateTopReadPostsConfig" />
> + <input type="submit" name="{$locale->tr("update_settings")}"
> value="{$locale->tr("update")}" />
> +</form>
> +{include file="$admintemplatepath/footernavigation.template"}
> +{include file="$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> Added:
> plugins/trunk/toptrackbackposts/class/action/
> plugintoptrackbackpostsconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/toptrackbackposts/class/action/
> plugintoptrackbackpostsconfigaction.class.php 2005-01-20 16:04:28 UTC
> (rev 778)
> +++
> plugins/trunk/toptrackbackposts/class/action/
> plugintoptrackbackpostsconfigaction.class.php 2005-01-20 16:06:26 UTC
> (rev 779)
> @@ -0,0 +1,35 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php"
> );
> +
> + /**
> + * shows a form with the current configuration
> + */
> + class PluginTopTrackbackPostsConfigAction extends AdminAction
> + {
> +
> + function PluginTopTrackbackPostsConfigAction( $actionInfo, $request
> )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function perform()
> + {
> + // load some configuration settings
> + $blogSettings = $this->_blogInfo->getSettings();
> + $pluginEnabled = $blogSettings->getValue(
> "plugin_toptrackbackposts_enabled" );
> + $maxPosts = $blogSettings->getValue(
> "plugin_toptrackbackposts_maxposts" );
> + if ($maxPosts == "") $maxPosts = 10;
> +
> + // create a view and export the settings to the template
> + $this->_view = new AdminPluginTemplatedView( $this->_blogInfo,
> "toptrackbackposts", "toptrackbackposts", true );
> + $this->_view->setValue( "pluginEnabled", $pluginEnabled );
> + $this->_view->setValue( "maxPosts", $maxPosts );
> +
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/toptrackbackposts/class/action/
> plugintoptrackbackpostsupdateconfigaction.class.php
> ===================================================================
> ---
> plugins/trunk/toptrackbackposts/class/action/
> plugintoptrackbackpostsupdateconfigaction.class.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/toptrackbackposts/class/action/
> plugintoptrackbackpostsupdateconfigaction.class.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,67 @@
> +<?php
> +
> + include_once(
> PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
> + include_once(
> PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
> +
> + /**
> + * updates the plugin configuration
> + */
> + class PluginTopTrackbackPostsUpdateConfigAction extends AdminAction
> + {
> + var $_pluginEnabled;
> + var $_maxPosts;
> +
> + function PluginRTopTrackbackPostsUpdateConfigAction( $actionInfo,
> $request )
> + {
> + $this->AdminAction( $actionInfo, $request );
> + }
> +
> + function validate()
> + {
> + $this->_pluginEnabled = $this->_request->getValue(
> "pluginEnabled" );
> + $this->_pluginEnabled = ($this->_pluginEnabled != "" );
> + $this->_maxPosts = $this->_request->getValue( "maxPosts"
> );
> + if( $this->_maxPosts <= 0 ) {
> +
> +
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("toptrackbackposts_error_maxposts"));
> + $this->setCommonData();
> + return false;
> + }
> +
> + return true;
> + }
> +
> + function perform()
> + {
> + // and check which smiley set we should be using, or if
> none, then the default one
> + $blogSettings = $this->_blogInfo->getSettings();
> + $blogSettings->setValue(
> "plugin_toptrackbackposts_enabled", $this->_pluginEnabled );
> + $blogSettings->setValue(
> "plugin_toptrackbackposts_maxposts", $this->_maxPosts );
> + $this->_blogInfo->setSettings( $blogSettings );
> +
> + // save the blogs settings
> + $blogs = new Blogs();
> + if( !$blogs->updateBlog( $this->_blogInfo->getId(),
> $this->_blogInfo )) {
> + $this->_view = new AdminErrorView( $this->_blogInfo );
> + $this->_view->setValue( "message",
> $this->_locale->tr("error_updating_settings"));
> + $this->setCommonData();
> +
> + return false;
> + }
> +
> + // if everything went ok...
> + $this->_blogInfo->setSettings( $blogSettings );
> + $this->_session->setValue( "blogInfo", $this->_blogInfo );
> + $this->saveSession();
> +
> + $this->_view = new AdminMessageView( $this->_blogInfo );
> + $this->_view->setMessage(
> $this->_locale->tr("toptrackbackposts_settings_saved_ok"));
> + $this->setCommonData();
> +
> + return true;
> + }
> + }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/toptrackbackposts/locale/locale_en_UK.php
> ===================================================================
> --- plugins/trunk/toptrackbackposts/locale/locale_en_UK.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/toptrackbackposts/locale/locale_en_UK.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["toptrackbackposts_maxposts"] = "Maximum Showed Posts";
> +$messages["toptrackbackposts_plugin_configuration"] = "Configuration
> this plugin";
> +$messages["toptrackbackposts_plugin_enabled"] = "Enable this plugin";
> +$messages["toptrackbackposts_plugin"] = "Top Trackback Posts Plugin";
> +$messages["toptrackbackposts_settings_saved_ok"] = "Top Trackback
> Posts settings saved successfully!";
> +$messages["toptrackbackposts_error_maxposts"] = "Maximum Showed Posts
> Should >= 0!";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/toptrackbackposts/locale/locale_zh_TW.php
> ===================================================================
> --- plugins/trunk/toptrackbackposts/locale/locale_zh_TW.php 2005-01-20
> 16:04:28 UTC (rev 778)
> +++ plugins/trunk/toptrackbackposts/locale/locale_zh_TW.php 2005-01-20
> 16:06:26 UTC (rev 779)
> @@ -0,0 +1,8 @@
> +<?php
> +$messages["toptrackbackposts_maxposts"] =
> "æå¤å¼ç¨æç« 顯示æ¸é";
> +$messages["toptrackbackposts_plugin_configuration"] =
> "夿ç¨å¼è¨å®";
> +$messages["toptrackbackposts_plugin_enabled"] = "åå夿ç¨å¼";
> +$messages["toptrackbackposts_plugin"] =
> "æå¤å¼ç¨æç« 夿ç¨å¼";
> +$messages["toptrackbackposts_settings_saved_ok"] =
> "æå¤å¼ç¨æç« è¨å®å²åæåã";
> +$messages["toptrackbackposts_error_maxposts"] =
> "æå¤å¼ç¨æç« 顯示æ¸éå¿
> é è¦ >= 0!";
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/toptrackbackposts/plugintoptrackbackposts.class.php
> ===================================================================
> ---
> plugins/trunk/toptrackbackposts/plugintoptrackbackposts.class.php
> 2005-01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/toptrackbackposts/plugintoptrackbackposts.class.php
> 2005-01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,127 @@
> +<?php
> +
> + include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php"
> );
> + include_once(
> PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
> + include_once( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
> + include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
> +
> + /**
> + * Plugin that offers features to returns the top trackback posts
> object of current blog
> + */
> + class PluginTopTrackbackPosts extends PluginBase
> + {
> + var $prefix;
> + var $pluginEnabled;
> + var $maxPosts;
> +
> + function PluginTopTrackbackPosts()
> + {
> + $this->PluginBase();
> +
> + $this->id = "toptrackbackposts";
> + $this->author = "Mark Wu";
> + $this->desc = "This plugin offers the rank list of
> articles by number of trackbacks. Usage as follow:<br /><br />Add the
> following code to footer.template<br /><br /><strong><p><br
> /><strong>Top Trackback Post</strong><br /><br
> />{assign var=posts
> value=\$toptrackbackposts->getTopTrackbackPosts()}<br />{foreach
> from=\$posts item=post}<br />{assign var=postid
> value=\$post->getId()}<br /><li><a
> title="{\$post->getText()|truncate:150:"..."
> |escape}"
> href="{\$url->postLink(\$post)}">{\$post->
> getTopic()}</a>
> ({\$toptrackbackposts->getArticleTrackbackCount(\$postid)}
> ½g)</li><br />{/foreach}<br /></p></strong> <br /><br
> />You can use <br /><br /><strong>getTopTrackbackPosts(5)</strong> to
> get top 5 trackback posts. The default view is BLOG. <br
> /><strong>getTopTrackbackPosts(10, 'SITE')</strong> to get top 10
> trackback posts from SITE view. It is very convenient for pLo
> g Host Provider.<br /><br />";
> +
> + $config =& Config::getConfig();
> + $this->prefix = $config->getValue('db_prefix');
> +
> + $this->locales = Array( "en_UK" , "zh_TW" );
> +
> + $this->init();
> + }
> +
> + function init()
> + {
> + $this->registerAdminAction( "toptrackbackposts",
> "PluginTopTrackbackPostsConfigAction" );
> + $this->registerAdminAction( "updateTopTrackbackPostsConfig",
> "PluginTopTrackbackPostsUpdateConfigAction" );
> +
> + $menu =& Menu::getMenu();
> + if( !$menu->entryExists( "/menu/controlCenter/manageTopActivities"
> ))
> + $this->addMenuEntry( "/menu/controlCenter",
> "manageTopActivities", "", "", true, false );
> + $this->addMenuEntry(
> "/menu/controlCenter/manageTopActivities", "TopTrackbackPosts",
> "?op=toptrackbackposts", "" );
> + }
> +
> + function register()
> + {
> + $blogSettings = $this->blogInfo->getSettings();
> + $this->pluginEnabled = $blogSettings->getValue(
> "plugin_toptrackbackposts_enabled" );
> + $this->maxPosts = $blogSettings->getValue(
> "plugin_toptrackbackposts_maxposts" );
> + }
> +
> + function isEnabled()
> + {
> + return $this->pluginEnabled;
> + }
> +
> + /**
> + * Returns the top trackback posts object of current blog
> + */
> + function getTopTrackbackPosts($maxPosts = 0, $based = 'BLOG')
> + {
> + $trackbacks = new Trackbacks();
> + $blogId = $this->blogInfo->getId();
> +
> + if ($based == 'BLOG') {
> + $query = "SELECT
> ".$this->prefix."trackbacks.article_id,count(".$this-
> >prefix."trackbacks.article_id) as trackback_count";
> + $query .= " FROM ".$this->prefix."trackbacks,
> ".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."trackbacks.article_id = ".$this->prefix."articles.id
> AND ".$this->prefix."articles.blog_id = ".$blogId." AND
> ".$this->prefix."articles.status = 1";
> + $query .= " GROUP BY
> ".$this->prefix."trackbacks.article_id ORDER BY trackback_count DESC";
> + } elseif ($based == 'SITE') {
> + $query = "SELECT
> ".$this->prefix."trackbacks.article_id,count(".$this-
> >prefix."trackbacks.article_id) as trackback_count";
> + $query .= " FROM ".$this->prefix."trackbacks,
> ".$this->prefix."articles";
> + $query .= " WHERE
> ".$this->prefix."trackbacks.article_id = ".$this->prefix."articles.id
> AND ".$this->prefix."articles.status = 1";
> + $query .= " GROUP BY
> ".$this->prefix."trackbacks.article_id ORDER BY trackback_count DESC";
> + } else {
> + return false;
> + }
> +
> + if( $maxPosts > 0 )
> + {
> + $query .= " LIMIT " . $maxPosts;
> + } else {
> + $query .= " LIMIT " . $this->maxPosts;
> + }
> +
> + $result = $trackbacks->_db->Execute( $query );
> +
> + if( !$result )
> + return false;
> +
> + $toptrackbackposts = Array();
> + while( $row = $result->FetchRow()) {
> + $article = $this->getArticle($row["article_id"]);
> + array_push( $toptrackbackposts, $article);
> + }
> +
> + return $toptrackbackposts;
> + }
> +
> + function getArticle( $artId )
> + {
> + $articles = new Articles();
> + $blogId = $this->blogInfo->getId();
> +
> + $query = "SELECT * FROM ".$this->prefix."articles WHERE
> id = ".$artId;
> +
> + $query .= " AND blog_id = ".$blogId;
> +
> + $query .= ";";
> +
> + // we send the query and then fetch the first array with
> the result
> + $result = $articles->_db->Execute( $query );
> +
> + if( $result == false )
> + return false;
> +
> + if ( $result->RecordCount() == 0)
> + return false;
> +
> + $row = $result->FetchRow( $result );
> +
> + $article = $articles->_fillArticleInformation( $row );
> +
> + return $article;
> + }
> + }
> +
> +?>
> \ No newline at end of file
>
> Added:
> plugins/trunk/toptrackbackposts/templates/toptrackbackposts.template
> ===================================================================
> ---
> plugins/trunk/toptrackbackposts/templates/toptrackbackposts.template
> 2005-01-20 16:04:28 UTC (rev 778)
> +++
> plugins/trunk/toptrackbackposts/templates/toptrackbackposts.template
> 2005-01-20 16:06:26 UTC (rev 779)
> @@ -0,0 +1,16 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"
> showOpt=TopTrackbackPosts
> title=$locale->tr("toptrackbackposts_plugin")}
> +<form name="toptrackbackpostsPluginConfig" method="post">
> + {$locale->tr("toptrackbackposts_plugin_enabled")}
> + <input type="checkbox" name="pluginEnabled" {if $pluginEnabled}
> checked="checked" {/if} value="1" /><br/>
> + <fieldset>
> +
> <legend>{$locale->tr("toptrackbackposts_plugin_configuration")}</
> legend>
> + {$locale->tr("toptrackbackposts_maxposts")}
> + <input type="text" name="maxPosts" value="{$maxPosts}" width="10" />
> + </fieldset>
> + <br/>
> + <input type="hidden" name="op" value="updateTopTrackbackPostsConfig"
> />
> + <input type="submit" name="{$locale->tr("update_settings")}"
> value="{$locale->tr("update")}" />
> +</form>
> +{include file="$admintemplatepath/footernavigation.template"}
> +{include file="$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.plogworld.net
> http://devel.plogworld.net/mailman/listinfo/plog-svn
>
More information about the pLog-svn
mailing list