]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activityobject.php
Misses this file to merge. I like the comments.
[quix0rs-gnu-social.git] / lib / activityobject.php
index b3940be824b9a0ab5c34d91f99c85b9241c02f31..2fe52eefcc5a84f883757f9aba8818446d1a657b 100644 (file)
@@ -195,15 +195,22 @@ class ActivityObject
             $this->type = self::PERSON; // XXX: is this fair?
         }
 
-        // start with <atom:title>
 
-        $title = ActivityUtils::childHtmlContent($element, self::TITLE);
+        // Start with <poco::displayName>
 
-        if (!empty($title)) {
-            $this->title = html_entity_decode(strip_tags($title), ENT_QUOTES, 'UTF-8');
+        $this->title = ActivityUtils::childContent($element, PoCo::DISPLAYNAME, PoCo::NS);
+
+        // try falling back to <atom:title>
+
+        if (empty($this->title)) {
+            $title = ActivityUtils::childHtmlContent($element, self::TITLE);
+
+            if (!empty($title)) {
+                $this->title = common_strip_html($title);
+            }
         }
 
-        // fall back to <atom:name>
+        // fall back to <atom:name> as a last resort
 
         if (empty($this->title)) {
             $this->title = $this->_childContent($element, self::NAME);
@@ -251,10 +258,7 @@ class ActivityObject
         $this->content = ActivityUtils::getContent($element);
 
         // We don't like HTML in our titles, although it's technically allowed
-
-        $title = ActivityUtils::childHtmlContent($element, self::TITLE);
-
-        $this->title = html_entity_decode(strip_tags($title), ENT_QUOTES, 'UTF-8');
+        $this->title = common_strip_html(ActivityUtils::childHtmlContent($element, self::TITLE));
 
         $this->source  = $this->_getSource($element);
 
@@ -270,6 +274,10 @@ class ActivityObject
     // @todo FIXME: rationalize with Activity::_fromRssItem()
     private function _fromRssItem($item)
     {
+        if (empty($this->type)) {
+            $this->type = ActivityObject::NOTE;
+        }
+
         $this->title = ActivityUtils::childContent($item, ActivityObject::TITLE, Activity::RSS);
 
         $contentEl = ActivityUtils::child($item, ActivityUtils::CONTENT, Activity::CONTENTNS);
@@ -431,32 +439,6 @@ class ActivityObject
         }
     }
 
-    static function fromNotice(Notice $notice)
-    {
-        $object = new ActivityObject();
-
-        if (Event::handle('StartActivityObjectFromNotice', array($notice, &$object))) {
-
-            $object->type    = (empty($notice->object_type)) ? ActivityObject::NOTE : $notice->object_type;
-
-            $object->id      = $notice->uri;
-            $object->title = 'New ' . self::canonicalType($object->type) . ' by ';
-            try {
-                $object->title .= $notice->getProfile()->getAcctUri();
-            } catch (ProfileNoAcctUriException $e) {
-                $object->title .= $e->profile->nickname;
-            }
-            $object->content = $notice->rendered;
-            $object->link    = $notice->getUrl();
-
-            $object->extra[] = array('status_net', array('notice_id' => $notice->id));
-
-            Event::handle('EndActivityObjectFromNotice', array($notice, &$object));
-        }
-
-        return $object;
-    }
-
     static function fromGroup(User_group $group)
     {
         $object = new ActivityObject();
@@ -530,11 +512,11 @@ class ActivityObject
 
             switch (self::canonicalType($object->type)) {
             case 'image':
-                $object->largerImage = $file->url;
+                $object->largerImage = $file->getUrl();
                 break;
             case 'video':
             case 'audio':
-                $object->stream = $file->url;
+                $object->stream = $file->getUrl();
                 break;
             }
 
@@ -879,7 +861,7 @@ class ActivityObject
                 if (is_string($this->thumbnail)) {
                     $object['image'] = array('url' => $this->thumbnail);
                 } else {
-                    $object['image'] = array('url' => $this->thumbnail->url);
+                    $object['image'] = array('url' => $this->thumbnail->getUrl());
                     if ($this->thumbnail->width) {
                         $object['image']['width'] = $this->thumbnail->width;
                     }