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');
|
2020-07-26 14:43:10 +02:00
|
|
|
$path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
|
2015-10-15 12:47:04 +02:00
|
|
|
|
|
|
|
foreach ($data['links'] as &$value) {
|
2020-09-22 12:44:08 +02:00
|
|
|
$isNote = startsWith($value['real_url'], '/shaare/');
|
|
|
|
if ($value['private'] && $isNote) {
|
2016-10-11 17:37:42 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-09-22 12:44:08 +02:00
|
|
|
$url = $isNote ? rtrim(index_url($_SERVER), '/') . $value['real_url'] : $value['real_url'];
|
|
|
|
$archive = sprintf($archive_html, $url, $path, 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.');
|
|
|
|
}
|