[pLog-svn] r4786 - in plog/branches/lifetype-1.2: . class/plugin
Jon Daley
plogworld at jon.limedaley.com
Tue Feb 20 17:04:53 EST 2007
I was thinking that a plugin could want to be active during XMLRPC
and ADMIN, but I guess the source is still only set to one thing at a
time, and then the plugin would still have multiple if statements anyway.
On Tue, 20 Feb 2007, Paul Westbrook wrote:
> Hello,
> I agree that not every plugin should be instantiated from rss or
> xmlrpc server. For example, ideally in xmlrpcserver, only plugins
> that have registered for EVENT_PRE/POST_POST_AD, EVENT_PRE/
> POST_POST_UPDATE, and EVENT_PRE/POST_POST_DELETE would be instantiated.
>
> Using a bit field might add confusion. Bitfields imply that multiple
> bits can be set at the same time. I can't imagine when multiple
> sources would be set.
>
> --Paul
>
>
> On Feb 20, 2007, at 12:17 PM, Jon Daley wrote:
>
>> Hrm - I wonder how many / which plugins should be called from the
>> rss and xmlrpcserver - maybe we could lower the resource usage on
>> them?
>> It would be nice to lower the RSS load.
>> Does php care if that parameter is a string versus an integer, in
>> terms of performance? I also wondered about using a bitfield like
>> define("SOURCE_INDEX", 1);
>> define("SOURCE_ADMIN", 2);
>> define("SOURCE_RSS", 4);
>>
>> and then do a
>> if($src & SOURCE_ADMIN)
>>
>>
>>
>> On Tue, 20 Feb 2007, Paul Westbrook wrote:
>>
>>> Hello,
>>> loadPlugins is called from rss and the xmlrpcserver code. Do we
>>> want to call these out as different sources? I would think that
>>> most plugins only care about being called from admin.php or not.
>>>
>>> When I port some plugins, I will check for "admin", and call the
>>> admin init function in this case. In all other cases, the simple
>>> init would be called.
>>>
>>> --Paul
>>>
>>>
>>> On Feb 20, 2007, at 2:16 AM, Jon Daley wrote:
>>>
>>>> Why is a default good? Does loadPlugins get called from somewhere
>>>> else? If there isn't a default, then one would get an error that
>>>> they
>>>> were missing a parameter when they call it, and so would know to
>>>> fix their
>>>> code.
>>>>
>>>> On Tue, 20 Feb 2007, Oscar Renalias wrote:
>>>>
>>>>> Specifying a default source is probably a good idea, I guess it
>>>>> should
>>>>> be "index".
>>>>>
>>>>> And plugins should want to know where they're being instantiated
>>>>> from,
>>>>> that's the idea, so that they can react in different ways and load
>>>>> different classes depending on whether they're being loaded from
>>>>> index.php and admin.php.
>>>>>
>>>>> On 2/20/07, Paul Westbrook <paul at westbrooks.org> wrote:
>>>>>> Hello,
>>>>>> Also, should there be a default source that is used in
>>>>>> loadPlugins. The only places that currently specify a source
>>>>>> are in
>>>>>> admin.php and index.php.
>>>>>>
>>>>>> Should the default be "index" and only admin.php set it to
>>>>>> "admin"?
>>>>>> Or would plugins want to know exactly where they are being
>>>>>> instantiated from?
>>>>>>
>>>>>> --Paul
>>>>>>
>>>>>>
>>>>>> On Feb 19, 2007, at 12:54 PM, oscar at devel.lifetype.net wrote:
>>>>>>
>>>>>>> Author: oscar
>>>>>>> Date: 2007-02-19 15:54:56 -0500 (Mon, 19 Feb 2007)
>>>>>>> New Revision: 4786
>>>>>>>
>>>>>>> Modified:
>>>>>>> plog/branches/lifetype-1.2/admin.php
>>>>>>> plog/branches/lifetype-1.2/class/plugin/pluginbase.class.php
>>>>>>> plog/branches/lifetype-1.2/class/plugin/
>>>>>>> pluginmanager.class.php
>>>>>>> plog/branches/lifetype-1.2/index.php
>>>>>>> Log:
>>>>>>> Added an extra parameter to the constructor of the PluginBase
>>>>>>> class: $source. This parameter will be provided by the
>>>>>>> PluginManager class when instantiating plugin classes and it
>>>>>>> should
>>>>>>> be used by plugin classes to differentiate whether they're being
>>>>>>> called by index.php or admin.php. This also means that the
>>>>>>> constructor can react in different ways depending on the value of
>>>>>>> the $source parameter, so for example when it's index.php calling
>>>>>>> us there is no need to register menu entries or add new admin
>>>>>>> actions because they're not going to be used anyway... By
>>>>>>> making a
>>>>>>> few small changes in the authimage plugin to accommodate this new
>>>>>>> parameter, I was able to save over 500kb of memory in addition to
>>>>>>> over 2000 function and method calls, which I think is quite good.
>>>>>>>
>>>>>>> Of course this change means nothing unless plugins are adapted
>>>>>>> for
>>>>>>> it, but I will get round to modifying the ported plugins right
>>>>>>> away.
>>>>>>>
>>>>>>> As a side effect this also means that our current
>>>>>>> implementation of
>>>>>>> dynamic menus is rubbish and that we should rethink the whole
>>>>>>> thing
>>>>>>> for 1.3 :)
>>>>>>>
>>>>>>>
>>>>>>> Modified: plog/branches/lifetype-1.2/admin.php
>>>>>>> =================================================================
>>>>>>> ==
>>>>>>> --- plog/branches/lifetype-1.2/admin.php 2007-02-19
>>>>>>> 20:40:28 UTC
>>>>>>> (rev 4785)
>>>>>>> +++ plog/branches/lifetype-1.2/admin.php 2007-02-19
>>>>>>> 20:54:56 UTC
>>>>>>> (rev 4786)
>>>>>>> @@ -37,7 +37,7 @@
>>>>>>> // Controller::process() method, as some of the plugins
>>>>>>> _might_
>>>>>>> // add new actions to the controller
>>>>>>> $pluginManager =& PluginManager::getPluginManager();
>>>>>>> - $pluginManager->loadPlugins();
>>>>>>> + $pluginManager->loadPlugins( "admin" );
>>>>>>>
>>>>>>> // give control to the, ehem, controller :)
>>>>>>> $controller->process( HttpVars::getRequest(), "op");
>>>>>>>
>>>>>>> Modified: plog/branches/lifetype-1.2/class/plugin/
>>>>>>> pluginbase.class.php
>>>>>>> =================================================================
>>>>>>> ==
>>>>>>> --- plog/branches/lifetype-1.2/class/plugin/pluginbase.class.php
>>>>>>> 2007-02-19 20:40:28 UTC (rev 4785)
>>>>>>> +++ plog/branches/lifetype-1.2/class/plugin/pluginbase.class.php
>>>>>>> 2007-02-19 20:54:56 UTC (rev 4786)
>>>>>>> @@ -80,8 +80,14 @@
>>>>>>>
>>>>>>> /**
>>>>>>> * Constructor. Feel free to do here whatever you
>>>>>>> need to.
>>>>>>> + *
>>>>>>> + * @param source Only defined to be 'blog' or
>>>>>>> 'admin'. This
>>>>>>> parameter should be used to determine
>>>>>>> + * whether it is index.php registering this plugin
>>>>>>> ("index") or
>>>>>>> admin.php doing it ("admin") so that
>>>>>>> + * we can perform different things. This means
>>>>>>> that the plugin
>>>>>>> can be initialized in two different ways
>>>>>>> + * depending on whether we're being called via
>>>>>>> index.php or via
>>>>>>> admin.php so things like menu entries
>>>>>>> + * or admin actions do not need to be registered
>>>>>>> unless it's
>>>>>>> admin.php calling, and so on.
>>>>>>> */
>>>>>>> - function PluginBase()
>>>>>>> + function PluginBase( $source = "" )
>>>>>>> {
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>> Modified: plog/branches/lifetype-1.2/class/plugin/
>>>>>>> pluginmanager.class.php
>>>>>>> =================================================================
>>>>>>> ==
>>>>>>> --- plog/branches/lifetype-1.2/class/plugin/
>>>>>>> pluginmanager.class.php
>>>>>>> 2007-02-19 20:40:28 UTC (rev 4785)
>>>>>>> +++ plog/branches/lifetype-1.2/class/plugin/
>>>>>>> pluginmanager.class.php
>>>>>>> 2007-02-19 20:54:56 UTC (rev 4786)
>>>>>>> @@ -41,6 +41,7 @@
>>>>>>> var $_blogInfo;
>>>>>>> var $_userInfo;
>>>>>>> var $_pluginInstances;
>>>>>>> + var $_source;
>>>>>>>
>>>>>>> /**
>>>>>>> * global variable to save the list of plugins
>>>>>>> registered
>>>>>>> so far
>>>>>>> @@ -60,9 +61,7 @@
>>>>>>> * @param filePattern
>>>>>>> */
>>>>>>> function PluginManager( $pluginDir =
>>>>>>> PLUGIN_MANAGER_DEFAULT_PLUGIN_FOLDER, $filePattern =
>>>>>>> PLUGIN_MANAGER_DEFAULT_PLUGIN_FILE_PATTERN )
>>>>>>> - {
>>>>>>> -
>>>>>>> -
>>>>>>> + {
>>>>>>> $config =& Config::getConfig();
>>>>>>>
>>>>>>> // initialize the arrays used to keep track of
>>>>>>> plugins
>>>>>>> and events
>>>>>>> @@ -165,11 +164,13 @@
>>>>>>> /**
>>>>>>> * Loads all the plugins from disk
>>>>>>> *
>>>>>>> - * @private
>>>>>>> + * @param source
>>>>>>> */
>>>>>>> - function loadPlugins()
>>>>>>> + function loadPlugins( $source )
>>>>>>> {
>>>>>>> $classLoader =&
>>>>>>> ResourceClassLoader::getLoader();
>>>>>>> +
>>>>>>> + $this->_source = $source;
>>>>>>>
>>>>>>> foreach( $this->_pluginList as $plugin ) {
>>>>>>> $pluginFile = "./plugins/$plugin";
>>>>>>> @@ -243,7 +244,7 @@
>>>>>>> if( File::isReadable( $pluginFile."/".
>>>>>>> $pluginFileName )) {
>>>>>>> $className = "Plugin".
>>>>>>> $plugin;
>>>>>>> lt_include
>>>>>>> ( $pluginFullPath );
>>>>>>> - $classInstance = new
>>>>>>> $className();
>>>>>>> + $classInstance = new
>>>>>>> $className( $this->_source );
>>>>>>> $classInstance-
>>>>>>>> setPluginFolder( PLOG_CLASS_PATH.
>>>>>>> $pluginFile."/" );
>>>>>>> $name = $classInstance-
>>>>>>>> getId();
>>>>>>>
>>>>>>>
>>>>>>> Modified: plog/branches/lifetype-1.2/index.php
>>>>>>> =================================================================
>>>>>>> ==
>>>>>>> --- plog/branches/lifetype-1.2/index.php 2007-02-19
>>>>>>> 20:40:28 UTC
>>>>>>> (rev 4785)
>>>>>>> +++ plog/branches/lifetype-1.2/index.php 2007-02-19
>>>>>>> 20:54:56 UTC
>>>>>>> (rev 4786)
>>>>>>> @@ -45,7 +45,7 @@
>>>>>>> // Controller::process() method, as some of the plugins
>>>>>>> _might_
>>>>>>> // add new actions to the controller
>>>>>>> $pluginManager =& PluginManager::getPluginManager();
>>>>>>> - $pluginManager->loadPlugins();
>>>>>>> + $pluginManager->loadPlugins( "index" );
>>>>>>>
>>>>>>> // give control to the, ehem, controller :)
>>>>>>> $controller->process( HttpVars::getRequest(), "op");
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> pLog-svn mailing list
>>>>>>> pLog-svn at devel.lifetype.net
>>>>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>>>
>>>>>> --
>>>>>> Paul Westbrook
>>>>>> paul at westbrooks.org
>>>>>> <http://www.westbrooks.org>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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/
>>>>
>>>> It's a question of whether we're going to go forward
>>>> into the future, or past into the back.
>>>> -- Dan Quayle
>>>> _______________________________________________
>>>> pLog-svn mailing list
>>>> pLog-svn at devel.lifetype.net
>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>
>>> --
>>> Paul Westbrook
>>> paul at westbrooks.org
>>> <http://www.westbrooks.org>
>>>
>>>
>>> _______________________________________________
>>> pLog-svn mailing list
>>> pLog-svn at devel.lifetype.net
>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>
>>
>> --
>> Jon Daley
>> http://jon.limedaley.com/
>>
>> Do not worry about your difficulties in mathematics, I assure you that
>> mine are greater.
>> -- Einstein
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://limedaley.com/mailman/listinfo/plog-svn
>
> --
> Paul Westbrook
> paul at westbrooks.org
> <http://www.westbrooks.org>
>
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>
--
Jon Daley
http://jon.limedaley.com/
During the first day of my human-anatomy course at Brigham Young
University, our professor said we would be studying real human
cadavers. He then told us about the unusual experience of driving
a large refrigerated truck cross-country to transpot the cadavers
to our campus. One student raised his hand and asked,
"Did you get to use the car-pool lane?"
-- Diane Chatwin
More information about the pLog-svn
mailing list