PLUGIN readityourself

Add an icon for each link (linklist) for ReadItYourself
This commit is contained in:
ArthurHoaro 2015-07-15 12:04:22 +02:00
parent a52e843593
commit 75b69987b3
4 changed files with 39 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

View File

@ -0,0 +1,3 @@
<?php
$GLOBALS['plugins']['READITYOUSELF_URL'] = 'http://someurl.com';

View File

@ -0,0 +1 @@
<span><a href="%s?url=%s"><img width="13" height="13" src="%s/readityourself/book-open.png" title="Read with Readityourself" /></a></span>

View File

@ -0,0 +1,35 @@
<?php
// If we're talking about https://github.com/memiks/readityourself
// it seems kinda dead.
// Not tested.
// don't raise unnecessary warnings
if (is_file(PluginManager::$PLUGINS_PATH . '/readityourself/config.php')) {
include PluginManager::$PLUGINS_PATH . '/readityourself/config.php';
}
if (!isset($GLOBALS['plugins']['READITYOUSELF_URL'])) {
header('Content-Type: text/plain; charset=utf-8');
echo 'ReadItYourself plugin error: '. PHP_EOL;
echo ' Please copy "plugins/readityourself/config.php.dist" to config.php and configure your readityourself URL.'. PHP_EOL;
echo ' You can also define "$GLOBALS[\'plugins\'][\'READITYOUSELF_URL\']" in your global Shaarli config.php file.';
exit;
}
/**
* Add readityourself icon to link_plugin when rendering linklist.
*
* @param $data - linklist data.
* @return mixed - linklist data with readityourself plugin.
*/
function hook_readityourself_render_linklist($data) {
$readityourself_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/readityourself/readityourself.html');
foreach ($data['links'] as &$value) {
$readityourself = sprintf($readityourself_html, $GLOBALS['plugins']['READITYOUSELF_URL'], $value['url'], PluginManager::$PLUGINS_PATH);
$value['link_plugin'][] = $readityourself;
}
return $data;
}