MediaCredit.php 4.9 KB

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