[pLog-svn] r3505 - in plugins/trunk: . cocomment cocomment/class cocomment/class/action cocomment/class/view cocomment/locale cocomment/template

Paul Westbrook paul at westbrooks.org
Fri Jun 2 09:25:45 GMT 2006


Hello,
    That is a pretty cool plugin.  I had to make some changes to make  
it work.  Here is my diff.  I am happy to check this in if you would  
like.

--Paul

Index: plugincocomment.class.php
===================================================================
using diff: /sw/bin/diff
45c45
<           function show()
---
 >           function show($postId)
47a48,51
 >
 >             // articles object
 >             $articles = new Articles;
 >
50a55
 >                       $post = $articles->getBlogArticle($postId);
55,70c60,66
<                       $str .= 'var blogURL = "{$url->blogLink()}";';
<                       $str .= 'var blogTitle = "{$blog->getBlog()}";';
<                       $str .= 'var postURL = "{$url->postPermalink 
($post)}";';
<                       $str .= 'var postTitle = "{$post->getTopic()}  
";';
<                       if ( $user_ID ) {
<                               $str .= 'var commentAuthor = "'. 
$user_identity.'"';
<                       } else {
<                               $str.= 'var commentAuthorFieldName =  
"author";';
<                       }
<                       $str .= 'var commentAuthorLoggedIn =';
<                       if ( !$user_ID ) {
<                               $str .= false.';';
<                       }else {
<                               $str .=true.';';
<                       }
<                       $str .='var commentFormID = "commentform";';
---
 >                       $str .= 'var blogURL = "'.$rg->blogLink().'";';
 >                       $str .= 'var blogTitle = "'.$this->blogInfo- 
 >getBlog().'";';
 >                       $str .= 'var postURL = "'.$rg->postPermalink 
($post).'";';
 >                       $str .= 'var postTitle = "'.$post->getTopic 
().'";';
 >                       $str .= 'var commentAuthorFieldName =  
"userName";';
 >                       $str .= 'var commentAuthorLoggedIn = false;';
 >                       $str .='var commentFormID = "NewComment";';
72,73c68,69
<                       $str .='var commentButtonName = "post";';
<                       $str .='var cocomment_force = false;';
---
 >                       $str .='var commentButtonName = "Add";';
 > //                    $str .='var cocomment_force = false;';
74a71,72
 >                       $str .='<script id="cocomment-fetchlet"  
src="http://www.cocomment.com/js/enabler.js"></script>';
 >


On Jun 1, 2006, at 1:21 PM, oscar at devel.lifetype.net wrote:

