CommentEntry.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 Photos
  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_Entry
  24. */
  25. require_once 'Zend/Gdata/Entry.php';
  26. /**
  27. * @see Zend_Gdata_Photos_Extension_Id
  28. */
  29. require_once 'Zend/Gdata/Photos/Extension/Id.php';
  30. /**
  31. * @see Zend_Gdata_Photos_Extension_PhotoId
  32. */
  33. require_once 'Zend/Gdata/Photos/Extension/PhotoId.php';
  34. /**
  35. * @see Zend_Gdata_Photos_Extension_Weight
  36. */
  37. require_once 'Zend/Gdata/Photos/Extension/Weight.php';
  38. /**
  39. * @see Zend_Gdata_App_Extension_Category
  40. */
  41. require_once 'Zend/Gdata/App/Extension/Category.php';
  42. /**
  43. * Data model class for a Comment Entry.
  44. *
  45. * To transfer user entries to and from the servers, including
  46. * creating new entries, refer to the service class,
  47. * Zend_Gdata_Photos.
  48. *
  49. * This class represents <atom:entry> in the Google Data protocol.
  50. *
  51. * @category Zend
  52. * @package Zend_Gdata
  53. * @subpackage Photos
  54. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  55. * @license http://framework.zend.com/license/new-bsd New BSD License
  56. */
  57. class Zend_Gdata_Photos_CommentEntry extends Zend_Gdata_Entry
  58. {
  59. protected $_entryClassName = 'Zend_Gdata_Photos_CommentEntry';
  60. /**
  61. * gphoto:id element
  62. *
  63. * @var Zend_Gdata_Photos_Extension_Id
  64. */
  65. protected $_gphotoId = null;
  66. /**
  67. * gphoto:photoid element, differs from gphoto:id as this is an
  68. * actual identification number unique exclusively to photo entries,
  69. * whereas gphoto:id can refer to all gphoto objects
  70. *
  71. * @var Zend_Gdata_Photos_Extension_PhotoId
  72. */
  73. protected $_gphotoPhotoId = null;
  74. /**
  75. * Create a new instance.
  76. *
  77. * @param DOMElement $element (optional) DOMElement from which this
  78. * object should be constructed.
  79. */
  80. public function __construct($element = null)
  81. {
  82. $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
  83. parent::__construct($element);
  84. $category = new Zend_Gdata_App_Extension_Category(
  85. 'http://schemas.google.com/photos/2007#comment',
  86. 'http://schemas.google.com/g/2005#kind');
  87. $this->setCategory(array($category));
  88. }
  89. /**
  90. * Retrieves a DOMElement which corresponds to this element and all
  91. * child properties. This is used to build an entry back into a DOM
  92. * and eventually XML text for application storage/persistence.
  93. *
  94. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  95. * @return DOMElement The DOMElement representing this element and all
  96. * child properties.
  97. */
  98. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  99. {
  100. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  101. if ($this->_gphotoId !== null) {
  102. $element->appendChild($this->_gphotoId->getDOM($element->ownerDocument));
  103. }
  104. if ($this->_gphotoPhotoId !== null) {
  105. $element->appendChild($this->_gphotoPhotoId->getDOM($element->ownerDocument));
  106. }
  107. return $element;
  108. }
  109. /**
  110. * Creates individual Entry objects of the appropriate type and
  111. * stores them as members of this entry based upon DOM data.
  112. *
  113. * @param DOMNode $child The DOMNode to process
  114. */
  115. protected function takeChildFromDOM($child)
  116. {
  117. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  118. switch ($absoluteNodeName) {
  119. case $this->lookupNamespace('gphoto') . ':' . 'id';
  120. $id = new Zend_Gdata_Photos_Extension_Id();
  121. $id->transferFromDOM($child);
  122. $this->_gphotoId = $id;
  123. break;
  124. case $this->lookupNamespace('gphoto') . ':' . 'photoid';
  125. $photoid = new Zend_Gdata_Photos_Extension_PhotoId();
  126. $photoid->transferFromDOM($child);
  127. $this->_gphotoPhotoId = $photoid;
  128. break;
  129. default:
  130. parent::takeChildFromDOM($child);
  131. break;
  132. }
  133. }
  134. /**
  135. * Get the value for this element's gphoto:photoid attribute.
  136. *
  137. * @see setGphotoPhotoId
  138. * @return string The requested attribute.
  139. */
  140. public function getGphotoPhotoId()
  141. {
  142. return $this->_gphotoPhotoId;
  143. }
  144. /**
  145. * Set the value for this element's gphoto:photoid attribute.
  146. *
  147. * @param string $value The desired value for this attribute.
  148. * @return Zend_Gdata_Photos_Extension_PhotoId The element being modified.
  149. */
  150. public function setGphotoPhotoId($value)
  151. {
  152. $this->_gphotoPhotoId = $value;
  153. return $this;
  154. }
  155. /**
  156. * Get the value for this element's gphoto:id attribute.
  157. *
  158. * @see setGphotoId
  159. * @return string The requested attribute.
  160. */
  161. public function getGphotoId()
  162. {
  163. return $this->_gphotoId;
  164. }
  165. /**
  166. * Set the value for this element's gphoto:id attribute.
  167. *
  168. * @param string $value The desired value for this attribute.
  169. * @return Zend_Gdata_Photos_Extension_Id The element being modified.
  170. */
  171. public function setGphotoId($value)
  172. {
  173. $this->_gphotoId = $value;
  174. return $this;
  175. }
  176. }