archiveorg.php 954 B

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