- if (Event::handle('StartActivityNoticeInfo', array(&$this, &$xs, &$noticeInfoAttr))) {
- $xs->element('statusnet:notice_info', $noticeInfoAttr, null);
- Event::handle('EndActivityNoticeInfo', array(&$this, &$xs, $noticeInfoAttr));
- }
-
- $replyNotice = null;
-
- if ($this->reply_to) {
- $replyNotice = Notice::staticGet('id', $this->reply_to);
- }
-
- if (Event::handle('StartActivityInReplyTo', array(&$this, &$xs, &$replyNotice))) {
- if (!empty($replyNotice)) {
- $xs->element('link', array('rel' => 'related',
- 'href' => $replyNotice->bestUrl()));
- $xs->element('thr:in-reply-to',
- array('ref' => $replyNotice->uri,
- 'href' => $replyNotice->bestUrl()));
- Event::handle('EndActivityInReplyTo', array(&$this, &$xs, $replyNotice));
- }
- }
-
- $conv = null;
-
- if (!empty($this->conversation)) {
- $conv = Conversation::staticGet('id', $this->conversation);
- }
-
- if (Event::handle('StartActivityConversation', array(&$this, &$xs, &$conv))) {
- if (!empty($conv)) {
- $xs->element('link', array('rel' => 'ostatus:conversation',
- 'href' => $conv->uri));
- }
- Event::handle('EndActivityConversation', array(&$this, &$xs, $conv));
- }
-
- $replyProfiles = array();
-
- $reply_ids = $this->getReplies();
-
- foreach ($reply_ids as $id) {
- $profile = Profile::staticGet('id', $id);
- if (!empty($profile)) {
- $replyProfiles[] = $profile;
- }
- }
-
- if (Event::handle('StartActivityAttentionProfiles', array(&$this, &$xs, &$replyProfiles))) {
- foreach ($replyProfiles as $profile) {
- $xs->element('link', array('rel' => 'ostatus:attention',
- 'href' => $profile->getUri()));
- $xs->element('link', array('rel' => 'mentioned',
- 'href' => $profile->getUri()));
- }
- Event::handle('EndActivityAttentionProfiles', array(&$this, &$xs, $replyProfiles));
- }
-
- $groups = $this->getGroups();
-
- if (Event::handle('StartActivityAttentionGroups', array(&$this, &$xs, &$groups))) {
- foreach ($groups as $group) {
- $xs->element('link', array('rel' => 'ostatus:attention',
- 'href' => $group->permalink()));
- $xs->element('link', array('rel' => 'mentioned',
- 'href' => $group->permalink()));
- }
- Event::handle('EndActivityAttentionGroups', array(&$this, &$xs, $groups));
- }
-
- $repeat = null;
-
- if (!empty($this->repeat_of)) {
- $repeat = Notice::staticGet('id', $this->repeat_of);
- }
-
- if (Event::handle('StartActivityForward', array(&$this, &$xs, &$repeat))) {
- if (!empty($repeat)) {
- $xs->element('ostatus:forward',
- array('ref' => $repeat->uri,
- 'href' => $repeat->bestUrl()));
- }
-
- Event::handle('EndActivityForward', array(&$this, &$xs, $repeat));
- }
-
- $tags = $this->getTags();
-
- if (Event::handle('StartActivityCategories', array(&$this, &$xs, &$tags))) {
- foreach ($tags as $tag) {
- $xs->element('category', array('term' => $tag));
- }
- Event::handle('EndActivityCategories', array(&$this, &$xs, $tags));
- }
-
- // Enclosures
-
- $enclosures = array();
-
- $attachments = $this->attachments();
-
- foreach ($attachments as $attachment) {
- $enclosure = $attachment->getEnclosure();
- if ($enclosure) {
- $enclosures[] = $enclosure;
- }
- }
-
- if (Event::handle('StartActivityEnclosures', array(&$this, &$xs, &$enclosures))) {
- foreach ($enclosures as $enclosure) {
- $attributes = array('rel' => 'enclosure',
- 'href' => $enclosure->url,
- 'type' => $enclosure->mimetype,
- 'length' => $enclosure->size);
-
- if ($enclosure->title) {
- $attributes['title'] = $enclosure->title;
- }
-
- $xs->element('link', $attributes, null);
- }
- Event::handle('EndActivityEnclosures', array(&$this, &$xs, $enclosures));
- }
-
- $lat = $this->lat;
- $lon = $this->lon;
-
- if (Event::handle('StartActivityGeo', array(&$this, &$xs, &$lat, &$lon))) {
- if (!empty($lat) && !empty($lon)) {
- $xs->element('georss:point', null, $lat . ' ' . $lon);
- }
- Event::handle('EndActivityGeo', array(&$this, &$xs, $lat, $lon));
- }
-
- if (Event::handle('StartActivityEnd', array(&$this, &$xs))) {
- $xs->elementEnd('entry');
- Event::handle('EndActivityEnd', array(&$this, &$xs));
- }
-
- return $xs->getString();