~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/Photos/UserFeed.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 Photos
 
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_Photos
 
25
 */
 
26
require_once 'Zend/Gdata/Photos.php';
 
27
 
 
28
/**
 
29
 * @see Zend_Gdata_Feed
 
30
 */
 
31
require_once 'Zend/Gdata/Feed.php';
 
32
 
 
33
/**
 
34
 * @see Zend_Gdata_Photos_UserEntry
 
35
 */
 
36
require_once 'Zend/Gdata/Photos/UserEntry.php';
 
37
 
 
38
/**
 
39
 * @see Zend_Gdata_Photos_AlbumEntry
 
40
 */
 
41
require_once 'Zend/Gdata/Photos/AlbumEntry.php';
 
42
 
 
43
/**
 
44
 * @see Zend_Gdata_Photos_PhotoEntry
 
45
 */
 
46
require_once 'Zend/Gdata/Photos/PhotoEntry.php';
 
47
 
 
48
/**
 
49
 * @see Zend_Gdata_Photos_TagEntry
 
50
 */
 
51
require_once 'Zend/Gdata/Photos/TagEntry.php';
 
52
 
 
53
/**
 
54
 * @see Zend_Gdata_Photos_CommentEntry
 
55
 */
 
56
require_once 'Zend/Gdata/Photos/CommentEntry.php';
 
57
 
 
58
/**
 
59
 * Data model for a collection of entries for a specific user, usually 
 
60
 * provided by the servers.
 
61
 * 
 
62
 * For information on requesting this feed from a server, see the
 
63
 * service class, Zend_Gdata_Photos.
 
64
 *
 
65
 * @category   Zend
 
66
 * @package    Zend_Gdata
 
67
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
68
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
69
 */
 
70
class Zend_Gdata_Photos_UserFeed extends Zend_Gdata_Feed
 
