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
  • Browsing and Searching
  • Firefox share
  • RSS feeds
  • +
  • REST API
  • How To

    Plugin System

    -
    -

    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.

    Developer API

    @@ -121,12 +120,21 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf | plugins/ |---| demo_plugin/ | |---| demo_plugin.php +

    Plugin initialization

    +

    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.

    Understanding hooks

    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:

    +

    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.

    Plugin's data

    Parameters

    @@ -159,6 +167,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf

    Note: In PHP, parse_ini_file() seems to want strings to be between by quotes " in the ini file.

    @@ -209,16 +218,28 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf 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:

    +

    plugin_start_end_zone_example

    +

    render_taglist

    +

    Triggered when taglist is displayed.

    +

    Allow to add content at the top and bottom of the page.

    +
    Data
    +

    $data is an array containing:

    + +
    Template placeholders
    +

    Items can be displayed in templates by adding an entry in $data['<placeholder>'] array.

    +

    List of placeholders:

    + +

    For each tag, the following placeholder can be used:

    +

    render_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:

    -
    Template placeholders
    +
    Template placeholders

    Items can be displayed in templates by adding an entry in $data['<placeholder>'] array.

    List of placeholders:

    - +

    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:

    + +
    Template placeholders
    +

    Tags can be added in feeds by adding an entry in $data['<placeholder>'] array.

    +

    List of placeholders:

    + +

    For each links:

    + +

    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:

    + +

    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:

    +

    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}