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 $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
646 $object->avatar = $avatar->displayUrl();
649 if (isset($profile->lat) && isset($profile->lon)) {
650 $object->geopoint = (float)$profile->lat . ' ' . (float)$profile->lon;
653 $object->poco = PoCo::fromProfile($profile);
658 static function fromGroup($group)
660 $object = new ActivityObject();
662 $object->type = ActivityObject::GROUP;
663 $object->id = $group->getUri();
664 $object->title = $group->getBestName();
665 $object->link = $group->getUri();
666 $object->avatar = $group->getAvatar();
668 $object->poco = PoCo::fromGroup($group);
673 function asString($tag='activity:object')
675 $xs = new XMLStringer(true);
677 $xs->elementStart($tag);
679 $xs->element('activity:object-type', null, $this->type);
681 $xs->element(self::ID, null, $this->id);
683 if (!empty($this->title)) {
684 $xs->element(self::TITLE, null, $this->title);
687 if (!empty($this->summary)) {
688 $xs->element(self::SUMMARY, null, $this->summary);
691 if (!empty($this->content)) {
692 // XXX: assuming HTML content here
693 $xs->element(ActivityUtils::CONTENT, array('type' => 'html'), $this->content);
696 if (!empty($this->link)) {
700 'rel' => 'alternate',
701 'type' => 'text/html',
702 'href' => $this->link
708 if ($this->type == ActivityObject::PERSON) {
711 'type' => empty($this->avatar) ? 'image/png' : $this->avatar->mediatype,
713 'href' => empty($this->avatar)
714 ? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
721 // XXX: Gotta figure out mime-type! Gar.
723 if ($this->type == ActivityObject::GROUP) {
727 'href' => $this->avatar
733 if (!empty($this->geopoint)) {
741 if (!empty($this->poco)) {
742 $xs->raw($this->poco->asString());
745 $xs->elementEnd($tag);
747 return $xs->getString();
752 * Utility class to hold a bunch of constant defining default verb types
756 * @author Evan Prodromou <evan@status.net>
757 * @copyright 2010 StatusNet, Inc.
758 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
759 * @link http://status.net/
764 const POST = 'http://activitystrea.ms/schema/1.0/post';
765 const SHARE = 'http://activitystrea.ms/schema/1.0/share';
766 const SAVE = 'http://activitystrea.ms/schema/1.0/save';
767 const FAVORITE = 'http://activitystrea.ms/schema/1.0/favorite';
768 const PLAY = 'http://activitystrea.ms/schema/1.0/play';
769 const FOLLOW = 'http://activitystrea.ms/schema/1.0/follow';
770 const FRIEND = 'http://activitystrea.ms/schema/1.0/make-friend';
771 const JOIN = 'http://activitystrea.ms/schema/1.0/join';
772 const TAG = 'http://activitystrea.ms/schema/1.0/tag';
774 // Custom OStatus verbs for the flipside until they're standardized
775 const DELETE = 'http://ostatus.org/schema/1.0/unfollow';
776 const UNFAVORITE = 'http://ostatus.org/schema/1.0/unfavorite';
777 const UNFOLLOW = 'http://ostatus.org/schema/1.0/unfollow';
778 const LEAVE = 'http://ostatus.org/schema/1.0/leave';
780 // For simple profile-update pings; no content to share.
781 const UPDATE_PROFILE = 'http://ostatus.org/schema/1.0/update-profile';
784 class ActivityContext
789 public $attention = array();
790 public $conversation;
792 const THR = 'http://purl.org/syndication/thread/1.0';
793 const GEORSS = 'http://www.georss.org/georss';
794 const OSTATUS = 'http://ostatus.org/schema/1.0';
796 const INREPLYTO = 'in-reply-to';
800 const POINT = 'point';
802 const ATTENTION = 'ostatus:attention';
803 const CONVERSATION = 'ostatus:conversation';
805 function __construct($element)
807 $replyToEl = ActivityUtils::child($element, self::INREPLYTO, self::THR);
809 if (!empty($replyToEl)) {
810 $this->replyToID = $replyToEl->getAttribute(self::REF);
811 $this->replyToUrl = $replyToEl->getAttribute(self::HREF);
814 $this->location = $this->getLocation($element);
816 $this->conversation = ActivityUtils::getLink($element, self::CONVERSATION);
818 // Multiple attention links allowed
820 $links = $element->getElementsByTagNameNS(ActivityUtils::ATOM, ActivityUtils::LINK);
822 for ($i = 0; $i < $links->length; $i++) {
824 $link = $links->item($i);
826 $linkRel = $link->getAttribute(ActivityUtils::REL);
828 if ($linkRel == self::ATTENTION) {
829 $this->attention[] = $link->getAttribute(self::HREF);
835 * Parse location given as a GeoRSS-simple point, if provided.
836 * http://www.georss.org/simple
838 * @param feed item $entry
839 * @return mixed Location or false
841 function getLocation($dom)
843 $points = $dom->getElementsByTagNameNS(self::GEORSS, self::POINT);
845 for ($i = 0; $i < $points->length; $i++) {
846 $point = $points->item($i)->textContent;
847 return self::locationFromPoint($point);
853 // XXX: Move to ActivityUtils or Location?
854 static function locationFromPoint($point)
856 $point = str_replace(',', ' ', $point); // per spec "treat commas as whitespace"
857 $point = preg_replace('/\s+/', ' ', $point);
858 $point = trim($point);
859 $coords = explode(' ', $point);
860 if (count($coords) == 2) {
861 list($lat, $lon) = $coords;
862 if (is_numeric($lat) && is_numeric($lon)) {
863 common_log(LOG_INFO, "Looking up location for $lat $lon from georss point");
864 return Location::fromLatLon($lat, $lon);
867 common_log(LOG_ERR, "Ignoring bogus georss:point value $point");
873 * An activity in the ActivityStrea.ms world
875 * An activity is kind of like a sentence: someone did something
878 * 'someone' is the 'actor'; 'did something' is the verb;
879 * 'something else' is the object.
883 * @author Evan Prodromou <evan@status.net>
884 * @copyright 2010 StatusNet, Inc.
885 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
886 * @link http://status.net/
891 const SPEC = 'http://activitystrea.ms/spec/1.0/';
892 const SCHEMA = 'http://activitystrea.ms/schema/1.0/';
895 const OBJECT = 'object';
896 const ACTOR = 'actor';
897 const SUBJECT = 'subject';
898 const OBJECTTYPE = 'object-type';
899 const CONTEXT = 'context';
900 const TARGET = 'target';
902 const ATOM = 'http://www.w3.org/2005/Atom';
904 const AUTHOR = 'author';
905 const PUBLISHED = 'published';
906 const UPDATED = 'updated';
908 public $actor; // an ActivityObject
909 public $verb; // a string (the URL)
910 public $object; // an ActivityObject
911 public $target; // an ActivityObject
912 public $context; // an ActivityObject
913 public $time; // Time of the activity
914 public $link; // an ActivityObject
915 public $entry; // the source entry
916 public $feed; // the source feed
918 public $summary; // summary of activity
919 public $content; // HTML content of activity
920 public $id; // ID of the activity
921 public $title; // title of the activity
922 public $categories = array(); // list of AtomCategory objects
925 * Turns a regular old Atom <entry> into a magical activity
927 * @param DOMElement $entry Atom entry to poke at
928 * @param DOMElement $feed Atom feed, for context
931 function __construct($entry = null, $feed = null)
933 if (is_null($entry)) {
937 $this->entry = $entry;
940 $pubEl = $this->_child($entry, self::PUBLISHED, self::ATOM);
942 if (!empty($pubEl)) {
943 $this->time = strtotime($pubEl->textContent);
945 // XXX technically an error; being liberal. Good idea...?
946 $updateEl = $this->_child($entry, self::UPDATED, self::ATOM);
947 if (!empty($updateEl)) {
948 $this->time = strtotime($updateEl->textContent);
954 $this->link = ActivityUtils::getPermalink($entry);
956 $verbEl = $this->_child($entry, self::VERB);
958 if (!empty($verbEl)) {
959 $this->verb = trim($verbEl->textContent);
961 $this->verb = ActivityVerb::POST;
962 // XXX: do other implied stuff here
965 $objectEl = $this->_child($entry, self::OBJECT);
967 if (!empty($objectEl)) {
968 $this->object = new ActivityObject($objectEl);
970 $this->object = new ActivityObject($entry);
973 $actorEl = $this->_child($entry, self::ACTOR);
975 if (!empty($actorEl)) {
977 $this->actor = new ActivityObject($actorEl);
979 } else if (!empty($feed) &&
980 $subjectEl = $this->_child($feed, self::SUBJECT)) {
982 $this->actor = new ActivityObject($subjectEl);
984 } else if ($authorEl = $this->_child($entry, self::AUTHOR, self::ATOM)) {
986 $this->actor = new ActivityObject($authorEl);
988 } else if (!empty($feed) && $authorEl = $this->_child($feed, self::AUTHOR,
991 $this->actor = new ActivityObject($authorEl);
994 $contextEl = $this->_child($entry, self::CONTEXT);
996 if (!empty($contextEl)) {
997 $this->context = new ActivityContext($contextEl);
999 $this->context = new ActivityContext($entry);
1002 $targetEl = $this->_child($entry, self::TARGET);
1004 if (!empty($targetEl)) {
1005 $this->target = new ActivityObject($targetEl);
1008 $this->summary = ActivityUtils::childContent($entry, 'summary');
1009 $this->id = ActivityUtils::childContent($entry, 'id');
1010 $this->content = ActivityUtils::getContent($entry);
1012 $catEls = $entry->getElementsByTagNameNS(self::ATOM, 'category');
1014 for ($i = 0; $i < $catEls->length; $i++) {
1015 $catEl = $catEls->item($i);
1016 $this->categories[] = new AtomCategory($catEl);
1022 * Returns an Atom <entry> based on this activity
1024 * @return DOMElement Atom entry
1027 function toAtomEntry()
1032 function asString($namespace=false)
1034 $xs = new XMLStringer(true);
1037 $attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
1038 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
1039 'xmlns:georss' => 'http://www.georss.org/georss',
1040 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
1041 'xmlns:poco' => 'http://portablecontacts.net/spec/1.0');
1046 $xs->elementStart('entry', $attrs);
1048 $xs->element('id', null, $this->id);
1049 $xs->element('title', null, $this->title);
1050 $xs->element('published', null, common_date_iso8601($this->time));
1051 $xs->element('content', array('type' => 'html'), $this->content);
1053 if (!empty($this->summary)) {
1054 $xs->element('summary', null, $this->summary);
1057 if (!empty($this->link)) {
1058 $xs->element('link', array('rel' => 'alternate',
1059 'type' => 'text/html'),
1065 $xs->elementStart('author');
1066 $xs->element('uri', array(), $this->actor->id);
1067 if ($this->actor->title) {
1068 $xs->element('name', array(), $this->actor->title);
1070 $xs->elementEnd('author');
1071 $xs->raw($this->actor->asString('activity:actor'));
1073 $xs->element('activity:verb', null, $this->verb);
1075 if ($this->object) {
1076 $xs->raw($this->object->asString());
1079 if ($this->target) {
1080 $xs->raw($this->target->asString('activity:target'));
1083 foreach ($this->categories as $cat) {
1084 $xs->raw($cat->asString());
1087 $xs->elementEnd('entry');
1089 return $xs->getString();
1092 private function _child($element, $tag, $namespace=self::SPEC)
1094 return ActivityUtils::child($element, $tag, $namespace);
1104 function __construct($element=null)
1106 if ($element && $element->attributes) {
1107 $this->term = $this->extract($element, 'term');
1108 $this->scheme = $this->extract($element, 'scheme');
1109 $this->label = $this->extract($element, 'label');
1113 protected function extract($element, $attrib)
1115 $node = $element->attributes->getNamedItemNS(Activity::ATOM, $attrib);
1117 return trim($node->textContent);
1119 $node = $element->attributes->getNamedItem($attrib);
1121 return trim($node->textContent);
1129 if ($this->term !== null) {
1130 $attribs['term'] = $this->term;
1132 if ($this->scheme !== null) {
1133 $attribs['scheme'] = $this->scheme;
1135 if ($this->label !== null) {
1136 $attribs['label'] = $this->label;
1138 $xs = new XMLStringer();
1139 $xs->element('category', $attribs);
1140 return $xs->asString();