X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=plugins%2Fwallabag%2Fwallabag.php;h=a6476c71c893b0b9f7b2fadef9e8610a86b807be;hb=a0ab3c3f68ed3bca7d218e6e5847820b82b086ca;hp=4726d9369fab4ef8dd9ef0bada8e323a626d3aac;hpb=eeea1c3daa87f133c57c96fa17ed26b02c392636;p=github%2Fshaarli%2FShaarli.git diff --git a/plugins/wallabag/wallabag.php b/plugins/wallabag/wallabag.php index 4726d936..a6476c71 100644 --- a/plugins/wallabag/wallabag.php +++ b/plugins/wallabag/wallabag.php @@ -5,25 +5,35 @@ */ require_once 'WallabagInstance.php'; +use Shaarli\Config\ConfigManager; -$conf = ConfigManager::getInstance(); -$wallabagUrl = $conf->get('plugins.WALLABAG_URL'); -if (empty($wallabagUrl)) { - $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '. - 'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '. - 'in "plugins/wallabag/config.php" or in your Shaarli config.php file.'; +/** + * 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 array($error); + } } /** * Add wallabag icon to link_plugin when rendering linklist. * - * @param mixed $data - linklist data. + * @param mixed $data Linklist data. + * @param ConfigManager $conf Configuration Manager instance. * * @return mixed - linklist data with wallabag plugin. */ -function hook_wallabag_render_linklist($data) +function hook_wallabag_render_linklist($data, $conf) { - $conf = ConfigManager::getInstance(); $wallabagUrl = $conf->get('plugins.WALLABAG_URL'); if (empty($wallabagUrl)) { return $data; @@ -34,12 +44,14 @@ function hook_wallabag_render_linklist($data) $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html'); + $linkTitle = t('Save to wallabag'); foreach ($data['links'] as &$value) { $wallabag = sprintf( $wallabagHtml, $wallabagInstance->getWallabagUrl(), urlencode($value['url']), - PluginManager::$PLUGINS_PATH + PluginManager::$PLUGINS_PATH, + $linkTitle ); $value['link_plugin'][] = $wallabag; } @@ -47,3 +59,13 @@ function hook_wallabag_render_linklist($data) 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)'); +}