2015-07-15 12:05:36 +02:00
|
|
|
<?php
|
|
|
|
|
2015-11-08 12:00:06 +01:00
|
|
|
/**
|
|
|
|
* Plugin Wallabag.
|
|
|
|
*/
|
|
|
|
|
2015-12-22 10:20:27 +01:00
|
|
|
require_once 'WallabagInstance.php';
|
|
|
|
|
2015-07-15 12:05:36 +02:00
|
|
|
// 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'])) {
|
2015-11-22 14:45:09 +01:00
|
|
|
$GLOBALS['plugin_errors'][] = 'Wallabag plugin error: '.
|
2015-11-08 12:00:06 +01:00
|
|
|
'Please define "$GLOBALS[\'plugins\'][\'WALLABAG_URL\']" '.
|
|
|
|
'in "plugins/wallabag/config.php" or in your Shaarli config.php file.';
|
2015-07-15 12:05:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add wallabag icon to link_plugin when rendering linklist.
|
|
|
|
*
|
2015-11-08 12:00:06 +01:00
|
|
|
* @param mixed $data - linklist data.
|
|
|
|
*
|
2015-07-15 12:05:36 +02:00
|
|
|
* @return mixed - linklist data with wallabag plugin.
|
|
|
|
*/
|
2015-11-08 12:00:06 +01:00
|
|
|
function hook_wallabag_render_linklist($data)
|
|
|
|
{
|
|
|
|
if (!isset($GLOBALS['plugins']['WALLABAG_URL'])) {
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2015-12-22 10:20:27 +01:00
|
|
|
$version = isset($GLOBALS['plugins']['WALLABAG_VERSION'])
|
|
|
|
? $GLOBALS['plugins']['WALLABAG_VERSION']
|
|
|
|
: '';
|
|
|
|
$wallabagInstance = new WallabagInstance($GLOBALS['plugins']['WALLABAG_URL'], $version);
|
|
|
|
|
|
|
|
$wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
|
2015-07-15 12:05:36 +02:00
|
|
|
|
|
|
|
foreach ($data['links'] as &$value) {
|
2015-12-22 10:20:27 +01:00
|
|
|
$wallabag = sprintf(
|
|
|
|
$wallabagHtml,
|
|
|
|
$wallabagInstance->getWallabagUrl(),
|
|
|
|
urlencode($value['url']),
|
|
|
|
PluginManager::$PLUGINS_PATH
|
|
|
|
);
|
2015-07-15 12:05:36 +02:00
|
|
|
$value['link_plugin'][] = $wallabag;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2015-12-22 10:20:27 +01:00
|
|
|
|