1 | <?php
|
---|
2 | /**
|
---|
3 | * Zend Framework
|
---|
4 | *
|
---|
5 | * LICENSE
|
---|
6 | *
|
---|
7 | * This source file is subject to the new BSD license that is bundled
|
---|
8 | * with this package in the file LICENSE.txt.
|
---|
9 | * It is also available through the world-wide-web at this URL:
|
---|
10 | * http://framework.zend.com/license/new-bsd
|
---|
11 | * If you did not receive a copy of the license and are unable to
|
---|
12 | * obtain it through the world-wide-web, please send an email
|
---|
13 | * to license@zend.com so we can send you a copy immediately.
|
---|
14 | *
|
---|
15 | * @category Zend
|
---|
16 | * @package Zend_Gdata
|
---|
17 | * @subpackage YouTube
|
---|
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_App_Extension_Control
|
---|
24 | */
|
---|
25 | require_once 'Zend/Gdata/App/Extension/Control.php';
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * @see Zend_Gdata_YouTube_Extension_State
|
---|
29 | */
|
---|
30 | require_once 'Zend/Gdata/YouTube/Extension/State.php';
|
---|
31 |
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Specialized Control class for use with YouTube. Enables use of yt extension elements.
|
---|
35 | *
|
---|
36 | * @category Zend
|
---|
37 | * @package Zend_Gdata
|
---|
38 | * @subpackage YouTube
|
---|
39 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
40 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
41 | */
|
---|
42 | class Zend_Gdata_YouTube_Extension_Control extends Zend_Gdata_App_Extension_Control
|
---|
43 | {
|
---|
44 |
|
---|
45 | protected $_state = null;
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Constructs a new Zend_Gdata_Calendar_Extension_Control object.
|
---|
49 | * @see Zend_Gdata_App_Extension_Control#__construct
|
---|
50 | * @param Zend_Gdata_App_Extension_Draft $draft
|
---|
51 | * @param Zend_Gdata_YouTube_Extension_State $state
|
---|
52 | */
|
---|
53 | public function __construct($draft = null, $state = null)
|
---|
54 | {
|
---|
55 | $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
|
---|
56 | parent::__construct($draft);
|
---|
57 | $this->_state = $state;
|
---|
58 | }
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
62 | * child properties. This is used to build an entry back into a DOM
|
---|
63 | * and eventually XML text for sending to the server upon updates, or
|
---|
64 | * for application storage/persistence.
|
---|
65 | *
|
---|
66 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
67 | * @return DOMElement The DOMElement representing this element and all
|
---|
68 | * child properties.
|
---|
69 | */
|
---|
70 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
71 | {
|
---|
72 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
73 | if ($this->_state != null) {
|
---|
74 | $element->appendChild($this->_state->getDOM($element->ownerDocument));
|
---|
75 | }
|
---|
76 | return $element;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Creates individual Entry objects of the appropriate type and
|
---|
81 | * stores them as members of this entry based upon DOM data.
|
---|
82 | *
|
---|
83 | * @param DOMNode $child The DOMNode to process
|
---|
84 | */
|
---|
85 | protected function takeChildFromDOM($child)
|
---|
86 | {
|
---|
87 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
|
---|
88 | switch ($absoluteNodeName) {
|
---|
89 | case $this->lookupNamespace('yt') . ':' . 'state':
|
---|
90 | $state = new Zend_Gdata_YouTube_Extension_State();
|
---|
91 | $state->transferFromDOM($child);
|
---|
92 | $this->_state = $state;
|
---|
93 | break;
|
---|
94 | default:
|
---|
95 | parent::takeChildFromDOM($child);
|
---|
96 | break;
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Get the value for this element's state attribute.
|
---|
102 | *
|
---|
103 | * @return Zend_Gdata_YouTube_Extension_State The state element.
|
---|
104 | */
|
---|
105 | public function getState()
|
---|
106 | {
|
---|
107 | return $this->_state;
|
---|
108 | }
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * Set the value for this element's state attribute.
|
---|
112 | *
|
---|
113 | * @param Zend_Gdata_YouTube_Extension_State $value The desired value for this attribute.
|
---|
114 | * @return Zend_YouTube_Extension_Control The element being modified.
|
---|
115 | */
|
---|
116 | public function setState($value)
|
---|
117 | {
|
---|
118 | $this->_state = $value;
|
---|
119 | return $this;
|
---|
120 | }
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Get the value of this element's state attribute.
|
---|
124 | *
|
---|
125 | * @return string The state's text value
|
---|
126 | */
|
---|
127 | public function getStateValue()
|
---|
128 | {
|
---|
129 | return $this->getState()->getText();
|
---|
130 | }
|
---|
131 |
|
---|
132 | }
|
---|