File indexing completed on 2025-03-02 05:29:27
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 Gapps 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: EmailList.php 20096 2010-01-06 02:05:09Z bkarwin $ 0022 */ 0023 0024 /** 0025 * @see Zend_Gdata_Extension 0026 */ 0027 // require_once 'Zend/Gdata/Extension.php'; 0028 0029 /** 0030 * @see Zend_Gdata_Gapps 0031 */ 0032 // require_once 'Zend/Gdata/Gapps.php'; 0033 0034 /** 0035 * Represents the apps:Property element used by the Apps data API. 0036 * 0037 * @category Zend 0038 * @package Zend_Gdata 0039 * @subpackage Gapps 0040 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0041 * @license http://framework.zend.com/license/new-bsd New BSD License 0042 */ 0043 class Zend_Gdata_Gapps_Extension_Property extends Zend_Gdata_Extension 0044 { 0045 0046 protected $_rootNamespace = 'apps'; 0047 protected $_rootElement = 'property'; 0048 0049 /** 0050 * The name of the property 0051 * 0052 * @var string 0053 */ 0054 protected $_name = null; 0055 0056 /** 0057 * The value of the property 0058 * @var string 0059 */ 0060 protected $_value = null; 0061 0062 /** 0063 * Constructs a new Zend_Gdata_Gapps_Extension_Property object. 0064 * 0065 * @param string $name The name of the property 0066 * @param string $value The value of the property 0067 */ 0068 public function __construct($name = null, $value = null) 0069 { 0070 $this->registerAllNamespaces(Zend_Gdata_Gapps::$namespaces); 0071 parent::__construct(); 0072 $this->_name = $name; 0073 $this->_value = $value; 0074 0075 } 0076 0077 0078 /** 0079 * Retrieves a DOMElement which corresponds to this element and all 0080 * child properties. This is used to build an entry back into a DOM 0081 * and eventually XML text for sending to the server upon updates, or 0082 * for application storage/persistence. 0083 * 0084 * @param DOMDocument $doc The DOMDocument used to construct DOMElements 0085 * @return DOMElement The DOMElement representing this element and all 0086 * child properties. 0087 */ 0088 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 0089 { 0090 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 0091 if ($this->_name !== null) { 0092 $element->setAttribute('name', $this->_name); 0093 } 0094 if ($this->_value !== null) { 0095 $element->setAttribute('value', $this->_value); 0096 } 0097 0098 return $element; 0099 0100 } 0101 0102 /** 0103 * Given a DOMNode representing an attribute, tries to map the data into 0104 * instance members. If no mapping is defined, the name and value are 0105 * stored in an array. 0106 * 0107 * @param DOMNode $attribute The DOMNode attribute needed to be handled 0108 */ 0109 protected function takeAttributeFromDOM($attribute) 0110 { 0111 switch ($attribute->localName) { 0112 case 'name': 0113 $this->_name = $attribute->nodeValue; 0114 break; 0115 case 'value': 0116 $this->_value = $attribute->nodeValue; 0117 break; 0118 default: 0119 parent::takeAttributeFromDOM($attribute); 0120 } 0121 } 0122 0123 /** 0124 * Get the value for this element's name attribute. 0125 * 0126 * @see setName 0127 * @return string The requested attribute. 0128 */ 0129 public function getName() 0130 { 0131 return $this->_name; 0132 } 0133 0134 /** 0135 * Set the value for this element's name attribute. 0136 * @param string $value The desired value for this attribute. 0137 * @return Zend_Gdata_Gapps_Extension_Property The element being modified. 0138 */ 0139 public function setName($value) 0140 { 0141 $this->_name = $value; 0142 return $this; 0143 } 0144 0145 /** 0146 * Get the value for this element's value attribute. 0147 * 0148 * @see setName 0149 * @return string The requested attribute. 0150 */ 0151 public function getValue() 0152 { 0153 return $this->_value; 0154 } 0155 0156 /** 0157 * Set the value for this element's value attribute. 0158 * 0159 * @param string $value The desired value for this attribute. 0160 * @return Zend_Gdata_Gapps_Extension_Property The element being modified. 0161 */ 0162 public function setValue($value) 0163 { 0164 $this->_value = $value; 0165 return $this; 0166 } 0167 0168 /** 0169 * Magic toString method allows using this directly via echo 0170 * Works best in PHP >= 4.2.0 0171 * 0172 * @return string 0173 */ 0174 public function __toString() 0175 { 0176 return "Property Name: " . $this->getName() . 0177 "\nProperty Value: " . $this->getValue(); 0178 } 0179 }