[pLog-svn] r1914 - plugins/trunk/blogtimes

oscar at devel.plogworld.net oscar at devel.plogworld.net
Fri Apr 29 07:03:38 GMT 2005


Author: oscar
Date: 2005-04-29 07:03:37 +0000 (Fri, 29 Apr 2005)
New Revision: 1914

Modified:
   plugins/trunk/blogtimes/pluginblogtimes.class.php
Log:
fixed issue 454 (http://bugs.plogworld.net/view.php?id=454), thanks pwestbro!!!


Modified: plugins/trunk/blogtimes/pluginblogtimes.class.php
===================================================================
--- plugins/trunk/blogtimes/pluginblogtimes.class.php	2005-04-29 06:57:52 UTC (rev 1913)
+++ plugins/trunk/blogtimes/pluginblogtimes.class.php	2005-04-29 07:03:37 UTC (rev 1914)
@@ -2,8 +2,8 @@
 
     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/model.class.php" );
-	include_once( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
+    include_once( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
 
     /**
      * Plugin that offers blogtimes for current blog
@@ -12,8 +12,8 @@
     class PluginBlogTimes extends PluginBase
     {
 
-		var $pluginEnabled;
-		var $prefix;
+        var $pluginEnabled;
+        var $prefix;
         var $backColor;
         var $boxColor;
         var $textColor;
@@ -42,56 +42,87 @@
             $this->init();            
         }
 
-		function init()
-		{
+        function init()
+        {
+            // register the events we want
+            $this->registerNotification( EVENT_POST_POST_ADD );
+        
             $this->registerAdminAction( "blogtimes", "PluginBlogTimesConfigAction" );
-			$this->registerAdminAction( "updateBlogTimesConfig", "PluginBlogTimesUpdateConfigAction" );
-			
-			$menu =& Menu::getMenu();
-			if( !$menu->entryExists( "/menu/controlCenter/manageAppearancePlugins" ))						
-				$this->addMenuEntry( "/menu/controlCenter", "manageAppearancePlugins", "", "", true, false );			
+            $this->registerAdminAction( "updateBlogTimesConfig", "PluginBlogTimesUpdateConfigAction" );
+            
+            $menu =& Menu::getMenu();
+            if( !$menu->entryExists( "/menu/controlCenter/manageAppearancePlugins" ))                       
+                $this->addMenuEntry( "/menu/controlCenter", "manageAppearancePlugins", "", "", true, false );           
             $this->addMenuEntry( "/menu/controlCenter/manageAppearancePlugins", "BlogTimes", "?op=blogtimes", "" );            
-		}
+        }
 
-		function register()
-		{
+        function register()
+        {
             $config =& Config::getConfig();
             $this->cacheFolder = $config->getValue('temp_folder');
-			$this->cacheFolder = $this->cacheFolder.'/blogtimes/'.$this->blogInfo->getId();
-			if( !File::exists( $this->cacheFolder )) {
-				File::createDir( $this->cacheFolder );
-			}
+            $this->cacheFolder = $this->cacheFolder.'/blogtimes/'.$this->blogInfo->getId();
+            if( !File::exists( $this->cacheFolder )) {
+                File::createDir( $this->cacheFolder );
+            }
 
-		    $blogSettings = $this->blogInfo->getSettings();
-		    $this->pluginEnabled = $blogSettings->getValue( "plugin_blogtimes_enabled" );
-		    $this->backColor = $blogSettings->getValue( "plugin_blogtimes_backcolor" );
-		    $this->boxColor = $blogSettings->getValue( "plugin_blogtimes_boxcolor" );
-		    $this->textColor = $blogSettings->getValue( "plugin_blogtimes_textcolor" );
-		    $this->lineColor = $blogSettings->getValue( "plugin_blogtimes_linecolor" );
-		    $this->borderColor = $blogSettings->getValue( "plugin_blogtimes_bordercolor" );
-		    $this->tickColor = $blogSettings->getValue( "plugin_blogtimes_tickcolor" );
-		    $this->title = $blogSettings->getValue( "plugin_blogtimes_title" );
-		    $this->width = $blogSettings->getValue( "plugin_blogtimes_width" );
-		    $this->height = $blogSettings->getValue( "plugin_blogtimes_height" );
-		    $this->lastDays = $blogSettings->getValue( "plugin_blogtimes_lastdays" );
-	    }
-	    
-	    function isEnabled()
-	    {
-	        return $this->pluginEnabled;
-	    }        
+            $blogSettings = $this->blogInfo->getSettings();
+            $this->pluginEnabled = $blogSettings->getValue( "plugin_blogtimes_enabled" );
+            $this->backColor = $blogSettings->getValue( "plugin_blogtimes_backcolor" );
+            $this->boxColor = $blogSettings->getValue( "plugin_blogtimes_boxcolor" );
+            $this->textColor = $blogSettings->getValue( "plugin_blogtimes_textcolor" );
+            $this->lineColor = $blogSettings->getValue( "plugin_blogtimes_linecolor" );
+            $this->borderColor = $blogSettings->getValue( "plugin_blogtimes_bordercolor" );
+            $this->tickColor = $blogSettings->getValue( "plugin_blogtimes_tickcolor" );
+            $this->title = $blogSettings->getValue( "plugin_blogtimes_title" );
+            $this->width = $blogSettings->getValue( "plugin_blogtimes_width" );
+            $this->height = $blogSettings->getValue( "plugin_blogtimes_height" );
+            $this->lastDays = $blogSettings->getValue( "plugin_blogtimes_lastdays" );
+        }
+        
+        function isEnabled()
+        {
+            return $this->pluginEnabled;
+        }        
 
+        /**
+         * process the events that we have registered
+         *
+         * @see PluginBase::process
+         * @see PluginManager
+         */
+        function process( $eventType, $params )
+        {
+            // make sure we're processing the right event!
+            if( $eventType != EVENT_POST_POST_ADD ) 
+            {
+                return true;
+            }
+            
+            // Load all of the settings for this blog
+            $this->register();
+            
+            // make sure that the plugin is enabled
+			if( !$this->isEnabled())
+            {
+                return true;
+            }
+                        
+            // Update the Blogtime png
+            $this->updateBlogTimePNG();
+
+            return true;
+        }
+        
         function show() {
             $saveFile = $this->cacheFolder."/blogtimes.png";
-   			$rg =& RequestGenerator::getRequestGenerator( $this->blogInfo );
-            $this->updateBlogTimePNG();
+            $rg =& RequestGenerator::getRequestGenerator( $this->blogInfo );
             $blogtimesTag = "<div align=\"center\"><img src=\"".$rg->getUrl($saveFile)."\" /></div>";
             return $blogtimesTag;                    
         }
         
         function updateBlogTimePNG()
         {
-        	$saveFile = $this->cacheFolder."/blogtimes.png";  
+            $saveFile = $this->cacheFolder."/blogtimes.png";  
             
             // constants defining image
             $width = $this->width;
@@ -203,19 +234,19 @@
         {
             $blogId = $this->blogInfo->getId();
 
-        	$query = "SELECT HOUR(date)*60+MINUTE(date) AS totmins FROM ".$this->prefix."articles";
-        	$query .= " WHERE blog_id = ".$blogId." AND status = 1";
-           	$query .= " AND (TO_DAYS(CURRENT_DATE) - TO_DAYS(date)) <= '$lastDays'";
+            $query = "SELECT HOUR(date)*60+MINUTE(date) AS totmins FROM ".$this->prefix."articles";
+            $query .= " WHERE blog_id = ".$blogId." AND status = 1";
+            $query .= " AND (TO_DAYS(CURRENT_DATE) - TO_DAYS(date)) <= '$lastDays'";
             $query .= " ORDER BY date ASC";
 
             $result = $this->db->Execute( $query );
 
             if( !$result )
-            	return false;
+                return false;
 
             $postTimes = Array();
             while( $row = $result->FetchRow()) {
-            	array_push( $postTimes, $row["totmins"]);
+                array_push( $postTimes, $row["totmins"]);
             }
             
             return $postTimes;




More information about the pLog-svn mailing list