[44] | 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-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
| 20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | /**
|
---|
| 24 | * @see Zend_Gdata_Extension
|
---|
| 25 | */
|
---|
| 26 | require_once 'Zend/Gdata/Extension.php';
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * Data model class to represent an entry's sendEventNotifications
|
---|
| 30 | *
|
---|
| 31 | * @category Zend
|
---|
| 32 | * @package Zend_Gdata
|
---|
| 33 | * @subpackage Calendar
|
---|
| 34 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
| 35 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
| 36 | */
|
---|
| 37 | class Zend_Gdata_Calendar_Extension_SendEventNotifications extends Zend_Gdata_Extension
|
---|
| 38 | {
|
---|
| 39 | protected $_rootNamespace = 'gCal';
|
---|
| 40 | protected $_rootElement = 'sendEventNotifications';
|
---|
| 41 | protected $_value = null;
|
---|
| 42 |
|
---|
| 43 | /**
|
---|
| 44 | * Constructs a new Zend_Gdata_Extension_SendEventNotifications object.
|
---|
| 45 | * @param bool $value (optional) SendEventNotifications value as URI.
|
---|
| 46 | */
|
---|
| 47 | public function __construct($value = null)
|
---|
| 48 | {
|
---|
| 49 | $this->registerAllNamespaces(Zend_Gdata_Calendar::$namespaces);
|
---|
| 50 | parent::__construct();
|
---|
| 51 | $this->_value = $value;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | /**
|
---|
| 55 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
| 56 | * child properties. This is used to build an entry back into a DOM
|
---|
| 57 | * and eventually XML text for sending to the server upon updates, or
|
---|
| 58 | * for application storage/persistence.
|
---|
| 59 | *
|
---|
| 60 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
| 61 | * @return DOMElement The DOMElement representing this element and all
|
---|
| 62 | * child properties.
|
---|
| 63 | */
|
---|
| 64 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
| 65 | {
|
---|
| 66 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
| 67 | if ($this->_value !== null) {
|
---|
| 68 | $element->setAttribute('value', ($this->_value ? "true" : "false"));
|
---|
| 69 | }
|
---|
| 70 | return $element;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | /**
|
---|
| 74 | * Given a DOMNode representing an attribute, tries to map the data into
|
---|
| 75 | * instance members. If no mapping is defined, the name and value are
|
---|
| 76 | * stored in an array.
|
---|
| 77 | *
|
---|
| 78 | * @param DOMNode $attribute The DOMNode attribute needed to be handled
|
---|
| 79 | */
|
---|
| 80 | protected function takeAttributeFromDOM($attribute)
|
---|
| 81 | {
|
---|
| 82 | switch ($attribute->localName) {
|
---|
| 83 | case 'value':
|
---|
| 84 | if ($attribute->nodeValue == "true") {
|
---|
| 85 | $this->_value = true;
|
---|
| 86 | }
|
---|
| 87 | else if ($attribute->nodeValue == "false") {
|
---|
| 88 | $this->_value = false;
|
---|
| 89 | }
|
---|
| 90 | else {
|
---|
| 91 | throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
|
---|
| 92 | }
|
---|
| 93 | break;
|
---|
| 94 | default:
|
---|
| 95 | parent::takeAttributeFromDOM($attribute);
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /**
|
---|
| 100 | * Get the value for this element's Value attribute.
|
---|
| 101 | *
|
---|
| 102 | * @return string The requested attribute.
|
---|
| 103 | */
|
---|
| 104 | public function getValue()
|
---|
| 105 | {
|
---|
| 106 | return $this->_value;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | /**
|
---|
| 110 | * Set the value for this element's Value attribute.
|
---|
| 111 | *
|
---|
| 112 | * @param string $value The desired value for this attribute.
|
---|
| 113 | * @return Zend_Gdata_Extension_SendEventNotifications The element being modified.
|
---|
| 114 | */
|
---|
| 115 | public function setValue($value)
|
---|
| 116 | {
|
---|
| 117 | $this->_value = $value;
|
---|
| 118 | return $this;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | /**
|
---|
| 122 | * Magic toString method allows using this directly via echo
|
---|
| 123 | * Works best in PHP >= 4.2.0
|
---|
| 124 | */
|
---|
| 125 | public function __toString()
|
---|
| 126 | {
|
---|
| 127 | return $this->getValue();
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | }
|
---|
| 131 |
|
---|