X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=plugins%2Fwallabag%2Fwallabag.php;h=f2003cb9953be148dde47e822de31f7af7c8dc7a;hb=53054b2bf6a919fd4ff9b44b6ad1986f21f488b6;hp=ec09c8a14d03dc89e2865efb794756d5ee199102;hpb=0c4c7ae818336d5b0f94562e551ca1a3f34d3435;p=github%2Fshaarli%2FShaarli.git diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index ec09c8a1..f2003cb9 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php @@ -1,15 +1,29 @@ get('plugins.WALLABAG_URL'); -if (empty($wallabagUrl)) { - $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '. - 'Please define the "WALLABAG_URL" setting in the plugin administration page.'; +/** + * Init function, return an error if the server is not set. + * + * @param $conf ConfigManager instance. + * + * @return array Eventual error. + */ +function wallabag_init($conf) +{ + $wallabagUrl = $conf->get('plugins.WALLABAG_URL'); + if (empty($wallabagUrl)) { + $error = t('Wallabag plugin error: ' . + 'Please define the "WALLABAG_URL" setting in the plugin administration page.'); + return [$error]; + } + $conf->setEmpty('plugins.WALLABAG_URL', '2'); } /** @@ -23,7 +37,7 @@ if (empty($wallabagUrl)) { function hook_wallabag_render_linklist($data, $conf) { $wallabagUrl = $conf->get('plugins.WALLABAG_URL'); - if (empty($wallabagUrl)) { + if (empty($wallabagUrl) || !$data['_LOGGEDIN_']) { return $data; } @@ -32,12 +46,16 @@ function hook_wallabag_render_linklist($data, $conf) $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); + $linkTitle = t('Save to wallabag'); + $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH; + foreach ($data['links'] as &$value) { $wallabag = sprintf( $wallabagHtml, $wallabagInstance->getWallabagUrl(), - urlencode($value['url']), - PluginManager::$PLUGINS_PATH + urlencode(unescape($value['url'])), + $path, + $linkTitle ); $value['link_plugin'][] = $wallabag; } @@ -45,3 +63,13 @@ function hook_wallabag_render_linklist($data, $conf) return $data; } +/** + * This function is never called, but contains translation calls for GNU gettext extraction. + */ +function wallabag_dummy_translation() +{ + // meta + t('For each link, add a QRCode icon.'); + t('Wallabag API URL'); + t('Wallabag API version (1 or 2)'); +}