aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/wallabag/wallabag.php
blob: 024a3d2bd1f5adee9fe6d8d7dc7fba23e58d05cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

/**
 * Plugin Wallabag.
 */

// don't raise unnecessary warnings
if (is_file(PluginManager::$PLUGINS_PATH . '/wallabag/config.php')) {
    include PluginManager::$PLUGINS_PATH . '/wallabag/config.php';
}

if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) {
    $GLOBALS['plugins']['errors'][] = 'Wallabag plugin error: '.
        'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '.
        'in "plugins/wallabag/config.php" or in your Shaarli config.php file.';
}

/**
 * Add wallabag icon to link_plugin when rendering linklist.
 *
 * @param mixed $data - linklist data.
 *
 * @return mixed - linklist data with wallabag plugin.
 */
function hook_wallabag_render_linklist($data)
{
    if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) {
        return $data;
    }

    $wallabag_html = 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);
        $value['link_plugin'][] = $wallabag;
    }

    return $data;
}