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.
18 * @subpackage Calendar
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_Extension
27 require_once 'Zend/Gdata/Extension.php';
30 * Represents the gCal:color element used by the Calendar data API
31 * to define the color of a calendar in the UI.
35 * @subpackage Calendar
36 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
37 * @license http://framework.zend.com/license/new-bsd New BSD License
39 class Zend_Gdata_Calendar_Extension_Color extends Zend_Gdata_Extension
42 protected $_rootNamespace = 'gCal';
43 protected $_rootElement = 'color';
44 protected $_value = null;
47 * Constructs a new Zend_Gdata_Calendar_Extension_Color object.
48 * @param string $value (optional) The text content of the element.
50 public function __construct($value = null)
52 $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces);
53 parent::__construct();
54 $this->_value = $value;
58 * Retrieves a DOMElement which corresponds to this element and all
59 * child properties. This is used to build an entry back into a DOM
60 * and eventually XML text for sending to the server upon updates, or
61 * for application storage/persistence.
63 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
64 * @return DOMElement The DOMElement representing this element and all
67 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
69 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
70 if ($this->_value != null) {
71 $element->setAttribute('value', $this->_value);
77 * Given a DOMNode representing an attribute, tries to map the data into
78 * instance members. If no mapping is defined, the name and value are
81 * @param DOMNode $attribute The DOMNode attribute needed to be handled
83 protected function takeAttributeFromDOM($attribute)
85 switch ($attribute->localName) {
87 $this->_value = $attribute->nodeValue;
90 parent::takeAttributeFromDOM($attribute);
95 * Get the value for this element's value attribute.
97 * @return string The value associated with this attribute.
99 public function getValue()
101 return $this->_value;
105 * Set the value for this element's value attribute.
107 * @param string $value The desired value for this attribute.
108 * @return Zend_Gdata_Calendar_Extension_Color The element being modified.
110 public function setValue($value)
112 $this->_value = $value;
117 * Magic toString method allows using this directly via echo
118 * Works best in PHP >= 4.2.0
120 public function __toString()
122 return $this->_value;