'Please define the "WALLABAG_URL" setting in the plugin administration page.');
return array($error);
}
+ $conf->setEmpty('plugins.WALLABAG_URL', '2');
}
/**
function hook_wallabag_render_linklist($data, $conf)
{
$wallabagUrl = $conf->get('plugins.WALLABAG_URL');
- if (empty($wallabagUrl)) {
+ if (empty($wallabagUrl) || !$data['_LOGGEDIN_']) {
return $data;
}
$wallabag = sprintf(
$wallabagHtml,
$wallabagInstance->getWallabagUrl(),
- urlencode($value['url']),
+ urlencode(unescape($value['url'])),
$path,
$linkTitle
);
$conf = new ConfigManager('');
$conf->set('plugins.WALLABAG_URL', 'value');
$str = 'http://randomstr.com/test';
- $data = array(
+ $data = [
'title' => $str,
- 'links' => array(
- array(
+ 'links' => [
+ [
'url' => $str,
- )
- )
- );
+ ]
+ ],
+ '_LOGGEDIN_' => true,
+ ];
$data = hook_wallabag_render_linklist($data, $conf);
$link = $data['links'][0];
$this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str)));
$this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
}
+
+ /**
+ * Test render_linklist hook while logged out: no change.
+ */
+ public function testWallabagLinklistLoggedOut(): void
+ {
+ $conf = new ConfigManager('');
+ $str = 'http://randomstr.com/test';
+ $data = [
+ 'title' => $str,
+ 'links' => [
+ [
+ 'url' => $str,
+ ]
+ ],
+ '_LOGGEDIN_' => false,
+ ];
+
+ $result = hook_wallabag_render_linklist($data, $conf);
+
+ static::assertSame($data, $result);
+ }
}