aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/addlink_toolbar/addlink_toolbar.php2
-rw-r--r--plugins/archiveorg/archiveorg.php2
-rw-r--r--plugins/default_colors/default_colors.css.template3
-rw-r--r--plugins/default_colors/default_colors.meta5
-rw-r--r--plugins/default_colors/default_colors.php111
-rw-r--r--plugins/demo_plugin/demo_plugin.meta3
-rw-r--r--plugins/demo_plugin/demo_plugin.php21
-rw-r--r--plugins/isso/isso.php2
-rw-r--r--plugins/markdown/markdown.php2
-rw-r--r--plugins/piwik/piwik.php2
-rw-r--r--plugins/playvideos/playvideos.php3
-rw-r--r--plugins/pubsubhubbub/pubsubhubbub.php3
-rw-r--r--plugins/qrcode/qrcode.html2
-rw-r--r--plugins/qrcode/qrcode.php4
-rw-r--r--plugins/wallabag/WallabagInstance.php1
-rw-r--r--plugins/wallabag/wallabag.php6
16 files changed, 167 insertions, 5 deletions
diff --git a/plugins/addlink_toolbar/addlink_toolbar.php b/plugins/addlink_toolbar/addlink_toolbar.php
index 8c05a231..8bf4ed46 100644
--- a/plugins/addlink_toolbar/addlink_toolbar.php
+++ b/plugins/addlink_toolbar/addlink_toolbar.php
@@ -5,6 +5,8 @@
5 * Adds the addlink input on the linklist page. 5 * Adds the addlink input on the linklist page.
6 */ 6 */
7 7
8use Shaarli\Router;
9
8/** 10/**
9 * When linklist is displayed, add play videos to header's toolbar. 11 * When linklist is displayed, add play videos to header's toolbar.
10 * 12 *
diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php
index 5dcea5a6..0ee1c73c 100644
--- a/plugins/archiveorg/archiveorg.php
+++ b/plugins/archiveorg/archiveorg.php
@@ -5,6 +5,8 @@
5 * Add an icon in the link list for archive.org. 5 * Add an icon in the link list for archive.org.
6 */ 6 */
7 7
8use Shaarli\Plugin\PluginManager;
9
8/** 10/**
9 * Add archive.org icon to link_plugin when rendering linklist. 11 * Add archive.org icon to link_plugin when rendering linklist.
10 * 12 *
diff --git a/plugins/default_colors/default_colors.css.template b/plugins/default_colors/default_colors.css.template
new file mode 100644
index 00000000..87e22a08
--- /dev/null
+++ b/plugins/default_colors/default_colors.css.template
@@ -0,0 +1,3 @@
1:root {
2%s
3}
diff --git a/plugins/default_colors/default_colors.meta b/plugins/default_colors/default_colors.meta
new file mode 100644
index 00000000..108962c6
--- /dev/null
+++ b/plugins/default_colors/default_colors.meta
@@ -0,0 +1,5 @@
1description="Override default theme colors. Use any CSS valid color."
2parameters="DEFAULT_COLORS_MAIN;DEFAULT_COLORS_BACKGROUND;DEFAULT_COLORS_DARK_MAIN"
3parameter.DEFAULT_COLORS_MAIN="Main color (navbar green)"
4parameter.DEFAULT_COLORS_BACKGROUND="Background color (light grey)"
5parameter.DEFAULT_COLORS_DARK_MAIN="Dark main color (e.g. visited links)"
diff --git a/plugins/default_colors/default_colors.php b/plugins/default_colors/default_colors.php
new file mode 100644
index 00000000..1928cc9f
--- /dev/null
+++ b/plugins/default_colors/default_colors.php
@@ -0,0 +1,111 @@
1<?php
2
3/**
4 * Plugin default_colors.
5 *
6 * Allow users to easily overrides colors of the default theme.
7 */
8
9use Shaarli\Config\ConfigManager;
10use Shaarli\Plugin\PluginManager;
11
12const DEFAULT_COLORS_PLACEHOLDERS = [
13 'DEFAULT_COLORS_MAIN',
14 'DEFAULT_COLORS_BACKGROUND',
15 'DEFAULT_COLORS_DARK_MAIN',
16];
17
18/**
19 * Display an error if the plugin is active a no color is configured.
20 *
21 * @param $conf ConfigManager instance
22 *
23 * @return array|null The errors array or null of there is none.
24 */
25function default_colors_init($conf)
26{
27 $params = '';
28 foreach (DEFAULT_COLORS_PLACEHOLDERS as $placeholder) {
29 $params .= trim($conf->get('plugins.'. $placeholder, ''));
30 }
31
32 if (empty($params)) {
33 $error = t('Default colors plugin error: '.
34 'This plugin is active and no custom color is configured.');
35 return array($error);
36 }
37}
38
39/**
40 * When plugin parameters are saved, we regenerate the custom CSS file with provided settings.
41 *
42 * @param array $data $_POST array
43 *
44 * @return array Updated $_POST array
45 */
46function hook_default_colors_save_plugin_parameters($data)
47{
48 $file = PluginManager::$PLUGINS_PATH . '/default_colors/default_colors.css';
49 $template = file_get_contents(PluginManager::$PLUGINS_PATH . '/default_colors/default_colors.css.template');
50 $content = '';
51 foreach (DEFAULT_COLORS_PLACEHOLDERS as $rule) {
52 $content .= ! empty($data[$rule])
53 ? default_colors_format_css_rule($data, $rule) .';'. PHP_EOL
54 : '';
55 }
56
57 if (! empty($content)) {
58 file_put_contents($file, sprintf($template, $content));
59 }
60
61 return $data;
62}
63
64/**
65 * When linklist is displayed, include default_colors CSS file.
66 *
67 * @param array $data - header data.
68 *
69 * @return mixed - header data with default_colors CSS file added.
70 */
71function hook_default_colors_render_includes($data)
72{
73 $file = PluginManager::$PLUGINS_PATH . '/default_colors/default_colors.css';
74 if (file_exists($file )) {
75 $data['css_files'][] = $file ;
76 }
77
78 return $data;
79}
80
81/**
82 * Create a valid CSS rule from parameters settings and plugin parameter.
83 *
84 * @param array $data $_POST array
85 * @param string $parameter Plugin parameter name
86 *
87 * @return string CSS rules for the provided parameter and its matching value.
88 */
89function default_colors_format_css_rule($data, $parameter)
90{
91 if (empty($data[$parameter])) {
92 return '';
93 }
94
95 $key = str_replace('DEFAULT_COLORS_', '', $parameter);
96 $key = str_replace('_', '-', strtolower($key)) .'-color';
97 return ' --'. $key .': '. $data[$parameter];
98}
99
100
101/**
102 * This function is never called, but contains translation calls for GNU gettext extraction.
103 */
104function default_colors_translation()
105{
106 // meta
107 t('Override default theme colors. Use any CSS valid color.');
108 t('Main color (navbar green)');
109 t('Background color (light grey)');
110 t('Dark main color (e.g. visited links)');
111}
diff --git a/plugins/demo_plugin/demo_plugin.meta b/plugins/demo_plugin/demo_plugin.meta
index b063ecb7..cd616441 100644
--- a/plugins/demo_plugin/demo_plugin.meta
+++ b/plugins/demo_plugin/demo_plugin.meta
@@ -1 +1,4 @@
1description="A demo plugin covering all use cases for template designers and plugin developers." 1description="A demo plugin covering all use cases for template designers and plugin developers."
2parameters="DEMO_PLUGIN_PARAMETER;DEMO_PLUGIN_OTHER_PARAMETER"
3parameter.DEMO_PLUGIN_PARAMETER="This is a parameter dedicated to the demo plugin. It'll be suffixed."
4parameter.DEMO_PLUGIN_OTHER_PARAMETER="Other demo parameter"
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php
index ca520d15..71ba7495 100644
--- a/plugins/demo_plugin/demo_plugin.php
+++ b/plugins/demo_plugin/demo_plugin.php
@@ -15,6 +15,8 @@
15 */ 15 */
16 16
17use Shaarli\Config\ConfigManager; 17use Shaarli\Config\ConfigManager;
18use Shaarli\Plugin\PluginManager;
19use Shaarli\Router;
18 20
19/** 21/**
20 * 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.
@@ -455,10 +457,29 @@ function hook_demo_plugin_render_feed($data)
455} 457}
456 458
457/** 459/**
460 * When plugin parameters are saved.
461 *
462 * @param array $data $_POST array
463 *
464 * @return array Updated $_POST array
465 */
466function hook_demo_plugin_save_plugin_parameters($data)
467{
468 // Here we edit the provided value, but we can use this to generate config files, etc.
469 if (! empty($data['DEMO_PLUGIN_PARAMETER']) && ! endsWith($data['DEMO_PLUGIN_PARAMETER'], '_SUFFIX')) {
470 $data['DEMO_PLUGIN_PARAMETER'] .= '_SUFFIX';
471 }
472
473 return $data;
474}
475
476/**
458 * This function is never called, but contains translation calls for GNU gettext extraction. 477 * This function is never called, but contains translation calls for GNU gettext extraction.
459 */ 478 */
460function demo_dummy_translation() 479function demo_dummy_translation()
461{ 480{
462 // meta 481 // meta
463 t('A demo plugin covering all use cases for template designers and plugin developers.'); 482 t('A demo plugin covering all use cases for template designers and plugin developers.');
483 t('This is a parameter dedicated to the demo plugin. It\'ll be suffixed.');
484 t('Other demo parameter');
464} 485}
diff --git a/plugins/isso/isso.php b/plugins/isso/isso.php
index 378c11af..dab75dd5 100644
--- a/plugins/isso/isso.php
+++ b/plugins/isso/isso.php
@@ -5,6 +5,8 @@
5 */ 5 */
6 6
7use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
8use Shaarli\Plugin\PluginManager;
9use Shaarli\Router;
8 10
9/** 11/**
10 * Display an error everywhere if the plugin is enabled without configuration. 12 * Display an error everywhere if the plugin is enabled without configuration.
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php
index 8823af91..628970d6 100644
--- a/plugins/markdown/markdown.php
+++ b/plugins/markdown/markdown.php
@@ -7,6 +7,8 @@
7 */ 7 */
8 8
9use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
10use Shaarli\Plugin\PluginManager;
11use Shaarli\Router;
10 12
11/* 13/*
12 * If this tag is used on a shaare, the description won't be processed by Parsedown. 14 * If this tag is used on a shaare, the description won't be processed by Parsedown.
diff --git a/plugins/piwik/piwik.php b/plugins/piwik/piwik.php
index ca00c2be..17b1aecc 100644
--- a/plugins/piwik/piwik.php
+++ b/plugins/piwik/piwik.php
@@ -4,6 +4,8 @@
4 * Adds tracking code on each page. 4 * Adds tracking code on each page.
5 */ 5 */
6 6
7use Shaarli\Plugin\PluginManager;
8
7/** 9/**
8 * Initialization function. 10 * Initialization function.
9 * It will be called when the plugin is loaded. 11 * It will be called when the plugin is loaded.
diff --git a/plugins/playvideos/playvideos.php b/plugins/playvideos/playvideos.php
index c6d6b0cc..0341ed59 100644
--- a/plugins/playvideos/playvideos.php
+++ b/plugins/playvideos/playvideos.php
@@ -6,6 +6,9 @@
6 * Note: this plugin adds jQuery. 6 * Note: this plugin adds jQuery.
7 */ 7 */
8 8
9use Shaarli\Plugin\PluginManager;
10use Shaarli\Router;
11
9/** 12/**
10 * When linklist is displayed, add play videos to header's toolbar. 13 * When linklist is displayed, add play videos to header's toolbar.
11 * 14 *
diff --git a/plugins/pubsubhubbub/pubsubhubbub.php b/plugins/pubsubhubbub/pubsubhubbub.php
index 9f0342a3..2878c050 100644
--- a/plugins/pubsubhubbub/pubsubhubbub.php
+++ b/plugins/pubsubhubbub/pubsubhubbub.php
@@ -11,6 +11,9 @@
11 11
12use pubsubhubbub\publisher\Publisher; 12use pubsubhubbub\publisher\Publisher;
13use Shaarli\Config\ConfigManager; 13use Shaarli\Config\ConfigManager;
14use Shaarli\Feed\FeedBuilder;
15use Shaarli\Plugin\PluginManager;
16use Shaarli\Router;
14 17
15/** 18/**
16 * Plugin init function - set the hub to the default appspot one. 19 * Plugin init function - set the hub to the default appspot one.
diff --git a/plugins/qrcode/qrcode.html b/plugins/qrcode/qrcode.html
index dc214ed1..a21f7932 100644
--- a/plugins/qrcode/qrcode.html
+++ b/plugins/qrcode/qrcode.html
@@ -1,5 +1,5 @@
1<div class="linkqrcode"> 1<div class="linkqrcode">
2 <a href="http://qrfree.kaywa.com/?l=1&amp;s=8&amp;d=%s" onclick="showQrCode(this); return false;" class="qrcode" data-permalink="%s"> 2 <a href="#" onclick="showQrCode(this); return false;" class="qrcode" data-permalink="%s">
3 <img src="%s/qrcode/qrcode.png" class="linklist-plugin-icon" title="QR-Code" alt="QRCode"> 3 <img src="%s/qrcode/qrcode.png" class="linklist-plugin-icon" title="QR-Code" alt="QRCode">
4 </a> 4 </a>
5</div> 5</div>
diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php
index 4b59caa0..c1d237d5 100644
--- a/plugins/qrcode/qrcode.php
+++ b/plugins/qrcode/qrcode.php
@@ -5,6 +5,9 @@
5 * Display a QRCode icon in link list. 5 * Display a QRCode icon in link list.
6 */ 6 */
7 7
8use Shaarli\Plugin\PluginManager;
9use Shaarli\Router;
10
8/** 11/**
9 * Add qrcode icon to link_plugin when rendering linklist. 12 * Add qrcode icon to link_plugin when rendering linklist.
10 * 13 *
@@ -19,7 +22,6 @@ function hook_qrcode_render_linklist($data)
19 foreach ($data['links'] as &$value) { 22 foreach ($data['links'] as &$value) {
20 $qrcode = sprintf( 23 $qrcode = sprintf(
21 $qrcode_html, 24 $qrcode_html,
22 urlencode($value['url']),
23 $value['url'], 25 $value['url'],
24 PluginManager::$PLUGINS_PATH 26 PluginManager::$PLUGINS_PATH
25 ); 27 );
diff --git a/plugins/wallabag/WallabagInstance.php b/plugins/wallabag/WallabagInstance.php
index eb8ab618..f4a0a92b 100644
--- a/plugins/wallabag/WallabagInstance.php
+++ b/plugins/wallabag/WallabagInstance.php
@@ -1,4 +1,5 @@
1<?php 1<?php
2namespace Shaarli\Plugin\Wallabag;
2 3
3/** 4/**
4 * Class WallabagInstance. 5 * Class WallabagInstance.
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php
index a6476c71..bc35df08 100644
--- a/plugins/wallabag/wallabag.php
+++ b/plugins/wallabag/wallabag.php
@@ -1,11 +1,11 @@
1<?php 1<?php
2
3/** 2/**
4 * Plugin Wallabag. 3 * Wallabag plugin
5 */ 4 */
6 5
7require_once 'WallabagInstance.php';
8use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
7use Shaarli\Plugin\PluginManager;
8use Shaarli\Plugin\Wallabag\WallabagInstance;
9 9
10/** 10/**
11 * Init function, return an error if the server is not set. 11 * Init function, return an error if the server is not set.