]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Gdata/Calendar/Extension/Color.php
Release 6.5.0
[Github/sugarcrm.git] / Zend / Gdata / Calendar / Extension / Color.php
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 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
21
22  */
23
24 /**
25  * @see Zend_Gdata_Extension
26  */
27 require_once 'Zend/Gdata/Extension.php';
28
29 /**
30  * Represents the gCal:color element used by the Calendar data API
31  * to define the color of a calendar in the UI.
32  *
33  * @category   Zend
34  * @package    Zend_Gdata
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
38  */
39 class Zend_Gdata_Calendar_Extension_Color extends Zend_Gdata_Extension
40 {
41
42     protected $_rootNamespace = 'gCal';
43     protected $_rootElement = 'color';
44     protected $_value = null;
45
46     /**
47      * Constructs a new Zend_Gdata_Calendar_Extension_Color object.
48      * @param string $value (optional) The text content of the element.
49      */
50     public function __construct($value = null)
51     {
52         $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces);
53         parent::__construct();
54         $this->_value = $value;
55     }
56
57     /**
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.
62      *
63      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
64      * @return DOMElement The DOMElement representing this element and all
65      * child properties.
66      */
67     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
68     {
69         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
70         if ($this->_value != null) {
71             $element->setAttribute('value', $this->_value);
72         }
73         return $element;
74     }
75
76     /**
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
79      * stored in an array.
80      *
81      * @param DOMNode $attribute The DOMNode attribute needed to be handled
82      */
83     protected function takeAttributeFromDOM($attribute)
84     {
85         switch ($attribute->localName) {
86         case 'value':
87             $this->_value = $attribute->nodeValue;
88             break;
89         default:
90             parent::takeAttributeFromDOM($attribute);
91         }
92     }
93
94     /**
95      * Get the value for this element's value attribute.
96      *
97      * @return string The value associated with this attribute.
98      */
99     public function getValue()
100     {
101         return $this->_value;
102     }
103
104     /**
105      * Set the value for this element's value attribute.
106      *
107      * @param string $value The desired value for this attribute.
108      * @return Zend_Gdata_Calendar_Extension_Color The element being modified.
109      */
110     public function setValue($value)
111     {
112         $this->_value = $value;
113         return $this;
114     }
115
116     /**
117      * Magic toString method allows using this directly via echo
118      * Works best in PHP >= 4.2.0
119      */
120     public function __toString()
121     {
122         return $this->_value;
123     }
124
125 }