~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/App/Entry.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
20
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
21
 */
 
22
 
 
23
/**
 
24
 * @see Zend_Gdata_App_FeedEntryParent
 
25
 */
 
26
require_once 'Zend/Gdata/App/FeedEntryParent.php';
 
27
 
 
28
/**
 
29
 * @see Zend_Gdata_App_Extension_Content
 
30
 */
 
31
require_once 'Zend/Gdata/App/Extension/Content.php';
 
32
 
 
33
/**
 
34
 * @see Zend_Gdata_App_Extension_Published
 
35
 */
 
36
require_once 'Zend/Gdata/App/Extension/Published.php';
 
37
 
 
38
/**
 
39
 * @see Zend_Gdata_App_Extension_Source
 
40
 */
 
41
require_once 'Zend/Gdata/App/Extension/Source.php';
 
42
 
 
43
/**
 
44
 * @see Zend_Gdata_App_Extension_Summary
 
45
 */
 
46
require_once 'Zend/Gdata/App/Extension/Summary.php';
 
47
 
 
48
/**
 
49
 * @see Zend_Gdata_App_Extension_Control
 
50
 */
 
51
require_once 'Zend/Gdata/App/Extension/Control.php';
 
52
 
 
53
/**
 
54
 * Concrete class for working with Atom entries.
 
55
 *
 
56
 * @category   Zend
 
57
 * @package    Zend_Gdata
 
58
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
59
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
60
 */
 
61
class Zend_Gdata_App_Entry extends Zend_Gdata_App_FeedEntryParent
 
