[pLog-svn] r4239 - in plugins/branches/lifetype-1.1: . ayearago ayearago/class ayearago/class/action ayearago/class/view ayearago/locale ayearago/templates categorycloud categorycloud/class categorycloud/class/action categorycloud/class/view categorycloud/locale categorycloud/templates

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Nov 5 17:18:00 GMT 2006


Author: oscar
Date: 2006-11-05 17:17:59 +0000 (Sun, 05 Nov 2006)
New Revision: 4239

Added:
   plugins/branches/lifetype-1.1/ayearago/
   plugins/branches/lifetype-1.1/ayearago/class/
   plugins/branches/lifetype-1.1/ayearago/class/action/
   plugins/branches/lifetype-1.1/ayearago/class/action/pluginayearagoconfigaction.class.php
   plugins/branches/lifetype-1.1/ayearago/class/action/pluginayearagoupdateconfigaction.class.php
   plugins/branches/lifetype-1.1/ayearago/class/view/
   plugins/branches/lifetype-1.1/ayearago/class/view/pluginayearagoconfigview.class.php
   plugins/branches/lifetype-1.1/ayearago/locale/
   plugins/branches/lifetype-1.1/ayearago/locale/locale_en_UK.php
   plugins/branches/lifetype-1.1/ayearago/locale/locale_es_ES.php
   plugins/branches/lifetype-1.1/ayearago/pluginayearago.class.php
   plugins/branches/lifetype-1.1/ayearago/readme.txt
   plugins/branches/lifetype-1.1/ayearago/templates/
   plugins/branches/lifetype-1.1/ayearago/templates/ayearago.template
   plugins/branches/lifetype-1.1/categorycloud/
   plugins/branches/lifetype-1.1/categorycloud/class/
   plugins/branches/lifetype-1.1/categorycloud/class/action/
   plugins/branches/lifetype-1.1/categorycloud/class/action/plugincategorycloudconfigaction.class.php
   plugins/branches/lifetype-1.1/categorycloud/class/action/plugincategorycloudupdateconfigaction.class.php
   plugins/branches/lifetype-1.1/categorycloud/class/view/
   plugins/branches/lifetype-1.1/categorycloud/class/view/plugincategorycloudconfigview.class.php
   plugins/branches/lifetype-1.1/categorycloud/locale/
   plugins/branches/lifetype-1.1/categorycloud/locale/locale_en_UK.php
   plugins/branches/lifetype-1.1/categorycloud/locale/locale_es_ES.php
   plugins/branches/lifetype-1.1/categorycloud/plugincategorycloud.class.php
   plugins/branches/lifetype-1.1/categorycloud/readme.txt
   plugins/branches/lifetype-1.1/categorycloud/templates/
   plugins/branches/lifetype-1.1/categorycloud/templates/categorycloud.template
Log:
added the 'categorycloud' and 'ayearago' plugins


Added: plugins/branches/lifetype-1.1/ayearago/class/action/pluginayearagoconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.1/ayearago/class/action/pluginayearagoconfigaction.class.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/ayearago/class/action/pluginayearagoconfigaction.class.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,27 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/ayearago/class/view/pluginayearagoconfigview.class.php" );	
+
+	/**
+	 * shows a form with the current configuration
+	 */
+	class PluginAYearAgoConfigAction extends AdminAction
+	{
+		
+		function PluginAYearAgoConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function perform()
+		{
+            $this->_view = new PluginAYearAgoConfigView( $this->_blogInfo );
+			
+			$this->setCommonData();
+			
+			return true;
+		}
+	}
+?>

