[pLog-svn] r3337 - plugins/trunk/tagcloud

pwestbro at devel.lifetype.net pwestbro at devel.lifetype.net
Fri May 5 05:28:48 GMT 2006


Author: pwestbro
Date: 2006-05-05 05:28:47 +0000 (Fri, 05 May 2006)
New Revision: 3337

Modified:
   plugins/trunk/tagcloud/plugintagcloud.class.php
Log:
Made the tag cloud plugin work with LifeType 1.1.

Also fixed a problem where the plugin would stop looking at tags after the
first $MaxKeywords valid words.  Now it looks through $MaxArticle to find
all of the keywords.


Modified: plugins/trunk/tagcloud/plugintagcloud.class.php
===================================================================
--- plugins/trunk/tagcloud/plugintagcloud.class.php	2006-05-05 04:48:51 UTC (rev 3336)
+++ plugins/trunk/tagcloud/plugintagcloud.class.php	2006-05-05 05:28:47 UTC (rev 3337)
@@ -26,7 +26,7 @@
 		    
 		$this->PluginBase();
 		$this->db =& Db::getDb();
-		$this->id = "TagCloud";
+		$this->id = "tagcloud";
 	}
 
 	/*
@@ -63,23 +63,31 @@
 		
 		// Remove unwanted keywords
 		$bannedwords = array( '', 'a', 'an', 'the', 'and', 'of', 'i', 'its' , 'to', 'is', 'in', 'with', 'for', 'as', 'that', 'on', 'at', 'this', 'my', 'was', 'our', 'it', 'you', 'we', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '10', 'about', 'after', 'all', 'almost', 'along', 'also', 'amp', 'another', 'any', 'are', 'area', 'around', 'available', 'back', 'be', 'because', 'been', 'being', 'best', 'better', 'big', 'bit', 'both', 'but', 'by', 'c', 'came', 'can', 'capable', 'control', 'could', 'course', 'd', 'dan', 'day', 'decided', 'did', 'didn', 'different', 'div', 'do', 'doesn', 'don', 'down', 'drive', 'e', 'each', 'easily', 'easy', 'edition', 'end', 'enough', 'even', 'every', 'example', 'few', 'find', 'first', 'found', 'from', 'get', 'go', 'going', 'good', 'got', 'gt', 'had', 'hard', 'has', 'have', 'he', 'her', 'here', 'how', 'if', 'into', 'isn', 'just', 'know', 'last', 'left', 'li', 'like', 'little', 'll', 'long', 'look', 'lot', 'lt', 'm', 'made', 'make', 'many', 'mb', 'me', 'menu', 'might', 'mm', 'more', 'most', 'much', 'name', 'nbsp', 'need', 'new', 'no', 'not', 'now', 'number', 'off', 'old', 'one', 'only', 'or', 'original', 'other', 'out', 'over', 'part', 'place', 'point', 'pretty', 'probably', 'problem', 'put', 'quite', 'quot', 'r', 're', 'really', 'results', 'right', 's', 'same', 'saw', 'see', 'set', 'several', 'she', 'sherree', 'should', 'since', 'size', 'small', 'so', 'some', 'something', 'special', 'still', 'stuff', 'such', 'sure', 'system', 't', 'take', 'than', 'their', 'them', 'then', 'there', 'these', 'they', 'thing', 'things', 'think', 'those', 'though', 'through', 'time', 'today', 'together', 'too', 'took', 'two', 'up', 'us', 'use', 'used', 'using', 've', 'very', 'want', 'way', 'well', 'went', 'were', 'what', 'when', 'where', 'which', 'while', 'white', 'who', 'will', 'would', 'your');
-		$i = 0;
 		foreach($acv as $k=>$v) {
-			if (!array_search(strtolower($k),$bannedwords) and eregi("[a-zA-Z]",$k) and $i<=$MaxKeywords and strlen($k)>2) {
+			if (!array_search(strtolower($k),$bannedwords) and eregi("[a-zA-Z]",$k) and strlen($k)>2) {
 				if (isset($new_acv[strtolower($k)] )) 
 					$new_acv[strtolower($k)] += $v;
 				else 
 					$new_acv[strtolower($k)] = $v;
-				$i++;
 			}
 		}
 		
+		// First sort the array by value, in reverse order
+		arsort($new_acv);
+		
+		// Now limit the array to $MaxKeywords
+		$chunkedArray = array_chunk( $new_acv, $MaxKeywords, true);
+		
+		// Get the first array chunk
+		$new_acv = $chunkedArray[0];
+		
 		// Sort the keys alphabetically.
 		ksort( $new_acv );
 		
 		// Create the Cloud
 		$Cloud = '';
 		foreach( $new_acv as $k=>$v) {
+
 			$size = $v*0.4;
 			$weight = $v*4;
 			



More information about the pLog-svn mailing list