X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=doc%2FPlugin-System.html;h=123bf1062915edd124ac4610c97f54c7c8914d90;hb=d5d22a6d07917865c44148ad76f43c65a929a890;hp=655536c60cc32190b5ada615202172408162c48d;hpb=adcdac1dec45090e2fa1cd4a340e91a40c7a205f;p=github%2Fshaarli%2FShaarli.git diff --git a/doc/Plugin-System.html b/doc/Plugin-System.html index 655536c6..123bf106 100644 --- a/doc/Plugin-System.html +++ b/doc/Plugin-System.html @@ -69,6 +69,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
-Note: Plugin current status - in development (not merged into master).
-
I am a developer. Developer API.
I am a template designer. Guide for template designer.
At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an init()
function to execute and run it if it exists. This function must be named this way, and takes the ConfigManager
as parameter.
<plugin_name>_init($conf)
+This function can be used to create initial data, load default settings, etc. But also to set plugin errors. If the initialization function returns an array of strings, they will be understand as errors, and displayed in the header to logged in users.
A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution.
These functions need to be named with this pattern:
-hook_<plugin_name>_<hook_name>
+hook_<plugin_name>_<hook_name>($data, $conf)
+Parameters:
+ConfigManager
instance.For exemple, if my plugin want to add data to the header, this function is needed:
-hook_demo_plugin_render_header()
+hook_demo_plugin_render_header
If this function is declared, and the plugin enabled, it will be called every time Shaarli is rendering the header.
description
: plugin descriptionparameters
: user parameter names, separated by a ;
.parameter.<PARAMETER_NAME>
: add a text description the specified parameter.Note: In PHP,
@@ -209,16 +218,28 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Infparse_ini_file()
seems to want strings to be between by quotes"
in the ini file.render_tagcloud -Allow to add content at the top and bottom of the page. +Allow to add content at the top and bottom of the page, and after all tags. + +render_taglist +Allow to add content at the top and bottom of the page, and after all tags. ++ render_daily Allow to add content at the top and bottom of the page, the bottom of each link and to alter data. + render_feed +Allow to do add tags in RSS and ATOM feeds. +- +savelink +save_link Allow to alter the link being saved in the datastore. + delete_link +Allow to do an action before a link is deleted from the datastore. +render_header
@@ -376,17 +397,41 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
plugin_start_zone
: before displaying the template content.+
plugin_end_zone
: after displaying the template content.For each tag, the following placeholder can be used:
++
+- +
tag_plugin
: after each tagrender_taglist
+Triggered when taglist is displayed.
+Allow to add content at the top and bottom of the page.
+Data
++
$data
is an array containing:+
+- +
_LOGGEDIN_
: true if user is logged in, false otherwise.- All templates data.
+Template placeholders
+Items can be displayed in templates by adding an entry in
+$data['<placeholder>']
array.List of placeholders:
++
+- +
plugin_start_zone
: before displaying the template content.- +
plugin_end_zone
: after displaying the template content.For each tag, the following placeholder can be used:
++
- +
tag_plugin
: after each tagrender_daily
Triggered when tagcloud is displayed.
Allow to add content at the top and bottom of the page, the bottom of each link and to alter data.
-Data
+Data
$data
is an array containing:-
_LOGGEDIN_
: true if user is logged in, false otherwise.- All templates data, including links.
Template placeholders
+Template placeholders
Items can be displayed in templates by adding an entry in
$data['<placeholder>']
array.List of placeholders:
@@ -397,18 +442,57 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
-
plugin_start_zone
: before displaying the template content.
plugin_end_zone
: after displaying the template content.savelink
+render_feed
+Triggered when the ATOM or RSS feed is displayed.
+Allow to add tags in the feed, either in the header or for each items. Items (links) can also be altered before being rendered.
+Data
++
$data
is an array containing:+
+- +
_LOGGEDIN_
: true if user is logged in, false otherwise.- +
_PAGE_
: containing eitherrss
oratom
.- All templates data, including links.
+Template placeholders
+Tags can be added in feeds by adding an entry in
+$data['<placeholder>']
array.List of placeholders:
++
+- +
feed_plugins_header
: used as a header tag in the feed.For each links:
++
+- +
feed_plugins
: additional tag for every link entry.save_link
Triggered when a link is save (new link or edit).
Allow to alter the link being saved in the datastore.
-Data
+Data
$data
is an array containing the link being saved:+
+- id
- title
- url
+- shorturl
- description
-- linkdate
- private
- tags
+- created
+- updated
+delete_link
+Triggered when a link is deleted.
+Allow to execute any action before the link is actually removed from the datastore
+Data
++
$data
is an array containing the link being saved:+
- id
+- title
+- url
+- shorturl
+- description
+- private
+- tags
+- created
+- updated
Guide for template designer
Plugin administration
@@ -537,5 +621,14 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf {$value} {/loop} </div> +feed.atom.xml and feed.rss.xml:
+In headers tags section:
++{loop="$feed_plugins_header"} + {$value} +{/loop}
After each entry:
+{loop="$value.feed_plugins"} + {$value} +{/loop}