Added: plugins/branches/lifetype-1.1/ayearago/class/action/pluginayearagoupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.1/ayearago/class/action/pluginayearagoupdateconfigaction.class.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/ayearago/class/action/pluginayearagoupdateconfigaction.class.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,69 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/ayearago/class/view/pluginayearagoconfigview.class.php" );	
+		
+	/**
+	 * updates the plugin configuration
+	 */
+	class PluginAYearAgoUpdateConfigAction extends AdminAction
+	{
+		var $_pluginEnabled;
+		var $_maxPosts;
+		
+		function PluginAYearAgoUpdateConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function validate()
+		{
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );			
+            $this->_maxPosts = $this->_request->getValue( "maxPosts" );
+            if( $this->_maxPosts <= 0  || !ctype_digit($this->_maxPosts) ) {
+                $this->_view = new PluginAYearAgoConfigView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("ayearago_error_maxposts"));
+                $this->setCommonData();
+
+                return false;
+            }        	                
+			
+			return true;
+		}
+		        
+		function perform()
+		{
+            // // update the plugin configurations to blog setting
+			$blogSettings = $this->_blogInfo->getSettings();
+            $blogSettings->setValue( "plugin_ayearago_enabled", $this->_pluginEnabled );
+            $blogSettings->setValue( "plugin_ayearago_maxcomments", $this->_maxPosts );
+            $this->_blogInfo->setSettings( $blogSettings ); 
+		
+			// save the blogs settings
+			$blogs = new Blogs();
+            if( !$blogs->updateBlog( $this->_blogInfo )) {
+                $this->_view = new PluginAYearAgoConfigView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+                $this->setCommonData();
+
+                return false;
+            }
+			
+			// if everything went ok...
+            $this->_blogInfo->setSettings( $blogSettings );
+            $this->_session->setValue( "blogInfo", $this->_blogInfo );
+            $this->saveSession();
+
+			$this->_view = new PluginAYearAgoConfigView( $this->_blogInfo );
+			$this->_view->setSuccessMessage( $this->_locale->tr("ayearago_settings_saved_ok"));
+			$this->setCommonData();
+			
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId());				
+            
+            return true;		
+		}
+	}
+?>

Added: plugins/branches/lifetype-1.1/ayearago/class/view/pluginayearagoconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.1/ayearago/class/view/pluginayearagoconfigview.class.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/ayearago/class/view/pluginayearagoconfigview.class.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,31 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+	/**
+	 * implements the main view of the a year ago plugin
+	 */
+	class PluginAYearAgoConfigView extends AdminPluginTemplatedView
+	{
+
+		function PluginAYearAgoConfigView( $blogInfo )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "ayearago", "ayearago" );
+		}
+		
+		function render()
+		{
+			// load some configuration settings
+			$blogSettings = $this->_blogInfo->getSettings();
+			$pluginEnabled = $blogSettings->getValue( "plugin_ayearago_enabled" );
+			$maxPosts = $blogSettings->getValue( "plugin_ayearago_maxposts" );
+			if ($maxPosts == "") $maxPosts = 3;
+			
+			// create a view and export the settings to the template
+			$this->setValue( "pluginEnabled", $pluginEnabled );
+			$this->setValue( "maxPosts", $maxPosts );		
+			
+			parent::render();
+		}
+	}
+?>

Added: plugins/branches/lifetype-1.1/ayearago/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.1/ayearago/locale/locale_en_UK.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/ayearago/locale/locale_en_UK.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,15 @@
+<?php
+$messages["AYearAgo"] = "A Year Ago";
+$messages["ayearago"] = "a year ago";
+
+$messages["ayearago_maxposts"] = "Maximum Showed Articles";
+$messages["ayearago_plugin_enabled"] = "Enable this plugin";
+$messages["ayearago_plugin"] = "A Year Ago Plugin";
+
+$messages["ayearago_settings_saved_ok"] = "A Year Ago settings saved successfully!";
+$messages["ayearago_error_maxposts"] = "Maximum Showed Posts Should be > 0!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["label_maxposts"] = "Max Articles";
+?>

Added: plugins/branches/lifetype-1.1/ayearago/locale/locale_es_ES.php
===================================================================
--- plugins/branches/lifetype-1.1/ayearago/locale/locale_es_ES.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/ayearago/locale/locale_es_ES.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,15 @@
+<?php
+$messages["AYearAgo"] = "Hace un a&ntilde;o";
+$messages["ayearago"] = "hace un a&ntilde;o";
+
+$messages["ayearago_maxposts"] = "M&aacute;ximo de art&iacute;culos a mostrar";
+$messages["ayearago_plugin_enabled"] = "Activar este plugin";
+$messages["ayearago_plugin"] = "Plugin Hace un a&ntilde;o";
+
+$messages["ayearago_settings_saved_ok"] = "Los datos se han guardado con &eacute;xito";
+$messages["ayearago_error_maxposts"] = "El m&aacute;ximo debe ser mayor a 0!";
+
+$messages["label_configuration"] = "Configuraci&oacute;n";
+$messages["label_enable"] = "Activar";
+$messages["label_maxposts"] = "M&aacute;x Art&iacute;culos";
+?>


