]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | /** | |
4 | * Plugin Archive.org. | |
5 | * | |
6 | * Add an icon in the link list for archive.org. | |
7 | */ | |
8 | ||
9 | use Shaarli\Plugin\PluginManager; | |
10 | ||
11 | /** | |
12 | * Add archive.org icon to link_plugin when rendering linklist. | |
13 | * | |
14 | * @param mixed $data - linklist data. | |
15 | * | |
16 | * @return mixed - linklist data with archive.org plugin. | |
17 | */ | |
18 | function hook_archiveorg_render_linklist($data) | |
19 | { | |
20 | $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); | |
21 | $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH; | |
22 | ||
23 | foreach ($data['links'] as &$value) { | |
24 | $isNote = startsWith($value['real_url'], '/shaare/'); | |
25 | if ($value['private'] && $isNote) { | |
26 | continue; | |
27 | } | |
28 | $url = $isNote ? rtrim(index_url($_SERVER), '/') . $value['real_url'] : $value['real_url']; | |
29 | $archive = sprintf($archive_html, $url, $path, t('View on archive.org')); | |
30 | $value['link_plugin'][] = $archive; | |
31 | } | |
32 | ||
33 | return $data; | |
34 | } | |
35 | ||
36 | /** | |
37 | * This function is never called, but contains translation calls for GNU gettext extraction. | |
38 | */ | |
39 | function archiveorg_dummy_translation() | |
40 | { | |
41 | // meta | |
42 | t('For each link, add an Archive.org icon.'); | |
43 | } |