[pLog-svn] r4051 - in plugins/branches/lifetype-1.1: . ectocustom ectocustom/class ectocustom/class/action ectocustom/class/view ectocustom/locale ectocustom/templates

pwestbro at devel.lifetype.net pwestbro at devel.lifetype.net
Wed Sep 27 16:46:33 GMT 2006


Author: pwestbro
Date: 2006-09-27 16:46:31 +0000 (Wed, 27 Sep 2006)
New Revision: 4051

Added:
   plugins/branches/lifetype-1.1/ectocustom/
   plugins/branches/lifetype-1.1/ectocustom/README.txt
   plugins/branches/lifetype-1.1/ectocustom/class/
   plugins/branches/lifetype-1.1/ectocustom/class/action/
   plugins/branches/lifetype-1.1/ectocustom/class/action/pluginectocustomconfigaction.class.php
   plugins/branches/lifetype-1.1/ectocustom/class/action/pluginectocustomupdateconfigaction.class.php
   plugins/branches/lifetype-1.1/ectocustom/class/view/
   plugins/branches/lifetype-1.1/ectocustom/class/view/pluginectocustomconfigview.class.php
   plugins/branches/lifetype-1.1/ectocustom/locale/
   plugins/branches/lifetype-1.1/ectocustom/locale/locale_en_UK.php
   plugins/branches/lifetype-1.1/ectocustom/pluginectocustom.class.php
   plugins/branches/lifetype-1.1/ectocustom/templates/
   plugins/branches/lifetype-1.1/ectocustom/templates/ectocustom.template
Log:
Added plugin to convert technorati tags inserted by ecto (In the html text
itself) into a format that the technorati plugin can parse.


Added: plugins/branches/lifetype-1.1/ectocustom/README.txt
===================================================================
--- plugins/branches/lifetype-1.1/ectocustom/README.txt	2006-09-26 18:19:29 UTC (rev 4050)
+++ plugins/branches/lifetype-1.1/ectocustom/README.txt	2006-09-27 16:46:31 UTC (rev 4051)
@@ -0,0 +1,15 @@
+[DESCRIPTION]
+Ecto (http://ecto.kung-foo.tv/) is a xmlrpc blogging client, that enables posting to LifeType from the desktop.  Ecto has the abilty to set technorati tags to posts, and these tags get added to the html of the body of the post.
+
+The Ecto Tags plugin converts this html markup and inserts it into the Custom field for use by the technorati plugin. 
+
+Ecto inserts it's tags between the <!-- technorati tags start --> and 
+<!-- technorati tags end --> tags, and this plugin usese these tags to find the tags.
+http://ecto.kung-foo.tv/archives/001368.php
+
+[USAGES]: 
+1. Upload: Upload all the extract files and directories to $LifeType_Install_Dir/plugin/ectocustom
+2. Enable the plugin in the admin panel
+
+[TODO]:
+Change the parsing to use regular expressions.
\ No newline at end of file

Added: plugins/branches/lifetype-1.1/ectocustom/class/action/pluginectocustomconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.1/ectocustom/class/action/pluginectocustomconfigaction.class.php	2006-09-26 18:19:29 UTC (rev 4050)
+++ plugins/branches/lifetype-1.1/ectocustom/class/action/pluginectocustomconfigaction.class.php	2006-09-27 16:46:31 UTC (rev 4051)
@@ -0,0 +1,49 @@
+<?php
+
+    /*
+    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
+    
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+    
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+    
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    */
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."plugins/ectocustom/class/view/pluginectocustomconfigview.class.php" ); 
+
+    class PluginEctoCustomConfigAction extends BlogOwnerAdminAction 
+	{
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function PluginEctoCustomConfigAction( $actionInfo, $request )
+        {
+        	$this->BlogOwnerAdminAction( $actionInfo, $request );
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+			$this->_view = new PluginEctoCustomConfigView( $this->_blogInfo );
+
+            $this->setCommonData();
+
+            // better to return true if everything fine
+            return true;
+        }
+    }
+?>

Added: plugins/branches/lifetype-1.1/ectocustom/class/action/pluginectocustomupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.1/ectocustom/class/action/pluginectocustomupdateconfigaction.class.php	2006-09-26 18:19:29 UTC (rev 4050)
+++ plugins/branches/lifetype-1.1/ectocustom/class/action/pluginectocustomupdateconfigaction.class.php	2006-09-27 16:46:31 UTC (rev 4051)
@@ -0,0 +1,87 @@
+<?php
+
+    /*
+    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
+    
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+    
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+    
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    */
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."plugins/ectocustom/class/view/pluginectocustomconfigview.class.php" ); 
+
+    $apiKeyValid = true;
+    
+    class PluginEctoCustomUpdateConfigAction extends BlogOwnerAdminAction 
+	{
+	
+		var $_pluginEnabled;
+
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function PluginEctoCustomUpdateConfigAction( $actionInfo, $request )
+        {
+        	$this->BlogOwnerAdminAction( $actionInfo, $request );
+        }
+		
+		function validate()
+		{
+
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );			
+        
+			return true;
+		}
+		
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+            // update the plugin configurations to blog setting
+			$blogSettings = $this->_blogInfo->getSettings();
+            $blogSettings->setValue( "plugin_ectocustom_enabled", $this->_pluginEnabled );
+
+            $this->_blogInfo->setSettings( $blogSettings ); 
+		
+			// save the blogs settings
+			$blogs = new Blogs();
+            if( !$blogs->updateBlog( $this->_blogInfo )) {
+                $this->_view = new PluginEctoCustomConfigView( $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 PluginEctoCustomConfigView( $this->_blogInfo );
+			$this->_view->setSuccessMessage( $this->_locale->tr("ectocustom_settings_saved_ok"));			
+			$this->setCommonData();
+			
+			// clear the cache
+			CacheControl::resetBlogCache( $this->_blogInfo->getId());					
+            
+            return true;		
+        }
+    }
+
+?>

