* 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.
// Fields in toolbar
$data['fields_toolbar'][] = 'DEMO_fields_toolbar';
}
+ // Another button always displayed
+ $data['buttons_toolbar'][] = '<li><a href="#">DEMO</a></li>';
return $data;
}
*
* Template placeholders:
* - text
+ * - endofpage
* - js_files
*
* Data:
// footer text
$data['text'][] = 'Shaarli is now enhanced by the awesome demo_plugin.';
+ // Free elements at the end of the page.
+ $data['endofpage'][] = '<marquee id="demo_marquee">' .
+ 'DEMO: it\'s 1999 all over again!' .
+ '</marquee>';
+
// List of plugin's JS files.
// Note that you just need to specify CSS path.
$data['js_files'][] = PluginManager::$PLUGINS_PATH . '/demo_plugin/demo_plugin.js';
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;
+}