]> git.mxchange.org Git - friendica.git/blobdiff - mod/parse_url.php
Merge pull request #2261 from tobiasd/20160118-admin
[friendica.git] / mod / parse_url.php
index 71d767675f8c51a1b3cba44b3edae4e2bd0c7bf8..28869b4c128d7ecd3d1f5b8436297b8b11aad5c5 100644 (file)
@@ -1,16 +1,20 @@
 <?php
-/* To-Do
-https://developers.google.com/+/plugins/snippet/
-
-<meta itemprop="name" content="Toller Titel">
-<meta itemprop="description" content="Eine tolle Beschreibung">
-<meta itemprop="image" content="http://maple.libertreeproject.org/images/tree-icon.png">
-
-<body itemscope itemtype="http://schema.org/Product">
-  <h1 itemprop="name">Shiny Trinket</h1>
-  <img itemprop="image" src="{image-url}" />
-  <p itemprop="description">Shiny trinkets are shiny.</p>
-</body>
+/** 
+ * @file mod/parse_url.php
+ * 
+ * @todo https://developers.google.com/+/plugins/snippet/
+ * 
+ * @verbatim
+ * <meta itemprop="name" content="Toller Titel">
+ * <meta itemprop="description" content="Eine tolle Beschreibung">
+ * <meta itemprop="image" content="http://maple.libertreeproject.org/images/tree-icon.png">
+ * 
+ * <body itemscope itemtype="http://schema.org/Product">
+ *   <h1 itemprop="name">Shiny Trinket</h1>
+ *   <img itemprop="image" src="{image-url}" />
+ *   <p itemprop="description">Shiny trinkets are shiny.</p>
+ * </body>
+ * @endverbatim
 */
 
 if(!function_exists('deletenode')) {
@@ -50,6 +54,21 @@ function completeurl($url, $scheme) {
        return($complete);
 }
 
+function parseurl_getsiteinfo_cached($url, $no_guessing = false, $do_oembed = true) {
+
+       $data = Cache::get("parse_url:".$no_guessing.":".$do_oembed.":".$url);
+       if (!is_null($data)) {
+               $data = unserialize($data);
+               return $data;
+       }
+
+       $data = parseurl_getsiteinfo($url, $no_guessing, $do_oembed);
+
+       Cache::set("parse_url:".$no_guessing.":".$do_oembed.":".$url,serialize($data), CACHE_DAY);
+
+       return $data;
+}
+
 function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1) {
        require_once("include/network.php");
 
@@ -265,7 +284,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
        if (isset($keywords)) {
                $siteinfo["keywords"] = array();
                foreach ($keywords as $keyword)
-                       $siteinfo["keywords"][] = trim($keyword);
+                       if (!in_array(trim($keyword), $siteinfo["keywords"]))
+                               $siteinfo["keywords"][] = trim($keyword);
        }
 
        //$list = $xpath->query("head/meta[@property]");