[pLog-svn] r3934 - in plugins/branches/lifetype-1.0: . relatedposts relatedposts/class relatedposts/class/action relatedposts/class/view relatedposts/locale relatedposts/templates

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Sep 3 19:19:58 GMT 2006


Author: oscar
Date: 2006-09-03 19:19:58 +0000 (Sun, 03 Sep 2006)
New Revision: 3934

Added:
   plugins/branches/lifetype-1.0/relatedposts/
   plugins/branches/lifetype-1.0/relatedposts/class/
   plugins/branches/lifetype-1.0/relatedposts/class/action/
   plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsconfigaction.class.php
   plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsupdateconfigaction.class.php
   plugins/branches/lifetype-1.0/relatedposts/class/view/
   plugins/branches/lifetype-1.0/relatedposts/class/view/pluginrelatedpostsconfigview.class.php
   plugins/branches/lifetype-1.0/relatedposts/locale/
   plugins/branches/lifetype-1.0/relatedposts/locale/locale_en_UK.php
   plugins/branches/lifetype-1.0/relatedposts/locale/locale_es_ES.php
   plugins/branches/lifetype-1.0/relatedposts/pluginrelatedposts.class.php
   plugins/branches/lifetype-1.0/relatedposts/templates/
   plugins/branches/lifetype-1.0/relatedposts/templates/relatedposts.template
Log:
New plugin relatedposts by user perublog



Added: plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsconfigaction.class.php	2006-09-03 19:09:52 UTC (rev 3933)
+++ plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsconfigaction.class.php	2006-09-03 19:19:58 UTC (rev 3934)
@@ -0,0 +1,28 @@
+<?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/relatedposts/class/view/pluginrelatedpostsconfigview.class.php" );	
+	
+
+	/**
+	 * shows a form with the current configuration
+	 */
+	class PluginRelatedPostsConfigAction extends AdminAction
+	{
+		
+		function PluginRelatedPostsConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function perform()
+		{
+            $this->_view = new PluginRelatedPostsConfigView( $this->_blogInfo );
+			
+			$this->setCommonData();
+			
+			return true;
+		}
+	}
+?>
\ No newline at end of file


Property changes on: plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsconfigaction.class.php
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsupdateconfigaction.class.php	2006-09-03 19:09:52 UTC (rev 3933)
+++ plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsupdateconfigaction.class.php	2006-09-03 19:19:58 UTC (rev 3934)
@@ -0,0 +1,76 @@
+<?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/relatedposts/class/view/pluginrelatedpostsconfigview.class.php" );	
+		
+	/**
+	 * updates the plugin configuration
+	 */
+	class PluginRelatedPostsUpdateConfigAction extends AdminAction
+	{
+		var $_pluginEnabled;
+		var $_maxPosts;
+		var $_tipOrder;
+		var $_showMain;
+		
+		function PluginRelatedPostsUpdateConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function validate()
+		{
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+            $this->_maxPosts = $this->_request->getValue( "maxPosts" );
+            $this->_tipOrder = $this->_request->getValue( "tipOrder" );
+            $this->_showMain = $this->_request->getValue( "showMain" );
+            $this->_showMain = ($this->_showMain != "" );
+            if( $this->_maxPosts <= 0  || !ctype_digit($this->_maxPosts) ) {
+                $this->_view = new PluginRelatedPostsConfigView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("relatedposts_error_maxposts"));
+                $this->setCommonData();
+
+                return false;
+            }        	                
+			
+			return true;
+		}
+		        
+		function perform()
+		{
+            // // update the plugin configurations to blog setting
+			$blogSettings = $this->_blogInfo->getSettings();
+            $blogSettings->setValue( "plugin_relatedposts_enabled", $this->_pluginEnabled );
+            $blogSettings->setValue( "plugin_relatedposts_maxposts", $this->_maxPosts );
+            $blogSettings->setValue( "plugin_relatedposts_tiporder", $this->_tipOrder );
+            $blogSettings->setValue( "plugin_relatedposts_showmain", $this->_showMain );
+            $this->_blogInfo->setSettings( $blogSettings ); 
+		
+			// save the blogs settings
+			$blogs = new Blogs();
+            if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+                $this->_view = new PluginRelatedPostsConfigView( $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 PluginRelatedPostsConfigView( $this->_blogInfo );
+			$this->_view->setSuccessMessage( $this->_locale->tr("relatedposts_settings_saved_ok"));
+			$this->setCommonData();
+			
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId());				
+            
+            return true;		
+		}
+	}
+?>
\ No newline at end of file


