From 938d9cce77ed5098dd69643795cb4014f3688b35 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 22 Dec 2015 10:20:27 +0100 Subject: Wallabag plugin improvement * Fixes a bug where URL weren't properly encoded. * Adds Wallabag V2 support. * Adds a URL function to handle trailing slash. * UT. * README updated. --- plugins/wallabag/wallabag.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'plugins/wallabag/wallabag.php') diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index 37969c97..e3c399a9 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php @@ -4,6 +4,8 @@ * Plugin Wallabag. */ +require_once 'WallabagInstance.php'; + // don't raise unnecessary warnings if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) { include PluginManager::$PLUGINS_PATH . '/wallabag/config.php'; @@ -28,12 +30,23 @@ function hook_wallabag_render_linklist($data) return $data; } - $wallabag_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); + $version = isset($GLOBALS['plugins']['WALLABAG_VERSION']) + ? $GLOBALS['plugins']['WALLABAG_VERSION'] + : ''; + $wallabagInstance = new WallabagInstance($GLOBALS['plugins']['WALLABAG_URL'], $version); + + $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); foreach ($data['links'] as &$value) { - $wallabag = sprintf($wallabag_html, $GLOBALS['plugins']['WALLABAG_URL'], $value['url'], PluginManager::$PLUGINS_PATH); + $wallabag = sprintf( + $wallabagHtml, + $wallabagInstance->getWallabagUrl(), + urlencode($value['url']), + PluginManager::$PLUGINS_PATH + ); $value['link_plugin'][] = $wallabag; } return $data; } + -- cgit v1.2.3