Property changes on: plugins/branches/lifetype-1.1/ayearago/locale/locale_es_ES.php
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/branches/lifetype-1.1/ayearago/pluginayearago.class.php
===================================================================
--- plugins/branches/lifetype-1.1/ayearago/pluginayearago.class.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/ayearago/pluginayearago.class.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,141 @@
+<?php
+	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+    include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+	
+    /**
+     * Plugin that returns an array of posts written a year before
+     */
+    class PluginAYearAgo extends PluginBase 
+    {
+        var $pluginEnabled;
+        var $maxPosts;
+        
+    	function PluginAYearAgo()
+        {
+        	$this->PluginBase();
+
+            $this->id        = "ayearago";
+            $this->author    = "Mariano Draghi (cHagHi)";
+            $this->desc      = "This plugin offers various methods to get a list of posts written a year before a given post, or based on the current date.";
+            $this->version   = '1.0';
+			$this->locales   = Array( "en_UK", "es_ES" );
+
+            $this->init();
+        }
+
+		function init()
+		{
+            $this->registerAdminAction( "ayearago", "PluginAYearAgoConfigAction" );
+			$this->registerAdminAction( "updateAYearAgoConfig", "PluginAYearAgoUpdateConfigAction" );
+			
+            $this->addMenuEntry( "/menu/controlCenter/manageSettings", "AYearAgo", "?op=ayearago", "" );
+		}
+        
+		function register()
+		{
+		    $blogSettings = $this->blogInfo->getSettings();
+			$this->pluginEnabled = $blogSettings->getValue( "plugin_ayearago_enabled" );
+			$this->maxPosts = $blogSettings->getValue( "plugin_ayearago_maxposts", 3 );
+		}
+        
+	    function isEnabled()
+	    {
+	        return $this->pluginEnabled;
+	    }
+		
+        function getOneYearAgoPosts( $post, $maxPosts = -1 )
+        {
+            if ( $maxPosts < 0 )
+            {
+                $maxPosts = $this->maxPosts;
+            }
+            
+            // Timestamp used to find the articles based on a post
+            $timestamp = $this->_getAYearAgoTimestamp( $post->getDateObject() );
+
+            // Get the articles                        
+            $minDate = $timestamp->getYear().$timestamp->getMonth().$this->_getDay( $timestamp );
+            $maxDate = $timestamp->getYear().$timestamp->getMonth().$this->_getDay( $timestamp )."235959";
+            $articles = new Articles();
+            return ( $articles->getBlogArticles( $this->blogInfo->getId(), $minDate, $maxPosts, 0, 0, 0, $maxDate, "", -1 ) );
+        }
+        
+        function getOneYearAgoPostsFuzzy( $post, $maxPosts = -1 )
+        {
+            if ( $maxPosts < 0 )
+            {
+                $maxPosts = $this->maxPosts;
+            }
+            
+            // Timestamp used to find the articles based on a post
+            $timestamp = $this->_getAYearAgoTimestamp( $post->getDateObject() );
+
+            // Get the articles                        
+            $maxDate = $timestamp->getYear().$timestamp->getMonth().$this->_getDay( $timestamp )."235959";
+            $articles = new Articles();
+            $posts = $articles->getBlogArticles( $this->blogInfo->getId(), -1, $maxPosts, 0, 0, 0, $maxDate, "", -1 );
+            
+            // Now check that the retrieved posts don't get overlaped with the previous post
+            $prevArticle = $post->getPrevArticle();
+            $prevTimestamp = $this->_getAYearAgoTimestamp( $prevArticle->getDateObject(), true );
+            $validPosts = Array();
+            foreach ( $posts as $post )
+            {
+                $t = new Timestamp( $post->getDateObject() );
+                if ( $t > $prevTimestamp )
+                {
+                    $validPosts[] = $post;
+                }
+            }
+            
+            return( $validPosts );
+        }
+        
+        function getRecentArticlesAYearAgo( $maxPosts = -1 )
+        {
+            if ( $maxPosts < 0 )
+            {
+                $blogSettings = $this->blogInfo->getSettings();
+                $maxPosts = $blogSettings->getValue( 'recent_posts_max' );
+            }
+
+            // Timestamp for a year ago            
+            $timestamp = $this->_getAYearAgoTimestamp( new Timestamp() );
+
+            // Get the articles
+            $maxDate = $timestamp->getYear().$timestamp->getMonth().$this->_getDay( $timestamp )."235959";
+            $articles = new Articles();
+            return ( $articles->getBlogArticles( $this->blogInfo->getId(), -1, $maxPosts, 0, 0, 0, $maxDate, "", -1 ) );
+        }
+        
+        function _getAYearAgoTimestamp( $date, $end = false )
+        {
+            if ( $date->getMonth() == 2 && $date->getDay() == 29 )
+            {
+                $date->setDay( 28 );
+            }
+
+            $date->setYear( $date->getYear() - 1 );
+            
+            if ( $end )
+            {
+                $date->setHour( 23 );
+                $date->setMinute( 59 );
+                $date->setSecond( 59 );
+                
+            }            
+            
+            return ( new Timestamp( $date ) );
+        }
+
+        function _getDay( $timestamp )
+        {
+            // returns a day ensuring 2 digits
+            $day = $timestamp->getDay();
+            if( $day < 10 && $day[0] != "0" )
+            $day = "0".$day;
+
+            return $day;
+        }
+    }
+?>