71
{
 
72
    
 
73
    /**
 
74
     * gphoto:user element
 
75
     *
 
76
     * @var Zend_Gdata_Photos_Extension_User
 
77
     */
 
78
    protected $_gphotoUser = null;
 
79
    
 
80
    /**
 
81
     * gphoto:thumbnail element
 
82
     *
 
83
     * @var Zend_Gdata_Photos_Extension_Thumbnail
 
84
     */
 
85
    protected $_gphotoThumbnail = null;
 
86
    
 
87
    /**
 
88
     * gphoto:nickname element
 
89
     *
 
90
     * @var Zend_Gdata_Photos_Extension_Nickname
 
91
     */
 
92
    protected $_gphotoNickname = null;
 
93
 
 
94
    protected $_entryClassName = 'Zend_Gdata_Photos_UserEntry';
 
95
    protected $_feedClassName = 'Zend_Gdata_Photos_UserFeed';
 
96
 
 
97
    protected $_entryKindClassMapping = array(
 
98
        'http://schemas.google.com/photos/2007#album' => 'Zend_Gdata_Photos_AlbumEntry',
 
99
        'http://schemas.google.com/photos/2007#photo' => 'Zend_Gdata_Photos_PhotoEntry',
 
100
        'http://schemas.google.com/photos/2007#comment' => 'Zend_Gdata_Photos_CommentEntry',
 
101
        'http://schemas.google.com/photos/2007#tag' => 'Zend_Gdata_Photos_TagEntry'
 
102
    );
 
103
 
 
104
    public function __construct($element = null)
 
105
    {
 
106
        foreach (Zend_Gdata_Photos::$namespaces as $nsPrefix => $nsUri) {
 
107
            $this->registerNamespace($nsPrefix, $nsUri);
 
108
        }
 
109
        parent::__construct($element);
 
110
    }
 
111
    
 
112
    /**
 
113
     * Creates individual Entry objects of the appropriate type and
 
114
     * stores them in the $_entry array based upon DOM data.
 
115
     *
 
116
     * @param DOMNode $child The DOMNode to process
 
117
     */
 
118
    protected function takeChildFromDOM($child)
 
119
    {
 
120
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
 
121
        switch ($absoluteNodeName) {
 
122
            case $this->lookupNamespace('gphoto') . ':' . 'user';
 
123
                $user = new Zend_Gdata_Photos_Extension_User();
 
124
                $user->transferFromDOM($child);
 
125
                $this->_gphotoUser = $user;
 
126
                break;
 
127
            case $this->lookupNamespace('gphoto') . ':' . 'nickname';
 
128
                $nickname = new Zend_Gdata_Photos_Extension_Nickname();
 
129
                $nickname->transferFromDOM($child);
 
130
                $this->_gphotoNickname = $nickname;
 
131
                break;
 
132
            case $this->lookupNamespace('gphoto') . ':' . 'thumbnail';
 
133
                $thumbnail = new Zend_Gdata_Photos_Extension_Thumbnail();
 
134
                $thumbnail->transferFromDOM($child);
 
135
                $this->_gphotoThumbnail = $thumbnail;
 
136
                break;
 
137
            case $this->lookupNamespace('atom') . ':' . 'entry':
 
138
                $entryClassName = $this->_entryClassName;
 
139
                $tmpEntry = new Zend_Gdata_App_Entry($child);
 
140
                $categories = $tmpEntry->getCategory();
 
141
                foreach ($categories as $category) {
 
142
                    if ($category->scheme == Zend_Gdata_Photos::KIND_PATH &&
 
143
                        $this->_entryKindClassMapping[$category->term] != "") {
 
144
                            $entryClassName = $this->_entryKindClassMapping[$category->term];
 
145
                            break;
 
146
                    } else {
 
147
                        require_once 'Zend/Gdata/App/Exception.php';
 
148
                        throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
 
149
                    }
 
150
                }
 
151
                
 
152
                $newEntry = new $entryClassName($child);
 
153
                $newEntry->setHttpClient($this->getHttpClient());
 
154
                $this->_entry[] = $newEntry;
 
155
                break;
 
156
            default:
 
157
                parent::takeChildFromDOM($child);
 
158
                break;
 
159
        }
 
160
    }
 
161
 
 
162
    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
 
163
    {
 
164
        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
 
165
        if ($this->_gphotoUser != null) {
 
166
            $element->appendChild($this->_gphotoUser->getDOM($element->ownerDocument));
 
167
        }
 
168
        if ($this->_gphotoNickname != null) {
 
169
            $element->appendChild($this->_gphotoNickname->getDOM($element->ownerDocument));
 
170
        }
 
171
        if ($this->_gphotoThumbnail != null) {
 
172
            $element->appendChild($this->_gphotoThumbnail->getDOM($element->ownerDocument));
 
173
        }
 
174
 
 
175
        return $element;
 
176
    }
 
177
    
 
178
    /**
 
179
     * Get the value for this element's gphoto:user attribute.
 
180
     *
 
181
     * @see setGphotoUser
 
182
     * @return string The requested attribute.
 
183
     */
 
184
    public function getGphotoUser()
 
185
    {
 
186
        return $this->_gphotoUser;
 
187
    }
 
188
    
 
189
    /**
 
190
     * Set the value for this element's gphoto:user attribute.
 
191
     *
 
192
     * @param string $value The desired value for this attribute.
 
193
     * @return Zend_Gdata_Photos_Extension_User The element being modified.
 
194
     */
 
195
    public function setGphotoUser($value)
 
196
    {
 
197
        $this->_gphotoUser = $value;
 
198
        return $this;
 
199
    }
 
200
 
 
201
    /**
 
202
     * Get the value for this element's gphoto:nickname attribute.
 
203
     *
 
204
     * @see setGphotoNickname
 
205
     * @return string The requested attribute.
 
206
     */
 
207
    public function getGphotoNickname()
 
208
    {
 
209
        return $this->_gphotoNickname;
 
210
    }
 
211
    
 
212
    /**
 
213
     * Set the value for this element's gphoto:nickname attribute.
 
214
     *
 
215
     * @param string $value The desired value for this attribute.
 
216
     * @return Zend_Gdata_Photos_Extension_Nickname The element being modified.
 
217
     */
 
218
    public function setGphotoNickname($value)
 
219
    {
 
220
        $this->_gphotoNickname = $value;
 
221
        return $this;
 
222
    }
 
223
 
 
224
    /**
 
225
     * Get the value for this element's gphoto:thumbnail attribute.
 
226
     *
 
227
     * @see setGphotoThumbnail
 
228
     * @return string The requested attribute.
 
229
     */
 
230
    public function getGphotoThumbnail()
 
231
    {
 
232
        return $this->_gphotoThumbnail;
 
233
    }
 
234
    
 
235
    /**
 
236
     * Set the value for this element's gphoto:thumbnail attribute.
 
237
     *
 
238
     * @param string $value The desired value for this attribute.
 
239
     * @return Zend_Gdata_Photos_Extension_Thumbnail The element being modified.
 
240
     */
 
241
    public function setGphotoThumbnail($value)
 
242
    {
 
243
        $this->_gphotoThumbnail = $value;
 
244
        return $this;
 
245
    }
 
246
    
 
247
}