Property changes on: plugins/branches/lifetype-1.0/relatedposts/class/action/pluginrelatedpostsupdateconfigaction.class.php
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/branches/lifetype-1.0/relatedposts/class/view/pluginrelatedpostsconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.0/relatedposts/class/view/pluginrelatedpostsconfigview.class.php	2006-09-03 19:09:52 UTC (rev 3933)
+++ plugins/branches/lifetype-1.0/relatedposts/class/view/pluginrelatedpostsconfigview.class.php	2006-09-03 19:19:58 UTC (rev 3934)
@@ -0,0 +1,36 @@
+<?php
+	
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+	/**
+	 * implements the main view of the feed reader plugin
+	 */
+	class PluginRelatedPostsConfigView extends AdminPluginTemplatedView
+	{
+
+		function PluginRelatedPostsConfigView( $blogInfo )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "relatedposts", "relatedposts" );
+		}
+		
+		function render()
+		{
+			// load some configuration settings
+			$blogSettings = $this->_blogInfo->getSettings();
+			$pluginEnabled = $blogSettings->getValue( "plugin_relatedposts_enabled" );
+			$maxPosts = $blogSettings->getValue( "plugin_relatedposts_maxposts" );
+			$tipOrder = $blogSettings->getValue( "plugin_relatedposts_tiporder" );
+			$showMain = $blogSettings->getValue( "plugin_relatedposts_showmain" );
+			
+			if ($maxPosts == "") $maxPosts = 5;
+			
+			// create a view and export the settings to the template
+			$this->setValue( "pluginEnabled", $pluginEnabled );
+			$this->setValue( "maxPosts", $maxPosts );
+			$this->setValue( "tipOrder", $tipOrder );
+			$this->setValue( "showMain", $showMain );
+			
+			parent::render();
+		}
+	}
+?>
\ No newline at end of file


Property changes on: plugins/branches/lifetype-1.0/relatedposts/class/view/pluginrelatedpostsconfigview.class.php
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/branches/lifetype-1.0/relatedposts/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.0/relatedposts/locale/locale_en_UK.php	2006-09-03 19:09:52 UTC (rev 3933)
+++ plugins/branches/lifetype-1.0/relatedposts/locale/locale_en_UK.php	2006-09-03 19:19:58 UTC (rev 3934)
@@ -0,0 +1,24 @@
+<?php
+
+// Fecha 26/06/2006
+
+$messages["relatedposts_plugin"] = "Related Post";
+
+$messages["relatedposts_maxposts"] = "Maximum of articles to show. ";
+$messages["relatedposts_plugin_enabled"] = "Enabled plugin";
+
+$messages["relatedposts_settings_saved_ok"] = "The data have been save with success";
+$messages["relatedposts_error_maxposts"] = "Quantity should be greater to 0!";
+
+$messages["label_relatedposts_configuration"] = "Configuration:";
+$messages["label_relatedposts_enable"] = "Enabled:";
+$messages["label_relatedposts_maxposts"] = "Quantity:";
+$messages["label_relatedposts_tiporder"] = "Order:";
+
+$messages["relatedposts_des"] = "Last they published";
+$messages["relatedposts_ran"] = "Random articles";
+
+$messages["label_relatedposts_showmain"] = "Showing in home page";
+$messages["relatedposts_showmain"] = "Activate if desires that the articles related be shown in the home page of your blog";
+ 
+?>
\ No newline at end of file


Property changes on: plugins/branches/lifetype-1.0/relatedposts/locale/locale_en_UK.php
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/branches/lifetype-1.0/relatedposts/locale/locale_es_ES.php
===================================================================
--- plugins/branches/lifetype-1.0/relatedposts/locale/locale_es_ES.php	2006-09-03 19:09:52 UTC (rev 3933)
+++ plugins/branches/lifetype-1.0/relatedposts/locale/locale_es_ES.php	2006-09-03 19:19:58 UTC (rev 3934)
@@ -0,0 +1,24 @@
+<?php
+
+// Fecha 26/06/2006
+
+$messages["relatedposts_plugin"] = "Articulos relacionados";
+
+$messages["relatedposts_maxposts"] = "M&aacute;ximo de articulos a mostrar";
+$messages["relatedposts_plugin_enabled"] = "Activar este plugin";
+
+$messages["relatedposts_settings_saved_ok"] = "Los datos se han guardado con &eacute;xito";
+$messages["relatedposts_error_maxposts"] = "Cantidad debe ser mayor a 0!";
+
+$messages["label_relatedposts_configuration"] = "Configuraci&oacute;n:";
+$messages["label_relatedposts_enable"] = "Activar:";
+$messages["label_relatedposts_maxposts"] = "Cantidad:";
+$messages["label_relatedposts_tiporder"] = "Orden:";
+
+$messages["relatedposts_des"] = "Ultimos publicados";
+$messages["relatedposts_ran"] = "Articulos aleatorios";
+
+$messages["label_relatedposts_showmain"] = "Mostrar en principal";
+$messages["relatedposts_showmain"] = "Active si desea que los articulos relacionados se muestren en la p&aacute;gina principal de su bit&aacute;cora.";
+ 
+?>
\ No newline at end of file


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

