2015-10-15 12:47:04 +02:00
|
|
|
<?php
|
2015-11-07 16:37:23 +01:00
|
|
|
/**
|
|
|
|
* Plugin Archive.org.
|
|
|
|
*
|
|
|
|
* Add an icon in the link list for archive.org.
|
|
|
|
*/
|
2015-10-15 12:47:04 +02:00
|
|
|
|
2018-12-04 00:26:50 +01:00
|
|
|
use Shaarli\Plugin\PluginManager;
|
|
|
|
|
2015-10-15 12:47:04 +02:00
|
|
|
/**
|
|
|
|
* Add archive.org icon to link_plugin when rendering linklist.
|
|
|
|
*
|
2015-11-07 16:37:23 +01:00
|
|
|
* @param mixed $data - linklist data.
|
|
|
|
*
|
2015-10-15 12:47:04 +02:00
|
|
|
* @return mixed - linklist data with archive.org plugin.
|
|
|
|
*/
|
2015-11-07 16:37:23 +01:00
|
|
|
function hook_archiveorg_render_linklist($data)
|
|
|
|
{
|
2015-10-15 12:47:04 +02:00
|
|
|
$archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html');
|
|
|
|
|
|
|
|
foreach ($data['links'] as &$value) {
|
2018-10-13 00:22:45 +02:00
|
|
|
if ($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) {
|
2016-10-11 17:37:42 +02:00
|
|
|
continue;
|
|
|
|
}
|
2017-05-09 18:12:15 +02:00
|
|
|
$archive = sprintf($archive_html, $value['url'], t('View on archive.org'));
|
2015-10-15 12:47:04 +02:00
|
|
|
$value['link_plugin'][] = $archive;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2017-05-09 18:12:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function is never called, but contains translation calls for GNU gettext extraction.
|
|
|
|
*/
|
|
|
|
function archiveorg_dummy_translation()
|
|
|
|
{
|
|
|
|
// meta
|
|
|
|
t('For each link, add an Archive.org icon.');
|
|
|
|
}
|