aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/wallabag/wallabag.php
blob: db8151c9587260191a9c1cd1fe85fc959ed539cd (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
<?php

// 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'])) {
    header('Content-Type: text/plain; charset=utf-8');
    echo 'Wallabag plugin error: '. PHP_EOL;
    echo '  Please copy "plugins/wallabag/config.php.dist" to config.php and configure your Wallabag URL.'. PHP_EOL;
    echo '  You can also define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" in your global Shaarli config.php file.';
    exit;
}

/**
 * Add wallabag icon to link_plugin when rendering linklist.
 *
 * @param $data - linklist data.
 * @return mixed - linklist data with wallabag plugin.
 */
function hook_wallabag_render_linklist($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;
}