Added: plugins/branches/lifetype-1.0/relatedposts/pluginrelatedposts.class.php
===================================================================
--- plugins/branches/lifetype-1.0/relatedposts/pluginrelatedposts.class.php	2006-09-03 19:09:52 UTC (rev 3933)
+++ plugins/branches/lifetype-1.0/relatedposts/pluginrelatedposts.class.php	2006-09-03 19:19:58 UTC (rev 3934)
@@ -0,0 +1,125 @@
+<?php
+
+    include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+    include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+    
+    /**
+     * Plugin that offers features to return a recent article comments from the current blog
+     */
+    class PluginRelatedPosts extends PluginBase
+    {
+        var $prefix;
+        var $pluginEnabled;
+        var $maxPosts;
+        var $tipOrder;
+        var $showMain;
+            
+        function PluginRelatedPosts()
+        {
+            $this->PluginBase();
+  
+            $this->id = "relatedposts";
+            $this->author = "PeruBlog.NET";
+            $this->prefix = Db::getPrefix();
+            $this->locales = Array( "en_US" ,"es_ES" );
+            $this->desc = 'Obtiene los ultimos articulos que tengan relaci&oacute;n con las categorias seleccionadas.<br/><br/>
+<b>Funciones:</b><br/><br/>
+1. $relatedposts->isEnabled() Para verificar si el plugin esta activado.<br/>
+2. $relatedposts->isShowMain() Para verificar si se muestran los articulos en la p&aacute;gina principal de tu bit&aacute;cora.<br/>
+3. $relatedposts->getRelatedPosts( Id del articulo ) Para obtener los ar&iacute;culos relacionados.<br/>
+<br/>
+Ejemplo: A&ntilde;ade el siguiente c&aacute;digo en tu archivo post.template<br/><br/>
+<b>{if $relatedposts-&gt;isEnabled() &amp;&amp; ( $user!=&quot;&quot; || $relatedposts-&gt;isShowMain() )}<br />
+{assign var=postid value=$post-&gt;getId()}<br />
+{assign var=recentsrelatedposts value=$relatedposts-&gt;getRelatedPosts($postid)}<br />
+&lt;p&gt;&lt;strong&gt;{$locale-&gt;tr(&quot;relatedposts_plugin&quot;)}:&lt;/strong&gt;<br />
+&lt;ul&gt;<br />
+{foreach from=$recentsrelatedposts item=relatedpost}<br />
+&lt;li&gt;<br />
+&lt;a title=&quot;{$locale-&gt;tr(&quot;permalink_title&quot;)}: {$relatedpost-&gt;getTopic()}&quot; href=&quot;{$url-&gt;postLink($relatedpost)}&quot;&gt;<br />
+{$relatedpost-&gt;getTopic()}<br />
+&lt;/a&gt;<br />
+&lt;/li&gt;<br />
+{/foreach}<br />
+ &lt;/ul&gt;&lt;/p&gt;<br />
+{/if}</b>';
+  
+            $this->init();
+        }
+
+		function init()
+		{
+			$this->registerAdminAction( "relatedposts", "PluginRelatedPostsConfigAction" );
+			$this->registerAdminAction( "updateRelatedPostsConfig", "PluginRelatedPostsUpdateConfigAction" );
+			
+			$menu =& Menu::getMenu();
+			if( !$menu->entryExists( "/menu/Manage/managePosts" ))
+			$this->addMenuEntry( "/menu/Manage", "managePosts", "", "", true, false );
+			$this->addMenuEntry( "/menu/Manage/managePosts", "RelatedPosts", "?op=relatedposts", "" );
+		}
+
+		function register()
+		{
+            $blogSettings = $this->blogInfo->getSettings();
+            $this->pluginEnabled = $blogSettings->getValue( "plugin_relatedposts_enabled" );
+            $this->maxPosts = $blogSettings->getValue( "plugin_relatedposts_maxposts" );
+            $this->tipOrder = $blogSettings->getValue( "plugin_relatedposts_tiporder" );
+            $this->showMain = $blogSettings->getValue( "plugin_relatedposts_showmain" );
+	    }
+	    
+	    function isEnabled()
+	    {
+	        return $this->pluginEnabled;
+	    }
+	    
+        function isShowMain()
+	    {
+	        return $this->showMain;
+	    }	    
+
+        /**
+        * Retorna una lista con los articulos que tengan la misma categoria que el artículo visto.
+        */
+        function getRelatedPosts($articleId)
+        {
+            $blogId = $this->blogInfo->getId();
+
+            switch (strtoupper($this->tipOrder)) {
+                case 'R':
+                    $order_by = 'RAND()';
+                    break;
+                case 'D':
+                    $order_by = 'date DESC';
+                    break;
+                case 'A':
+                    $order_by = 'date ASC';
+                    break;
+            }
+	
+         
+            $query = "select distinct a.* from ".$this->prefix."article_categories_link c, ".$this->prefix."articles a";
+            $query .= " where c.article_id = a.id and c.article_id <> ".$articleId." and";
+            $query .= " a.status = 1 and";
+            $query .= " c.category_id in (SELECT p.category_id FROM ".$this->prefix."article_categories_link p where p.article_id=".$articleId.")";
+            $query .= " order by ".$order_by." limit ".$this->maxPosts.";";
+
+            $articles = new Articles();
+            // Ejecutamos el query
+            $result = $articles->Execute( $query );
+
+            if ( $result->RecordCount() == 0)
+                return false;
+
+            $relatedposts = Array();
+            while( $row = $result->FetchRow()) { 
+               array_push( $relatedposts, $articles->_fillArticleInformation( $row ));
+            } 
+            $result->Close();
+            
+            return $relatedposts; 
+        }
+        
+    }
+?>
\ No newline at end of file


