/library/Zend/Gdata/YouTube/InboxEntry.php

https://bitbucket.org/hamidrezas/melobit · PHP · 281 lines · 119 code · 26 blank · 136 comment · 15 complexity · 2c70ff169b143fc005ea00d252280402 MD5 · raw file

  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-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: InboxEntry.php 24594 2012-01-05 21:27:01Z matthew $
  21. */
  22. /**
  23. * @see Zend_Gdata_Media_Entry
  24. */
  25. require_once 'Zend/Gdata/Media/Entry.php';
  26. /**
  27. * @see Zend_Gdata_Extension_Rating
  28. */
  29. require_once 'Zend/Gdata/Extension/Rating.php';
  30. /**
  31. * @see Zend_Gdata_Extension_Comments
  32. */
  33. require_once 'Zend/Gdata/Extension/Comments.php';
  34. /**
  35. * @see Zend_Gdata_YouTube_Extension_Statistics
  36. */
  37. require_once 'Zend/Gdata/YouTube/Extension/Statistics.php';
  38. /**
  39. * @see Zend_Gdata_YouTube_Extension_Description
  40. */
  41. require_once 'Zend/Gdata/YouTube/Extension/Description.php';
  42. /**
  43. * Represents the YouTube message flavor of an Atom entry
  44. *
  45. * @category Zend
  46. * @package Zend_Gdata
  47. * @subpackage YouTube
  48. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  49. * @license http://framework.zend.com/license/new-bsd New BSD License
  50. */
  51. class Zend_Gdata_YouTube_InboxEntry extends Zend_Gdata_Media_Entry
  52. {
  53. protected $_entryClassName = 'Zend_Gdata_YouTube_InboxEntry';
  54. /**
  55. * The gd:comments element of this entry.
  56. *
  57. * @var Zend_Gdata_Extension_Comments
  58. */
  59. protected $_comments = null;
  60. /**
  61. * The gd:rating element of this entry.
  62. *
  63. * @var Zend_Gdata_Extension_Rating
  64. */
  65. protected $_rating = null;
  66. /**
  67. * The yt:statistics element of this entry.
  68. *
  69. * @var Zend_Gdata_YouTube_Extension_Statistics
  70. */
  71. protected $_statistics = null;
  72. /**
  73. * The yt:description element of this entry.
  74. *
  75. * @var Zend_Gdata_YouTube_Extension_Description
  76. */
  77. protected $_description = null;
  78. /**
  79. * Creates a subscription entry, representing an individual subscription
  80. * in a list of subscriptions, usually associated with an individual user.
  81. *
  82. * @param DOMElement $element (optional) DOMElement from which this
  83. * object should be constructed.
  84. */
  85. public function __construct($element = null)
  86. {
  87. $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
  88. parent::__construct($element);
  89. }
  90. /**
  91. * Retrieves a DOMElement which corresponds to this element and all
  92. * child properties. This is used to build an entry back into a DOM
  93. * and eventually XML text for sending to the server upon updates, or
  94. * for application storage/persistence.
  95. *
  96. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  97. * @return DOMElement The DOMElement representing this element and all
  98. * child properties.
  99. */
  100. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  101. {
  102. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  103. if ($this->_description != null) {
  104. $element->appendChild(
  105. $this->_description->getDOM($element->ownerDocument));
  106. }
  107. if ($this->_rating != null) {
  108. $element->appendChild(
  109. $this->_rating->getDOM($element->ownerDocument));
  110. }
  111. if ($this->_statistics != null) {
  112. $element->appendChild(
  113. $this->_statistics->getDOM($element->ownerDocument));
  114. }
  115. if ($this->_comments != null) {
  116. $element->appendChild(
  117. $this->_comments->getDOM($element->ownerDocument));
  118. }
  119. return $element;
  120. }
  121. /**
  122. * Creates individual Entry objects of the appropriate type and
  123. * stores them in the $_entry array based upon DOM data.
  124. *
  125. * @param DOMNode $child The DOMNode to process
  126. */
  127. protected function takeChildFromDOM($child)
  128. {
  129. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  130. switch ($absoluteNodeName) {
  131. case $this->lookupNamespace('gd') . ':' . 'comments':
  132. $comments = new Zend_Gdata_Extension_Comments();
  133. $comments->transferFromDOM($child);
  134. $this->_comments = $comments;
  135. break;
  136. case $this->lookupNamespace('gd') . ':' . 'rating':
  137. $rating = new Zend_Gdata_Extension_Rating();
  138. $rating->transferFromDOM($child);
  139. $this->_rating = $rating;
  140. break;
  141. case $this->lookupNamespace('yt') . ':' . 'description':
  142. $description = new Zend_Gdata_YouTube_Extension_Description();
  143. $description->transferFromDOM($child);
  144. $this->_description = $description;
  145. break;
  146. case $this->lookupNamespace('yt') . ':' . 'statistics':
  147. $statistics = new Zend_Gdata_YouTube_Extension_Statistics();
  148. $statistics->transferFromDOM($child);
  149. $this->_statistics = $statistics;
  150. break;
  151. default:
  152. parent::takeChildFromDOM($child);
  153. break;
  154. }
  155. }
  156. /**
  157. * Get the yt:description
  158. *
  159. * @throws Zend_Gdata_App_VersionException
  160. * @return Zend_Gdata_YouTube_Extension_Description|null
  161. */
  162. public function getDescription()
  163. {
  164. if ($this->getMajorProtocolVersion() == 2) {
  165. require_once 'Zend/Gdata/App/VersionException.php';
  166. throw new Zend_Gdata_App_VersionException('The getDescription ' .
  167. ' method is only supported in version 1 of the YouTube ' .
  168. 'API.');
  169. } else {
  170. return $this->_description;
  171. }
  172. }
  173. /**
  174. * Sets the yt:description element for a new inbox entry.
  175. *
  176. * @param Zend_Gdata_YouTube_Extension_Description $description The
  177. * description.
  178. * @throws Zend_Gdata_App_VersionException
  179. * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
  180. */
  181. public function setDescription($description = null)
  182. {
  183. if ($this->getMajorProtocolVersion() == 2) {
  184. require_once 'Zend/Gdata/App/VersionException.php';
  185. throw new Zend_Gdata_App_VersionException('The setDescription ' .
  186. ' method is only supported in version 1 of the YouTube ' .
  187. 'API.');
  188. } else {
  189. $this->_description = $description;
  190. return $this;
  191. }
  192. }
  193. /**
  194. * Get the gd:rating element for the inbox entry
  195. *
  196. * @return Zend_Gdata_Extension_Rating|null
  197. */
  198. public function getRating()
  199. {
  200. return $this->_rating;
  201. }
  202. /**
  203. * Sets the gd:rating element for the inbox entry
  204. *
  205. * @param Zend_Gdata_Extension_Rating $rating The rating for the video in
  206. * the message
  207. * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
  208. */
  209. public function setRating($rating = null)
  210. {
  211. $this->_rating = $rating;
  212. return $this;
  213. }
  214. /**
  215. * Get the gd:comments element of the inbox entry.
  216. *
  217. * @return Zend_Gdata_Extension_Comments|null
  218. */
  219. public function getComments()
  220. {
  221. return $this->_comments;
  222. }
  223. /**
  224. * Sets the gd:comments element for the inbox entry
  225. *
  226. * @param Zend_Gdata_Extension_Comments $comments The comments feed link
  227. * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
  228. */
  229. public function setComments($comments = null)
  230. {
  231. $this->_comments = $comments;
  232. return $this;
  233. }
  234. /**
  235. * Get the yt:statistics element for the inbox entry
  236. *
  237. * @return Zend_Gdata_YouTube_Extension_Statistics|null
  238. */
  239. public function getStatistics()
  240. {
  241. return $this->_statistics;
  242. }
  243. /**
  244. * Sets the yt:statistics element for the inbox entry
  245. *
  246. * @param Zend_Gdata_YouTube_Extension_Statistics $statistics The
  247. * statistics element for the video in the message
  248. * @return Zend_Gdata_YouTube_InboxEntry Provides a fluent interface
  249. */
  250. public function setStatistics($statistics = null)
  251. {
  252. $this->_statistics = $statistics;
  253. return $this;
  254. }
  255. }