File indexing completed on 2024-06-23 05:55:21

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:accessLevel element used by the Calendar data API
0031  *
0032  * @category   Zend
0033  * @package    Zend_Gdata
0034  * @subpackage Calendar
0035  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0036  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0037  */
0038 class Zend_Gdata_Calendar_Extension_AccessLevel extends Zend_Gdata_Extension
0039 {
0040 
0041     protected $_rootNamespace = 'gCal';
0042     protected $_rootElement = 'accesslevel';
0043     protected $_value = null;
0044 
0045     /**
0046      * Constructs a new Zend_Gdata_Calendar_Extension_AccessLevel object.
0047      * @param string $value (optional) The text content of the element.
0048      */
0049     public function __construct($value = null)
0050     {
0051         $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces);
0052         parent::__construct();
0053         $this->_value = $value;
0054     }
0055 
0056     /**
0057      * Retrieves a DOMElement which corresponds to this element and all
0058      * child properties.  This is used to build an entry back into a DOM
0059      * and eventually XML text for sending to the server upon updates, or
0060      * for application storage/persistence.
0061      *
0062      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0063      * @return DOMElement The DOMElement representing this element and all
0064      * child properties.
0065      */
0066     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0067     {
0068         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0069         if ($this->_value != null) {
0070             $element->setAttribute('value', $this->_value);
0071         }
0072         return $element;
0073     }
0074 
0075     /**
0076      * Given a DOMNode representing an attribute, tries to map the data into
0077      * instance members.  If no mapping is defined, the name and value are
0078      * stored in an array.
0079      *
0080      * @param DOMNode $attribute The DOMNode attribute needed to be handled
0081      */
0082     protected function takeAttributeFromDOM($attribute)
0083     {
0084         switch ($attribute->localName) {
0085         case 'value':
0086             $this->_value = $attribute->nodeValue;
0087             break;
0088         default:
0089             parent::takeAttributeFromDOM($attribute);
0090         }
0091     }
0092 
0093     /**
0094      * Get the value for this element's value attribute.
0095      *
0096      * @return string The attribute being modified.
0097      */
0098     public function getValue()
0099     {
0100         return $this->_value;
0101     }
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_Selected 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->getValue();
0123     }
0124 
0125 }