[pLog-svn] r4967 - plugins/branches/lifetype-1.2/tagcloud

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sat Mar 3 19:31:34 EST 2007


Author: jondaley
Date: 2007-03-03 19:31:33 -0500 (Sat, 03 Mar 2007)
New Revision: 4967

Modified:
   plugins/branches/lifetype-1.2/tagcloud/plugintagcloud.class.php
Log:
prevent a php exception if the tagcloud hasn't been generated yet. removed a manual call to register(), that should be called automatically. check enabled before doing stuff

Modified: plugins/branches/lifetype-1.2/tagcloud/plugintagcloud.class.php
===================================================================
--- plugins/branches/lifetype-1.2/tagcloud/plugintagcloud.class.php	2007-03-04 00:21:50 UTC (rev 4966)
+++ plugins/branches/lifetype-1.2/tagcloud/plugintagcloud.class.php	2007-03-04 00:31:33 UTC (rev 4967)
@@ -96,14 +96,9 @@
                 return true;
             }
             
-            // Load all of the settings for this blog
-            $this->register();
-            
             // make sure that the plugin is enabled
-			if( !$this->isEnabled())
-            {
+			if(!$this->isEnabled())
                 return true;
-            }
                         
             // Update the Blogtime png
             $this->createCloud();
@@ -118,16 +113,12 @@
 	*/
 	function createCloud(){
 
-		$this->_prefix = Db::getPrefix();
+		$prefix = Db::getPrefix();
 		$blogId = $this->blogInfo->getId();
-	
-
 		$blogSettings = $this->blogInfo->getSettings();
-        $pluginEnabled = $blogSettings->getValue( "plugin_tagcloud_enabled" );
         
-        if (!$pluginEnabled) {
-            return;
-        }
+        if (!$this->pluginEnabled)
+            return false;
 
         $MaxArticles = $blogSettings->getValue( "plugin_tagcloud_max_articles" );
         $MaxKeywords = $blogSettings->getValue( "plugin_tagcloud_max_keywords" );
@@ -144,8 +135,8 @@
 
 		$MaxArticles = mysql_escape_string($MaxArticles);
 	
-		$query = "SELECT t.normalized_text,t.normalized_topic FROM " . $this->_prefix . 
-		    "articles a, " . $this->_prefix."articles_text t" .
+		$query = "SELECT t.normalized_text,t.normalized_topic FROM " . $prefix . 
+		    "articles a, " . $prefix."articles_text t" .
 		    " WHERE a.id=t.article_id " .
 		    " AND a.status=1 AND a.blog_id = " . $blogId . 
 		    " ORDER BY a.date DESC LIMIT 0,$MaxArticles;";
@@ -234,21 +225,17 @@
         $saveFile = $this->cacheFolder."/tagcloud";  
 	    
 	    $Cloud = '';
-	    
-	    $fh = fopen( $saveFile, "r");
-	    if ($fh)
-	    {
-    	    $Cloud = fread($fh, filesize($saveFile));
-            fclose($fh);
-	    }
-		
-	
-		return $Cloud;
-		
+
+        if(File::isReadable($saveFile)){
+            $fh = fopen( $saveFile, "r");
+            if ($fh)
+            {
+                $Cloud = fread($fh, filesize($saveFile));
+                fclose($fh);
+            }
+        }
+
+        return $Cloud;
     }
-	
-	
 }
-        
-        
 ?>
\ No newline at end of file



More information about the pLog-svn mailing list