GreyBeard Inc.

    
     

Hastymail 2 ideas

avatar
plugins
Ok, so here is the plugin topic thread.
Reply /Quote
avatar
The life of a plugin

So here is my thought on how a plugin will work:

User logs in, main config file is parsed out, which includes plugin configs.

Baisc syntax:
$plugins['pluginname']['key'] = "value";

the $plugins array is itterated though, for each element, an array is expected. What goes in there is up to the plugin author, except for the manditory "enabled" option.  If $plugins['pluginname']['enabled'] is anything but true, the plugin will not be loaded. This array is then stored in $_SESSION once its all been parsed.  The config will not be parsed again during the session.

Then HM does include($pluginname+"_src.php") and calls $pluginname+"_register"() which is expected to register any hooks (which will be documented). This will only be done once per session.

Each time a hook is encountered (list_folders, whatever) from that point forward, $pluginname+"_"+$hookname($args) is called. 

Future page loads only call hooks.  One such important and spcial hook will be "init" which is called before other processing is done at each page load (so the plugin can initialize database connections, or whatnot). But the "init" hook will only be called if the plugin has other hooks to be called on this page load.  This means HM needs to know very early in the process what hooks will be called on that page load.

 

Reply /Quote
avatar
Plugin config syntaxes

Here are some example syntaxes for the plugin config 

http://docs.google.com/Doc?id=dpwkdp9_1qdndvkdm

Reply /Quote
avatar
sort of

Good point about needing an init function, defining the hooks based on the page should not be a problem. Also we want to provide additional means to create stand along pages within the site (not ones that hook into existing pages) so we need a mechanism for that, which I already have floating around in my head. It would be very much like the existing mechanism for outputting pages within framework, but encapsulated into the plugin include file.

I think you have an extra step in the initial process. What if we have only the main plugin config file, parsed at login and stored in the session. There is no need to parse individual files from the plugin until a hook (or init for that page) is called. Then when we hit a hook execution point we include the file associated with that hook/plugin and run a predetermined function in the plugin file. There are no arguments to the hook function. Everything they might need to do can be done by including the global $user object.

Reply /Quote
avatar
location of hook requests
I think the difference between your idea and mine is where the hook requests come from.  I look at the config file as something the admin is going to read and modify. I dont think the plugin hook requests belong there, since they are not really configurable.  Which means the hook requests should come from within the plugin source itself, which means the plugin source needs to be included.
Reply /Quote
avatar
Plugins should support global themes

Plugins should use the same theme or color scheme as the rest of hm2. At least as a default option.  There could be reasons to use a special one if it was a photo album or something.

 

Reply /Quote
avatar
re: location of hook requests
We than have to include a file per enabled plugin on login at least, which I don't really care for that much. Maybe this is the bit we should automate via an install procedure of some sort.
Reply /Quote
avatar
Re: Plugins should support global themes
we could allow a plugin to include its own additional css file during the page init in which it has hooks.
Reply /Quote