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