]> git.mxchange.org Git - friendica.git/commitdiff
Just some more code cleanup and documentation.
authorMichael Vogel <icarus@dabo.de>
Sat, 6 Feb 2016 20:44:10 +0000 (21:44 +0100)
committerMichael Vogel <icarus@dabo.de>
Sat, 6 Feb 2016 20:44:10 +0000 (21:44 +0100)
include/dfrn.php

index 043f02cc2f9dd0221a3d66e2658bf13171a2afd2..84660a0d18cb4f0b5753a3b0c6da07274d2ac6ba 100644 (file)
@@ -26,9 +26,9 @@ require_once("library/HTMLPurifier.auto.php");
  */
 class dfrn {
 
-       const DFRN_TOP_LEVEL = 0;
-       const DFRN_REPLY = 1;
-       const DFRN_REPLY_RC = 2;
+       const DFRN_TOP_LEVEL = 0;       // Top level posting
+       const DFRN_REPLY = 1;           // Regular reply that is stored locally
+       const DFRN_REPLY_RC = 2;        // Reply that will be relayed
 
        /**
         * @brief Generates the atom entries for delivery.php
@@ -1840,6 +1840,47 @@ class dfrn {
                return true;
        }
 
+       /**
+        * @brief Processes the link elements
+        *
+        * @param object $links link elements
+        * @param array $item the item record
+        */
+       private function parse_links($links, &$item) {
+               $rel = "";
+               $href = "";
+               $type = "";
+               $length = "0";
+               $title = "";
+               foreach ($links AS $link) {
+                       foreach($link->attributes AS $attributes) {
+                               if ($attributes->name == "href")
+                                       $href = $attributes->textContent;
+                               if ($attributes->name == "rel")
+                                       $rel = $attributes->textContent;
+                               if ($attributes->name == "type")
+                                       $type = $attributes->textContent;
+                               if ($attributes->name == "length")
+                                       $length = $attributes->textContent;
+                               if ($attributes->name == "title")
+                                       $title = $attributes->textContent;
+                       }
+                       if (($rel != "") AND ($href != ""))
+                               switch($rel) {
+                                       case "alternate":
+                                               $item["plink"] = $href;
+                                               break;
+                                       case "enclosure":
+                                               $enclosure = $href;
+                                               if(strlen($item["attach"]))
+                                                       $item["attach"] .= ",";
+
+                                               $item["attach"] .= '[attach]href="'.$href.'" length="'.$length.'" type="'.$type.'" title="'.$title.'"[/attach]';
+                                               break;
+                               }
+               }
+       }
+
        /**
         * @brief Processes the entry elements which contain the items and comments
         *
@@ -1970,40 +2011,8 @@ class dfrn {
                $enclosure = "";
 
                $links = $xpath->query("atom:link", $entry);
-               if ($links) {
-                       $rel = "";
-                       $href = "";
-                       $type = "";
-                       $length = "0";
-                       $title = "";
-                       foreach ($links AS $link) {
-                               foreach($link->attributes AS $attributes) {
-                                       if ($attributes->name == "href")
-                                               $href = $attributes->textContent;
-                                       if ($attributes->name == "rel")
-                                               $rel = $attributes->textContent;
-                                       if ($attributes->name == "type")
-                                               $type = $attributes->textContent;
-                                       if ($attributes->name == "length")
-                                               $length = $attributes->textContent;
-                                       if ($attributes->name == "title")
-                                               $title = $attributes->textContent;
-                               }
-                               if (($rel != "") AND ($href != ""))
-                                       switch($rel) {
-                                               case "alternate":
-                                                       $item["plink"] = $href;
-                                                       break;
-                                               case "enclosure":
-                                                       $enclosure = $href;
-                                                       if(strlen($item["attach"]))
-                                                               $item["attach"] .= ",";
-
-                                                       $item["attach"] .= '[attach]href="'.$href.'" length="'.$length.'" type="'.$type.'" title="'.$title.'"[/attach]';
-                                                       break;
-                                       }
-                       }
-               }
+               if ($links)
+                       self::parse_links($links, $item);
 
                // Is it a reply or a top level posting?
                $item["parent-uri"] = $item["uri"];