> Author: oscar
> Date: 2006-06-01 20:21:29 +0000 (Thu, 01 Jun 2006)
> New Revision: 3505
>
> Added:
>    plugins/trunk/cocomment/
>    plugins/trunk/cocomment/README.txt
>    plugins/trunk/cocomment/class/
>    plugins/trunk/cocomment/class/action/
>    plugins/trunk/cocomment/class/action/ 
> plugincocommentconfigaction.class.php
>    plugins/trunk/cocomment/class/action/ 
> plugincocommentupdateconfigaction.class.php
>    plugins/trunk/cocomment/class/action/showcocommentaction.class.php
>    plugins/trunk/cocomment/class/view/
>    plugins/trunk/cocomment/class/view/ 
> plugincocommentconfigview.class.php
>    plugins/trunk/cocomment/locale/
>    plugins/trunk/cocomment/locale/locale_en_UK.php
>    plugins/trunk/cocomment/locale/locale_zh_TW.php
>    plugins/trunk/cocomment/plugincocomment.class.php
>    plugins/trunk/cocomment/template/
>    plugins/trunk/cocomment/template/cocomment.template
> Log:
> added the cocomment plugin
>
>
> Added: plugins/trunk/cocomment/README.txt
> ===================================================================
> --- plugins/trunk/cocomment/README.txt	2006-06-01 20:14:33 UTC (rev  
> 3504)
> +++ plugins/trunk/cocomment/README.txt	2006-06-01 20:21:29 UTC (rev  
> 3505)
> @@ -0,0 +1,23 @@
> +[USAGES]:
> +1. Upload: Upload all the extract files and directorys to  
> $LifeType_Install_Dir/plugin/cocomment
> +2. Modify template: Use $cocomment->show($postId) in template file  
> to enbed coComment toggle-integration script in LiFeType.
> +
> +
> +[IMPORTANT NOTICE]
> +1. The form must has name and id attribute with value  
> "NewComment", just like
> +Code:
> +<form id="NewComment" name="NewComment" ....>
> +
> +2. The submit button must has name and id attribute with value  
> "post", like
> +Code:
> +<input type="submit" name="post" id="post"....>
> +
> +
> +
> +[EXAMPLE]:
> +Add the following code in commentform.template to replace </form>:
> +
> +Code:
> +{assign var="postId" value=$post->getId()}
> +{$cocomment->show($postId)}
> +</form>
> \ No newline at end of file
>
> Added: plugins/trunk/cocomment/class/action/ 
> plugincocommentconfigaction.class.php
> ===================================================================
> --- plugins/trunk/cocomment/class/action/ 
> plugincocommentconfigaction.class.php	2006-06-01 20:14:33 UTC (rev  
> 3504)
> +++ plugins/trunk/cocomment/class/action/ 
> plugincocommentconfigaction.class.php	2006-06-01 20:21:29 UTC (rev  
> 3505)
> @@ -0,0 +1,26 @@
> +<?php
> +
> +	include_once( PLOG_CLASS_PATH."class/action/admin/ 
> adminaction.class.php" );
> +	include_once( PLOG_CLASS_PATH."plugins/cocomment/class/view/ 
> plugincocommentconfigview.class.php" );
> +
> +	/**
> +	 * shows a form with the current configuration
> +	 */
> +	class PlugincoCommentConfigAction extends AdminAction
> +	{
> +		
> +		function PlugincoCommentConfigAction( $actionInfo, $request )
> +		{
> +			$this->AdminAction( $actionInfo, $request );
> +		}
> +		
> +		function perform()
> +		{
> +            $this->_view = new PlugincoCommentConfigView( $this- 
> >_blogInfo );
> +			
> +			$this->setCommonData();
> +			
> +			return true;
> +		}
> +	}
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/cocomment/class/action/ 
> plugincocommentupdateconfigaction.class.php
> ===================================================================
> --- plugins/trunk/cocomment/class/action/ 
> plugincocommentupdateconfigaction.class.php	2006-06-01 20:14:33 UTC  
> (rev 3504)
> +++ plugins/trunk/cocomment/class/action/ 
> plugincocommentupdateconfigaction.class.php	2006-06-01 20:21:29 UTC  
> (rev 3505)
> @@ -0,0 +1,58 @@
> +<?php
> +
> +	include_once( PLOG_CLASS_PATH."class/action/admin/ 
> adminaction.class.php" );
> +	include_once( PLOG_CLASS_PATH."plugins/cocomment/class/view/ 
> plugincocommentconfigview.class.php" );
> +		
> +	/**
> +	 * updates the plugin configuration
> +	 */
> +	class PlugincoCommentUpdateConfigAction extends AdminAction
> +	{
> +		var $_pluginEnabled;
> +		
> +		function PlugincoCommentUpdateConfigAction( $actionInfo, $request )
> +		{
> +			$this->AdminAction( $actionInfo, $request );
> +		}
> +		
> +		function validate()
> +		{
> +            $this->_pluginEnabled = $this->_request->getValue 
> ( "pluginEnabled" );
> +            $this->_pluginEnabled = ($this->_pluginEnabled !=  
> "" );			
> +			
> +			return true;
> +		}
> +		
> +		function perform()
> +		{
> +            // update the plugin configurations to blog setting
> +			$blogSettings = $this->_blogInfo->getSettings();
> +            $blogSettings->setValue( "plugin_cocomment_enabled",  
> $this->_pluginEnabled );
> +            $this->_blogInfo->setSettings( $blogSettings );
> +		
> +			// save the blogs settings
> +			$blogs = new Blogs();
> +            if( !$blogs->updateBlog( $this->_blogInfo )) {
> +                $this->_view = new PlugincoCommentConfigView 
> ( $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 PlugincoCommentConfigView( $this->_blogInfo );
> +			$this->_view->setSuccessMessage( $this->_locale->tr 
> ("cocomment_settings_saved_ok"));			
> +			$this->setCommonData();
> +			
> +			// clear the cache
> +			CacheControl::resetBlogCache( $this->_blogInfo->getId());					
> +
> +            return true;		
> +		}
> +	}
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/cocomment/class/action/ 
> showcocommentaction.class.php
> ===================================================================
> --- plugins/trunk/cocomment/class/action/ 
> showcocommentaction.class.php	2006-06-01 20:14:33 UTC (rev 3504)
> +++ plugins/trunk/cocomment/class/action/ 
> showcocommentaction.class.php	2006-06-01 20:21:29 UTC (rev 3505)
> @@ -0,0 +1,25 @@
> +<?php
> +
> +    include_once( PLOG_CLASS_PATH."class/action/ 
> blogaction.class.php" );
> +    include_once( PLOG_CLASS_PATH."class/view/ 
> plugintemplatedview.class.php" );
> +
> +    class ShowcoCommentAction extends BlogAction
> +    {
> +		var $_cocommentTemplate;
> +		
> +        function ShowcoCommentAction( $actionInfo, $request )
> +        {
> +            $this->BlogAction( $actionInfo, $request );
> +        }
> +
> +        function perform()
> +        {
> +            $this->_cocommentTemplate = $this->_request->getValue 
> ( "show" );
> +
> +            $this->_view = new PluginTemplatedView( $this- 
> >_blogInfo, "cocomment", $this->_cocommentTemplate );
> +            $this->setCommonData();
> +
> +            return true;
> +        }
> +    }
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/cocomment/class/view/ 
> plugincocommentconfigview.class.php
> ===================================================================
> --- plugins/trunk/cocomment/class/view/ 
> plugincocommentconfigview.class.php	2006-06-01 20:14:33 UTC (rev 3504)
> +++ plugins/trunk/cocomment/class/view/ 
> plugincocommentconfigview.class.php	2006-06-01 20:21:29 UTC (rev 3505)
> @@ -0,0 +1,28 @@
> +<?php
> +	
> +	include_once( PLOG_CLASS_PATH."class/view/admin/ 
> adminplugintemplatedview.class.php" );
> +
> +	/**
> +	 * implements the main view of the feed reader plugin
> +	 */
> +	class PlugincoCommentConfigView extends AdminPluginTemplatedView
> +	{
> +
> +		function PlugincoCommentConfigView( $blogInfo )
> +		{
> +			$this->AdminPluginTemplatedView( $blogInfo, "cocomment",  
> "cocomment" );
> +		}
> +		
> +		function render()
> +		{
> +			// load some configuration settings
> +			$blogSettings = $this->_blogInfo->getSettings();
> +			$pluginEnabled = $blogSettings->getValue 
> ( "plugin_cocomment_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/trunk/cocomment/locale/locale_en_UK.php
> ===================================================================
> --- plugins/trunk/cocomment/locale/locale_en_UK.php	2006-06-01  
> 20:14:33 UTC (rev 3504)
> +++ plugins/trunk/cocomment/locale/locale_en_UK.php	2006-06-01  
> 20:21:29 UTC (rev 3505)
> @@ -0,0 +1,13 @@
> +<?php
> +$messages["manageAppearancePlugins"] = "Appearance Management";
> +$messages["coComment"] = "coComment";
> +
> +$messages["cocomment_plugin_enabled"] = "Enable this plugin";
> +$messages["cocomment_plugin"] = "coComment Plugin";
> +$messages["detail"] = "Detail";
> +
> +$messages["cocomment_settings_saved_ok"] = "coComment settings  
> saved successfully!";
> +
> +$messages["label_configuration"] = "Configuration";
> +$messages["label_enable"] = "Enable";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/cocomment/locale/locale_zh_TW.php
> ===================================================================
> --- plugins/trunk/cocomment/locale/locale_zh_TW.php	2006-06-01  
> 20:14:33 UTC (rev 3504)
> +++ plugins/trunk/cocomment/locale/locale_zh_TW.php	2006-06-01  
> 20:21:29 UTC (rev 3505)
> @@ -0,0 +1,13 @@
> +<?php
> +$messages["manageAppearancePlugins"] = "網誌外觀管理";
> +$messages["coComment"] = "coComment迴響追蹤設定";
> +
> +$messages["cocomment_plugin_enabled"] = "啟動外掛程式";
> +$messages["cocomment_plugin"] = "coComment迴響追蹤外掛程式";
> +$messages["detail"] = "詳細";
> +
> +$messages["cocomment_settings_saved_ok"] = "coComment迴響追蹤 
> 設定儲存成功。";
> +
> +$messages["label_configuration"] = "設定";
> +$messages["label_enable"] = "啟動";
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/cocomment/plugincocomment.class.php
> ===================================================================
> --- plugins/trunk/cocomment/plugincocomment.class.php	2006-06-01  
> 20:14:33 UTC (rev 3504)
> +++ plugins/trunk/cocomment/plugincocomment.class.php	2006-06-01  
> 20:21:29 UTC (rev 3505)
> @@ -0,0 +1,78 @@
> +<?php
> +	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
> +	include_once( PLOG_CLASS_PATH."class/plugin/ 
> pluginmanager.class.php" );
> +
> +	class PlugincoComment extends PluginBase
> +	{
> +		var $pluginEnabled;
> +		
> +		function PlugincoComment()
> +		{
> +			$this->PluginBase();
> +
> +			$this->id      = "cocomment";
> +			$this->author  = "James Huang";
> +			$this->desc    = "Integrate cocomment into LifeType commentform  
> template.";
> +
> +			$this->locales = Array( "en_UK" , "zh_TW" );
> +
> +			$this->init();
> +		}
> +
> +		function init()
> +		{
> +            $this->registerBlogAction( "coComment",  
> "ShowcoCommentAction" );
> +            $this->registerAdminAction( "coCommentConfig",  
> "PlugincoCommentConfigAction" );
> +			$this->registerAdminAction( "updatecoCommentConfig",  
> "PlugincoCommentUpdateConfigAction" );
> +			
> +			$menu =& Menu::getMenu();
> +			if( !$menu->entryExists( "/menu/controlCenter/ 
> manageAppearancePlugins" ))						
> +				$this->addMenuEntry( "/menu/controlCenter",  
> "manageAppearancePlugins", "", "", true, false );			
> +            $this->addMenuEntry( "/menu/controlCenter/ 
> manageAppearancePlugins", "coComment", "?op=coCommentConfig", "" );
> +		}
> +
> +		function register()
> +		{
> +		    $blogSettings = $this->blogInfo->getSettings();
> +			$this->pluginEnabled = $blogSettings->getValue 
> ( "plugin_cocomment_enabled" );
> +		}
> +
> +	    function isEnabled()
> +	    {
> +	        return $this->pluginEnabled;
> +	    }
> +	
> +	    function show()
> +	    {
> +            $locale = $this->blogInfo->getLocale();
> +
> +			$rg = $this->blogInfo->getBlogRequestGenerator();
> +			$baseUrl = $rg->getBaseUrl();
> +
> +			$str = '';
> +			$str = '<script type="text/javascript">';
> +			$str .= 'var blogTool = "LifeType";';
> +			$str .= 'var blogURL = "{$url->blogLink()}";';
> +			$str .= 'var blogTitle = "{$blog->getBlog()}";';
> +			$str .= 'var postURL = "{$url->postPermalink($post)}";';
> +			$str .= 'var postTitle = "{$post->getTopic()} ";';
> +			if ( $user_ID ) {
> +				$str .= 'var commentAuthor = "'.$user_identity.'"';
> +			} else {
> +				$str.= 'var commentAuthorFieldName = "author";';
> +			}
> +			$str .= 'var commentAuthorLoggedIn =';
> +			if ( !$user_ID ) {
> +				$str .= false.';';
> +			}else {
> +				$str .=true.';';
> +			}
> +			$str .='var commentFormID = "commentform";';
> +			$str .='var commentTextFieldName = "commentText";';
> +			$str .='var commentButtonName = "post";';
> +			$str .='var cocomment_force = false;';
> +			$str .='</script>';
> +	    	return $str;
> +		}
> +	}
> +?>
> \ No newline at end of file
>
> Added: plugins/trunk/cocomment/template/cocomment.template
> ===================================================================
> --- plugins/trunk/cocomment/template/cocomment.template	2006-06-01  
> 20:14:33 UTC (rev 3504)
> +++ plugins/trunk/cocomment/template/cocomment.template	2006-06-01  
> 20:21:29 UTC (rev 3505)
> @@ -0,0 +1,24 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"  
> showOpt=coComment title=$locale->tr("cocomment_plugin")}
> +<form name="cocommentPluginConfig" 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("cocomment_plugin_enabled")}
> +   </div>
> +  </div>
> +
> + </fieldset>
> +
> + <div class="buttons">
> +  <input type="hidden" name="op" value="updatecoCommentConfig" />
> +  <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
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
>

--
Paul Westbrook
paul at westbrooks.org
<http://www.westbrooks.org>




More information about the pLog-svn mailing list