3 * StatusNet, the distributed open-source microblogging tool
7 * LICENCE: This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 * @author Evan Prodromou <evan@status.net>
23 * @author Zach Copley <zach@status.net>
24 * @copyright 2010 StatusNet, Inc.
25 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
26 * @link http://status.net/
29 if (!defined('STATUSNET')) {
39 function __construct($element=null)
41 if ($element && $element->attributes) {
42 $this->term = $this->extract($element, 'term');
43 $this->scheme = $this->extract($element, 'scheme');
44 $this->label = $this->extract($element, 'label');
48 protected function extract($element, $attrib)
50 $node = $element->attributes->getNamedItemNS(Activity::ATOM, $attrib);
52 return trim($node->textContent);
54 $node = $element->attributes->getNamedItem($attrib);
56 return trim($node->textContent);
64 if ($this->term !== null) {
65 $attribs['term'] = $this->term;
67 if ($this->scheme !== null) {
68 $attribs['scheme'] = $this->scheme;
70 if ($this->label !== null) {
71 $attribs['label'] = $this->label;
73 $xs = new XMLStringer();
74 $xs->element('category', $attribs);
75 return $xs->asString();