3 * StatusNet, the distributed open-source microblogging tool
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @author Zach Copley <zach@status.net>
26 * @copyright 2010 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
39 const VALUE = 'value';
40 const PRIMARY = 'primary';
46 function __construct($type, $value, $primary = false)
49 $this->value = $value;
50 $this->primary = $primary;
55 $xs = new XMLStringer(true);
56 $xs->elementStart('poco:urls');
57 $xs->element('poco:type', null, $this->type);
58 $xs->element('poco:value', null, $this->value);
59 if (!empty($this->primary)) {
60 $xs->element('poco:primary', null, 'true');
62 $xs->elementEnd('poco:urls');
63 return $xs->getString();
69 const ADDRESS = 'address';
70 const FORMATTED = 'formatted';
74 // @todo Other address fields
78 if (!empty($this->formatted)) {
79 $xs = new XMLStringer(true);
80 $xs->elementStart('poco:address');
81 $xs->element('poco:formatted', null, $this->formatted);
82 $xs->elementEnd('poco:address');
83 return $xs->getString();
92 const NS = 'http://portablecontacts.net/spec/1.0';
94 const USERNAME = 'preferredUsername';
95 const DISPLAYNAME = 'displayName';
98 public $preferredUsername;
102 public $urls = array();
104 function __construct($element = null)
106 if (empty($element)) {
110 $this->preferredUsername = ActivityUtils::childContent(
116 $this->displayName = ActivityUtils::childContent(
122 $this->note = ActivityUtils::childContent(
128 $this->address = $this->_getAddress($element);
129 $this->urls = $this->_getURLs($element);
132 private function _getURLs($element)
134 $urlEls = $element->getElementsByTagnameNS(self::NS, PoCoURL::URLS);
137 foreach ($urlEls as $urlEl) {
139 $type = ActivityUtils::childContent(
145 $value = ActivityUtils::childContent(
151 $primary = ActivityUtils::childContent(
159 if (isset($primary) && $primary == 'true') {
163 // @todo check to make sure a primary hasn't already been added
165 array_push($urls, new PoCoURL($type, $value, $isPrimary));
170 private function _getAddress($element)
172 $addressEl = ActivityUtils::child(
174 PoCoAddress::ADDRESS,
178 if (!empty($addressEl)) {
179 $formatted = ActivityUtils::childContent(
181 PoCoAddress::FORMATTED,
185 if (!empty($formatted)) {
186 $address = new PoCoAddress();
187 $address->formatted = $formatted;
195 function fromProfile($profile)
197 if (empty($profile)) {
203 $poco->preferredUsername = $profile->nickname;
204 $poco->displayName = $profile->getBestName();
206 $poco->note = $profile->bio;
208 $paddy = new PoCoAddress();
209 $paddy->formatted = $profile->location;
210 $poco->address = $paddy;
212 if (!empty($profile->homepage)) {
226 function fromGroup($group)
234 $poco->preferredUsername = $group->nickname;
235 $poco->displayName = $group->getBestName();
237 $poco->note = $group->description;
239 $paddy = new PoCoAddress();
240 $paddy->formatted = $group->location;
241 $poco->address = $paddy;
243 if (!empty($group->homepage)) {
257 function getPrimaryURL()
259 foreach ($this->urls as $url) {
268 $xs = new XMLStringer(true);
270 'poco:preferredUsername',
272 $this->preferredUsername
281 if (!empty($this->note)) {
282 $xs->element('poco:note', null, $this->note);
285 if (!empty($this->address)) {
286 $xs->raw($this->address->asString());
289 foreach ($this->urls as $url) {
290 $xs->raw($url->asString());
293 return $xs->getString();
298 * Utilities for turning DOMish things into Activityish things
300 * Some common functions that I didn't have the bandwidth to try to factor
301 * into some kind of reasonable superclass, so just dumped here. Might
302 * be useful to have an ActivityObject parent class or something.
306 * @author Evan Prodromou <evan@status.net>
307 * @copyright 2010 StatusNet, Inc.
308 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
309 * @link http://status.net/
314 const ATOM = 'http://www.w3.org/2005/Atom';
321 const CONTENT = 'content';
325 * Get the permalink for an Activity object
327 * @param DOMElement $element A DOM element
329 * @return string related link, if any
332 static function getPermalink($element)
334 return self::getLink($element, 'alternate', 'text/html');
338 * Get the permalink for an Activity object
340 * @param DOMElement $element A DOM element
342 * @return string related link, if any
345 static function getLink(DOMNode $element, $rel, $type=null)
347 $links = $element->getElementsByTagnameNS(self::ATOM, self::LINK);
349 foreach ($links as $link) {
351 $linkRel = $link->getAttribute(self::REL);
352 $linkType = $link->getAttribute(self::TYPE);
354 if ($linkRel == $rel &&
355 (is_null($type) || $linkType == $type)) {
356 return $link->getAttribute(self::HREF);
364 * Gets the first child element with the given tag
366 * @param DOMElement $element element to pick at
367 * @param string $tag tag to look for
368 * @param string $namespace Namespace to look under
370 * @return DOMElement found element or null
373 static function child(DOMNode $element, $tag, $namespace=self::ATOM)
375 $els = $element->childNodes;
376 if (empty($els) || $els->length == 0) {
379 for ($i = 0; $i < $els->length; $i++) {
380 $el = $els->item($i);
381 if ($el->localName == $tag && $el->namespaceURI == $namespace) {
389 * Grab the text content of a DOM element child of the current element
391 * @param DOMElement $element Element whose children we examine
392 * @param string $tag Tag to look up
393 * @param string $namespace Namespace to use, defaults to Atom
395 * @return string content of the child
398 static function childContent(DOMNode $element, $tag, $namespace=self::ATOM)
400 $el = self::child($element, $tag, $namespace);
405 return $el->textContent;
410 * Get the content of an atom:entry-like object
412 * @param DOMElement $element The element to examine.
414 * @return string unencoded HTML content of the element, like "This -< is <b>HTML</b>."
416 * @todo handle remote content
417 * @todo handle embedded XML mime types
418 * @todo handle base64-encoded non-XML and non-text mime types
421 static function getContent($element)
423 $contentEl = ActivityUtils::child($element, self::CONTENT);
425 if (!empty($contentEl)) {
427 $src = $contentEl->getAttribute(self::SRC);
430 throw new ClientException(_("Can't handle remote content yet."));
433 $type = $contentEl->getAttribute(self::TYPE);
435 // slavishly following http://atompub.org/rfc4287.html#rfc.section.4.1.3.3
437 if ($type == 'text') {
438 return $contentEl->textContent;
439 } else if ($type == 'html') {
440 $text = $contentEl->textContent;
441 return htmlspecialchars_decode($text, ENT_QUOTES);
442 } else if ($type == 'xhtml') {
443 $divEl = ActivityUtils::child($contentEl, 'div');
447 $doc = $divEl->ownerDocument;
449 $children = $divEl->childNodes;
451 for ($i = 0; $i < $children->length; $i++) {
452 $child = $children->item($i);
453 $text .= $doc->saveXML($child);
456 } else if (in_array(array('text/xml', 'application/xml'), $type) ||
457 preg_match('#(+|/)xml$#', $type)) {
458 throw new ClientException(_("Can't handle embedded XML content yet."));
459 } else if (strncasecmp($type, 'text/', 5)) {
460 return $contentEl->textContent;
462 throw new ClientException(_("Can't handle embedded Base64 content yet."));
469 * A noun-ish thing in the activity universe
471 * The activity streams spec talks about activity objects, while also having
472 * a tag activity:object, which is in fact an activity object. Aaaaaah!
474 * This is just a thing in the activity universe. Can be the subject, object,
475 * or indirect object (target!) of an activity verb. Rotten name, and I'm
476 * propagating it. *sigh*
480 * @author Evan Prodromou <evan@status.net>
481 * @copyright 2010 StatusNet, Inc.
482 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
483 * @link http://status.net/
488 const ARTICLE = 'http://activitystrea.ms/schema/1.0/article';
489 const BLOGENTRY = 'http://activitystrea.ms/schema/1.0/blog-entry';
490 const NOTE = 'http://activitystrea.ms/schema/1.0/note';
491 const STATUS = 'http://activitystrea.ms/schema/1.0/status';
492 const FILE = 'http://activitystrea.ms/schema/1.0/file';
493 const PHOTO = 'http://activitystrea.ms/schema/1.0/photo';
494 const ALBUM = 'http://activitystrea.ms/schema/1.0/photo-album';
495 const PLAYLIST = 'http://activitystrea.ms/schema/1.0/playlist';
496 const VIDEO = 'http://activitystrea.ms/schema/1.0/video';
497 const AUDIO = 'http://activitystrea.ms/schema/1.0/audio';
498 const BOOKMARK = 'http://activitystrea.ms/schema/1.0/bookmark';
499 const PERSON = 'http://activitystrea.ms/schema/1.0/person';
500 const GROUP = 'http://activitystrea.ms/schema/1.0/group';
501 const PLACE = 'http://activitystrea.ms/schema/1.0/place';
502 const COMMENT = 'http://activitystrea.ms/schema/1.0/comment';
505 // Atom elements we snarf
507 const TITLE = 'title';
508 const SUMMARY = 'summary';
510 const SOURCE = 'source';
514 const EMAIL = 'email';
532 * This probably needs to be refactored
533 * to generate a local class (ActivityPerson, ActivityFile, ...)
534 * based on the object type.
536 * @param DOMElement $element DOM thing to turn into an Activity thing
539 function __construct($element = null)
541 if (empty($element)) {
545 $this->element = $element;
547 $this->geopoint = $this->_childContent(
549 ActivityContext::POINT,
550 ActivityContext::GEORSS
553 if ($element->tagName == 'author') {
555 $this->type = self::PERSON; // XXX: is this fair?
556 $this->title = $this->_childContent($element, self::NAME);
557 $this->id = $this->_childContent($element, self::URI);
559 if (empty($this->id)) {
560 $email = $this->_childContent($element, self::EMAIL);
561 if (!empty($email)) {
563 $this->id = 'mailto:'.$email;
569 $this->type = $this->_childContent($element, Activity::OBJECTTYPE,
572 if (empty($this->type)) {
573 $this->type = ActivityObject::NOTE;
576 $this->id = $this->_childContent($element, self::ID);
577 $this->title = $this->_childContent($element, self::TITLE);
578 $this->summary = $this->_childContent($element, self::SUMMARY);
580 $this->source = $this->_getSource($element);
582 $this->content = ActivityUtils::getContent($element);
584 $this->link = ActivityUtils::getPermalink($element);
588 // Some per-type attributes...
589 if ($this->type == self::PERSON || $this->type == self::GROUP) {
590 $this->displayName = $this->title;
592 // @fixme we may have multiple avatars with different resolutions specified
593 $this->avatar = ActivityUtils::getLink($element, 'avatar');
595 $this->poco = new PoCo($element);
599 private function _childContent($element, $tag, $namespace=ActivityUtils::ATOM)
601 return ActivityUtils::childContent($element, $tag, $namespace);
604 // Try to get a unique id for the source feed
606 private function _getSource($element)
608 $sourceEl = ActivityUtils::child($element, 'source');
610 if (empty($sourceEl)) {
613 $href = ActivityUtils::getLink($sourceEl, 'self');
617 return ActivityUtils::childContent($sourceEl, 'id');
622 static function fromNotice($notice)
624 $object = new ActivityObject();
626 $object->type = ActivityObject::NOTE;
628 $object->id = $notice->uri;
629 $object->title = $notice->content;
630 $object->content = $notice->rendered;
631 $object->link = $notice->bestUrl();
636 static function fromProfile($profile)
638 $object = new ActivityObject();
640 $object->type = ActivityObject::PERSON;
641 $object->id = $profile->getUri();
642 $object->title = $profile->getBestName();
643 $object->link = $profile->profileurl;
644 $object->avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
646 if (isset($profile->lat) && isset($profile->lon)) {
647 $object->geopoint = (float)$profile->lat . ' ' . (float)$profile->lon;
650 $object->poco = PoCo::fromProfile($profile);
655 static function fromGroup($group)
657 $object = new ActivityObject();
659 $object->type = ActivityObject::GROUP;
660 $object->id = $group->getUri();
661 $object->title = $group->getBestName();
662 $object->link = $group->getUri();
663 $object->avatar = $group->getAvatar();
665 $object->poco = PoCo::fromGroup($group);
670 function asString($tag='activity:object')
672 $xs = new XMLStringer(true);
674 $xs->elementStart($tag);
676 $xs->element('activity:object-type', null, $this->type);
678 $xs->element(self::ID, null, $this->id);
680 if (!empty($this->title)) {
681 $xs->element(self::TITLE, null, $this->title);
684 if (!empty($this->summary)) {
685 $xs->element(self::SUMMARY, null, $this->summary);
688 if (!empty($this->content)) {
689 // XXX: assuming HTML content here
690 $xs->element(ActivityUtils::CONTENT, array('type' => 'html'), $this->content);
693 if (!empty($this->link)) {
697 'rel' => 'alternate',
698 'type' => 'text/html',
699 'href' => $this->link
705 if ($this->type == ActivityObject::PERSON) {
708 'type' => empty($this->avatar) ? 'image/png' : $this->avatar->mediatype,
710 'href' => empty($this->avatar)
711 ? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
712 : $this->avatar->displayUrl()
718 // XXX: Gotta figure out mime-type! Gar.
720 if ($this->type == ActivityObject::GROUP) {
724 'href' => $this->avatar
730 if (!empty($this->geopoint)) {
738 if (!empty($this->poco)) {
739 $xs->raw($this->poco->asString());
742 $xs->elementEnd($tag);
744 return $xs->getString();
749 * Utility class to hold a bunch of constant defining default verb types
753 * @author Evan Prodromou <evan@status.net>
754 * @copyright 2010 StatusNet, Inc.
755 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
756 * @link http://status.net/
761 const POST = 'http://activitystrea.ms/schema/1.0/post';
762 const SHARE = 'http://activitystrea.ms/schema/1.0/share';
763 const SAVE = 'http://activitystrea.ms/schema/1.0/save';
764 const FAVORITE = 'http://activitystrea.ms/schema/1.0/favorite';
765 const PLAY = 'http://activitystrea.ms/schema/1.0/play';
766 const FOLLOW = 'http://activitystrea.ms/schema/1.0/follow';
767 const FRIEND = 'http://activitystrea.ms/schema/1.0/make-friend';
768 const JOIN = 'http://activitystrea.ms/schema/1.0/join';
769 const TAG = 'http://activitystrea.ms/schema/1.0/tag';
771 // Custom OStatus verbs for the flipside until they're standardized
772 const DELETE = 'http://ostatus.org/schema/1.0/unfollow';
773 const UNFAVORITE = 'http://ostatus.org/schema/1.0/unfavorite';
774 const UNFOLLOW = 'http://ostatus.org/schema/1.0/unfollow';
775 const LEAVE = 'http://ostatus.org/schema/1.0/leave';
777 // For simple profile-update pings; no content to share.
778 const UPDATE_PROFILE = 'http://ostatus.org/schema/1.0/update-profile';
781 class ActivityContext
786 public $attention = array();
787 public $conversation;
789 const THR = 'http://purl.org/syndication/thread/1.0';
790 const GEORSS = 'http://www.georss.org/georss';
791 const OSTATUS = 'http://ostatus.org/schema/1.0';
793 const INREPLYTO = 'in-reply-to';
797 const POINT = 'point';
799 const ATTENTION = 'ostatus:attention';
800 const CONVERSATION = 'ostatus:conversation';
802 function __construct($element)
804 $replyToEl = ActivityUtils::child($element, self::INREPLYTO, self::THR);
806 if (!empty($replyToEl)) {
807 $this->replyToID = $replyToEl->getAttribute(self::REF);
808 $this->replyToUrl = $replyToEl->getAttribute(self::HREF);
811 $this->location = $this->getLocation($element);
813 $this->conversation = ActivityUtils::getLink($element, self::CONVERSATION);
815 // Multiple attention links allowed
817 $links = $element->getElementsByTagNameNS(ActivityUtils::ATOM, ActivityUtils::LINK);
819 for ($i = 0; $i < $links->length; $i++) {
821 $link = $links->item($i);
823 $linkRel = $link->getAttribute(ActivityUtils::REL);
825 if ($linkRel == self::ATTENTION) {
826 $this->attention[] = $link->getAttribute(self::HREF);
832 * Parse location given as a GeoRSS-simple point, if provided.
833 * http://www.georss.org/simple
835 * @param feed item $entry
836 * @return mixed Location or false
838 function getLocation($dom)
840 $points = $dom->getElementsByTagNameNS(self::GEORSS, self::POINT);
842 for ($i = 0; $i < $points->length; $i++) {
843 $point = $points->item($i)->textContent;
844 return self::locationFromPoint($point);
850 // XXX: Move to ActivityUtils or Location?
851 static function locationFromPoint($point)
853 $point = str_replace(',', ' ', $point); // per spec "treat commas as whitespace"
854 $point = preg_replace('/\s+/', ' ', $point);
855 $point = trim($point);
856 $coords = explode(' ', $point);
857 if (count($coords) == 2) {
858 list($lat, $lon) = $coords;
859 if (is_numeric($lat) && is_numeric($lon)) {
860 common_log(LOG_INFO, "Looking up location for $lat $lon from georss point");
861 return Location::fromLatLon($lat, $lon);
864 common_log(LOG_ERR, "Ignoring bogus georss:point value $point");
870 * An activity in the ActivityStrea.ms world
872 * An activity is kind of like a sentence: someone did something
875 * 'someone' is the 'actor'; 'did something' is the verb;
876 * 'something else' is the object.
880 * @author Evan Prodromou <evan@status.net>
881 * @copyright 2010 StatusNet, Inc.
882 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
883 * @link http://status.net/
888 const SPEC = 'http://activitystrea.ms/spec/1.0/';
889 const SCHEMA = 'http://activitystrea.ms/schema/1.0/';
892 const OBJECT = 'object';
893 const ACTOR = 'actor';
894 const SUBJECT = 'subject';
895 const OBJECTTYPE = 'object-type';
896 const CONTEXT = 'context';
897 const TARGET = 'target';
899 const ATOM = 'http://www.w3.org/2005/Atom';
901 const AUTHOR = 'author';
902 const PUBLISHED = 'published';
903 const UPDATED = 'updated';
905 public $actor; // an ActivityObject
906 public $verb; // a string (the URL)
907 public $object; // an ActivityObject
908 public $target; // an ActivityObject
909 public $context; // an ActivityObject
910 public $time; // Time of the activity
911 public $link; // an ActivityObject
912 public $entry; // the source entry
913 public $feed; // the source feed
915 public $summary; // summary of activity
916 public $content; // HTML content of activity
917 public $id; // ID of the activity
918 public $title; // title of the activity
919 public $categories = array(); // list of AtomCategory objects
922 * Turns a regular old Atom <entry> into a magical activity
924 * @param DOMElement $entry Atom entry to poke at
925 * @param DOMElement $feed Atom feed, for context
928 function __construct($entry = null, $feed = null)
930 if (is_null($entry)) {
934 $this->entry = $entry;
937 $pubEl = $this->_child($entry, self::PUBLISHED, self::ATOM);
939 if (!empty($pubEl)) {
940 $this->time = strtotime($pubEl->textContent);
942 // XXX technically an error; being liberal. Good idea...?
943 $updateEl = $this->_child($entry, self::UPDATED, self::ATOM);
944 if (!empty($updateEl)) {
945 $this->time = strtotime($updateEl->textContent);
951 $this->link = ActivityUtils::getPermalink($entry);
953 $verbEl = $this->_child($entry, self::VERB);
955 if (!empty($verbEl)) {
956 $this->verb = trim($verbEl->textContent);
958 $this->verb = ActivityVerb::POST;
959 // XXX: do other implied stuff here
962 $objectEl = $this->_child($entry, self::OBJECT);
964 if (!empty($objectEl)) {
965 $this->object = new ActivityObject($objectEl);
967 $this->object = new ActivityObject($entry);
970 $actorEl = $this->_child($entry, self::ACTOR);
972 if (!empty($actorEl)) {
974 $this->actor = new ActivityObject($actorEl);
976 } else if (!empty($feed) &&
977 $subjectEl = $this->_child($feed, self::SUBJECT)) {
979 $this->actor = new ActivityObject($subjectEl);
981 } else if ($authorEl = $this->_child($entry, self::AUTHOR, self::ATOM)) {
983 $this->actor = new ActivityObject($authorEl);
985 } else if (!empty($feed) && $authorEl = $this->_child($feed, self::AUTHOR,
988 $this->actor = new ActivityObject($authorEl);
991 $contextEl = $this->_child($entry, self::CONTEXT);
993 if (!empty($contextEl)) {
994 $this->context = new ActivityContext($contextEl);
996 $this->context = new ActivityContext($entry);
999 $targetEl = $this->_child($entry, self::TARGET);
1001 if (!empty($targetEl)) {
1002 $this->target = new ActivityObject($targetEl);
1005 $this->summary = ActivityUtils::childContent($entry, 'summary');
1006 $this->id = ActivityUtils::childContent($entry, 'id');
1007 $this->content = ActivityUtils::getContent($entry);
1009 $catEls = $entry->getElementsByTagNameNS(self::ATOM, 'category');
1011 for ($i = 0; $i < $catEls->length; $i++) {
1012 $catEl = $catEls->item($i);
1013 $this->categories[] = new AtomCategory($catEl);
1019 * Returns an Atom <entry> based on this activity
1021 * @return DOMElement Atom entry
1024 function toAtomEntry()
1029 function asString($namespace=false)
1031 $xs = new XMLStringer(true);
1034 $attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
1035 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
1036 'xmlns:georss' => 'http://www.georss.org/georss',
1037 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
1038 'xmlns:poco' => 'http://portablecontacts.net/spec/1.0');
1043 $xs->elementStart('entry', $attrs);
1045 $xs->element('id', null, $this->id);
1046 $xs->element('title', null, $this->title);
1047 $xs->element('published', null, common_date_iso8601($this->time));
1048 $xs->element('content', array('type' => 'html'), $this->content);
1050 if (!empty($this->summary)) {
1051 $xs->element('summary', null, $this->summary);
1054 if (!empty($this->link)) {
1055 $xs->element('link', array('rel' => 'alternate',
1056 'type' => 'text/html'),
1062 $xs->elementStart('author');
1063 $xs->element('uri', array(), $this->actor->id);
1064 if ($this->actor->title) {
1065 $xs->element('name', array(), $this->actor->title);
1067 $xs->elementEnd('author');
1068 $xs->raw($this->actor->asString('activity:actor'));
1070 $xs->element('activity:verb', null, $this->verb);
1072 if ($this->object) {
1073 $xs->raw($this->object->asString());
1076 if ($this->target) {
1077 $xs->raw($this->target->asString('activity:target'));
1080 foreach ($this->categories as $cat) {
1081 $xs->raw($cat->asString());
1084 $xs->elementEnd('entry');
1086 return $xs->getString();
1089 private function _child($element, $tag, $namespace=self::SPEC)
1091 return ActivityUtils::child($element, $tag, $namespace);
1101 function __construct($element=null)
1103 if ($element && $element->attributes) {
1104 $this->term = $this->extract($element, 'term');
1105 $this->scheme = $this->extract($element, 'scheme');
1106 $this->label = $this->extract($element, 'label');
1110 protected function extract($element, $attrib)
1112 $node = $element->attributes->getNamedItemNS(Activity::ATOM, $attrib);
1114 return trim($node->textContent);
1116 $node = $element->attributes->getNamedItem($attrib);
1118 return trim($node->textContent);
1126 if ($this->term !== null) {
1127 $attribs['term'] = $this->term;
1129 if ($this->scheme !== null) {
1130 $attribs['scheme'] = $this->scheme;
1132 if ($this->label !== null) {
1133 $attribs['label'] = $this->label;
1135 $xs = new XMLStringer();
1136 $xs->element('category', $attribs);
1137 return $xs->asString();