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 Gapps |
---|
19 | * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License |
---|
21 | * @version $Id: EmailList.php 20096 2010-01-06 02:05:09Z bkarwin $ |
---|
22 | */ |
---|
23 | |
---|
24 | /** |
---|
25 | * @see Zend_Gdata_Extension |
---|
26 | */ |
---|
27 | require_once 'Zend/Gdata/Extension.php'; |
---|
28 | |
---|
29 | /** |
---|
30 | * @see Zend_Gdata_Gapps |
---|
31 | */ |
---|
32 | require_once 'Zend/Gdata/Gapps.php'; |
---|
33 | |
---|
34 | /** |
---|
35 | * Represents the apps:Property element used by the Apps data API. |
---|
36 | * |
---|
37 | * @category Zend |
---|
38 | * @package Zend_Gdata |
---|
39 | * @subpackage Gapps |
---|
40 | * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
---|
41 | * @license http://framework.zend.com/license/new-bsd New BSD License |
---|
42 | */ |
---|
43 | class Zend_Gdata_Gapps_Extension_Property extends Zend_Gdata_Extension |
---|
44 | { |
---|
45 | |
---|
46 | protected $_rootNamespace = 'apps'; |
---|
47 | protected $_rootElement = 'property'; |
---|
48 | |
---|
49 | /** |
---|
50 | * The name of the property |
---|
51 | * |
---|
52 | * @var string |
---|
53 | */ |
---|
54 | protected $_name = null; |
---|
55 | |
---|
56 | /** |
---|
57 | * The value of the property |
---|
58 | * @var string |
---|
59 | */ |
---|
60 | protected $_value = null; |
---|
61 | |
---|
62 | /** |
---|
63 | * Constructs a new Zend_Gdata_Gapps_Extension_Property object. |
---|
64 | * |
---|
65 | * @param string $name The name of the property |
---|
66 | * @param string $value The value of the property |
---|
67 | */ |
---|
68 | public function __construct($name = null, $value = null) |
---|
69 | { |
---|
70 | $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); |
---|
71 | parent::__construct(); |
---|
72 | $this->_name = $name; |
---|
73 | $this->_value = $value; |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | /** |
---|
79 | * Retrieves a DOMElement which corresponds to this element and all |
---|
80 | * child properties. This is used to build an entry back into a DOM |
---|
81 | * and eventually XML text for sending to the server upon updates, or |
---|
82 | * for application storage/persistence. |
---|
83 | * |
---|
84 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements |
---|
85 | * @return DOMElement The DOMElement representing this element and all |
---|
86 | * child properties. |
---|
87 | */ |
---|
88 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) |
---|
89 | { |
---|
90 | $element = parent::getDOM($doc, $majorVersion, $minorVersion); |
---|
91 | if ($this->_name !== null) { |
---|
92 | $element->setAttribute('name', $this->_name); |
---|
93 | } |
---|
94 | if ($this->_value !== null) { |
---|
95 | $element->setAttribute('value', $this->_value); |
---|
96 | } |
---|
97 | |
---|
98 | return $element; |
---|
99 | |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * Given a DOMNode representing an attribute, tries to map the data into |
---|
104 | * instance members. If no mapping is defined, the name and value are |
---|
105 | * stored in an array. |
---|
106 | * |
---|
107 | * @param DOMNode $attribute The DOMNode attribute needed to be handled |
---|
108 | */ |
---|
109 | protected function takeAttributeFromDOM($attribute) |
---|
110 | { |
---|
111 | switch ($attribute->localName) { |
---|
112 | case 'name': |
---|
113 | $this->_name = $attribute->nodeValue; |
---|
114 | break; |
---|
115 | case 'value': |
---|
116 | $this->_value = $attribute->nodeValue; |
---|
117 | break; |
---|
118 | default: |
---|
119 | parent::takeAttributeFromDOM($attribute); |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | /** |
---|
124 | * Get the value for this element's name attribute. |
---|
125 | * |
---|
126 | * @see setName |
---|
127 | * @return string The requested attribute. |
---|
128 | */ |
---|
129 | public function getName() |
---|
130 | { |
---|
131 | return $this->_name; |
---|
132 | } |
---|
133 | |
---|
134 | /** |
---|
135 | * Set the value for this element's name attribute. |
---|
136 | * @param string $value The desired value for this attribute. |
---|
137 | * @return Zend_Gdata_Gapps_Extension_Property The element being modified. |
---|
138 | */ |
---|
139 | public function setName($value) |
---|
140 | { |
---|
141 | $this->_name = $value; |
---|
142 | return $this; |
---|
143 | } |
---|
144 | |
---|
145 | /** |
---|
146 | * Get the value for this element's value attribute. |
---|
147 | * |
---|
148 | * @see setName |
---|
149 | * @return string The requested attribute. |
---|
150 | */ |
---|
151 | public function getValue() |
---|
152 | { |
---|
153 | return $this->_value; |
---|
154 | } |
---|
155 | |
---|
156 | /** |
---|
157 | * Set the value for this element's value attribute. |
---|
158 | * |
---|
159 | * @param string $value The desired value for this attribute. |
---|
160 | * @return Zend_Gdata_Gapps_Extension_Property The element being modified. |
---|
161 | */ |
---|
162 | public function setValue($value) |
---|
163 | { |
---|
164 | $this->_value = $value; |
---|
165 | return $this; |
---|
166 | } |
---|
167 | |
---|
168 | /** |
---|
169 | * Magic toString method allows using this directly via echo |
---|
170 | * Works best in PHP >= 4.2.0 |
---|
171 | * |
---|
172 | * @return string |
---|
173 | */ |
---|
174 | public function __toString() |
---|
175 | { |
---|
176 | return "Property Name: " . $this->getName() . |
---|
177 | "\nProperty Value: " . $this->getValue(); |
---|
178 | } |
---|
179 | } |
---|