]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - plugins/wallabag/wallabag.php
Improve SessionManager constructor and tests
[github/shaarli/Shaarli.git] / plugins / wallabag / wallabag.php
CommitLineData
263d1f64
A
1<?php
2
1696f6aa
A
3/**
4 * Plugin Wallabag.
5 */
6
938d9cce 7require_once 'WallabagInstance.php';
12266213 8use Shaarli\Config\ConfigManager;
938d9cce 9
7fde6de1
A
10/**
11 * Init function, return an error if the server is not set.
12 *
13 * @param $conf ConfigManager instance.
14 *
15 * @return array Eventual error.
16 */
17function wallabag_init($conf)
18{
19 $wallabagUrl = $conf->get('plugins.WALLABAG_URL');
20 if (empty($wallabagUrl)) {
12266213
A
21 $error = t('Wallabag plugin error: '.
22 'Please define the "WALLABAG_URL" setting in the plugin administration page.');
7fde6de1
A
23 return array($error);
24 }
263d1f64
A
25}
26
27/**
28 * Add wallabag icon to link_plugin when rendering linklist.
29 *
51def0d8
A
30 * @param mixed $data Linklist data.
31 * @param ConfigManager $conf Configuration Manager instance.
1696f6aa 32 *
263d1f64
A
33 * @return mixed - linklist data with wallabag plugin.
34 */
51def0d8 35function hook_wallabag_render_linklist($data, $conf)
1696f6aa 36{
eeea1c3d
A
37 $wallabagUrl = $conf->get('plugins.WALLABAG_URL');
38 if (empty($wallabagUrl)) {
1696f6aa
A
39 return $data;
40 }
41
eeea1c3d
A
42 $version = $conf->get('plugins.WALLABAG_VERSION');
43 $wallabagInstance = new WallabagInstance($wallabagUrl, $version);
938d9cce
A
44
45 $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
263d1f64 46
12266213 47 $linkTitle = t('Save to wallabag');
263d1f64 48 foreach ($data['links'] as &$value) {
938d9cce
A
49 $wallabag = sprintf(
50 $wallabagHtml,
51 $wallabagInstance->getWallabagUrl(),
52 urlencode($value['url']),
12266213
A
53 PluginManager::$PLUGINS_PATH,
54 $linkTitle
938d9cce 55 );
263d1f64
A
56 $value['link_plugin'][] = $wallabag;
57 }
58
59 return $data;
60}
938d9cce 61
12266213
A
62/**
63 * This function is never called, but contains translation calls for GNU gettext extraction.
64 */
65function wallabag_dummy_translation()
66{
67 // meta
68 t('For each link, add a QRCode icon.');
69 t('Wallabag API URL');
70 t('Wallabag API version (1 or 2)');
71}
72