[pLog-svn] r4116 - plugins/branches/lifetype-1.1/tagcloud

Jon Daley plogworld at jon.limedaley.com
Tue Oct 10 15:44:29 GMT 2006


I forgot to say that I also removed this check:
  eregi("[a-zA-Z]",$k)

eregi is case-insensitive, so it is doing extra work to start with, and 
since the numbers are on the default banned list, and normalized text 
doesn't have non-ascii, I don't think we needed this extra check?

On Tue, 10 Oct 2006, jondaley at devel.lifetype.net wrote:

> Author: jondaley
> Date: 2006-10-10 15:27:22 +0000 (Tue, 10 Oct 2006)
> New Revision: 4116
>
> Modified:
>   plugins/branches/lifetype-1.1/tagcloud/plugintagcloud.class.php
> Log:
> capitalized words weren't being banned correctly. Everything is now case-insensitive. The first word also wasn't being banned, since 0 is similar to NULL and FALSE.  added nofollow to links, to keep search engines from indexing the search pages - it is better to index the page that actually contains the post in context.  Also changed a line-height -- stylistic change, the css should probably be moved to the config page.
>
> Modified: plugins/branches/lifetype-1.1/tagcloud/plugintagcloud.class.php
> ===================================================================
> --- plugins/branches/lifetype-1.1/tagcloud/plugintagcloud.class.php	2006-10-10 15:04:31 UTC (rev 4115)
> +++ plugins/branches/lifetype-1.1/tagcloud/plugintagcloud.class.php	2006-10-10 15:27:22 UTC (rev 4116)
> @@ -47,7 +47,6 @@
>
>         $this->registerAdminAction( "tagcloud", "PluginTagCloudConfigAction" );
>         $this->registerAdminAction( "updateTagCloudConfig", "PluginTagCloudUpdateConfigAction" );
> -
>         include_once( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
>         $menu =& Menu::getMenu();
>         if( !$menu->entryExists( "/menu/controlCenter/manageAppearancePlugins" ))
> @@ -134,9 +133,8 @@
> 		$minWeight = $blogSettings->getValue( "plugin_tagcloud_min_weight" );
>
> 		$bannedwords = $blogSettings->getValue( "plugin_tagcloud_banned_keywords" );
> -		$bannedwords = explode(",", $bannedwords);
> -
> -
> +		$bannedwords = explode(",", strtolower($bannedwords));
> +
> 		$MaxArticles = mysql_escape_string($MaxArticles);
>
> 		$query = "SELECT t.normalized_text,t.normalized_topic FROM " . $this->_prefix .
> @@ -157,16 +155,17 @@
> 		$data = implode(' ',$data);
>
> 		// Split keywords
> -		$words = preg_split('/\s*[\s+\.|\?|,|(|)|\-+|\'|\"|!|=|;|×|\$|\/|:|{|}]\s*/i', $data);
> +		$words = preg_split('/\s*[\s+\.|\?|,|(|)|\-+|\'|\"|!|=|;|×|\$|\/|:|{|}]\s*/i', strtolower($data));
> 		$acv = array_count_values( $words );
> -
> +
> 		// Remove unwanted keywords
> 		foreach($acv as $k=>$v) {
> -			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;
> +            $found = array_search($k,$bannedwords);
> +			if(($found === FALSE || $found === NULL) && strlen($k)>2) {
> +				if (isset($new_acv[$k]))
> +					$new_acv[$k] += $v;
> 				else
> -					$new_acv[strtolower($k)] = $v;
> +					$new_acv[$k] = $v;
> 			}
> 		}
>
> @@ -205,7 +204,7 @@
>
>             $rg = $this->blogInfo->getBlogRequestGenerator();
>             $baseUrl = $rg->getBaseUrl();
> -			$Cloud .= "<a href=\"{$baseUrl}?searchTerms=$k&op=Search&blogId={$blogId}\" style=\"font-size: {$size}em; font-weight: {$weight}\" title=\"$k\">$k</a> \n";
> +			$Cloud .= "<a rel=\"nofollow\" href=\"{$baseUrl}?searchTerms=$k&op=Search&blogId={$blogId}\" style=\"font-size: {$size}em; font-weight: {$weight}; line-height: 90%\" title=\"$k\">$k</a>\n";
> 		}
>
>         $saveFile = $this->cacheFolder."/tagcloud";
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
>

-- 
Jon Daley
http://jon.limedaley.com/

Scientists have proven that it's impossible to long-jump 30 feet,
but I don't listen to that kind of talk.
Thoughts like that have a way of sinking into your feet.
-- Carl Lewis


More information about the pLog-svn mailing list