diff options
author | Arthur <arthur@hoa.ro> | 2016-07-09 07:19:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-09 07:19:48 +0200 |
commit | 649af5b501d2a90448242f53764ff693e9854039 (patch) | |
tree | 23cde80a7ee2949e552c48939ae22fa462cfa0fc /plugins/readityourself | |
parent | a9cfa38df92bd2e1e2c00a67b6ac1516a2116ade (diff) | |
parent | 5ff23f02b80ec6ddee28dee869171ee8e3656b7c (diff) | |
download | Shaarli-649af5b501d2a90448242f53764ff693e9854039.tar.gz Shaarli-649af5b501d2a90448242f53764ff693e9854039.tar.zst Shaarli-649af5b501d2a90448242f53764ff693e9854039.zip |
Merge pull request #570 from ArthurHoaro/config-manager
Introduce a configuration manager
Diffstat (limited to 'plugins/readityourself')
-rw-r--r-- | plugins/readityourself/config.php.dist | 3 | ||||
-rw-r--r-- | plugins/readityourself/readityourself.php | 21 |
2 files changed, 9 insertions, 15 deletions
diff --git a/plugins/readityourself/config.php.dist b/plugins/readityourself/config.php.dist deleted file mode 100644 index d6b5cb85..00000000 --- a/plugins/readityourself/config.php.dist +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | $GLOBALS['plugins']['READITYOUSELF_URL'] = 'http://someurl.com'; \ No newline at end of file | ||
diff --git a/plugins/readityourself/readityourself.php b/plugins/readityourself/readityourself.php index c8df4c4f..4bfcf501 100644 --- a/plugins/readityourself/readityourself.php +++ b/plugins/readityourself/readityourself.php | |||
@@ -8,34 +8,31 @@ | |||
8 | // it seems kinda dead. | 8 | // it seems kinda dead. |
9 | // Not tested. | 9 | // Not tested. |
10 | 10 | ||
11 | // don't raise unnecessary warnings | 11 | $riyUrl = $conf->get('plugins.READITYOUSELF_URL'); |
12 | if (is_file(PluginManager::$PLUGINS_PATH . '/readityourself/config.php')) { | 12 | if (empty($riyUrl)) { |
13 | include PluginManager::$PLUGINS_PATH . '/readityourself/config.php'; | ||
14 | } | ||
15 | |||
16 | if (empty($GLOBALS['plugins']['READITYOUSELF_URL'])) { | ||
17 | $GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '. | 13 | $GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '. |
18 | 'Please define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" '. | 14 | 'Please define the "READITYOUSELF_URL" setting in the plugin administration page.'; |
19 | 'in "plugins/readityourself/config.php" or in your Shaarli config.php file.'; | ||
20 | } | 15 | } |
21 | 16 | ||
22 | /** | 17 | /** |
23 | * Add readityourself icon to link_plugin when rendering linklist. | 18 | * Add readityourself icon to link_plugin when rendering linklist. |
24 | * | 19 | * |
25 | * @param mixed $data - linklist data. | 20 | * @param mixed $data Linklist data. |
21 | * @param ConfigManager $conf Configuration Manager instance. | ||
26 | * | 22 | * |
27 | * @return mixed - linklist data with readityourself plugin. | 23 | * @return mixed - linklist data with readityourself plugin. |
28 | */ | 24 | */ |
29 | function hook_readityourself_render_linklist($data) | 25 | function hook_readityourself_render_linklist($data, $conf) |
30 | { | 26 | { |
31 | if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) { | 27 | $riyUrl = $conf->get('plugins.READITYOUSELF_URL'); |
28 | if (empty($riyUrl)) { | ||
32 | return $data; | 29 | return $data; |
33 | } | 30 | } |
34 | 31 | ||
35 | $readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html'); | 32 | $readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html'); |
36 | 33 | ||
37 | foreach ($data['links'] as &$value) { | 34 | foreach ($data['links'] as &$value) { |
38 | $readityourself = sprintf($readityourself_html, $GLOBALS['plugins']['READITYOUSELF_URL'], $value['url'], PluginManager::$PLUGINS_PATH); | 35 | $readityourself = sprintf($readityourself_html, $riyUrl, $value['url'], PluginManager::$PLUGINS_PATH); |
39 | $value['link_plugin'][] = $readityourself; | 36 | $value['link_plugin'][] = $readityourself; |
40 | } | 37 | } |
41 | 38 | ||