|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Gdata |
|
17 * @subpackage Analytics |
|
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id$ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Gdata_Extension |
|
25 */ |
|
26 require_once 'Zend/Gdata/Extension.php'; |
|
27 |
|
28 /** |
|
29 * @category Zend |
|
30 * @package Zend_Gdata |
|
31 * @subpackage Analytics |
|
32 */ |
|
33 class Zend_Gdata_Analytics_Extension_Property extends Zend_Gdata_Extension |
|
34 { |
|
35 protected $_rootNamespace = 'ga'; |
|
36 protected $_rootElement = 'property'; |
|
37 protected $_value = null; |
|
38 protected $_name = null; |
|
39 |
|
40 /** |
|
41 * Constructs a new Zend_Gdata_Calendar_Extension_Timezone object. |
|
42 * @param string $value (optional) The text content of the element. |
|
43 */ |
|
44 public function __construct($value = null, $name = null) |
|
45 { |
|
46 $this->registerAllNamespaces(Zend_Gdata_Analytics::$namespaces); |
|
47 parent::__construct(); |
|
48 $this->_value = $value; |
|
49 $this->_name = $name; |
|
50 } |
|
51 |
|
52 /** |
|
53 * Given a DOMNode representing an attribute, tries to map the data into |
|
54 * instance members. If no mapping is defined, the name and value are |
|
55 * stored in an array. |
|
56 * |
|
57 * @param DOMNode $attribute The DOMNode attribute needed to be handled |
|
58 */ |
|
59 protected function takeAttributeFromDOM($attribute) |
|
60 { |
|
61 switch ($attribute->localName) { |
|
62 case 'name': |
|
63 $name = explode(':', $attribute->nodeValue); |
|
64 $this->_name = end($name); |
|
65 break; |
|
66 case 'value': |
|
67 $this->_value = $attribute->nodeValue; |
|
68 break; |
|
69 default: |
|
70 parent::takeAttributeFromDOM($attribute); |
|
71 } |
|
72 } |
|
73 |
|
74 /** |
|
75 * Get the value for this element's value attribute. |
|
76 * |
|
77 * @return string The value associated with this attribute. |
|
78 */ |
|
79 public function getValue() |
|
80 { |
|
81 return $this->_value; |
|
82 } |
|
83 |
|
84 /** |
|
85 * Set the value for this element's value attribute. |
|
86 * |
|
87 * @param string $value The desired value for this attribute. |
|
88 * @return Zend_Gdata_Analytics_Extension_Property The element being modified. |
|
89 */ |
|
90 public function setValue($value) |
|
91 { |
|
92 $this->_value = $value; |
|
93 return $this; |
|
94 } |
|
95 |
|
96 /** |
|
97 * @param string $name |
|
98 * @return Zend_Gdata_Analytics_Extension_Property |
|
99 */ |
|
100 public function setName($name) |
|
101 { |
|
102 $this->_name = $name; |
|
103 return $this; |
|
104 } |
|
105 |
|
106 /** |
|
107 * @return string |
|
108 */ |
|
109 public function getName() |
|
110 { |
|
111 return $this->_name; |
|
112 } |
|
113 |
|
114 /** |
|
115 * Magic toString method allows using this directly via echo |
|
116 * Works best in PHP >= 4.2.0 |
|
117 */ |
|
118 public function __toString() |
|
119 { |
|
120 return $this->getValue(); |
|
121 } |
|
122 } |