Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I retrieved @nodiscc plugin system proposed in shaarli#164 and changed it to create PHP plugin system. It relies on hooks triggered by certain actions (only template rendering for now). **It's only a proposition, let me know what you think of it**. * I think that an 'only template' plugin system might be too restrictive, and doesn't allow a lot of extension. * I raised concerns in shaarli#44 and don't blend too well with user made templates. * @nodiscc lacks of time to finish this. * I'd like to see 0.9beta release one day. :) PluginManager class includes enabled plugin PHP files at loading and register their hook function. When we want to trigger a hook, 'PluginManager::executeHooks()' is called, eventually with rendering data. It will call every plugin function registered under the standardized name: hook_<plugin_name>_<hook_name> Rendering data can be altered and/or completed. This is exactly what @nodiscc did. Templates contain plugin display at specific location, which are populated by the plugin functions. Here is what's has been done: * hook_render_linklist: when linklist is rendered, all links data passed to plugins. It allows plugins to alter link rendering (such as Markdown parsing). They can also add a linklist icon for every link (QRCode, etc.) * hook_render_header: every page builder triggers this hook. Plugins can add specific data to header if the current page is concerned (toolbar). * hook_render_footer: : every page builder triggers this hook. Plugins can add specific data to header if the current page is concerned (JS file). * hook_render_includes: : every page builder triggers this hook. Plugins can add specific data to header if the current page is concerned (CSS file). We can easily add hooks to whatever is pertinent (link add, picwal rendering, etc.). * Strong documentation, especially for plugin developers. * Unit tests for PluginManger and Router. * Test this heavily. Later: * finish Markdown plugin. * Add a plugin page in administration.
- Loading branch information