get('plugins.ExternalThumbshot_URL'))) {
$error = 'myShaarli plugin error: ' .
'Please define the "ExternalThumbshot_URL" setting in the plugin administration page.';
$conf->set('thumbnails.mode', 'none');
return array($error);
}
if (!in_array($conf->get('resource.theme'), ['myShaarli', 'myShaarli_Columns'])) {
$error = 'myShaarli plugin: ' .
'This plugin need modification of template. Use myShaarli theme for test.';
$conf->set('thumbnails.mode', 'none');
return array($error);
}
$conf->set('thumbnails.mode', 'full');
}
/**
* Hook render_header.
* Executed on every page render.
*
* Template placeholders:
* - buttons_toolbar
* - fields_toolbar
*
* @param array $data data passed to plugin
*
* @return array altered $data.
*/
function hook_myShaarli_render_header($data) {
$conf = new ConfigManager();
if ($conf->get('plugins.WebSite_URL')) {
$button = [
'attr' => [
'href' => $conf->get('plugins.WebSite_URL'),
],
'html' => 'Site',
];
$data['buttons_toolbar'][] = $button;
}
return $data;
}
/**
* Add externalThumbshot icon to link_plugin when rendering linklist.
*
* @param mixed $data - linklist data.
*
* @return mixed - linklist data with readityourself plugin.
*/
function hook_myShaarli_render_linklist($data, $conf) {
$action = array(
'attr' => array(
'href' => '?searchtags=note',
'title' => 'Note',
),
'html' => ' ',
);
if (isset($_GET['searchtags']) && $_GET['searchtags'] === 'note') {
$action['on'] = true;
} else {
$action['off'] = true;
}
$data['action_plugin'][] = $action;
$thumUrl = $conf->get('plugins.ExternalThumbshot_URL');
if (!empty($conf->get('plugins.ExternalThumbshot_KEY'))) {
$key = $conf->get('plugins.ExternalThumbshot_KEY');
}
if (!isset($thumUrl)) {
return $data;
}
foreach ($data['links'] as &$value) {
if (!empty($key)) {
$hmac = 'type=thumb&hmac=' . hash_hmac('sha1', $value['url'], $key) . '&url=';
} else {
$hmac = null;
}
$value['thumbnail'] = $thumUrl . $hmac . urlencode($value['url']);
if (empty($value['favicon'])) {
if (!empty($key)) {
$hmac = 'type=fav&hmac=' . hash_hmac('sha1', $value['url'], $key) . '&url=';
} else {
$hmac = null;
}
$value['favicon'] = $thumUrl . $hmac . urlencode($value['url']);
} else {
$value['favicon'] = $thumb['src'];
}
}
return $data;
}
function hook_myShaarli_render_picwall($data, $conf) {
$thumUrl = $conf->get('plugins.ExternalThumbshot_URL');
if (!empty($conf->get('plugins.ExternalThumbshot_KEY'))) {
$key = $conf->get('plugins.ExternalThumbshot_KEY');
}
if (!isset($thumUrl)) {
return $data;
}
foreach ($data['linksToDisplay'] as &$value) {
if (!empty($key)) {
$hmac = 'type=thumb&hmac=' . hash_hmac('sha1', $value['url'], $key) . '&url=';
} else {
$hmac = null;
}
$value['thumbnail'] = $thumUrl . $hmac . urlencode($value['url']);
}
return $data;
}
/**
* Add externalThumbshot icon to link_plugin when rendering linklist.
*
* @param mixed $data - linklist data.
*
* @return mixed - linklist data with readityourself plugin.
*/
function hook_myShaarli_render_daily($data, $conf) {
$thumUrl = $conf->get('plugins.ExternalThumbshot_URL');
if (!empty($conf->get('plugins.ExternalThumbshot_KEY'))) {
$key = $conf->get('plugins.ExternalThumbshot_KEY');
}
if (!isset($thumUrl)) {
return $data;
}
foreach ($data['linksToDisplay'] as &$value) {
//$thumb = computeThumbnail($conf, $value['url']);
if (empty($thumb)) {
if (!empty($key)) {
$hmac = 'type=thumb&hmac=' . hash_hmac('sha1', $value['url'], $key) . '&url=';
} else {
$hmac = null;
}
$value['thumbnail'] = $thumUrl . $hmac . urlencode($value['url']);
} else {
$value['thumbnail'] = $thumb['src'];
}
}
return $data;
}
/**
* Hook render_footer.
*/
function hook_myShaarli_render_footer($data) {
$data['text'][] = '
Theme and plugin MyShaarli by Knah Tsaeb';
$conf = new ConfigManager();
if ($conf->get('plugins.ContactPage_URL')) {
$data['text'][] = ' · /contact';
}
$data['js_files'][] = PluginManager::$PLUGINS_PATH . '/myShaarli/myShaarli.js';
return $data;
}
/**
* Hook render_editlink.
*
* Template placeholders:
* - field_plugin: add link fields after tags.
*
* @param array $data data passed to plugin
*
* @return array altered $data.
*/
function hook_myShaarli_render_editlink($data) {
if ((int) $data['link_is_new'] === 1 && $data['link']['url'][0] === '?' && strlen($data['link']['url']) === 7) {
$data['link']['tags'] = 'note ';
}
return $data;
}
/**
* Améliore la sortie print
* @author Tatane http://www.tatane.info/index.php/print_rn
* @author http://www.blog.cactuscrew.com/77-print_rn.html
* @param $data (array) tableau ou variable à examiner
* @param $name (string) nom a afficher
* @return false affiche les clef valeur du tableau $data
* @example n_print($array, 'Tableau de valeur');
*/
function n_print($data, $name = '') {
$aBackTrace = debug_backtrace();
echo '