]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activitycontext.php
Merge branch '0.9.x' into 1.0.x
[quix0rs-gnu-social.git] / lib / activitycontext.php
index 5afbb7fd28b75b4bc36315a74f1e3cecd3b3f944..ff3bc9411d53baeaa48b9b8d007769382bafef44 100644 (file)
@@ -54,8 +54,12 @@ class ActivityContext
     const MENTIONED    = 'mentioned';
     const CONVERSATION = 'ostatus:conversation';
 
-    function __construct($element)
+    function __construct($element = null)
     {
+        if (empty($element)) {
+            return;
+        }
+
         $replyToEl = ActivityUtils::child($element, self::INREPLYTO, self::THR);
 
         if (!empty($replyToEl)) {
@@ -71,8 +75,8 @@ class ActivityContext
 
         $links = $element->getElementsByTagNameNS(ActivityUtils::ATOM, ActivityUtils::LINK);
 
+        $attention = array();
         for ($i = 0; $i < $links->length; $i++) {
-
             $link = $links->item($i);
 
             $linkRel = $link->getAttribute(ActivityUtils::REL);
@@ -80,11 +84,12 @@ class ActivityContext
             // XXX: Deprecate this in favour of "mentioned" from Salmon spec
             // http://salmon-protocol.googlecode.com/svn/trunk/draft-panzer-salmon-00.html#SALR
             if ($linkRel == self::ATTENTION) {
-                $this->attention[] = $link->getAttribute(self::HREF);
+                $attention[] = $link->getAttribute(self::HREF);
             } elseif ($linkRel == self::MENTIONED) {
-                $this->attention[] = $link->getAttribute(self::HREF);
+                $attention[] = $link->getAttribute(self::HREF);
             }
         }
+        $this->attention = array_unique($attention);
     }
 
     /**