[pLog-svn] r4787 - plugins/branches/lifetype-1.2/authimage

Oscar Renalias oscar at renalias.net
Mon Feb 19 17:11:53 EST 2007


I also set out to implement this in a way that didn't require changes  
to plugins but then I realized that it wasn't going to be that easy.

Most if not all the plugins register their menu entries, filters,  
blog and admin actions in the constructor all at once so it will  
require some discipline from plugin authors to check what is needed  
when being called from index.php and what is needed when being called  
from admin.php. It's not too difficult, though :)

On 19 Feb 2007, at 23:55, Jon Daley wrote:

>  	Yeah.  I originally was thinking along the lines of not having to
> modify plugins, unless they actually needed to be modified, and  
> started
> writing up a bunch of code, but then realized that there is the new
> parameter, so I think the plugins have to be modified.
>  	So, wanting to justify my time wasted on thinking on that, had to
> say something...  :)
>  	I don't know if it is important or not - I haven't thought through
> if it matters -- are there plugins that actually call the same  
> functions
> from the admin and user side?
>
>   On Mon, 19 Feb 2007, Oscar Renalias wrote:
>
>> I guess you're right. I could save the value of the $source parameter
>> in PluginBase::$source and then add a PluginBase::getSource() method
>> in case it is neded later on... I'm sure that the same sort of
>> optimization that we've just added to the constructor of the plugin
>> could be used somewhere else.
>>
>> Is that what you had in mind?
>>
>> On 19 Feb 2007, at 23:04, Jon Daley wrote:
>>
>>>  	Should PluginBase() be PluginBase($source) and save the value
>>> somewhere?  Does it make sense to need it anywhere else?  I am not
>>> sure if
>>> it does, I just thought this might be a "base" sort of change,
>>> rather than
>>> each plugin keeping track of it.
>>>
>>>   On Mon, 19 Feb 2007, oscar at devel.lifetype.net wrote:
>>>
>>>> Author: oscar
>>>> Date: 2007-02-19 15:55:46 -0500 (Mon, 19 Feb 2007)
>>>> New Revision: 4787
>>>>
>>>> Modified:
>>>>   plugins/branches/lifetype-1.2/authimage/pluginauthimage.class.php
>>>> Log:
>>>> this small change saves us 500kb of memory and a couple thousand
>>>> method calls when index.php loads its plugins...
>>>>
>>>>
>>>> Modified: plugins/branches/lifetype-1.2/authimage/
>>>> pluginauthimage.class.php
>>>> ===================================================================
>>>> --- plugins/branches/lifetype-1.2/authimage/
>>>> pluginauthimage.class.php	2007-02-19 20:54:56 UTC (rev 4786)
>>>> +++ plugins/branches/lifetype-1.2/authimage/
>>>> pluginauthimage.class.php	2007-02-19 20:55:46 UTC (rev 4787)
>>>> @@ -20,22 +20,32 @@
>>>>         var $default;
>>>>         var $cacheFolder;
>>>>
>>>> -        function PluginAuthImage()
>>>> +        function PluginAuthImage( $source = "" )
>>>>         {
>>>>             $this->PluginBase();
>>>>
>>>>             $this->id      = "authimage";
>>>>             $this->author  = "Mark Wu";
>>>> -            $this->desc    = 'This plugin offers extra comment
>>>> authentication for LifeType. The idea is inspired by <a
>>>> href="http://www.gudlyf.com/index.php?p=376">WordPress AuthImage
>>>> Plugin</a> written by Gudlyf.';
>>>> +            $this->desc    = 'This plugin offers extra comment
>>>> authentication for LifeType.';
>>>>             $this->version = '1.0.1';
>>>>
>>>>             $this->locales = Array( "en_UK" , "zh_TW" , "zh_CN",
>>>> "es_ES", "de_DE" );
>>>> -
>>>> -            $this->init();
>>>> +
>>>> +			if( $source == "index" )
>>>> +				$this->init();
>>>> +			else
>>>> +				$this->initAdmin();
>>>>         }
>>>>
>>>> 		function init()
>>>> 		{
>>>> +			// register the filter
>>>> +			$this->registerFilter( "AuthImageFilter" );
>>>> +			$this->registerBlogAction( "AuthImageShow",
>>>> "PluginAuthImageShowAction" );
>>>> +		}
>>>> +
>>>> +		function initAdmin()
>>>> +		{
>>>>             include_once( PLOG_CLASS_PATH."class/template/menu/
>>>> menu.class.php" );
>>>>
>>>> 			// register the filter
>>>> @@ -50,7 +60,7 @@
>>>> 			if( !$menu->entryExists( "/menu/controlCenter/
>>>> manageAntiSpamPlugins" ))
>>>> 				$this->addMenuEntry( "/menu/controlCenter",
>>>> "manageAntiSpamPlugins", "", "" );
>>>>
>>>> -            $this->addMenuEntry( "/menu/controlCenter/
>>>> manageAntiSpamPlugins", "AuthImage", "?op=authimage", "" );
>>>> +            $this->addMenuEntry( "/menu/controlCenter/
>>>> manageAntiSpamPlugins", "AuthImage", "?op=authimage", "" );
>>>> 		}
>>>>
>>>> 		function register()
>>>> @@ -68,7 +78,7 @@
>>>> 			$this->key = $blogSettings->getValue( "plugin_authimage_key" );
>>>> 			$this->expiredTime = $blogSettings->getValue
>>>> ( "plugin_authimage_expiredtime" );
>>>> 			if ($this->expiredTime == "") $this->expiredTime = 3600;
>>>> -			$this->default = $blogSettings->getValue
>>>> ( "plugin_authimage_default" );
>>>> +			$this->default = $blogSettings->getValue
>>>> ( "plugin_authimage_default" );
>>>> 		}
>>>>
>>>> 	    function isEnabled()
>>>>
>>>> _______________________________________________
>>>> pLog-svn mailing list
>>>> pLog-svn at devel.lifetype.net
>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>
>>>
>>> --
>>> Jon Daley
>>> http://jon.limedaley.com/
>>>
>>> One of the "Best T-Shirts of 1998"
>>> "I am the person your parents warned you about"
>>> _______________________________________________
>>> pLog-svn mailing list
>>> pLog-svn at devel.lifetype.net
>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>
>>
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://limedaley.com/mailman/listinfo/plog-svn
>>
>
> -- 
> Jon Daley
> http://jon.limedaley.com/
>
> The gospel causes us to be able to live and eat for the glory of God.
> -- Mark Prater
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>



More information about the pLog-svn mailing list