~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/Calendar/Extension/Timezone.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
20
 */
 
21
 
 
22
/**
 
23
 * @see Zend_Gdata_Extension
 
24
 */
 
25
require_once 'Zend/Gdata/Extension.php';
 
26
 
 
27
/**
 
28
 * Represents the gCal:timezone element used by the Calendar data API
 
29
 *
 
30
 * @category   Zend
 
31
 * @package    Zend_Gdata
 
32
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
33
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
34
 */
 
35
class Zend_Gdata_Calendar_Extension_Timezone extends Zend_Gdata_Extension
 
36
{
 
37
 
 
38
    protected $_rootNamespace = 'gCal';
 
39
    protected $_rootElement = 'timezone';
 
40
    protected $_value = null;
 
41
 
 
42
    /**
 
43
     * Constructs a new Zend_Gdata_Calendar_Extension_Timezone object.
 
44
     * @param string $value (optional) The text content of the element.
 
45
     */
 
46
    public function __construct($value = null)
 
47
    {
 
48
        foreach (Zend_Gdata_Calendar::$namespaces as $nsPrefix => $nsUri) {
 
49
            $this->registerNamespace($nsPrefix, $nsUri);
 
50
        }
 
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);
 
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
            $this->_value = $attribute->nodeValue;
 
86
            break;
 
87
        default:
 
88
            parent::takeAttributeFromDOM($attribute);
 
89
        }
 
90
    }
 
91
 
 
92
    /**
 
93
     * Get the value for this element's value attribute.
 
94
     *
 
95
     * @return string The value associated with this attribute.
 
96
     */
 
97
    public function getValue()
 
98
    {
 
99
        return $this->_value;
 
100
    }
 
101
 
 
102
    /**
 
103
     * Set the value for this element's value attribute.
 
104
     *
 
105
     * @param string $value The desired value for this attribute.
 
106
     * @return Zend_Gdata_Calendar_Extension_Timezone The element being modified.
 
107
     */
 
108
    public function setValue($value)
 
109
    {
 
110
        $this->_value = $value;
 
111
        return $this;
 
112
    }
 
113
 
 
114
    /**
 
115
     * Magic toString method allows using this directly via echo
 
116
     * Works best in PHP >= 4.2.0
 
117
     */
 
118
    public function __toString()
 
119
    {
 
120
        return $this->getValue();
 
121
    }
 
122
 
 
123
}