[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/lib/zend/Zend/Gdata/Photos/ -> UserFeed.php (source)

   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 [email protected] so we can send you a copy immediately.
  15   *
  16   * @category   Zend
  17   * @package    Zend_Gdata
  18   * @subpackage Photos
  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   * @version    $Id$
  22   */
  23  
  24  /**
  25   * @see Zend_Gdata_Photos
  26   */
  27  require_once 'Zend/Gdata/Photos.php';
  28  
  29  /**
  30   * @see Zend_Gdata_Feed
  31   */
  32  require_once 'Zend/Gdata/Feed.php';
  33  
  34  /**
  35   * @see Zend_Gdata_Photos_UserEntry
  36   */
  37  require_once 'Zend/Gdata/Photos/UserEntry.php';
  38  
  39  /**
  40   * @see Zend_Gdata_Photos_AlbumEntry
  41   */
  42  require_once 'Zend/Gdata/Photos/AlbumEntry.php';
  43  
  44  /**
  45   * @see Zend_Gdata_Photos_PhotoEntry
  46   */
  47  require_once 'Zend/Gdata/Photos/PhotoEntry.php';
  48  
  49  /**
  50   * @see Zend_Gdata_Photos_TagEntry
  51   */
  52  require_once 'Zend/Gdata/Photos/TagEntry.php';
  53  
  54  /**
  55   * @see Zend_Gdata_Photos_CommentEntry
  56   */
  57  require_once 'Zend/Gdata/Photos/CommentEntry.php';
  58  
  59  /**
  60   * Data model for a collection of entries for a specific user, usually
  61   * provided by the servers.
  62   *
  63   * For information on requesting this feed from a server, see the
  64   * service class, Zend_Gdata_Photos.
  65   *
  66   * @category   Zend
  67   * @package    Zend_Gdata
  68   * @subpackage Photos
  69   * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  70   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  71   */
  72  class Zend_Gdata_Photos_UserFeed extends Zend_Gdata_Feed
  73  {
  74  
  75      /**
  76       * gphoto:user element
  77       *
  78       * @var Zend_Gdata_Photos_Extension_User
  79       */
  80      protected $_gphotoUser = null;
  81  
  82      /**
  83       * gphoto:thumbnail element
  84       *
  85       * @var Zend_Gdata_Photos_Extension_Thumbnail
  86       */
  87      protected $_gphotoThumbnail = null;
  88  
  89      /**
  90       * gphoto:nickname element
  91       *
  92       * @var Zend_Gdata_Photos_Extension_Nickname
  93       */
  94      protected $_gphotoNickname = null;
  95  
  96      protected $_entryClassName = 'Zend_Gdata_Photos_UserEntry';
  97      protected $_feedClassName = 'Zend_Gdata_Photos_UserFeed';
  98  
  99      protected $_entryKindClassMapping = array(
 100          'http://schemas.google.com/photos/2007#album' => 'Zend_Gdata_Photos_AlbumEntry',
 101          'http://schemas.google.com/photos/2007#photo' => 'Zend_Gdata_Photos_PhotoEntry',
 102          'http://schemas.google.com/photos/2007#comment' => 'Zend_Gdata_Photos_CommentEntry',
 103          'http://schemas.google.com/photos/2007#tag' => 'Zend_Gdata_Photos_TagEntry'
 104      );
 105  
 106      public function __construct($element = null)
 107      {
 108          $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces);
 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  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1