Use the configuration manager for wallabag and readityourself plugin
This commit is contained in:
parent
d93d51b213
commit
eeea1c3daa
4 changed files with 22 additions and 23 deletions
|
@ -8,12 +8,9 @@
|
||||||
// it seems kinda dead.
|
// it seems kinda dead.
|
||||||
// Not tested.
|
// Not tested.
|
||||||
|
|
||||||
// don't raise unnecessary warnings
|
$conf = ConfigManager::getInstance();
|
||||||
if (is_file(PluginManager::$PLUGINS_PATH . '/readityourself/config.php')) {
|
$riyUrl = $conf->get('plugins.READITYOUSELF_URL');
|
||||||
include PluginManager::$PLUGINS_PATH . '/readityourself/config.php';
|
if (empty($riyUrl)) {
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($GLOBALS['plugins']['READITYOUSELF_URL'])) {
|
|
||||||
$GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '.
|
$GLOBALS['plugin_errors'][] = 'Readityourself plugin error: '.
|
||||||
'Please define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" '.
|
'Please define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" '.
|
||||||
'in "plugins/readityourself/config.php" or in your Shaarli config.php file.';
|
'in "plugins/readityourself/config.php" or in your Shaarli config.php file.';
|
||||||
|
@ -28,14 +25,16 @@
|
||||||
*/
|
*/
|
||||||
function hook_readityourself_render_linklist($data)
|
function hook_readityourself_render_linklist($data)
|
||||||
{
|
{
|
||||||
if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) {
|
$conf = ConfigManager::getInstance();
|
||||||
|
$riyUrl = $conf->get('plugins.READITYOUSELF_URL');
|
||||||
|
if (empty($riyUrl)) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html');
|
$readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html');
|
||||||
|
|
||||||
foreach ($data['links'] as &$value) {
|
foreach ($data['links'] as &$value) {
|
||||||
$readityourself = sprintf($readityourself_html, $GLOBALS['plugins']['READITYOUSELF_URL'], $value['url'], PluginManager::$PLUGINS_PATH);
|
$readityourself = sprintf($readityourself_html, $riyUrl, $value['url'], PluginManager::$PLUGINS_PATH);
|
||||||
$value['link_plugin'][] = $readityourself;
|
$value['link_plugin'][] = $readityourself;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,9 @@
|
||||||
|
|
||||||
require_once 'WallabagInstance.php';
|
require_once 'WallabagInstance.php';
|
||||||
|
|
||||||
// don't raise unnecessary warnings
|
$conf = ConfigManager::getInstance();
|
||||||
if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) {
|
$wallabagUrl = $conf->get('plugins.WALLABAG_URL');
|
||||||
include PluginManager::$PLUGINS_PATH . '/wallabag/config.php';
|
if (empty($wallabagUrl)) {
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($GLOBALS['plugins']['WALLABAG_URL'])) {
|
|
||||||
$GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '.
|
$GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '.
|
||||||
'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '.
|
'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '.
|
||||||
'in "plugins/wallabag/config.php" or in your Shaarli config.php file.';
|
'in "plugins/wallabag/config.php" or in your Shaarli config.php file.';
|
||||||
|
@ -26,14 +23,14 @@
|
||||||
*/
|
*/
|
||||||
function hook_wallabag_render_linklist($data)
|
function hook_wallabag_render_linklist($data)
|
||||||
{
|
{
|
||||||
if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) {
|
$conf = ConfigManager::getInstance();
|
||||||
|
$wallabagUrl = $conf->get('plugins.WALLABAG_URL');
|
||||||
|
if (empty($wallabagUrl)) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$version = isset($GLOBALS['plugins']['WALLABAG_VERSION'])
|
$version = $conf->get('plugins.WALLABAG_VERSION');
|
||||||
? $GLOBALS['plugins']['WALLABAG_VERSION']
|
$wallabagInstance = new WallabagInstance($wallabagUrl, $version);
|
||||||
: '';
|
|
||||||
$wallabagInstance = new WallabagInstance($GLOBALS['plugins']['WALLABAG_URL'], $version);
|
|
||||||
|
|
||||||
$wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
|
$wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@ function setUp()
|
||||||
*/
|
*/
|
||||||
function testReadityourselfLinklist()
|
function testReadityourselfLinklist()
|
||||||
{
|
{
|
||||||
$GLOBALS['plugins']['READITYOUSELF_URL'] = 'value';
|
$conf = ConfigManager::getInstance();
|
||||||
|
$conf->set('plugins.READITYOUSELF_URL', 'value');
|
||||||
$str = 'http://randomstr.com/test';
|
$str = 'http://randomstr.com/test';
|
||||||
$data = array(
|
$data = array(
|
||||||
'title' => $str,
|
'title' => $str,
|
||||||
|
@ -52,7 +53,8 @@ function testReadityourselfLinklist()
|
||||||
*/
|
*/
|
||||||
function testReadityourselfLinklistWithoutConfig()
|
function testReadityourselfLinklistWithoutConfig()
|
||||||
{
|
{
|
||||||
unset($GLOBALS['plugins']['READITYOUSELF_URL']);
|
$conf = ConfigManager::getInstance();
|
||||||
|
$conf->set('plugins.READITYOUSELF_URL', null);
|
||||||
$str = 'http://randomstr.com/test';
|
$str = 'http://randomstr.com/test';
|
||||||
$data = array(
|
$data = array(
|
||||||
'title' => $str,
|
'title' => $str,
|
||||||
|
|
|
@ -25,7 +25,8 @@ function setUp()
|
||||||
*/
|
*/
|
||||||
function testWallabagLinklist()
|
function testWallabagLinklist()
|
||||||
{
|
{
|
||||||
$GLOBALS['plugins']['WALLABAG_URL'] = 'value';
|
$conf = ConfigManager::getInstance();
|
||||||
|
$conf->set('plugins.WALLABAG_URL', 'value');
|
||||||
$str = 'http://randomstr.com/test';
|
$str = 'http://randomstr.com/test';
|
||||||
$data = array(
|
$data = array(
|
||||||
'title' => $str,
|
'title' => $str,
|
||||||
|
@ -45,7 +46,7 @@ function testWallabagLinklist()
|
||||||
// plugin data
|
// plugin data
|
||||||
$this->assertEquals(1, count($link['link_plugin']));
|
$this->assertEquals(1, count($link['link_plugin']));
|
||||||
$this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
|
$this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
|
||||||
$this->assertNotFalse(strpos($link['link_plugin'][0], $GLOBALS['plugins']['WALLABAG_URL']));
|
$this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue