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