2
0

FeedSourceParent.php 7.2 KB

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