Added: plugins/branches/lifetype-1.1/ayearago/readme.txt
===================================================================
--- plugins/branches/lifetype-1.1/ayearago/readme.txt	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/ayearago/readme.txt	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,51 @@
+Plugin: A Year Ago
+Author: Mariano Draghi
+Release Date: 2006/11/02
+Version: 1.0
+
+This plugin offers various methods to get a list of posts written a year
+before a given post, or a year before based on the current date.
+Usage as follow:
+
+You can use:
+1.   $ayearago->isEnabled() 
+     To check if the plugin is enabled or not. 
+
+2.a. $ayearago->getOneYearAgoPosts( $post, $maxPosts )
+     To get the posts (if any) written EXACTLY a year ago the given post.
+     Useful if you post very frecuently.
+
+2.b. $ayearago->getOneYearAgoPostsFuzzy( $post, $maxPosts )
+     To get the posts (if any) written between the given post and the
+     previous one, but a year before.
+     This alternative is more useful if you doesn't post that frequently.
+
+Both 2.a & 2.b are meant to be used in the post.template
+
+3.   $ayearago->getRecentArticlesAYearAgo( $maxPosts )
+     To get the posts written a year ago, based on the current date.
+     This is similar to the normal Recent Articles feature, but for
+     the previous year. This is meant to be used in the header or
+     footer template.
+
+Where:
+1. $post is the current post
+2. $maxPosts is the max. quantity of posts to return. It's optional.
+   If ommitted, for 2.a & 2.b the plugin uses the
+   plugin_ayearago_maxposts setting. For 3, recent_posts_max is used
+   (same setting as the standard Recent Articles feature).
+
+Example:
+Add the following code to post.template:
+{if $ayearago->isEnabled()}
+{assign var="yearAgoPosts" value=$ayearago->getOneYearAgoPostsFuzzy($post)}
+{if sizeof($yearAgoPosts) > 0}
+<div class="ayearago">
+{foreach name=ayearago from=$yearAgoPosts item=yearAgoPost}
+ {if $smarty.foreach.ayearago.first}A year ago I was writting: {/if}
+ <a href="{$url->postPermalink($yearAgoPost)}">{$yearAgoPost->getTopic()}</a>
+ {if !$smarty.foreach.ayearago.last} :: {/if}
+{/foreach} 
+</div>
+{/if}
+{/if}

