X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=plugins%2Fdemo_plugin%2Fdemo_plugin.php;h=7335c9d4665a0429549d7fd3977ca961f81e58fa;hb=7fde6de1212323418401c15efba06026c704ca87;hp=f03ddb2b5fd340faf6e4b3d422c99ec76369a93c;hpb=40a5f296a6f983e5a31961994e7c2db461e70f5e;p=github%2Fshaarli%2FShaarli.git diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index f03ddb2b..7335c9d4 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php @@ -14,6 +14,23 @@ * and check user status with _LOGGEDIN_. */ +/** + * Initialization function. + * It will be called when the plugin is loaded. + * This function can be used to return a list of initialization errors. + * + * @param $conf ConfigManager instance. + * + * @return array List of errors (optional). + */ +function demo_plugin_init($conf) +{ + $conf->get('toto', 'nope'); + + $errors[] = 'This a demo init error.'; + return $errors; +} + /** * Hook render_header. * Executed on every page redering. @@ -40,6 +57,8 @@ function hook_demo_plugin_render_header($data) // Fields in toolbar $data['fields_toolbar'][] = 'DEMO_fields_toolbar'; } + // Another button always displayed + $data['buttons_toolbar'][] = '
  • DEMO
  • '; return $data; } @@ -320,4 +339,29 @@ function hook_demo_plugin_delete_link($data) if (strpos($data['url'], 'youtube.com') !== false) { exit('You can not delete a YouTube link. Don\'t ask.'); } -} \ No newline at end of file +} + +/** + * Execute render_feed hook. + * Called with ATOM and RSS feed. + * + * Special data keys: + * - _PAGE_: current page + * - _LOGGEDIN_: true/false + * + * @param array $data data passed to plugin + * + * @return array altered $data. + */ +function hook_demo_plugin_render_feed($data) +{ + foreach ($data['links'] as &$link) { + if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { + $link['description'] .= ' - ATOM Feed' ; + } + elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { + $link['description'] .= ' - RSS Feed'; + } + } + return $data; +}