]> git.immae.eu Git - github/shaarli/Shaarli.git/blame_incremental - plugins/wallabag/wallabag.php
Merge pull request #525 from ArthurHoaro/plugins/feeds-markdown2
[github/shaarli/Shaarli.git] / plugins / wallabag / wallabag.php
... / ...
CommitLineData
1<?php
2
3/**
4 * Plugin Wallabag.
5 */
6
7require_once 'WallabagInstance.php';
8
9// don't raise unnecessary warnings
10if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) {
11 include PluginManager::$PLUGINS_PATH . '/wallabag/config.php';
12}
13
14if (empty($GLOBALS['plugins']['WALLABAG_URL'])) {
15 $GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '.
16 'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '.
17 'in "plugins/wallabag/config.php" or in your Shaarli config.php file.';
18}
19
20/**
21 * Add wallabag icon to link_plugin when rendering linklist.
22 *
23 * @param mixed $data - linklist data.
24 *
25 * @return mixed - linklist data with wallabag plugin.
26 */
27function hook_wallabag_render_linklist($data)
28{
29 if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) {
30 return $data;
31 }
32
33 $version = isset($GLOBALS['plugins']['WALLABAG_VERSION'])
34 ? $GLOBALS['plugins']['WALLABAG_VERSION']
35 : '';
36 $wallabagInstance = new WallabagInstance($GLOBALS['plugins']['WALLABAG_URL'], $version);
37
38 $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
39
40 foreach ($data['links'] as &$value) {
41 $wallabag = sprintf(
42 $wallabagHtml,
43 $wallabagInstance->getWallabagUrl(),
44 urlencode($value['url']),
45 PluginManager::$PLUGINS_PATH
46 );
47 $value['link_plugin'][] = $wallabag;
48 }
49
50 return $data;
51}
52