Added: plugins/branches/lifetype-1.1/ayearago/templates/ayearago.template
===================================================================
--- plugins/branches/lifetype-1.1/ayearago/templates/ayearago.template	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/ayearago/templates/ayearago.template	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,32 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=AYearAgo title=$locale->tr("ayearago_plugin")}
+<form name="ayearagoPluginConfig" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"}  
+  <div class="field">
+   <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+   <span class="required"></span>
+   <div class="formHelp">
+    <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("ayearago_plugin_enabled")}
+   </div>
+  </div>
+  
+  <div class="field">
+   <label for="maxPosts">{$locale->tr("label_maxposts")}</label>
+   <span class="required">*</span>
+   <div class="formHelp">{$locale->tr("ayearago_maxposts")}</div>
+   <input class="text" type="text" name="maxPosts" id="maxPosts" value="{$maxPosts}" width="10" />
+  </div>
+  
+ </fieldset>
+ 
+ <div class="buttons">  
+  <input type="hidden" name="op" value="updateAYearAgoConfig" />
+  <input type="reset" name="{$locale->tr("reset")}" />  
+  <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}

Added: plugins/branches/lifetype-1.1/categorycloud/class/action/plugincategorycloudconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.1/categorycloud/class/action/plugincategorycloudconfigaction.class.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/categorycloud/class/action/plugincategorycloudconfigaction.class.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,26 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/categorycloud/class/view/plugincategorycloudconfigview.class.php" );	
+
+	/**
+	 * shows a form with the current configuration
+	 */
+	class PluginCategoryCloudConfigAction extends AdminAction
+	{
+		
+		function PluginCategoryCloudConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function perform()
+		{
+            $this->_view = new PluginCategoryCloudConfigView( $this->_blogInfo );
+			
+			$this->setCommonData();
+			
+			return true;
+		}
+	}
+?>

Added: plugins/branches/lifetype-1.1/categorycloud/class/action/plugincategorycloudupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.1/categorycloud/class/action/plugincategorycloudupdateconfigaction.class.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/categorycloud/class/action/plugincategorycloudupdateconfigaction.class.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,89 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/categorycloud/class/view/plugincategorycloudconfigview.class.php" );	
+			
+	/**
+	 * updates the plugin configuration
+	 */
+	class PluginCategoryCloudUpdateConfigAction extends AdminAction
+	{
+		var $_pluginEnabled;
+        var $_minFont;
+        var $_maxFont;
+        var $_minWeight;
+        var $_maxWeight;
+		
+		function PluginCategoryCloudUpdateConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function validate()
+		{
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );	
+
+            $this->_minFont = $this->_request->getValue( "minFont" );
+
+            $this->_maxFont = $this->_request->getValue( "maxFont" );
+
+            $this->_minWeight = $this->_request->getValue( "minWeight" );
+            
+            $this->_maxWeight = $this->_request->getValue( "maxWeight" );
+
+            return true;
+		}
+		        
+		function perform()
+		{
+            // update the plugin configurations to blog setting
+			$blogSettings = $this->_blogInfo->getSettings();
+            $blogSettings->setValue( "plugin_categorycloud_enabled", $this->_pluginEnabled );
+            $blogSettings->setValue( "plugin_categorycloud_min_size", $this->_minFont );
+            $blogSettings->setValue( "plugin_categorycloud_max_size", $this->_maxFont );
+            $blogSettings->setValue( "plugin_categorycloud_min_weight", $this->_minWeight );
+            $blogSettings->setValue( "plugin_categorycloud_max_weight", $this->_maxWeight );
+            $this->_blogInfo->setSettings( $blogSettings ); 
+		
+			// save the blogs settings
+			$blogs = new Blogs();
+            if( !$blogs->updateBlog( $this->_blogInfo )) {
+                $this->_view = new PluginCategoryCloudConfigView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+                $this->setCommonData();
+
+                return false;
+            }
+			
+			// if everything went ok...
+            $this->_blogInfo->setSettings( $blogSettings );
+            $this->_session->setValue( "blogInfo", $this->_blogInfo );
+            $this->saveSession();
+			
+			$this->_view = new PluginCategoryCloudConfigView( $this->_blogInfo );
+			$this->_view->setSuccessMessage( $this->_locale->tr("categorycloud_settings_saved_ok"));
+			$this->setCommonData();
+
+			$plugins = $this->_pm->getPlugins();
+
+            $plugin = $plugins["categorycloud"];
+            $plugin->createCloud();
+			
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId());			
+            
+            return true;		
+		}
+		
+		function isValidColor($colorCode) {
+		    $pattern = "#[a-fA-F0-9]{6}";
+		    $length = strlen($colorCode);
+            if (ereg ($pattern, $colorCode) && $length == 7) {
+               return true;
+            } else {
+               return false;
+            }
+	    }
+	}
+?>

