aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--plugins/readityourself/readityourself.php15
-rw-r--r--plugins/wallabag/wallabag.php19
-rw-r--r--tests/plugins/PluginReadityourselfTest.php6
-rw-r--r--tests/plugins/PluginWallabagTest.php5
4 files changed, 22 insertions, 23 deletions
diff --git a/plugins/readityourself/readityourself.php b/plugins/readityourself/readityourself.php
index c8df4c4f..9ca73e01 100644
--- a/plugins/readityourself/readityourself.php
+++ b/plugins/readityourself/readityourself.php
@@ -8,12 +8,9 @@
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$conf = ConfigManager::getInstance();
12if (is_file(PluginManager::$PLUGINS_PATH . '/readityourself/config.php')) { 12$riyUrl = $conf->get('plugins.READITYOUSELF_URL');
13 include PluginManager::$PLUGINS_PATH . '/readityourself/config.php'; 13if (empty($riyUrl)) {
14}
15
16if (empty($GLOBALS['plugins']['READITYOUSELF_URL'])) {
17 $GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '. 14 $GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '.
18 'Please define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" '. 15 'Please define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" '.
19 'in "plugins/readityourself/config.php" or in your Shaarli config.php file.'; 16 'in "plugins/readityourself/config.php" or in your Shaarli config.php file.';
@@ -28,14 +25,16 @@ if (empty($GLOBALS['plugins']['READITYOUSELF_URL'])) {
28 */ 25 */
29function hook_readityourself_render_linklist($data) 26function hook_readityourself_render_linklist($data)
30{ 27{
31 if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) { 28 $conf = ConfigManager::getInstance();
29 $riyUrl = $conf->get('plugins.READITYOUSELF_URL');
30 if (empty($riyUrl)) {
32 return $data; 31 return $data;
33 } 32 }
34 33
35 $readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html'); 34 $readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html');
36 35
37 foreach ($data['links'] as &$value) { 36 foreach ($data['links'] as &$value) {
38 $readityourself = sprintf($readityourself_html, $GLOBALS['plugins']['READITYOUSELF_URL'], $value['url'], PluginManager::$PLUGINS_PATH); 37 $readityourself = sprintf($readityourself_html, $riyUrl, $value['url'], PluginManager::$PLUGINS_PATH);
39 $value['link_plugin'][] = $readityourself; 38 $value['link_plugin'][] = $readityourself;
40 } 39 }
41 40
diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php
index 0d6fc66d..4726d936 100644
--- a/plugins/wallabag/wallabag.php
+++ b/plugins/wallabag/wallabag.php
@@ -6,12 +6,9 @@
6 6
7require_once 'WallabagInstance.php'; 7require_once 'WallabagInstance.php';
8 8
9// don't raise unnecessary warnings 9$conf = ConfigManager::getInstance();
10if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) { 10$wallabagUrl = $conf->get('plugins.WALLABAG_URL');
11 include PluginManager::$PLUGINS_PATH . '/wallabag/config.php'; 11if (empty($wallabagUrl)) {
12}
13
14if (empty($GLOBALS['plugins']['WALLABAG_URL'])) {
15 $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '. 12 $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '.
16 'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '. 13 'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '.
17 'in "plugins/wallabag/config.php" or in your Shaarli config.php file.'; 14 'in "plugins/wallabag/config.php" or in your Shaarli config.php file.';
@@ -26,14 +23,14 @@ if (empty($GLOBALS['plugins']['WALLABAG_URL'])) {
26 */ 23 */
27function hook_wallabag_render_linklist($data) 24function hook_wallabag_render_linklist($data)
28{ 25{
29 if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) { 26 $conf = ConfigManager::getInstance();
27 $wallabagUrl = $conf->get('plugins.WALLABAG_URL');
28 if (empty($wallabagUrl)) {
30 return $data; 29 return $data;
31 } 30 }
32 31
33 $version = isset($GLOBALS['plugins']['WALLABAG_VERSION']) 32 $version = $conf->get('plugins.WALLABAG_VERSION');
34 ? $GLOBALS['plugins']['WALLABAG_VERSION'] 33 $wallabagInstance = new WallabagInstance($wallabagUrl, $version);
35 : '';
36 $wallabagInstance = new WallabagInstance($GLOBALS['plugins']['WALLABAG_URL'], $version);
37 34
38 $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); 35 $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
39 36
diff --git a/tests/plugins/PluginReadityourselfTest.php b/tests/plugins/PluginReadityourselfTest.php
index 8bf17bf1..bc5da042 100644
--- a/tests/plugins/PluginReadityourselfTest.php
+++ b/tests/plugins/PluginReadityourselfTest.php
@@ -25,7 +25,8 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
25 */ 25 */
26 function testReadityourselfLinklist() 26 function testReadityourselfLinklist()
27 { 27 {
28 $GLOBALS['plugins']['READITYOUSELF_URL'] = 'value'; 28 $conf = ConfigManager::getInstance();
29 $conf->set('plugins.READITYOUSELF_URL', 'value');
29 $str = 'http://randomstr.com/test'; 30 $str = 'http://randomstr.com/test';
30 $data = array( 31 $data = array(
31 'title' => $str, 32 'title' => $str,
@@ -52,7 +53,8 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
52 */ 53 */
53 function testReadityourselfLinklistWithoutConfig() 54 function testReadityourselfLinklistWithoutConfig()
54 { 55 {
55 unset($GLOBALS['plugins']['READITYOUSELF_URL']); 56 $conf = ConfigManager::getInstance();
57 $conf->set('plugins.READITYOUSELF_URL', null);
56 $str = 'http://randomstr.com/test'; 58 $str = 'http://randomstr.com/test';
57 $data = array( 59 $data = array(
58 'title' => $str, 60 'title' => $str,
diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php
index 5d3a60e0..e6f8a8b6 100644
--- a/tests/plugins/PluginWallabagTest.php
+++ b/tests/plugins/PluginWallabagTest.php
@@ -25,7 +25,8 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
25 */ 25 */
26 function testWallabagLinklist() 26 function testWallabagLinklist()
27 { 27 {
28 $GLOBALS['plugins']['WALLABAG_URL'] = 'value'; 28 $conf = ConfigManager::getInstance();
29 $conf->set('plugins.WALLABAG_URL', 'value');
29 $str = 'http://randomstr.com/test'; 30 $str = 'http://randomstr.com/test';
30 $data = array( 31 $data = array(
31 'title' => $str, 32 'title' => $str,
@@ -45,7 +46,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
45 // plugin data 46 // plugin data
46 $this->assertEquals(1, count($link['link_plugin'])); 47 $this->assertEquals(1, count($link['link_plugin']));
47 $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str))); 48 $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
48 $this->assertNotFalse(strpos($link['link_plugin'][0], $GLOBALS['plugins']['WALLABAG_URL'])); 49 $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
49 } 50 }
50} 51}
51 52