*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Gdata / YouTube / Extension / State.php
blobe8886a131681fbfbf47b66b6043d49af4ac4d05e
1 <?php
3 /**
4 * Zend Framework
6 * LICENSE
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.
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage YouTube
19 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id: State.php 16971 2009-07-22 18:05:45Z mikaelkael $
24 /**
25 * @see Zend_Gdata_Extension
27 require_once 'Zend/Gdata/Extension.php';
29 /**
30 * Represents the yt:state element used by the YouTube data API
32 * @category Zend
33 * @package Zend_Gdata
34 * @subpackage YouTube
35 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
38 class Zend_Gdata_YouTube_Extension_State extends Zend_Gdata_Extension
41 protected $_rootNamespace = 'yt';
42 protected $_rootElement = 'state';
43 protected $_name = null;
44 protected $_reasonCode = null;
45 protected $_helpUrl = null;
47 /**
48 * Constructs a new Zend_Gdata_YouTube_Extension_State object.
50 * @param string $explanation(optional) The explanation of this state
51 * @param string $name(optional) The name value
52 * @param string $reasonCode(optional) The reasonCode value
53 * @param string $helpUrl(optional) The helpUrl value
55 public function __construct($explanation = null, $name = null,
56 $reasonCode = null, $helpUrl = null)
58 $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
59 parent::__construct();
60 $this->_text = $explanation;
61 $this->_name = $name;
62 $this->_reasonCode = $reasonCode;
63 $this->_helpUrl = $reasonCode;
66 /**
67 * Retrieves a DOMElement which corresponds to this element and all
68 * child properties. This is used to build an entry back into a DOM
69 * and eventually XML text for sending to the server upon updates, or
70 * for application storage/persistence.
72 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
73 * @return DOMElement The DOMElement representing this element and all
74 * child properties.
76 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
78 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
79 if ($this->_name !== null) {
80 $element->setAttribute('name', $this->_name);
82 if ($this->_reasonCode !== null) {
83 $element->setAttribute('reasonCode', $this->_reasonCode);
85 if ($this->_helpUrl !== null) {
86 $element->setAttribute('helpUrl', $this->_helpUrl);
88 return $element;
91 /**
92 * Given a DOMNode representing an attribute, tries to map the data into
93 * instance members. If no mapping is defined, the name and valueare
94 * stored in an array.
95 * TODO: Convert attributes to proper types
97 * @param DOMNode $attribute The DOMNode attribute needed to be handled
99 protected function takeAttributeFromDOM($attribute)
101 switch ($attribute->localName) {
102 case 'name':
103 $this->_name = $attribute->nodeValue;
104 break;
105 case 'reasonCode':
106 $this->_reasonCode = $attribute->nodeValue;
107 break;
108 case 'helpUrl':
109 $this->_helpUrl = $attribute->nodeValue;
110 break;
111 default:
112 parent::takeAttributeFromDOM($attribute);
117 * Get the value for this element's name attribute.
119 * @return int The value associated with this attribute.
121 public function getName()
123 return $this->_name;
127 * Set the value for this element's name attribute.
129 * @param int $value The desired value for this attribute.
130 * @return Zend_Gdata_YouTube_Extension_State The element being modified.
132 public function setName($value)
134 $this->_name = $value;
135 return $this;
139 * Get the value for this element's reasonCode attribute.
141 * @return int The value associated with this attribute.
143 public function getReasonCode()
145 return $this->_reasonCode;
149 * Set the value for this element's reasonCode attribute.
151 * @param int $value The desired value for this attribute.
152 * @return Zend_Gdata_YouTube_Extension_State The element being modified.
154 public function setReasonCode($value)
156 $this->_reasonCode = $value;
157 return $this;
161 * Get the value for this element's helpUrl attribute.
163 * @return int The value associated with this attribute.
165 public function getHelpUrl()
167 return $this->_helpUrl;
171 * Set the value for this element's helpUrl attribute.
173 * @param int $value The desired value for this attribute.
174 * @return Zend_Gdata_YouTube_Extension_State The element being modified.
176 public function setHelpUrl($value)
178 $this->_helpUrl = $value;
179 return $this;
183 * Magic toString method allows using this directly via echo
184 * Works best in PHP >= 4.2.0
186 * @return string
188 public function __toString()
190 return $this->_text;