|
1 <?php |
|
2 |
|
3 /** |
|
4 * Zend Framework |
|
5 * |
|
6 * LICENSE |
|
7 * |
|
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. |
|
15 * |
|
16 * @category Zend |
|
17 * @package Zend_Gdata |
|
18 * @subpackage Media |
|
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 |
|
21 * @version $Id: MediaCategory.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
22 */ |
|
23 |
|
24 /** |
|
25 * @see Zend_Gdata_App_Extension |
|
26 */ |
|
27 require_once 'Zend/Gdata/App/Extension.php'; |
|
28 |
|
29 /** |
|
30 * Represents the media:category element |
|
31 * |
|
32 * @category Zend |
|
33 * @package Zend_Gdata |
|
34 * @subpackage Media |
|
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 |
|
37 */ |
|
38 class Zend_Gdata_Media_Extension_MediaCategory extends Zend_Gdata_Extension |
|
39 { |
|
40 |
|
41 protected $_rootElement = 'category'; |
|
42 protected $_rootNamespace = 'media'; |
|
43 |
|
44 /** |
|
45 * @var string |
|
46 */ |
|
47 protected $_scheme = null; |
|
48 protected $_label = null; |
|
49 |
|
50 /** |
|
51 * Creates an individual MediaCategory object. |
|
52 * |
|
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 |
|
56 */ |
|
57 public function __construct($text = null, $scheme = null, $label = null) |
|
58 { |
|
59 $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces); |
|
60 parent::__construct(); |
|
61 $this->_text = $text; |
|
62 $this->_scheme = $scheme; |
|
63 $this->_label = $label; |
|
64 } |
|
65 |
|
66 /** |
|
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. |
|
71 * |
|
72 * @param DOMDocument $doc The DOMDocument used to construct DOMElements |
|
73 * @return DOMElement The DOMElement representing this element and all |
|
74 * child properties. |
|
75 */ |
|
76 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) |
|
77 { |
|
78 $element = parent::getDOM($doc, $majorVersion, $minorVersion); |
|
79 if ($this->_scheme !== null) { |
|
80 $element->setAttribute('scheme', $this->_scheme); |
|
81 } |
|
82 if ($this->_label !== null) { |
|
83 $element->setAttribute('label', $this->_label); |
|
84 } |
|
85 return $element; |
|
86 } |
|
87 |
|
88 /** |
|
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 |
|
91 * stored in an array. |
|
92 * |
|
93 * @param DOMNode $attribute The DOMNode attribute needed to be handled |
|
94 */ |
|
95 protected function takeAttributeFromDOM($attribute) |
|
96 { |
|
97 switch ($attribute->localName) { |
|
98 case 'scheme': |
|
99 $this->_scheme = $attribute->nodeValue; |
|
100 break; |
|
101 case 'label': |
|
102 $this->_label = $attribute->nodeValue; |
|
103 break; |
|
104 default: |
|
105 parent::takeAttributeFromDOM($attribute); |
|
106 } |
|
107 } |
|
108 |
|
109 /** |
|
110 * Returns the URI that identifies the categorization scheme |
|
111 * Optional. |
|
112 * |
|
113 * @return string URI that identifies the categorization scheme |
|
114 */ |
|
115 public function getScheme() |
|
116 { |
|
117 return $this->_scheme; |
|
118 } |
|
119 |
|
120 /** |
|
121 * @param string $value URI that identifies the categorization scheme |
|
122 * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface |
|
123 */ |
|
124 public function setScheme($value) |
|
125 { |
|
126 $this->_scheme = $value; |
|
127 return $this; |
|
128 } |
|
129 |
|
130 /** |
|
131 * @return string Human-readable label to be displayed in applications |
|
132 */ |
|
133 public function getLabel() |
|
134 { |
|
135 return $this->_label; |
|
136 } |
|
137 |
|
138 /** |
|
139 * @param string $value Human-readable label to be displayed in applications |
|
140 * @return Zend_Gdata_Media_Extension_MediaCategory Provides a fluent interface |
|
141 */ |
|
142 public function setLabel($value) |
|
143 { |
|
144 $this->_label = $value; |
|
145 return $this; |
|
146 } |
|
147 |
|
148 } |