8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_App_Extension
27 require_once 'Zend/Gdata/App/Extension.php';
30 * Represents the media:category element
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
38 class Zend_Gdata_Media_Extension_MediaCategory extends Zend_Gdata_Extension
41 protected $_rootElement = 'category';
42 protected $_rootNamespace = 'media';
47 protected $_scheme = null;
48 protected $_label = null;
51 * Creates an individual MediaCategory object.
53 * @param string $text Indication of the type and content of the media
54 * @param string $scheme URI that identifies the categorization scheme
55 * @param string $label Human-readable label to be displayed in applications
57 public function __construct($text = null, $scheme = null, $label = null)
59 $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
60 parent::__construct();
62 $this->_scheme = $scheme;
63 $this->_label = $label;
67 * Retrieves a DOMElement which corresponds to this element and all
68 * child properties. This is used to build an entry back into a DOM
69 * and eventually XML text for sending to the server upon updates, or
70 * for application storage/persistence.
72 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
73 * @return DOMElement The DOMElement representing this element and all
76 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
78 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
79 if ($this->_scheme !== null) {
80 $element->setAttribute('scheme', $this->_scheme);
82 if ($this->_label !== null) {
83 $element->setAttribute('label', $this->_label);
89 * Given a DOMNode representing an attribute, tries to map the data into
90 * instance members. If no mapping is defined, the name and value are
93 * @param DOMNode $attribute The DOMNode attribute needed to be handled
95 protected function takeAttributeFromDOM($attribute)
97 switch ($attribute->localName) {
99 $this->_scheme = $attribute->nodeValue;
102 $this->_label = $attribute->nodeValue;
105 parent::takeAttributeFromDOM($attribute);
110 * Returns the URI that identifies the categorization scheme
113 * @return string URI that identifies the categorization scheme
115 public function getScheme()
117 return $this->_scheme;
121 * @param string $value URI that identifies the categorization scheme
122 * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface
124 public function setScheme($value)
126 $this->_scheme = $value;
131 * @return string Human-readable label to be displayed in applications
133 public function getLabel()
135 return $this->_label;
139 * @param string $value Human-readable label to be displayed in applications
140 * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface
142 public function setLabel($value)
144 $this->_label = $value;