File indexing completed on 2024-05-26 06:03:03

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 Gdata
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  * @see Zend_Gdata_Extension_Reminder
0031  */
0032 // require_once 'Zend/Gdata/Extension/Reminder.php';
0033 
0034 /**
0035  * Represents the gd:when element
0036  *
0037  * @category   Zend
0038  * @package    Zend_Gdata
0039  * @subpackage Gdata
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_Extension_When extends Zend_Gdata_Extension
0044 {
0045 
0046     protected $_rootElement = 'when';
0047     protected $_reminders = array();
0048     protected $_startTime = null;
0049     protected $_valueString = null;
0050     protected $_endTime = null;
0051 
0052     public function __construct($startTime = null, $endTime = null,
0053             $valueString = null, $reminders = null)
0054     {
0055         parent::__construct();
0056         $this->_startTime = $startTime;
0057         $this->_endTime = $endTime;
0058         $this->_valueString = $valueString;
0059         $this->_reminders = $reminders;
0060     }
0061 
0062     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0063     {
0064         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0065         if ($this->_startTime !== null) {
0066             $element->setAttribute('startTime', $this->_startTime);
0067         }
0068         if ($this->_endTime !== null) {
0069             $element->setAttribute('endTime', $this->_endTime);
0070         }
0071         if ($this->_valueString !== null) {
0072             $element->setAttribute('valueString', $this->_valueString);
0073         }
0074         if ($this->_reminders !== null) {
0075             foreach ($this->_reminders as $reminder) {
0076                 $element->appendChild(
0077                         $reminder->getDOM($element->ownerDocument));
0078             }
0079         }
0080         return $element;
0081     }
0082 
0083     protected function takeChildFromDOM($child)
0084     {
0085         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
0086         switch ($absoluteNodeName) {
0087             case $this->lookupNamespace('gd') . ':' . 'reminder';
0088                 $reminder = new Zend_Gdata_Extension_Reminder();
0089                 $reminder->transferFromDOM($child);
0090                 $this->_reminders[] = $reminder;
0091                 break;
0092         default:
0093             parent::takeChildFromDOM($child);
0094             break;
0095         }
0096     }
0097 
0098     protected function takeAttributeFromDOM($attribute)
0099     {
0100         switch ($attribute->localName) {
0101             case 'startTime':
0102                 $this->_startTime = $attribute->nodeValue;
0103                 break;
0104             case 'endTime':
0105                 $this->_endTime = $attribute->nodeValue;
0106                 break;
0107             case 'valueString':
0108                 $this->_valueString = $attribute->nodeValue;
0109                 break;
0110             default:
0111                 parent::takeAttributeFromDOM($attribute);
0112         }
0113     }
0114 
0115     public function __toString()
0116     {
0117         if ($this->_valueString)
0118             return $this->_valueString;
0119         else {
0120             return 'Starts: ' . $this->getStartTime() . ' ' .
0121                    'Ends: ' .  $this->getEndTime();
0122         }
0123     }
0124 
0125     public function getStartTime()
0126     {
0127         return $this->_startTime;
0128     }
0129 
0130     public function setStartTime($value)
0131     {
0132         $this->_startTime = $value;
0133         return $this;
0134     }
0135 
0136     public function getEndTime()
0137     {
0138         return $this->_endTime;
0139     }
0140 
0141     public function setEndTime($value)
0142     {
0143         $this->_endTime = $value;
0144         return $this;
0145     }
0146 
0147     public function getValueString()
0148     {
0149         return $this->_valueString;
0150     }
0151 
0152     public function setValueString($value)
0153     {
0154         $this->_valueString = $value;
0155         return $this;
0156     }
0157 
0158     public function getReminders()
0159     {
0160         return $this->_reminders;
0161     }
0162 
0163     public function setReminders($value)
0164     {
0165         $this->_reminders = $value;
0166         return $this;
0167     }
0168 
0169 }