]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - Zend/Gdata/YouTube/Extension/MediaCredit.php
Release 6.2.0
[Github/sugarcrm.git] / Zend / Gdata / YouTube / Extension / MediaCredit.php
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 Media
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
22  */
23
24 /**
25  * @see Zend_Gdata_App_Extension
26  */
27 require_once 'Zend/Gdata/App/Extension.php';
28
29 /**
30  * Represents the YouTube specific media:credit element
31  *
32  * @category   Zend
33  * @package    Zend_Gdata
34  * @subpackage Media
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_YouTube_Extension_MediaCredit extends Zend_Gdata_Extension
39 {
40
41     protected $_rootElement = 'credit';
42     protected $_rootNamespace = 'media';
43
44     /**
45      * @var string
46      */
47     protected $_role = null;
48
49     /**
50      * @var string
51      */
52     protected $_scheme = null;
53
54     /**
55      * Represents the value of the yt:type attribute.
56      *
57      * Set to 'partner' if the uploader of this video is a YouTube
58      * partner.
59      *
60      * @var string
61      */
62     protected $_yttype = null;
63
64     /**
65      * Creates an individual MediaCredit object.
66      *
67      * @param string $text
68      * @param string $role
69      * @param string $scheme
70      */
71     public function __construct($text = null, $role = null,  $scheme = null,
72         $yttype = null)
73     {
74         $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
75         parent::__construct();
76         $this->_text = $text;
77         $this->_role = $role;
78         $this->_scheme = $scheme;
79         $this->_yttype = $yttype;
80     }
81
82     /**
83      * Retrieves a DOMElement which corresponds to this element and all
84      * child properties.  This is used to build an entry back into a DOM
85      * and eventually XML text for sending to the server upon updates, or
86      * for application storage/persistence.
87      *
88      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
89      * @return DOMElement The DOMElement representing this element and all
90      * child properties.
91      */
92     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
93     {
94         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
95         if ($this->_role !== null) {
96             $element->setAttribute('role', $this->_role);
97         }
98         if ($this->_scheme !== null) {
99             $element->setAttribute('scheme', $this->_scheme);
100         }
101         if ($this->_yttype !== null) {
102             $element->setAttributeNS('http://gdata.youtube.com/schemas/2007',
103                 'yt:type', $this->_yttype);
104         }
105         return $element;
106     }
107
108     /**
109      * Given a DOMNode representing an attribute, tries to map the data into
110      * instance members.  If no mapping is defined, the name and value are
111      * stored in an array.
112      *
113      * @param DOMNode $attribute The DOMNode attribute needed to be handled
114      */
115     protected function takeAttributeFromDOM($attribute)
116     {
117         switch ($attribute->localName) {
118             case 'role':
119                 $this->_role = $attribute->nodeValue;
120                 break;
121             case 'scheme':
122                 $this->_scheme = $attribute->nodeValue;
123                 break;
124             case 'type':
125                 $this->_yttype = $attribute->nodeValue;
126                 break;
127             default:
128                 parent::takeAttributeFromDOM($attribute);
129         }
130     }
131
132     /**
133      * @return string
134      */
135     public function getRole()
136     {
137         return $this->_role;
138     }
139
140     /**
141      * @param string $value
142      * @return Zend_Gdata_Media_Extension_MediaCredit Provides a fluent
143      *         interface
144      */
145     public function setRole($value)
146     {
147         $this->_role = $value;
148         return $this;
149     }
150
151     /**
152      * @return string
153      */
154     public function getScheme()
155     {
156         return $this->_scheme;
157     }
158
159     /**
160      * @param string $value
161      * @return Zend_Gdata_Media_Extension_MediaCredit Provides a fluent
162      *         interface
163      */
164     public function setScheme($value)
165     {
166         $this->_scheme = $value;
167         return $this;
168     }
169
170     /**
171      * @return string
172      */
173     public function getYTtype()
174     {
175         return $this->_yttype;
176     }
177
178     /**
179      * @param string $value
180      * @return Zend_Gdata_Media_Extension_MediaCredit Provides a fluent
181      *         interface
182      */
183     public function setYTtype($value)
184     {
185         $this->_yttype = $value;
186         return $this;
187     }
188
189 }