]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - plugins/archiveorg/archiveorg.php
Merge pull request #1248 from virtualtam/refactor/namespacing
[github/shaarli/Shaarli.git] / plugins / archiveorg / archiveorg.php
1 <?php
2 /**
3 * Plugin Archive.org.
4 *
5 * Add an icon in the link list for archive.org.
6 */
7
8 use Shaarli\Plugin\PluginManager;
9
10 /**
11 * Add archive.org icon to link_plugin when rendering linklist.
12 *
13 * @param mixed $data - linklist data.
14 *
15 * @return mixed - linklist data with archive.org plugin.
16 */
17 function hook_archiveorg_render_linklist($data)
18 {
19 $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html');
20
21 foreach ($data['links'] as &$value) {
22 if ($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) {
23 continue;
24 }
25 $archive = sprintf($archive_html, $value['url'], t('View on archive.org'));
26 $value['link_plugin'][] = $archive;
27 }
28
29 return $data;
30 }
31
32 /**
33 * This function is never called, but contains translation calls for GNU gettext extraction.
34 */
35 function archiveorg_dummy_translation()
36 {
37 // meta
38 t('For each link, add an Archive.org icon.');
39 }