Added: plugins/branches/lifetype-1.1/categorycloud/class/view/plugincategorycloudconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.1/categorycloud/class/view/plugincategorycloudconfigview.class.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/categorycloud/class/view/plugincategorycloudconfigview.class.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,39 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+	/**
+	 * implements the main view of the tag cloud plugin
+	 */
+	class PluginCategoryCloudConfigView extends AdminPluginTemplatedView
+	{
+
+		function PluginCategoryCloudConfigView( $blogInfo )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "categorycloud", "categorycloud" );
+		}
+		
+		function render()
+		{
+			$blogSettings = $this->_blogInfo->getSettings();
+			$pluginEnabled = $blogSettings->getValue( "plugin_categorycloud_enabled" );
+			$minSize = $blogSettings->getValue( "plugin_categorycloud_min_size" );
+			if ($minSize == "") $minSize = .4;
+			$maxSize = $blogSettings->getValue( "plugin_categorycloud_max_size" );
+			if ($maxSize == "") $maxSize = 3;
+			$minWeight = $blogSettings->getValue( "plugin_categorycloud_min_weight" );
+			if ($minWeight == "") $minWeight = 100;
+			$maxWeight = $blogSettings->getValue( "plugin_categorycloud_max_weight" );
+			if ($maxWeight == "") $maxWeight = 900;
+			
+			// create a view and export the settings to the template
+			$this->setValue( "pluginEnabled", $pluginEnabled );
+			$this->setValue( "minFont", $minSize );
+			$this->setValue( "maxFont", $maxSize );
+			$this->setValue( "minWeight", $minWeight );
+			$this->setValue( "maxWeight", $maxWeight );
+
+			parent::render();
+		}
+	}
+?>

Added: plugins/branches/lifetype-1.1/categorycloud/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.1/categorycloud/locale/locale_en_UK.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/categorycloud/locale/locale_en_UK.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,21 @@
+<?php
+$messages["manageAppearancePlugins"] = "Appearance Management";
+$messages["CategoryCloud"] = "Category Cloud";
+
+$messages["categorycloud_plugin_enabled"] = "Enable this plugin";
+$messages["categorycloud_plugin"] = "Category Cloud Plugin";
+
+$messages["categorycloud_min_font"] = "Minimum font size for the cloud.";
+$messages["categorycloud_max_font"] = "Maximum font size for the cloud.";
+$messages["categorycloud_min_weight"] = "Minimum font size for the cloud. (valid values: 100, 200, ..., 900)";
+$messages["categorycloud_max_weight"] = "Maximum font size for the cloud. (valid values: 100, 200, ..., 900)";
+
+$messages["categorycloud_settings_saved_ok"] = "Category Cloud settings saved successfully!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["min_font_size"] = "Minimum Font Size";
+$messages["max_font_size"] = "Maximum Font Size";
+$messages["min_font_weight"] = "Minimum Font Weight";
+$messages["max_font_weight"] = "Maximum Font Weight";
+?>

