diff options
author | Arthur <arthur@hoa.ro> | 2016-10-17 08:50:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-17 08:50:18 +0200 |
commit | 06eec9bf764662cd328627247a1f43e4abd3c5ad (patch) | |
tree | fd66a3e1cb4cd93aa80b6f04c43958623140a008 /plugins | |
parent | bb70e690598d270951148e003a4dc253b05868b4 (diff) | |
parent | 7fde6de1212323418401c15efba06026c704ca87 (diff) | |
download | Shaarli-06eec9bf764662cd328627247a1f43e4abd3c5ad.tar.gz Shaarli-06eec9bf764662cd328627247a1f43e4abd3c5ad.tar.zst Shaarli-06eec9bf764662cd328627247a1f43e4abd3c5ad.zip |
Merge pull request #659 from ArthurHoaro/plugin-errors
New init function for plugins, supports errors reporting
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/demo_plugin/demo_plugin.php | 17 | ||||
-rw-r--r-- | plugins/readityourself/readityourself.php | 19 | ||||
-rw-r--r-- | plugins/wallabag/wallabag.php | 19 |
3 files changed, 47 insertions, 8 deletions
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index 18834e53..7335c9d4 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php | |||
@@ -15,6 +15,23 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * Initialization function. | ||
19 | * It will be called when the plugin is loaded. | ||
20 | * This function can be used to return a list of initialization errors. | ||
21 | * | ||
22 | * @param $conf ConfigManager instance. | ||
23 | * | ||
24 | * @return array List of errors (optional). | ||
25 | */ | ||
26 | function demo_plugin_init($conf) | ||
27 | { | ||
28 | $conf->get('toto', 'nope'); | ||
29 | |||
30 | $errors[] = 'This a demo init error.'; | ||
31 | return $errors; | ||
32 | } | ||
33 | |||
34 | /** | ||
18 | * Hook render_header. | 35 | * Hook render_header. |
19 | * Executed on every page redering. | 36 | * Executed on every page redering. |
20 | * | 37 | * |
diff --git a/plugins/readityourself/readityourself.php b/plugins/readityourself/readityourself.php index 4bfcf501..961c5bda 100644 --- a/plugins/readityourself/readityourself.php +++ b/plugins/readityourself/readityourself.php | |||
@@ -8,10 +8,21 @@ | |||
8 | // it seems kinda dead. | 8 | // it seems kinda dead. |
9 | // Not tested. | 9 | // Not tested. |
10 | 10 | ||
11 | $riyUrl = $conf->get('plugins.READITYOUSELF_URL'); | 11 | /** |
12 | if (empty($riyUrl)) { | 12 | * Init function, return an error if the server is not set. |
13 | $GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '. | 13 | * |
14 | 'Please define the "READITYOUSELF_URL" setting in the plugin administration page.'; | 14 | * @param $conf ConfigManager instance. |
15 | * | ||
16 | * @return array Eventual error. | ||
17 | */ | ||
18 | function readityourself_init($conf) | ||
19 | { | ||
20 | $riyUrl = $conf->get('plugins.READITYOUSELF_URL'); | ||
21 | if (empty($riyUrl)) { | ||
22 | $error = 'Readityourself plugin error: '. | ||
23 | 'Please define the "READITYOUSELF_URL" setting in the plugin administration page.'; | ||
24 | return array($error); | ||
25 | } | ||
15 | } | 26 | } |
16 | 27 | ||
17 | /** | 28 | /** |
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index ec09c8a1..641e4cc2 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php | |||
@@ -6,10 +6,21 @@ | |||
6 | 6 | ||
7 | require_once 'WallabagInstance.php'; | 7 | require_once 'WallabagInstance.php'; |
8 | 8 | ||
9 | $wallabagUrl = $conf->get('plugins.WALLABAG_URL'); | 9 | /** |
10 | if (empty($wallabagUrl)) { | 10 | * Init function, return an error if the server is not set. |
11 | $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '. | 11 | * |
12 | 'Please define the "WALLABAG_URL" setting in the plugin administration page.'; | 12 | * @param $conf ConfigManager instance. |
13 | * | ||
14 | * @return array Eventual error. | ||
15 | */ | ||
16 | function wallabag_init($conf) | ||
17 | { | ||
18 | $wallabagUrl = $conf->get('plugins.WALLABAG_URL'); | ||
19 | if (empty($wallabagUrl)) { | ||
20 | $error = 'Wallabag plugin error: '. | ||
21 | 'Please define the "WALLABAG_URL" setting in the plugin administration page.'; | ||
22 | return array($error); | ||
23 | } | ||
13 | } | 24 | } |
14 | 25 | ||
15 | /** | 26 | /** |