62
{
 
63
 
 
64
    /**
 
65
     * Root XML element for Atom entries.
 
66
     *
 
67
     * @var string
 
68
     */
 
69
    protected $_rootElement = 'entry';
 
70
 
 
71
    /**
 
72
     * Class name for each entry in this feed*
 
73
     *
 
74
     * @var string
 
75
     */
 
76
    protected $_entryClassName = 'Zend_Gdata_App_Entry';
 
77
 
 
78
    /**
 
79
     * atom:content element
 
80
     *
 
81
     * @var Zend_Gdata_App_Extension_Content
 
82
     */
 
83
    protected $_content = null;
 
84
 
 
85
    /**
 
86
     * atom:published element
 
87
     *
 
88
     * @var Zend_Gdata_App_Extension_Published
 
89
     */
 
90
    protected $_published = null;
 
91
 
 
92
    /**
 
93
     * atom:source element
 
94
     *
 
95
     * @var Zend_Gdata_App_Extension_Source
 
96
     */
 
97
    protected $_source = null;
 
98
 
 
99
    /**
 
100
     * atom:summary element
 
101
     *
 
102
     * @var Zend_Gdata_App_Extension_Summary
 
103
     */
 
104
    protected $_summary = null;
 
105
 
 
106
    /**
 
107
     * app:control element
 
108
     *
 
109
     * @var Zend_Gdata_App_Extension_Control
 
110
     */
 
111
    protected $_control = null;
 
112
 
 
113
    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
 
114
    {
 
115
        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
 
116
        if ($this->_content != null) {
 
117
            $element->appendChild($this->_content->getDOM($element->ownerDocument));
 
118
        }
 
119
        if ($this->_published != null) {
 
120
            $element->appendChild($this->_published->getDOM($element->ownerDocument));
 
121
        }
 
122
        if ($this->_source != null) {
 
123
            $element->appendChild($this->_source->getDOM($element->ownerDocument));
 
124
        }
 
125
        if ($this->_summary != null) {
 
126
            $element->appendChild($this->_summary->getDOM($element->ownerDocument));
 
127
        }
 
128
        if ($this->_control != null) {
 
129
            $element->appendChild($this->_control->getDOM($element->ownerDocument));
 
130
        }
 
131
        return $element;
 
132
    }
 
133
 
 
134
    protected function takeChildFromDOM($child)
 
135
    {
 
136
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
 
137
        switch ($absoluteNodeName) {
 
138
        case $this->lookupNamespace('atom') . ':' . 'content':
 
139
            $content = new Zend_Gdata_App_Extension_Content();
 
140
            $content->transferFromDOM($child);
 
141
            $this->_content = $content;
 
142
            break;
 
143
        case $this->lookupNamespace('atom') . ':' . 'published':
 
144
            $published = new Zend_Gdata_App_Extension_Published();
 
145
            $published->transferFromDOM($child);
 
146
            $this->_published = $published;
 
147
            break;
 
148
        case $this->lookupNamespace('atom') . ':' . 'source':
 
149
            $source = new Zend_Gdata_App_Extension_Source();
 
150
            $source->transferFromDOM($child);
 
151
            $this->_source = $source;
 
152
            break;
 
153
        case $this->lookupNamespace('atom') . ':' . 'summary':
 
154
            $summary = new Zend_Gdata_App_Extension_Summary();
 
155
            $summary->transferFromDOM($child);
 
156
            $this->_summary = $summary;
 
157
            break;
 
158
        case $this->lookupNamespace('app') . ':' . 'control':
 
159
            $control = new Zend_Gdata_App_Extension_Control();
 
160
            $control->transferFromDOM($child);
 
161
            $this->_control = $control;
 
162
            break;
 
163
        default:
 
164
            parent::takeChildFromDOM($child);
 
165
            break;
 
166
        }
 
167
    }
 
168
 
 
169
    /**
 
170
     * Uploads changes in this entry to the server using Zend_Gdata_App
 
171
     *
 
172
     * @param string|null $uri The URI to send requests to, or null if $data
 
173
     *        contains the URI.
 
174
     * @param string|null $className The name of the class that should we
 
175
     *        deserializing the server response. If null, then
 
176
     *        'Zend_Gdata_App_Entry' will be used.
 
177
     * @param array $extraHeaders Extra headers to add to the request, as an
 
178
     *        array of string-based key/value pairs.
 
179
     * @return Zend_Gdata_App_Entry The updated entry.
 
180
     * @throws Zend_Gdata_App_Exception
 
181
     */
 
182
    public function save($uri = null, $className = null, $extraHeaders = array())
 
183
    {
 
184
        return $this->getService()->updateEntry($this,
 
185
                                                $uri,
 
186
                                                $className,
 
187
                                                $extraHeaders);
 
188
    }
 
189
 
 
190
    /**
 
191
     * Deletes this entry to the server using the referenced
 
192
     * Zend_Http_Client to do a HTTP DELETE to the edit link stored in this
 
193
     * entry's link collection.
 
194
     *
 
195
     * @return void
 
196
     * @throws Zend_Gdata_App_Exception
 
197
     */
 
198
    public function delete()
 
199
    {
 
200
        $this->getService()->delete($this);
 
201
    }
 
202
 
 
203
    /**
 
204
     * Reload the current entry. Returns a new copy of the entry as returned
 
205
     * by the server, or null if no changes exist. This does not
 
206
     * modify the current entry instance.
 
207
     *
 
208
     * @param string|null The URI to send requests to, or null if $data
 
209
     *        contains the URI.
 
210
     * @param string|null The name of the class that should we deserializing
 
211
     *        the server response. If null, then 'Zend_Gdata_App_Entry' will
 
212
     *        be used.
 
213
     * @param array $extraHeaders Extra headers to add to the request, as an
 
214
     *        array of string-based key/value pairs.
 
215
     * @return mixed A new instance of the current entry with updated data, or
 
216
     *         null if the server reports that no changes have been made.
 
217
     * @throws Zend_Gdata_App_Exception
 
218
     */
 
219
    public function reload($uri = null, $className = null, $extraHeaders = array())
 
220
    {
 
221
        // Get URI
 
222
        $editLink = $this->getEditLink();
 
223
        if (is_null($uri) && $editLink != null) {
 
224
            $uri = $editLink->getHref();
 
225
        }
 
226
        
 
227
        // Set classname to current class, if not otherwise set
 
228
        if (is_null($className)) {
 
229
            $className = get_class($this);
 
230
        }
 
231
        
 
232
        // Append ETag, if present (Gdata v2 and above, only) and doesn't
 
233
        // conflict with existing headers
 
234
        if ($this->_etag != null
 
235
                && !array_key_exists('If-Match', $extraHeaders)
 
236
                && !array_key_exists('If-None-Match', $extraHeaders)) {
 
237
            $extraHeaders['If-None-Match'] = $this->_etag;
 
238
        }
 
239
        
 
240
        // If an HTTP 304 status (Not Modified)is returned, then we return
 
241
        // null.
 
242
        $result = null;
 
243
        try {
 
244
            $result = $this->service->importUrl($uri, $className, $extraHeaders);
 
245
        } catch (Zend_Gdata_App_HttpException $e) {
 
246
            if ($e->getResponse()->getStatus() != '304')
 
247
                throw $e;
 
248
        }
 
249
        
 
250
        return $result;
 
251
    }
 
252
 
 
253
    /**
 
254
     * Gets the value of the atom:content element
 
255
     *
 
256
     * @return Zend_Gdata_App_Extension_Content
 
257
     */
 
258
    public function getContent()
 
259
    {
 
260
        return $this->_content;
 
261
    }
 
262
 
 
263
    /**
 
264
     * Sets the value of the atom:content element
 
265
     *
 
266
     * @param Zend_Gdata_App_Extension_Content $value
 
267
     * @return Zend_Gdata_App_Entry Provides a fluent interface
 
268
     */
 
269
    public function setContent($value)
 
270
    {
 
271
        $this->_content = $value;
 
272
        return $this;
 
273
    }
 
274
 
 
275
    /**
 
276
     * Sets the value of the atom:published element
 
277
     * This represents the publishing date for an entry
 
278
     *
 
279
     * @return Zend_Gdata_App_Extension_Published
 
280
     */
 
281
    public function getPublished()
 
282
    {
 
283
        return $this->_published;
 
284
    }
 
285
 
 
286
    /**
 
287
     * Sets the value of the atom:published element
 
288
     * This represents the publishing date for an entry
 
289
     *
 
290
     * @param Zend_Gdata_App_Extension_Published $value
 
291
     * @return Zend_Gdata_App_Entry Provides a fluent interface
 
292
     */
 
293
    public function setPublished($value)
 
294
    {
 
295
        $this->_published = $value;
 
296
        return $this;
 
297
    }
 
298
 
 
299
    /**
 
300
     * Gets the value of the atom:source element
 
301
     *
 
302
     * @return Zend_Gdata_App_Extension_Source
 
303
     */
 
304
    public function getSource()
 
305
    {
 
306
        return $this->_source;
 
307
    }
 
308
 
 
309
    /**
 
310
     * Sets the value of the atom:source element
 
311
     *
 
312
     * @param Zend_Gdata_App_Extension_Source $value
 
313
     * @return Zend_Gdata_App_Entry Provides a fluent interface
 
314
     */
 
315
    public function setSource($value)
 
316
    {
 
317
        $this->_source = $value;
 
318
        return $this;
 
319
    }
 
320
 
 
321
    /**
 
322
     * Gets the value of the atom:summary element
 
323
     * This represents a textual summary of this entry's content
 
324
     *
 
325
     * @return Zend_Gdata_App_Extension_Summary
 
326
     */
 
327
    public function getSummary()
 
328
    {
 
329
        return $this->_summary;
 
330
    }
 
331
 
 
332
    /**
 
333
     * Sets the value of the atom:summary element
 
334
     * This represents a textual summary of this entry's content
 
335
     *
 
336
     * @param Zend_Gdata_App_Extension_Summary $value
 
337
     * @return Zend_Gdata_App_Entry Provides a fluent interface
 
338
     */
 
339
    public function setSummary($value)
 
340
    {
 
341
        $this->_summary = $value;
 
342
        return $this;
 
343
    }
 
344
 
 
345
    /**
 
346
     * Gets the value of the app:control element
 
347
     *
 
348
     * @return Zend_Gdata_App_Extension_Control
 
349
     */
 
350
    public function getControl()
 
351
    {
 
352
        return $this->_control;
 
353
    }
 
354
 
 
355
    /**
 
356
     * Sets the value of the app:control element
 
357
     *
 
358
     * @param Zend_Gdata_App_Extension_Control $value
 
359
     * @return Zend_Gdata_App_Entry Provides a fluent interface
 
360
     */
 
361
    public function setControl($value)
 
362
    {
 
363
        $this->_control = $value;
 
364
        return $this;
 
365
    }
 
366
 
 
367
}