[pLog-svn] r5376 - in plugins/branches/lifetype-1.2: . categorycloud unported
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Wed May 2 23:42:17 EDT 2007
Author: jondaley
Date: 2007-05-02 23:42:16 -0400 (Wed, 02 May 2007)
New Revision: 5376
Added:
plugins/branches/lifetype-1.2/categorycloud/
plugins/branches/lifetype-1.2/categorycloud/class/
plugins/branches/lifetype-1.2/categorycloud/locale/
plugins/branches/lifetype-1.2/categorycloud/plugincategorycloud.class.php
plugins/branches/lifetype-1.2/categorycloud/readme.txt
plugins/branches/lifetype-1.2/categorycloud/templates/
Removed:
plugins/branches/lifetype-1.2/categorycloud/class/
plugins/branches/lifetype-1.2/categorycloud/locale/
plugins/branches/lifetype-1.2/categorycloud/plugincategorycloud.class.php
plugins/branches/lifetype-1.2/categorycloud/readme.txt
plugins/branches/lifetype-1.2/categorycloud/templates/
plugins/branches/lifetype-1.2/unported/categorycloud/
Log:
ported to 1.2
Copied: plugins/branches/lifetype-1.2/categorycloud (from rev 5374, plugins/branches/lifetype-1.2/unported/categorycloud)
Copied: plugins/branches/lifetype-1.2/categorycloud/class (from rev 5375, plugins/branches/lifetype-1.2/unported/categorycloud/class)
Copied: plugins/branches/lifetype-1.2/categorycloud/locale (from rev 5375, plugins/branches/lifetype-1.2/unported/categorycloud/locale)
Deleted: plugins/branches/lifetype-1.2/categorycloud/plugincategorycloud.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/categorycloud/plugincategorycloud.class.php 2007-05-02 14:09:07 UTC (rev 5374)
+++ plugins/branches/lifetype-1.2/categorycloud/plugincategorycloud.class.php 2007-05-03 03:42:16 UTC (rev 5376)
@@ -1,210 +0,0 @@
-<?php
-
-lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
-lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
-
-
- /*
- * This plugin generates a CategoryCloud for a specific Blog
- *
- * The plugin is based on TagCloud, by Ben Yacoub Hatem. In fact, most
- * of the admin interface and the main algorithm to build the cloud is
- * EXACTLY the same.
- */
- class PluginCategoryCloud extends PluginBase
- {
-
- var $pluginEnabled;
- var $cacheFolder;
-
- /*
- * Constructor
- */
- function PluginCategoryCloud() {
-
- $this->PluginBase();
-
- $this->id = "categorycloud";
- $this->author = "Mariano Draghi (cHagHi)";
- $this->desc = "This plugin offers a CategoryCloud for a specific Blog";
-
- $this->version = '1.0';
- $this->locales = Array( "en_UK", "es_ES" );
-
- $this->init();
- }
-
-
- function init()
- {
- // register the events we want
- $this->registerNotification( EVENT_POST_POST_ADD );
- $this->registerNotification( EVENT_POST_POST_UPDATE );
- $this->registerNotification( EVENT_POST_POST_DELETE );
-
- $this->registerAdminAction( "categorycloud", "PluginCategoryCloudConfigAction" );
- $this->registerAdminAction( "updateCategoryCloudConfig", "PluginCategoryCloudUpdateConfigAction" );
- $menu =& Menu::getMenu();
- if( !$menu->entryExists( "/menu/controlCenter/manageAppearancePlugins" ))
- $this->addMenuEntry( "/menu/controlCenter", "manageAppearancePlugins", "", "", true, false );
- $this->addMenuEntry( "/menu/controlCenter/manageAppearancePlugins", "CategoryCloud", "?op=categorycloud", "" );
- }
-
- function register()
- {
- $config =& Config::getConfig();
- $this->cacheFolder = $config->getValue('temp_folder');
- $this->cacheFolder = $this->cacheFolder.'/categorycloud/'.$this->blogInfo->getId();
- if( !File::exists( $this->cacheFolder )) {
- File::createDir( $this->cacheFolder, 0755 );
- }
-
- $blogSettings = $this->blogInfo->getSettings();
- $this->pluginEnabled = $blogSettings->getValue( "plugin_categorycloud_enabled" );
-
- }
-
-
- 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 &&
- $eventType != EVENT_POST_POST_UPDATE &&
- $eventType != EVENT_POST_POST_DELETE )
- {
- 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 CategoryCloud png
- $this->createCloud();
-
- return true;
- }
-
-
-
- /*
- * Return cloud of the blog categories
- */
- function createCloud(){
-
- $blogId = $this->blogInfo->getId();
-
- $blogSettings = $this->blogInfo->getSettings();
- $pluginEnabled = $blogSettings->getValue( "plugin_categorycloud_enabled" );
-
- if (!$pluginEnabled) {
- return;
- }
-
- $maxSize = $blogSettings->getValue( "plugin_categorycloud_max_size" );
- $maxWeight = $blogSettings->getValue( "plugin_categorycloud_max_weight" );
-
- $minSize = $blogSettings->getValue( "plugin_categorycloud_min_size" );
- $minWeight = $blogSettings->getValue( "plugin_categorycloud_min_weight" );
-
- $categories = Array();
- $urls = Array();
- $rg = $this->blogInfo->getBlogRequestGenerator();
- $articlecategories = new ArticleCategories();
- $categoryobjects = $articlecategories->getBlogCategories( $blogId );
-
- if (!$categoryobjects || (count($categoryobjects) == 0))
- return false;
-
- foreach ($categoryobjects as $category) {
- $categories[$category->getName()] = $category->getNumPublishedArticles();
- $urls[$category->getName()] = $rg->categoryLink( $category );
- }
-
- // First sort the array by value, in reverse order
- arsort($categories);
-
- // get the highest and lowest occurrences
- $maxValue = current($categories);
- $minValue = end($categories);
-
- // Sort the keys alphabetically.
- ksort( $categories );
-
- // Normalize the max value
- $maxValue = $maxValue - $minValue;
- // avoid a divide by zero if all of the words in our group
- // occur exactly the same number of times.
- if($maxValue == 0)
- $maxValue = 1;
-
- // Create the Cloud
- $Cloud = '';
- foreach( $categories as $k=>$v) {
-
- $value = $v - $minValue;
-
- $size = (($value *$maxSize)/$maxValue) + $minSize;
- $weight = (($value *$maxWeight)/$maxValue) + $minWeight;
-
- if ($size > $maxSize) $size = $maxSize;
- if ($weight > $maxWeight) $weight = $maxWeight;
- $weight = floor($weight / 100) * 100;
-
- $Cloud .= "<a rel=\"nofollow\" href=\"{$urls[$k]}\" style=\"font-size: {$size}em; font-weight: {$weight}; line-height: 90%\" title=\"$k\">$k</a>\n";
- }
-
- $saveFile = $this->cacheFolder."/categorycloud";
-
- $fh = fopen( $saveFile, "w");
- if ($fh)
- {
- fwrite($fh, $Cloud);
- fclose($fh);
- File::chMod($saveFile, 0644);
- }
-
- }
-
- /*
- * Return cloud for blog's categories
- */
- function getCategoryCloud(){
-
- $saveFile = $this->cacheFolder."/categorycloud";
-
- $Cloud = '';
-
- $fh = fopen( $saveFile, "r");
- if ($fh)
- {
- $Cloud = fread($fh, filesize($saveFile));
- fclose($fh);
- }
-
-
- return $Cloud;
-
- }
-
-
-}
-
-
-?>
Copied: plugins/branches/lifetype-1.2/categorycloud/plugincategorycloud.class.php (from rev 5375, plugins/branches/lifetype-1.2/unported/categorycloud/plugincategorycloud.class.php)
===================================================================
--- plugins/branches/lifetype-1.2/categorycloud/plugincategorycloud.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/categorycloud/plugincategorycloud.class.php 2007-05-03 03:42:16 UTC (rev 5376)
@@ -0,0 +1,227 @@
+<?php
+
+lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+
+
+ /*
+ * This plugin generates a CategoryCloud for a specific Blog
+ */
+ class PluginCategoryCloud extends PluginBase
+ {
+
+ var $pluginEnabled;
+ var $cacheFolder;
+
+ /*
+ * Constructor
+ */
+ function PluginCategoryCloud() {
+
+ $this->PluginBase();
+
+ $this->id = "categorycloud";
+ $this->author = "Mariano Draghi (cHagHi)";
+ $this->desc = "This plugin offers a CategoryCloud for a specific Blog";
+
+ $this->version = '20070502';
+ $this->locales = Array( "en_UK", "es_ES" );
+
+ $this->init();
+ }
+
+
+ function init()
+ {
+ // register the events we want
+ $this->registerNotification( EVENT_POST_POST_ADD );
+ $this->registerNotification( EVENT_POST_POST_UPDATE );
+ $this->registerNotification( EVENT_POST_POST_DELETE );
+
+ $this->registerAdminAction( "categorycloud", "PluginCategoryCloudConfigAction" );
+ $this->registerAdminAction( "updateCategoryCloudConfig", "PluginCategoryCloudUpdateConfigAction" );
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/manageAppearancePlugins" ))
+ $this->addMenuEntry( "/menu/controlCenter", "manageAppearancePlugins", "", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/manageAppearancePlugins", "CategoryCloud", "?op=categorycloud", "" );
+ }
+
+ function register()
+ {
+ $config =& Config::getConfig();
+ $this->cacheFolder = $config->getValue('temp_folder');
+ $this->cacheFolder = $this->cacheFolder.'/categorycloud/'.$this->blogInfo->getId();
+ if( !File::exists( $this->cacheFolder )) {
+ File::createDir( $this->cacheFolder, 0755 );
+ }
+
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_categorycloud_enabled" );
+
+ }
+
+
+ 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 &&
+ $eventType != EVENT_POST_POST_UPDATE &&
+ $eventType != EVENT_POST_POST_DELETE )
+ {
+ 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 CategoryCloud png
+ $this->createCloud();
+
+ return true;
+ }
+
+
+
+ /*
+ * Return cloud of the blog categories
+ */
+ function createCloud(){
+ lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+
+ $blogId = $this->blogInfo->getId();
+
+ $blogSettings = $this->blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_categorycloud_enabled" );
+
+ if (!$pluginEnabled) {
+ return;
+ }
+
+ $maxSize = $blogSettings->getValue( "plugin_categorycloud_max_size" );
+ $maxWeight = $blogSettings->getValue( "plugin_categorycloud_max_weight" );
+
+ $minSize = $blogSettings->getValue( "plugin_categorycloud_min_size" );
+ $minWeight = $blogSettings->getValue( "plugin_categorycloud_min_weight" );
+
+ $categories = Array();
+ $urls = Array();
+ $rg = $this->blogInfo->getBlogRequestGenerator();
+ $articlecategories = new ArticleCategories();
+ $categoryobjects = $articlecategories->getBlogCategories( $blogId );
+
+ if (!$categoryobjects || (count($categoryobjects) == 0))
+ return false;
+
+ foreach ($categoryobjects as $category) {
+ $categories[$category->getName()] = $category->getNumPublishedArticles();
+ $urls[$category->getName()] = $rg->categoryLink( $category );
+ }
+
+ // First sort the array by value, in reverse order
+ arsort($categories);
+
+ // get the highest and lowest occurrences
+ $maxValue = current($categories);
+ $minValue = end($categories);
+
+ // Sort the keys alphabetically.
+ ksort( $categories );
+
+ // Normalize the max value
+ $maxValue = $maxValue - $minValue;
+ // avoid a divide by zero if all of the words in our group
+ // occur exactly the same number of times.
+ if($maxValue == 0)
+ $maxValue = 1;
+
+ // Create the Cloud
+ $Cloud = '';
+ foreach( $categories as $k=>$v) {
+
+ $value = $v - $minValue;
+
+ $size = (($value *$maxSize)/$maxValue) + $minSize;
+ $weight = (($value *$maxWeight)/$maxValue) + $minWeight;
+
+ if ($size > $maxSize) $size = $maxSize;
+ if ($weight > $maxWeight) $weight = $maxWeight;
+ $weight = floor($weight / 100) * 100;
+
+ $Cloud .= "<a rel=\"nofollow\" href=\"{$urls[$k]}\" style=\"font-size: {$size}em; font-weight: {$weight}; line-height: 90%\" title=\"$k\">$k</a>\n";
+ }
+
+ $saveFile = $this->cacheFolder."/categorycloud";
+
+ $fh = fopen( $saveFile, "w");
+ if ($fh)
+ {
+ fwrite($fh, $Cloud);
+ fclose($fh);
+ File::chMod($saveFile, 0644);
+ }
+
+ }
+
+ /*
+ * Return cloud for blog categories
+ */
+ function getCategoryCloud(){
+
+ $Cloud = '';
+
+ if ($this->isEnabled())
+ {
+ $saveFile = $this->cacheFolder."/categorycloud";
+
+
+ if(File::isReadable($saveFile)){
+ $fh = fopen( $saveFile, "r");
+ if ($fh)
+ {
+ $Cloud = fread($fh, filesize($saveFile));
+ fclose($fh);
+ }
+ }
+ }
+
+ return $Cloud;
+ }
+
+ function getPluginConfigurationKeys()
+ {
+ lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/floatvalidator.class.php" );
+
+ return( Array(
+ Array( "name" => "plugin_categorycloud_enabled", "type" => "boolean" ),
+ Array( "name" => "plugin_categorycloud_min_size",
+ "validator" => new FloatValidator(), "type" => "integer", "allowEmpty" => true ),
+ Array( "name" => "plugin_categorycloud_max_size",
+ "validator" => new FloatValidator(), "type" => "integer", "allowEmpty" => true ),
+ Array( "name" => "plugin_categorycloud_min_weight",
+ "validator" => new IntegerValidator(), "type" => "integer", "allowEmpty" => true ),
+ Array( "name" => "plugin_categorycloud_max_weight",
+ "validator" => new IntegerValidator(), "type" => "integer", "allowEmpty" => true ),
+ ));
+ }
+
+}
+
+
+?>
Deleted: plugins/branches/lifetype-1.2/categorycloud/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/unported/categorycloud/readme.txt 2007-05-02 14:09:07 UTC (rev 5374)
+++ plugins/branches/lifetype-1.2/categorycloud/readme.txt 2007-05-03 03:42:16 UTC (rev 5376)
@@ -1,28 +0,0 @@
-Plugin: CategoryCloud
-Author: Mariano Draghi
-Release Date: 2006/11/05
-Version: 1.0
-
-This plugin offers a category cloud for a blog.
-
-The plugin is based on TagCloud, by Ben Yacoub Hatem. In fact, most
-of the admin interface and the main algorithm to build the cloud is
-EXACTLY the same.
-
-
-Example usage:
-
-<div class="sidetitle">{$locale->tr("categories")}</div>
-<div class="side">
-{if $categorycloud->isEnabled()}
- <div style="text-align:center; padding: 3px;">{ $categorycloud->getCategoryCloud()}</div>
-{else}
- <!-- fallback to "classic" categories sidebar -->
- <ul>
- {foreach from=$articlecategories item=category}
- <li><a href="{$url->categoryLink($category)}">{$category->getName()}</a></li>
- {/foreach}
- </ul>
-{/if}
-</div>
-
Copied: plugins/branches/lifetype-1.2/categorycloud/readme.txt (from rev 5375, plugins/branches/lifetype-1.2/unported/categorycloud/readme.txt)
===================================================================
--- plugins/branches/lifetype-1.2/categorycloud/readme.txt (rev 0)
+++ plugins/branches/lifetype-1.2/categorycloud/readme.txt 2007-05-03 03:42:16 UTC (rev 5376)
@@ -0,0 +1,26 @@
+Plugin: CategoryCloud
+Author: Mariano Draghi
+Release Date: 2006/11/05
+Current Version: 20070502
+
+This plugin offers a category cloud.
+
+The plugin is based on TagCloud, by Ben Yacoub Hatem.
+
+Usage:
+
+
+{if $categorycloud && $categorycloud->isEnabled()}
+<h2> {$locale->tr("Category cloud")} </h2>
+<ul>
+ <li><div style="text-align:center">
+ {$categorycloud->getCategoryCloud()}
+ </div></li>
+</ul>
+{/if}
+
+Changelog
+=========
+20070502 - Migration to LifeType 1.2
+1.0.0 - Initial version
+
Copied: plugins/branches/lifetype-1.2/categorycloud/templates (from rev 5375, plugins/branches/lifetype-1.2/unported/categorycloud/templates)
More information about the pLog-svn
mailing list