$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);
$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);
// @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);
}
}
- 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 fromProfile(Profile $profile)
- {
- $object = new ActivityObject();
-
- if (Event::handle('StartActivityObjectFromProfile', array($profile, &$object))) {
- $object->type = ActivityObject::PERSON;
- $object->id = $profile->getUri();
- $object->title = $profile->getBestName();
- $object->link = $profile->profileurl;
-
- try {
- $avatar = Avatar::getUploaded($profile);
- $object->avatarLinks[] = AvatarLink::fromAvatar($avatar);
- } catch (NoAvatarException $e) {
- // Could not find an original avatar to link
- }
-
- $sizes = array(
- AVATAR_PROFILE_SIZE,
- AVATAR_STREAM_SIZE,
- AVATAR_MINI_SIZE
- );
-
- foreach ($sizes as $size) {
- $alink = null;
- try {
- $avatar = Avatar::byProfile($profile, $size);
- $alink = AvatarLink::fromAvatar($avatar);
- } catch (NoAvatarException $e) {
- $alink = new AvatarLink();
- $alink->type = 'image/png';
- $alink->height = $size;
- $alink->width = $size;
- $alink->url = Avatar::defaultImage($size);
- }
-
- $object->avatarLinks[] = $alink;
- }
-
- if (isset($profile->lat) && isset($profile->lon)) {
- $object->geopoint = (float)$profile->lat
- . ' ' . (float)$profile->lon;
- }
-
- $object->poco = PoCo::fromProfile($profile);
-
- if ($profile->isLocal()) {
- $object->extra[] = array('followers', array('url' => common_local_url('subscribers', array('nickname' => $profile->nickname))));
- }
-
- Event::handle('EndActivityObjectFromProfile', array($profile, &$object));
- }
-
- return $object;
- }
-
static function fromGroup(User_group $group)
{
$object = new ActivityObject();