aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/demo_plugin
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-13 12:05:08 +0200
committerArthurHoaro <arthur@hoa.ro>2020-10-13 12:05:08 +0200
commitb6f678a5a1d15acf284ebcec16c905e976671ce1 (patch)
tree33c7da831482ed79c44896ef19c73c72ada84f2e /plugins/demo_plugin
parentb14687036b9b800681197f51fdc47e62f0c88e2e (diff)
parent1c1520b6b98ab20201bfe15577782a52320339df (diff)
downloadShaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.gz
Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.zst
Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.zip
Merge branch 'v0.12' into latest
Diffstat (limited to 'plugins/demo_plugin')
-rw-r--r--plugins/demo_plugin/demo_plugin.php33
1 files changed, 14 insertions, 19 deletions
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php
index 71ba7495..defb01f7 100644
--- a/plugins/demo_plugin/demo_plugin.php
+++ b/plugins/demo_plugin/demo_plugin.php
@@ -2,8 +2,8 @@
2/** 2/**
3 * Demo Plugin. 3 * Demo Plugin.
4 * 4 *
5 * This plugin try to cover Shaarli's plugin API entirely. 5 * This plugin tries to completely cover Shaarli's plugin API.
6 * Can be used by plugin developper to make their own. 6 * Can be used by plugin developers to make their own plugin.
7 */ 7 */
8 8
9/* 9/*
@@ -16,7 +16,7 @@
16 16
17use Shaarli\Config\ConfigManager; 17use Shaarli\Config\ConfigManager;
18use Shaarli\Plugin\PluginManager; 18use Shaarli\Plugin\PluginManager;
19use Shaarli\Router; 19use Shaarli\Render\TemplatePage;
20 20
21/** 21/**
22 * In the footer hook, there is a working example of a translation extension for Shaarli. 22 * In the footer hook, there is a working example of a translation extension for Shaarli.
@@ -61,7 +61,7 @@ function demo_plugin_init($conf)
61 61
62/** 62/**
63 * Hook render_header. 63 * Hook render_header.
64 * Executed on every page redering. 64 * Executed on every page render.
65 * 65 *
66 * Template placeholders: 66 * Template placeholders:
67 * - buttons_toolbar 67 * - buttons_toolbar
@@ -74,7 +74,7 @@ function demo_plugin_init($conf)
74function hook_demo_plugin_render_header($data) 74function hook_demo_plugin_render_header($data)
75{ 75{
76 // Only execute when linklist is rendered. 76 // Only execute when linklist is rendered.
77 if ($data['_PAGE_'] == Router::$PAGE_LINKLIST) { 77 if ($data['_PAGE_'] == TemplatePage::LINKLIST) {
78 // If loggedin 78 // If loggedin
79 if ($data['_LOGGEDIN_'] === true) { 79 if ($data['_LOGGEDIN_'] === true) {
80 /* 80 /*
@@ -118,7 +118,7 @@ function hook_demo_plugin_render_header($data)
118 $form = array( 118 $form = array(
119 'attr' => array( 119 'attr' => array(
120 'method' => 'GET', 120 'method' => 'GET',
121 'action' => '?', 121 'action' => $data['_BASE_PATH_'] . '/',
122 'class' => 'addform', 122 'class' => 'addform',
123 ), 123 ),
124 'inputs' => array( 124 'inputs' => array(
@@ -145,7 +145,7 @@ function hook_demo_plugin_render_header($data)
145 145
146/** 146/**
147 * Hook render_includes. 147 * Hook render_includes.
148 * Executed on every page redering. 148 * Executed on every page render.
149 * 149 *
150 * Template placeholders: 150 * Template placeholders:
151 * - css_files 151 * - css_files
@@ -169,7 +169,7 @@ function hook_demo_plugin_render_includes($data)
169 169
170/** 170/**
171 * Hook render_footer. 171 * Hook render_footer.
172 * Executed on every page redering. 172 * Executed on every page render.
173 * 173 *
174 * Template placeholders: 174 * Template placeholders:
175 * - text 175 * - text
@@ -186,7 +186,7 @@ function hook_demo_plugin_render_includes($data)
186 */ 186 */
187function hook_demo_plugin_render_footer($data) 187function hook_demo_plugin_render_footer($data)
188{ 188{
189 // footer text 189 // Footer text
190 $data['text'][] = '<br>'. demo_plugin_t('Shaarli is now enhanced by the awesome demo_plugin.'); 190 $data['text'][] = '<br>'. demo_plugin_t('Shaarli is now enhanced by the awesome demo_plugin.');
191 191
192 // Free elements at the end of the page. 192 // Free elements at the end of the page.
@@ -277,7 +277,7 @@ function hook_demo_plugin_render_editlink($data)
277 // Load HTML into a string 277 // Load HTML into a string
278 $html = file_get_contents(PluginManager::$PLUGINS_PATH .'/demo_plugin/field.html'); 278 $html = file_get_contents(PluginManager::$PLUGINS_PATH .'/demo_plugin/field.html');
279 279
280 // replace value in HTML if it exists in $data 280 // Replace value in HTML if it exists in $data
281 if (!empty($data['link']['stuff'])) { 281 if (!empty($data['link']['stuff'])) {
282 $html = sprintf($html, $data['link']['stuff']); 282 $html = sprintf($html, $data['link']['stuff']);
283 } else { 283 } else {
@@ -324,9 +324,7 @@ function hook_demo_plugin_render_tools($data)
324 */ 324 */
325function hook_demo_plugin_render_picwall($data) 325function hook_demo_plugin_render_picwall($data)
326{ 326{
327 // plugin_start_zone
328 $data['plugin_start_zone'][] = '<center>BEFORE</center>'; 327 $data['plugin_start_zone'][] = '<center>BEFORE</center>';
329 // plugin_end_zone
330 $data['plugin_end_zone'][] = '<center>AFTER</center>'; 328 $data['plugin_end_zone'][] = '<center>AFTER</center>';
331 329
332 return $data; 330 return $data;
@@ -348,9 +346,7 @@ function hook_demo_plugin_render_picwall($data)
348 */ 346 */
349function hook_demo_plugin_render_tagcloud($data) 347function hook_demo_plugin_render_tagcloud($data)
350{ 348{
351 // plugin_start_zone
352 $data['plugin_start_zone'][] = '<center>BEFORE</center>'; 349 $data['plugin_start_zone'][] = '<center>BEFORE</center>';
353 // plugin_end_zone
354 $data['plugin_end_zone'][] = '<center>AFTER</center>'; 350 $data['plugin_end_zone'][] = '<center>AFTER</center>';
355 351
356 return $data; 352 return $data;
@@ -372,9 +368,7 @@ function hook_demo_plugin_render_tagcloud($data)
372 */ 368 */
373function hook_demo_plugin_render_daily($data) 369function hook_demo_plugin_render_daily($data)
374{ 370{
375 // plugin_start_zone
376 $data['plugin_start_zone'][] = '<center>BEFORE</center>'; 371 $data['plugin_start_zone'][] = '<center>BEFORE</center>';
377 // plugin_end_zone
378 $data['plugin_end_zone'][] = '<center>AFTER</center>'; 372 $data['plugin_end_zone'][] = '<center>AFTER</center>';
379 373
380 374
@@ -447,9 +441,9 @@ function hook_demo_plugin_delete_link($data)
447function hook_demo_plugin_render_feed($data) 441function hook_demo_plugin_render_feed($data)
448{ 442{
449 foreach ($data['links'] as &$link) { 443 foreach ($data['links'] as &$link) {
450 if ($data['_PAGE_'] == Router::$PAGE_FEED_ATOM) { 444 if ($data['_PAGE_'] == TemplatePage::FEED_ATOM) {
451 $link['description'] .= ' - ATOM Feed' ; 445 $link['description'] .= ' - ATOM Feed' ;
452 } elseif ($data['_PAGE_'] == Router::$PAGE_FEED_RSS) { 446 } elseif ($data['_PAGE_'] == TemplatePage::FEED_RSS) {
453 $link['description'] .= ' - RSS Feed'; 447 $link['description'] .= ' - RSS Feed';
454 } 448 }
455 } 449 }
@@ -465,7 +459,8 @@ function hook_demo_plugin_render_feed($data)
465 */ 459 */
466function hook_demo_plugin_save_plugin_parameters($data) 460function hook_demo_plugin_save_plugin_parameters($data)
467{ 461{
468 // Here we edit the provided value, but we can use this to generate config files, etc. 462 // Here we edit the provided value.
463 // This hook can also be used to generate config files, etc.
469 if (! empty($data['DEMO_PLUGIN_PARAMETER']) && ! endsWith($data['DEMO_PLUGIN_PARAMETER'], '_SUFFIX')) { 464 if (! empty($data['DEMO_PLUGIN_PARAMETER']) && ! endsWith($data['DEMO_PLUGIN_PARAMETER'], '_SUFFIX')) {
470 $data['DEMO_PLUGIN_PARAMETER'] .= '_SUFFIX'; 465 $data['DEMO_PLUGIN_PARAMETER'] .= '_SUFFIX';
471 } 466 }