File indexing completed on 2024-06-16 05:30:08

0001 <?php
0002 
0003 /**
0004  * Zend Framework
0005  *
0006  * LICENSE
0007  *
0008  * This source file is subject to the new BSD license that is bundled
0009  * with this package in the file LICENSE.txt.
0010  * It is also available through the world-wide-web at this URL:
0011  * http://framework.zend.com/license/new-bsd
0012  * If you did not receive a copy of the license and are unable to
0013  * obtain it through the world-wide-web, please send an email
0014  * to license@zend.com so we can send you a copy immediately.
0015  *
0016  * @category   Zend
0017  * @package    Zend_Gdata
0018  * @subpackage Photos
0019  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  * @version    $Id$
0022  */
0023 
0024 /**
0025  * @see Zend_Gdata_Photos
0026  */
0027 // require_once 'Zend/Gdata/Photos.php';
0028 
0029 /**
0030  * @see Zend_Gdata_Feed
0031  */
0032 // require_once 'Zend/Gdata/Feed.php';
0033 
0034 /**
0035  * @see Zend_Gdata_Photos_UserEntry
0036  */
0037 // require_once 'Zend/Gdata/Photos/UserEntry.php';
0038 
0039 /**
0040  * @see Zend_Gdata_Photos_AlbumEntry
0041  */
0042 // require_once 'Zend/Gdata/Photos/AlbumEntry.php';
0043 
0044 /**
0045  * @see Zend_Gdata_Photos_PhotoEntry
0046  */
0047 // require_once 'Zend/Gdata/Photos/PhotoEntry.php';
0048 
0049 /**
0050  * @see Zend_Gdata_Photos_TagEntry
0051  */
0052 // require_once 'Zend/Gdata/Photos/TagEntry.php';
0053 
0054 /**
0055  * @see Zend_Gdata_Photos_CommentEntry
0056  */
0057 // require_once 'Zend/Gdata/Photos/CommentEntry.php';
0058 
0059 /**
0060  * Data model for a collection of entries for a specific user, usually
0061  * provided by the servers.
0062  *
0063  * For information on requesting this feed from a server, see the
0064  * service class, Zend_Gdata_Photos.
0065  *
0066  * @category   Zend
0067  * @package    Zend_Gdata
0068  * @subpackage Photos
0069  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0070  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0071  */
0072 class Zend_Gdata_Photos_UserFeed extends Zend_Gdata_Feed
0073 {
0074 
0075     /**
0076      * gphoto:user element
0077      *
0078      * @var Zend_Gdata_Photos_Extension_User
0079      */
0080     protected $_gphotoUser = null;
0081 
0082     /**
0083      * gphoto:thumbnail element
0084      *
0085      * @var Zend_Gdata_Photos_Extension_Thumbnail
0086      */
0087     protected $_gphotoThumbnail = null;
0088 
0089     /**
0090      * gphoto:nickname element
0091      *
0092      * @var Zend_Gdata_Photos_Extension_Nickname
0093      */
0094     protected $_gphotoNickname = null;
0095 
0096     protected $_entryClassName = 'Zend_Gdata_Photos_UserEntry';
0097     protected $_feedClassName = 'Zend_Gdata_Photos_UserFeed';
0098 
0099     protected $_entryKindClassMapping = array(
0100         'http://schemas.google.com/photos/2007#album' => 'Zend_Gdata_Photos_AlbumEntry',
0101         'http://schemas.google.com/photos/2007#photo' => 'Zend_Gdata_Photos_PhotoEntry',
0102         'http://schemas.google.com/photos/2007#comment' => 'Zend_Gdata_Photos_CommentEntry',
0103         'http://schemas.google.com/photos/2007#tag' => 'Zend_Gdata_Photos_TagEntry'
0104     );
0105 
0106     public function __construct($element = null)
0107     {
0108         $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
0109         parent::__construct($element);
0110     }
0111 
0112     /**
0113      * Creates individual Entry objects of the appropriate type and
0114      * stores them in the $_entry array based upon DOM data.
0115      *
0116      * @param DOMNode $child The DOMNode to process
0117      */
0118     protected function takeChildFromDOM($child)
0119     {
0120         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
0121         switch ($absoluteNodeName) {
0122             case $this->lookupNamespace('gphoto') . ':' . 'user';
0123                 $user = new Zend_Gdata_Photos_Extension_User();
0124                 $user->transferFromDOM($child);
0125                 $this->_gphotoUser = $user;
0126                 break;
0127             case $this->lookupNamespace('gphoto') . ':' . 'nickname';
0128                 $nickname = new Zend_Gdata_Photos_Extension_Nickname();
0129                 $nickname->transferFromDOM($child);
0130                 $this->_gphotoNickname = $nickname;
0131                 break;
0132             case $this->lookupNamespace('gphoto') . ':' . 'thumbnail';
0133                 $thumbnail = new Zend_Gdata_Photos_Extension_Thumbnail();
0134                 $thumbnail->transferFromDOM($child);
0135                 $this->_gphotoThumbnail = $thumbnail;
0136                 break;
0137             case $this->lookupNamespace('atom') . ':' . 'entry':
0138                 $entryClassName = $this->_entryClassName;
0139                 $tmpEntry = new Zend_Gdata_App_Entry($child);
0140                 $categories = $tmpEntry->getCategory();
0141                 foreach ($categories as $category) {
0142                     if ($category->scheme == Zend_Gdata_Photos::KIND_PATH &&
0143                         $this->_entryKindClassMapping[$category->term] != "") {
0144                             $entryClassName = $this->_entryKindClassMapping[$category->term];
0145                             break;
0146                     } else {
0147                         // require_once 'Zend/Gdata/App/Exception.php';
0148                         throw new Zend_Gdata_App_Exception('Entry is missing kind declaration.');
0149                     }
0150                 }
0151 
0152                 $newEntry = new $entryClassName($child);
0153                 $newEntry->setHttpClient($this->getHttpClient());
0154                 $this->_entry[] = $newEntry;
0155                 break;
0156             default:
0157                 parent::takeChildFromDOM($child);
0158                 break;
0159         }
0160     }
0161 
0162     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0163     {
0164         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0165         if ($this->_gphotoUser != null) {
0166             $element->appendChild($this->_gphotoUser->getDOM($element->ownerDocument));
0167         }
0168         if ($this->_gphotoNickname != null) {
0169             $element->appendChild($this->_gphotoNickname->getDOM($element->ownerDocument));
0170         }
0171         if ($this->_gphotoThumbnail != null) {
0172             $element->appendChild($this->_gphotoThumbnail->getDOM($element->ownerDocument));
0173         }
0174 
0175         return $element;
0176     }
0177 
0178     /**
0179      * Get the value for this element's gphoto:user attribute.
0180      *
0181      * @see setGphotoUser
0182      * @return string The requested attribute.
0183      */
0184     public function getGphotoUser()
0185     {
0186         return $this->_gphotoUser;
0187     }
0188 
0189     /**
0190      * Set the value for this element's gphoto:user attribute.
0191      *
0192      * @param string $value The desired value for this attribute.
0193      * @return Zend_Gdata_Photos_Extension_User The element being modified.
0194      */
0195     public function setGphotoUser($value)
0196     {
0197         $this->_gphotoUser = $value;
0198         return $this;
0199     }
0200 
0201     /**
0202      * Get the value for this element's gphoto:nickname attribute.
0203      *
0204      * @see setGphotoNickname
0205      * @return string The requested attribute.
0206      */
0207     public function getGphotoNickname()
0208     {
0209         return $this->_gphotoNickname;
0210     }
0211 
0212     /**
0213      * Set the value for this element's gphoto:nickname attribute.
0214      *
0215      * @param string $value The desired value for this attribute.
0216      * @return Zend_Gdata_Photos_Extension_Nickname The element being modified.
0217      */
0218     public function setGphotoNickname($value)
0219     {
0220         $this->_gphotoNickname = $value;
0221         return $this;
0222     }
0223 
0224     /**
0225      * Get the value for this element's gphoto:thumbnail attribute.
0226      *
0227      * @see setGphotoThumbnail
0228      * @return string The requested attribute.
0229      */
0230     public function getGphotoThumbnail()
0231     {
0232         return $this->_gphotoThumbnail;
0233     }
0234 
0235     /**
0236      * Set the value for this element's gphoto:thumbnail attribute.
0237      *
0238      * @param string $value The desired value for this attribute.
0239      * @return Zend_Gdata_Photos_Extension_Thumbnail The element being modified.
0240      */
0241     public function setGphotoThumbnail($value)
0242     {
0243         $this->_gphotoThumbnail = $value;
0244         return $this;
0245     }
0246 
0247 }