Added: plugins/branches/lifetype-1.1/ectocustom/class/view/pluginectocustomconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.1/ectocustom/class/view/pluginectocustomconfigview.class.php	2006-09-26 18:19:29 UTC (rev 4050)
+++ plugins/branches/lifetype-1.1/ectocustom/class/view/pluginectocustomconfigview.class.php	2006-09-27 16:46:31 UTC (rev 4051)
@@ -0,0 +1,47 @@
+<?php
+	
+    /*
+    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
+    
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+    
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+    
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    */
+
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+	/**
+	 * implements the main view of the validate trackback plugin
+	 */
+	class PluginEctoCustomConfigView extends AdminPluginTemplatedView
+	{
+
+		function PluginEctoCustomConfigView( $blogInfo )
+		{
+			$this->AdminPluginTemplatedView( $blogInfo, "ectocustom", "ectocustom" );
+		}
+		
+		function render()
+		{
+			// load some configuration settings
+			$blogSettings = $this->_blogInfo->getSettings();
+			$pluginEnabled = $blogSettings->getValue( "plugin_ectocustom_enabled" );
+			
+			
+			// create a view and export the settings to the template
+			$this->setValue( "pluginEnabled", $pluginEnabled );
+			
+			parent::render();
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/branches/lifetype-1.1/ectocustom/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.1/ectocustom/locale/locale_en_UK.php	2006-09-26 18:19:29 UTC (rev 4050)
+++ plugins/branches/lifetype-1.1/ectocustom/locale/locale_en_UK.php	2006-09-27 16:46:31 UTC (rev 4051)
@@ -0,0 +1,13 @@
+<?php
+$messages["manageIntegrationPlugins"] = "Integration Management";
+$messages["ectocustomPluginSettings"] = "Ecto Tags";
+$messages["ectocustom"] = "Ecto Tags";
+
+$messages["ectocustom_plugin_enabled"] = "Enable this plugin";
+$messages["ectocustom_plugin"] = "Ecto Tags Plugin";
+
+$messages["ectocustom_settings_saved_ok"] = "Ecto Tags settings saved successfully!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+?>
\ No newline at end of file

Added: plugins/branches/lifetype-1.1/ectocustom/pluginectocustom.class.php
===================================================================
--- plugins/branches/lifetype-1.1/ectocustom/pluginectocustom.class.php	2006-09-26 18:19:29 UTC (rev 4050)
+++ plugins/branches/lifetype-1.1/ectocustom/pluginectocustom.class.php	2006-09-27 16:46:31 UTC (rev 4051)
@@ -0,0 +1,204 @@
+<?php
+
+    /*
+    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
+    
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+    
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+    
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    */
+
+	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+	include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+
+	class PluginEctoCustom extends PluginBase
+	{
+		var $pluginEnabled;
+		
+		function PluginEctoCustom()
+		{
+			$this->PluginBase();
+
+			$this->id      = "ectocustom";
+			$this->desc    = "The Ecto Custom plugin inserts the ecto technotati tags into the custom field used by the technorati plugin.";
+			$this->author  = "Paul Westbrook";
+			$this->locales = Array( "en_UK" );
+
+			$this->init();
+		}
+
+		function init()
+		{
+		
+            // register the events we want
+            $this->registerNotification( EVENT_PRE_POST_ADD );
+            $this->registerNotification( EVENT_PRE_POST_UPDATE );
+
+            $this->registerAdminAction( "ectocustom", "PluginEctoCustomConfigAction" );
+			$this->registerAdminAction( "updateEctoCustomConfig", "PluginEctoCustomUpdateConfigAction" );
+			
+		    include_once( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
+
+			$menu =& Menu::getMenu();
+			if( !$menu->entryExists( "/menu/controlCenter/manageIntegrationPlugins" ))						
+				$this->addMenuEntry( "/menu/controlCenter", "manageIntegrationPlugins", "", "", true, false );			
+            $this->addMenuEntry( "/menu/controlCenter/manageIntegrationPlugins", "ectocustom", "?op=ectocustom", "" );            
+		}
+
+		function register()
+		{
+		    $blogSettings = $this->blogInfo->getSettings();
+			$this->pluginEnabled = $blogSettings->getValue( "plugin_ectocustom_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_PRE_POST_ADD &&
+                $eventType != EVENT_PRE_POST_UPDATE  )
+            {
+                return true;
+            }
+            
+            // Load all of the settings for this blog
+            $this->register();
+            
+            // make sure that the plugin is enabled
+			if( !$this->isEnabled())
+            {
+                return true;
+            }
+            
+            $article = $params["article"];
+                        
+            // Update the Blogtime png
+            $params["article"] = $this->convertTagsToCustomFields($article);
+
+            return true;
+        }
+        
+        /**
+         * strips the tags added by ecto, and adds them to the technorati custom field
+         */
+        function convertTagsToCustomFields( $post )
+        {
+            // Get the text of the post
+            $text = $post->getText(false);
+            
+            
+            // Are the tags in the post
+            
+            /**
+             * The format is:
+             <!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: <a href="http://www.technorati.com/tag/Apple Mail" rel="tag">Apple Mail</a>, <a href="http://www.technorati.com/tag/IMAP IDLE" rel="tag">IMAP IDLE</a>, <a href="http://www.technorati.com/tag/Mac OS X" rel="tag">Mac OS X</a>, <a href="http://www.technorati.com/tag/Mail.app plugin" rel="tag">Mail.app plugin</a></p><!-- technorati tags end -->
+            */
+            
+            $beginningTag = "<!-- technorati tags start -->";
+            
+            $pos = strpos($text, $beginningTag);
+            if ( $pos === false )
+            {
+                // just return the original post
+                return $post;
+            }
+            
+            $endOfText = $pos;
+            $posBeginTags = $pos + strlen($beginningTag);
+            
+            // Make sure the end tag is present
+            $endTag = "<!-- technorati tags end -->";
+            $pos = strpos($text, $endTag, $posBeginTags);
+            if ( $pos === false )
+            {
+                // just return the original post
+                return $post;
+            }
+            
+            // Get the string with the tags
+            $tagString = substr($text, $posBeginTags, $pos - $posBeginTags);
+            
+            // Get the text without the tags;
+            $text = substr( $text, 0, $endOfText) . substr( $text, $pos + strlen($endTag));
+            
+            // This really should be done as a regular expression
+            
+            $customFieldValueText = "";
+            //Break out the tags
+            $tags = explode( "rel=\"tag\">", $tagString);
+            // Skip over the first one
+            array_shift($tags);
+            foreach($tags as $tag)
+            {
+                $tagArray = explode( "</a>", $tag );
+                
+                if ($customFieldValueText != "")
+                {
+                    $customFieldValueText = $customFieldValueText . ",";
+                }
+                $customFieldValueText = $customFieldValueText . $tagArray[0];
+            }
+
+            include_once( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
+
+            $customFields = new CustomFields();
+			$blogFields = $customFields->getBlogCustomFields( $this->blogInfo->getId());
+
+            $foundField = false;
+            $fieldId = 0;
+            foreach($blogFields as $blogField)
+            {
+               if ( $blogField->getName() == "technoratiTags" )
+               {
+                   $foundField = true;
+                   $fieldId = $blogField->getId();
+                   break;
+               }
+            }
+
+            if( $foundField == false) {
+                // The field doesn't exist, bail out
+                return $post;
+			}
+
+            // Add the modified text back to the post
+            $post->setText($text);
+            include_once( PLOG_CLASS_PATH."class/dao/customfields/customfieldvalue.class.php" );
+            
+            // Create a new CustomFieldValue
+            $postCustomFields = $post->getCustomFields();
+            
+            $customFieldValue = new CustomFieldValue( $fieldId,
+                                           $customFieldValueText,
+                                           $post->getId(),
+                                           $this->blogInfo->getId());
+                                                       
+            $postCustomFields["technoratiTags"] = $customFieldValue;
+           
+            $post->setFields( $postCustomFields );
+
+            
+            return $post;
+        }
+	}
+?>
\ No newline at end of file

Added: plugins/branches/lifetype-1.1/ectocustom/templates/ectocustom.template
===================================================================
--- plugins/branches/lifetype-1.1/ectocustom/templates/ectocustom.template	2006-09-26 18:19:29 UTC (rev 4050)
+++ plugins/branches/lifetype-1.1/ectocustom/templates/ectocustom.template	2006-09-27 16:46:31 UTC (rev 4051)
@@ -0,0 +1,25 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=ectocustom title=$locale->tr("ectocustom_plugin")}
+<form name="ectocustomPluginSettings" 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>
+   <div class="formHelp">   
+    <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("ectocustom_plugin_enabled")}
+   </div>
+  </div>
+
+  
+ </fieldset>  
+
+ <div class="buttons">
+  <input type="hidden" name="op" value="updateEctoCustomConfig" />
+  <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"}
\ No newline at end of file



More information about the pLog-svn mailing list