]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - plugins/archiveorg/archiveorg.php
Merge pull request #1234 from virtualtam/lint
[github/shaarli/Shaarli.git] / plugins / archiveorg / archiveorg.php
index 1db3e4cb1139d4e094504ee79fc2dcaf4586fdb7..5dcea5a647930b43d6226fc8033f9e51408db67c 100644 (file)
@@ -1,18 +1,37 @@
 <?php
+/**
+ * Plugin Archive.org.
+ *
+ * Add an icon in the link list for archive.org.
+ */
 
 /**
  * Add archive.org icon to link_plugin when rendering linklist.
  *
- * @param $data - linklist data.
+ * @param mixed $data - linklist data.
+ *
  * @return mixed - linklist data with archive.org plugin.
  */
-function hook_archiveorg_render_linklist($data) {
+function hook_archiveorg_render_linklist($data)
+{
     $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html');
 
     foreach ($data['links'] as &$value) {
-        $archive = sprintf($archive_html, $value['url']);
+        if ($value['private'] && preg_match('/^\?[a-zA-Z0-9-_@]{6}($|&|#)/', $value['real_url'])) {
+            continue;
+        }
+        $archive = sprintf($archive_html, $value['url'], t('View on archive.org'));
         $value['link_plugin'][] = $archive;
     }
 
     return $data;
 }
+
+/**
+ * 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.');
+}