File indexing completed on 2025-03-02 05:29:26
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage Calendar 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 /** 0025 * @see Zend_Gdata_Extension 0026 */ 0027 // require_once 'Zend/Gdata/Extension.php'; 0028 0029 /** 0030 * Represents the gCal:color element used by the Calendar data API 0031 * to define the color of a calendar in the UI. 0032 * 0033 * @category Zend 0034 * @package Zend_Gdata 0035 * @subpackage Calendar 0036 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0037 * @license http://framework.zend.com/license/new-bsd New BSD License 0038 */ 0039 class Zend_Gdata_Calendar_Extension_Color extends Zend_Gdata_Extension 0040 { 0041 0042 protected $_rootNamespace = 'gCal'; 0043 protected $_rootElement = 'color'; 0044 protected $_value = null; 0045 0046 /** 0047 * Constructs a new Zend_Gdata_Calendar_Extension_Color object. 0048 * @param string $value (optional) The text content of the element. 0049 */ 0050 public function __construct($value = null) 0051 { 0052 $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces); 0053 parent::__construct(); 0054 $this->_value = $value; 0055 } 0056 0057 /** 0058 * Retrieves a DOMElement which corresponds to this element and all 0059 * child properties. This is used to build an entry back into a DOM 0060 * and eventually XML text for sending to the server upon updates, or 0061 * for application storage/persistence. 0062 * 0063 * @param DOMDocument $doc The DOMDocument used to construct DOMElements 0064 * @return DOMElement The DOMElement representing this element and all 0065 * child properties. 0066 */ 0067 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 0068 { 0069 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 0070 if ($this->_value != null) { 0071 $element->setAttribute('value', $this->_value); 0072 } 0073 return $element; 0074 } 0075 0076 /** 0077 * Given a DOMNode representing an attribute, tries to map the data into 0078 * instance members. If no mapping is defined, the name and value are 0079 * stored in an array. 0080 * 0081 * @param DOMNode $attribute The DOMNode attribute needed to be handled 0082 */ 0083 protected function takeAttributeFromDOM($attribute) 0084 { 0085 switch ($attribute->localName) { 0086 case 'value': 0087 $this->_value = $attribute->nodeValue; 0088 break; 0089 default: 0090 parent::takeAttributeFromDOM($attribute); 0091 } 0092 } 0093 0094 /** 0095 * Get the value for this element's value attribute. 0096 * 0097 * @return string The value associated with this attribute. 0098 */ 0099 public function getValue() 0100 { 0101 return $this->_value; 0102 } 0103 0104 /** 0105 * Set the value for this element's value attribute. 0106 * 0107 * @param string $value The desired value for this attribute. 0108 * @return Zend_Gdata_Calendar_Extension_Color The element being modified. 0109 */ 0110 public function setValue($value) 0111 { 0112 $this->_value = $value; 0113 return $this; 0114 } 0115 0116 /** 0117 * Magic toString method allows using this directly via echo 0118 * Works best in PHP >= 4.2.0 0119 */ 0120 public function __toString() 0121 { 0122 return $this->_value; 0123 } 0124 0125 }