FeedSourceParent.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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 App
  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_Entry
  24. */
  25. require_once 'Zend/Gdata/App/Entry.php';
  26. /**
  27. * @see Zend_Gdata_App_FeedSourceParent
  28. */
  29. require_once 'Zend/Gdata/App/FeedEntryParent.php';
  30. /**
  31. * @see Zend_Gdata_App_Extension_Generator
  32. */
  33. require_once 'Zend/Gdata/App/Extension/Generator.php';
  34. /**
  35. * @see Zend_Gdata_App_Extension_Icon
  36. */
  37. require_once 'Zend/Gdata/App/Extension/Icon.php';
  38. /**
  39. * @see Zend_Gdata_App_Extension_Logo
  40. */
  41. require_once 'Zend/Gdata/App/Extension/Logo.php';
  42. /**
  43. * @see Zend_Gdata_App_Extension_Subtitle
  44. */
  45. require_once 'Zend/Gdata/App/Extension/Subtitle.php';
  46. /**
  47. * Atom feed class
  48. *
  49. * @category Zend
  50. * @package Zend_Gdata
  51. * @subpackage App
  52. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  53. * @license http://framework.zend.com/license/new-bsd New BSD License
  54. */
  55. abstract class Zend_Gdata_App_FeedSourceParent extends Zend_Gdata_App_FeedEntryParent
  56. {
  57. /**
  58. * The classname for individual feed elements.
  59. *
  60. * @var string
  61. */
  62. protected $_entryClassName = 'Zend_Gdata_App_Entry';
  63. /**
  64. * Root XML element for Atom entries.
  65. *
  66. * @var string
  67. */
  68. protected $_rootElement = null;
  69. protected $_generator = null;
  70. protected $_icon = null;
  71. protected $_logo = null;
  72. protected $_subtitle = null;
  73. /**
  74. * Set the HTTP client instance
  75. *
  76. * Sets the HTTP client object to use for retrieving the feed.
  77. *
  78. * @deprecated Deprecated as of Zend Framework 1.7. Use
  79. * setService() instead.
  80. * @param Zend_Http_Client $httpClient
  81. * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface
  82. */
  83. public function setHttpClient(Zend_Http_Client $httpClient)
  84. {
  85. parent::setHttpClient($httpClient);
  86. foreach ($this->_entry as $entry) {
  87. $entry->setHttpClient($httpClient);
  88. }
  89. return $this;
  90. }
  91. /**
  92. * Set the active service instance for this feed and all enclosed entries.
  93. * This will be used to perform network requests, such as when calling
  94. * save() and delete().
  95. *
  96. * @param Zend_Gdata_App $instance The new service instance.
  97. * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface.
  98. */
  99. public function setService($instance)
  100. {
  101. parent::setService($instance);
  102. foreach ($this->_entry as $entry) {
  103. $entry->setService($instance);
  104. }
  105. return $this;
  106. }
  107. /**
  108. * Make accessing some individual elements of the feed easier.
  109. *
  110. * Special accessors 'entry' and 'entries' are provided so that if
  111. * you wish to iterate over an Atom feed's entries, you can do so
  112. * using foreach ($feed->entries as $entry) or foreach
  113. * ($feed->entry as $entry).
  114. *
  115. * @param string $var The property to access.
  116. * @return mixed
  117. */
  118. public function __get($var)
  119. {
  120. switch ($var) {
  121. default:
  122. return parent::__get($var);
  123. }
  124. }
  125. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  126. {
  127. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  128. if ($this->_generator != null) {
  129. $element->appendChild($this->_generator->getDOM($element->ownerDocument));
  130. }
  131. if ($this->_icon != null) {
  132. $element->appendChild($this->_icon->getDOM($element->ownerDocument));
  133. }
  134. if ($this->_logo != null) {
  135. $element->appendChild($this->_logo->getDOM($element->ownerDocument));
  136. }
  137. if ($this->_subtitle != null) {
  138. $element->appendChild($this->_subtitle->getDOM($element->ownerDocument));
  139. }
  140. return $element;
  141. }
  142. /**
  143. * Creates individual Entry objects of the appropriate type and
  144. * stores them in the $_entry array based upon DOM data.
  145. *
  146. * @param DOMNode $child The DOMNode to process
  147. */
  148. protected function takeChildFromDOM($child)
  149. {
  150. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  151. switch ($absoluteNodeName) {
  152. case $this->lookupNamespace('atom') . ':' . 'generator':
  153. $generator = new Zend_Gdata_App_Extension_Generator();
  154. $generator->transferFromDOM($child);
  155. $this->_generator = $generator;
  156. break;
  157. case $this->lookupNamespace('atom') . ':' . 'icon':
  158. $icon = new Zend_Gdata_App_Extension_Icon();
  159. $icon->transferFromDOM($child);
  160. $this->_icon = $icon;
  161. break;
  162. case $this->lookupNamespace('atom') . ':' . 'logo':
  163. $logo = new Zend_Gdata_App_Extension_Logo();
  164. $logo->transferFromDOM($child);
  165. $this->_logo = $logo;
  166. break;
  167. case $this->lookupNamespace('atom') . ':' . 'subtitle':
  168. $subtitle = new Zend_Gdata_App_Extension_Subtitle();
  169. $subtitle->transferFromDOM($child);
  170. $this->_subtitle = $subtitle;
  171. break;
  172. default:
  173. parent::takeChildFromDOM($child);
  174. break;
  175. }
  176. }
  177. /**
  178. * @return Zend_Gdata_AppExtension_Generator
  179. */
  180. public function getGenerator()
  181. {
  182. return $this->_generator;
  183. }
  184. /**
  185. * @param Zend_Gdata_App_Extension_Generator $value
  186. * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface
  187. */
  188. public function setGenerator($value)
  189. {
  190. $this->_generator = $value;
  191. return $this;
  192. }
  193. /**
  194. * @return Zend_Gdata_AppExtension_Icon
  195. */
  196. public function getIcon()
  197. {
  198. return $this->_icon;
  199. }
  200. /**
  201. * @param Zend_Gdata_App_Extension_Icon $value
  202. * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface
  203. */
  204. public function setIcon($value)
  205. {
  206. $this->_icon = $value;
  207. return $this;
  208. }
  209. /**
  210. * @return Zend_Gdata_AppExtension_logo
  211. */
  212. public function getlogo()
  213. {
  214. return $this->_logo;
  215. }
  216. /**
  217. * @param Zend_Gdata_App_Extension_logo $value
  218. * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface
  219. */
  220. public function setlogo($value)
  221. {
  222. $this->_logo = $value;
  223. return $this;
  224. }
  225. /**
  226. * @return Zend_Gdata_AppExtension_Subtitle
  227. */
  228. public function getSubtitle()
  229. {
  230. return $this->_subtitle;
  231. }
  232. /**
  233. * @param Zend_Gdata_App_Extension_Subtitle $value
  234. * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface
  235. */
  236. public function setSubtitle($value)
  237. {
  238. $this->_subtitle = $value;
  239. return $this;
  240. }
  241. }