Property changes on: plugins/branches/lifetype-1.0/relatedposts/pluginrelatedposts.class.php
___________________________________________________________________
Name: svn:executable
   + *

Added: plugins/branches/lifetype-1.0/relatedposts/templates/relatedposts.template
===================================================================
--- plugins/branches/lifetype-1.0/relatedposts/templates/relatedposts.template	2006-09-03 19:09:52 UTC (rev 3933)
+++ plugins/branches/lifetype-1.0/relatedposts/templates/relatedposts.template	2006-09-03 19:19:58 UTC (rev 3934)
@@ -0,0 +1,49 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=RelatedPosts title=$locale->tr("relatedposts_plugin")}
+<form name="relatedpostsPluginConfig" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_relatedposts_configuration")}</legend>
+  {include file="$admintemplatepath/successmessage.template"}
+  {include file="$admintemplatepath/errormessage.template"}  
+  <div class="field">
+   <label for="pluginEnabled">{$locale->tr("label_relatedposts_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("relatedposts_plugin_enabled")}
+   </div>
+  </div>
+  
+  <div class="field">
+   <label for="maxPosts">{$locale->tr("label_relatedposts_maxposts")}</label>
+   <span class="required">*</span>
+   <div class="formHelp">{$locale->tr("relatedposts_maxposts")}</div>
+   <input class="text" type="text" name="maxPosts" id="maxPosts" value="{$maxPosts}" width="10" />
+  </div>
+  
+  <div class="field">
+   <label for="tipOrder">{$locale->tr("label_relatedposts_tiporder")}</label>
+   <span class="required">*</span>
+    <select name="tipOrder" id="tipOrder">
+        <option value="D" {if $tipOrder=="D"}selected="selected"{/if}>{$locale->tr("relatedposts_des")}</option>
+        <option value="R" {if $tipOrder=="R"}selected="selected"{/if}>{$locale->tr("relatedposts_ran")}</option>
+    </select>
+  </div>
+  
+  <div class="field">
+   <label for="relatedposts_showmain">{$locale->tr("label_relatedposts_showmain")}</label>
+   <span class="required"></span>
+   <div class="formHelp">
+    <input class="checkbox" type="checkbox" name="showMain" id="showMain" {if $showMain} checked="checked" {/if} value="1" />{$locale->tr("relatedposts_showmain")}
+   </div>
+  </div>
+  
+ </fieldset>
+ 
+ <div class="buttons">  
+  <input type="hidden" name="op" value="updateRelatedPostsConfig" />
+  <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"}


Property changes on: plugins/branches/lifetype-1.0/relatedposts/templates/relatedposts.template
___________________________________________________________________
Name: svn:executable
   + *



More information about the pLog-svn mailing list