Added: plugins/branches/lifetype-1.1/categorycloud/locale/locale_es_ES.php
===================================================================
--- plugins/branches/lifetype-1.1/categorycloud/locale/locale_es_ES.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/categorycloud/locale/locale_es_ES.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,21 @@
+<?php
+$messages["manageAppearancePlugins"] = "Administraci&oacute;n de la Apariencia";
+$messages["CategoryCloud"] = "Nube de Categor&iacute;as";
+
+$messages["categorycloud_plugin_enabled"] = "Habilitar este plugin";
+$messages["categorycloud_plugin"] = "Plugin Category Cloud";
+
+$messages["categorycloud_min_font"] = "Tama&ntilde;o m&iacute;nimo de la fuente de la nube.";
+$messages["categorycloud_max_font"] = "Tama&ntilde;o m&aacute;ximo de la fuente de la nube.";
+$messages["categorycloud_min_weight"] = "Grosor m&iacute;nimo de la fuente de la nube. (valores v&aacute;lidos: 100, 200, ..., 900)";
+$messages["categorycloud_max_weight"] = "Grosor m&aacute;ximo de la fuente de la nube. (valores v&aacute;lidos: 100, 200, ..., 900)";
+
+$messages["categorycloud_settings_saved_ok"] = "La configuraci&oacute;n de la Nube de Categor&iacute;as ha sido actualizada!";
+
+$messages["label_configuration"] = "Configuraci&oacute;n";
+$messages["label_enable"] = "Habilitar";
+$messages["min_font_size"] = "Tama&ntilde;o m&iacute;nimo de la fuente";
+$messages["max_font_size"] = "Tama&ntilde;o m&aacute;ximo de la fuente";
+$messages["min_font_weight"] = "Grosor m&iacute;nimo de la fuente";
+$messages["max_font_weight"] = "Grosor m&aacute;ximo de la fuente";
+?>

Added: plugins/branches/lifetype-1.1/categorycloud/plugincategorycloud.class.php
===================================================================
--- plugins/branches/lifetype-1.1/categorycloud/plugincategorycloud.class.php	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/categorycloud/plugincategorycloud.class.php	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,211 @@
+<?php
+
+include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+include_once( 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" );
+        include_once( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
+        $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;
+		
+    }
+	
+	
+}
+        
+        
+?>


Property changes on: plugins/branches/lifetype-1.1/categorycloud/plugincategorycloud.class.php
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/branches/lifetype-1.1/categorycloud/readme.txt
===================================================================
--- plugins/branches/lifetype-1.1/categorycloud/readme.txt	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/categorycloud/readme.txt	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,28 @@
+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>
+


Property changes on: plugins/branches/lifetype-1.1/categorycloud/readme.txt
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/branches/lifetype-1.1/categorycloud/templates/categorycloud.template
===================================================================
--- plugins/branches/lifetype-1.1/categorycloud/templates/categorycloud.template	2006-11-05 17:17:30 UTC (rev 4238)
+++ plugins/branches/lifetype-1.1/categorycloud/templates/categorycloud.template	2006-11-05 17:17:59 UTC (rev 4239)
@@ -0,0 +1,53 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=CategoryCloud title=$locale->tr("categorycloud_plugin")}
+<form name="categoryCloudPluginConfig" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend> 
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"} 
+  <div class="field">
+   <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+   <span class="required"></span>
+   <div class="formHelp">
+    <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("categorycloud_plugin_enabled")}
+   </div>
+  </div>
+  
+  <div class="field">
+   <label for="width">{$locale->tr("min_font_size")}</label>
+   <span class="required">*</span>
+   <div class="formHelp">{$locale->tr("categorycloud_min_font")}</div>
+   <input class="text" type="text" name="minFont" id="minFont" value="{$minFont}" width="10" />
+  </div>
+
+ <div class="field">
+   <label for="width">{$locale->tr("max_font_size")}</label>
+   <span class="required">*</span>
+   <div class="formHelp">{$locale->tr("categorycloud_max_font")}</div>
+   <input class="text" type="text" name="maxFont" id="maxFont" value="{$maxFont}" width="10" />
+  </div>
+
+  <div class="field">
+   <label for="width">{$locale->tr("min_font_weight")}</label>
+   <span class="required">*</span>
+   <div class="formHelp">{$locale->tr("categorycloud_min_weight")}</div>
+   <input class="text" type="text" name="minWeight" id="minWeight" value="{$minWeight}" width="10" />
+  </div>
+
+ <div class="field">
+   <label for="width">{$locale->tr("max_font_weight")}</label>
+   <span class="required">*</span>
+   <div class="formHelp">{$locale->tr("categorycloud_max_weight")}</div>
+   <input class="text" type="text" name="maxWeight" id="maxWeight" value="{$maxWeight}" width="10" />
+  </div>
+
+ </fieldset>
+
+ <div class="buttons"> 
+  <input type="hidden" name="op" value="updateCategoryCloudConfig" />
+  <input type="reset" name="{$locale->tr("reset")}" />
+  <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}



More information about the pLog-svn mailing list