MediaCredit.php 4.9 KB

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