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