Example #1
0
 public function getQueryUrl($incomingUri = '')
 {
     $uri = '';
     if ($this->getAlbumName() !== null && $this->getAlbumId() === null) {
         $uri .= '/album/' . $this->getAlbumName();
     } elseif ($this->getAlbumName() === null && $this->getAlbumId() !== null) {
         $uri .= '/albumid/' . $this->getAlbumId();
     } elseif ($this->getAlbumName() !== null && $this->getAlbumId() !== null) {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('AlbumName and AlbumId cannot both be non-null');
     } else {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('AlbumName and AlbumId cannot both be null');
     }
     $uri .= $incomingUri;
     return parent::getQueryUrl($uri);
 }
Example #2
0
/**
 * Outputs an HTML unordered list (ul), with each list item representing an
 * album in the user's feed.
 *
 * @param  Zend_Http_Client $client The authenticated client object
 * @param  string           $user   The user's account name
 * @return void
 */
function outputUserFeed($client, $user)
{
    $photos = new Zend_Gdata_Photos($client);
    $query = new Zend_Gdata_Photos_UserQuery();
    $query->setUser($user);
    $userFeed = $photos->getUserFeed(null, $query);
    echo "<h2>User Feed for: " . $userFeed->getTitle() . "</h2>";
    echo "<ul class='user'>\n";
    foreach ($userFeed as $entry) {
        if ($entry instanceof Zend_Gdata_Photos_AlbumEntry) {
            echo "\t<li class='user'>";
            echo "<a href='?command=retrieveAlbumFeed&user="******"&album=" . $entry->getGphotoId();
            echo "'>";
            $thumb = $entry->getMediaGroup()->getThumbnail();
            echo "<img class='thumb' src='" . $thumb[0]->getUrl() . "' /><br />";
            echo $entry->getTitle() . "</a>";
            echo "<form action='" . getCurrentScript() . "'' method='post' class='deleteForm'>";
            echo "<input type='hidden' name='user' value='" . $user . "' />";
            echo "<input type='hidden' name='album' value='" . $entry->getGphotoId();
            echo "' />";
            echo "<input type='hidden' name='command' value='deleteAlbum' />";
            echo "<input type='submit' value='Delete' /></form>";
            echo "</li>\n";
        }
    }
    echo "</ul><br />\n";
    echo "<h3>Add an Album</h3>";
    ?>
    <form method="POST" action="<?php 
    echo getCurrentScript();
    ?>
">
        <input type="hidden" name="command" value="addAlbum" />
        <input type="hidden" name="user" value="<?php 
    echo $user;
    ?>
" />
        <input type="text" name="name" />
        <input type="submit" name="Add Album" />
    </form>
<?php 
    displayBackLink();
}
 /**
  * Check the consistency of a user feed request for private data
  */
 public function testPrivateUserQuery()
 {
     $queryString = "http://picasaweb.google.com/data/feed/api/user/sample.user?access=private";
     $query = new Zend_Gdata_Photos_UserQuery();
     $query->setUser("sample.user");
     $query->setAccess("private");
     $generatedString = $query->getQueryUrl();
     // Assert that the generated query matches the correct one
     $this->assertEquals($queryString, $generatedString);
 }
Example #4
0
 function getUserFeed()
 {
     if (!isset($userQuery)) {
         $this->loadZendClasses();
         $userQuery = new Zend_Gdata_Photos_UserQuery();
     }
     $picasaUsername = $this->_params->get('username');
     $userQuery->setUser($picasaUsername);
     if (!isset($userFeed)) {
         $service = $this->getService();
         $userFeed = $service->getUserFeed(null, $userQuery);
     }
     return $userFeed;
 }
Example #5
0
 public function get_album_list($max_album_results, $album_thumb_size)
 {
     try {
         // Create an instance of the service
         $this->service = new Zend_Gdata_Photos();
     } catch (Zend_Gdata_App_Exception $ex) {
         $this->errors[] = $ex->getMessage();
         $this->get_errors($this->errors);
     }
     try {
         $query = new Zend_Gdata_Photos_UserQuery();
     } catch (Zend_Gdata_App_Exception $ex) {
         $this->errors[] = $ex->getMessage();
         $this->get_errors($this->errors);
     }
     // Construct the query
     $query->setUser($this->user);
     $query->setThumbSize($album_thumb_size . 'c');
     $query->setMaxResults($max_album_results);
     try {
         $userFeed = $this->service->getUserFeed(null, $query);
     } catch (Zend_Gdata_App_Exception $ex) {
         $this->errors[] = $ex->getMessage();
         $this->get_errors($this->errors);
     }
     if (count($this->errors) > 0) {
         // Display any errors in error log.
         $this->get_errors($this->errors);
         return false;
     } else {
         return $userFeed;
     }
 }
Example #6
0
 /**
  * Retrieves a list of Picasa albums.  There are three possible scenarios that
  * this method can be used.
  * <ol>
  *  <li>
  *    Pass instance of Zend_Gdata_Photos_UserFeed and retrieve the album
  *    attributes
  *  </li>
  *  <li>
  *    If {@link getUserFeedInstance()} has been called and is an instance of
  *    Zend_Gdata_Photos_UserFeed the retrieve the album attributes
  *  </li>
  *  <li>
  *    If there isn't an instance of Zend_Gdata_Photos_UserFeed then create
  *    the query and retrieve the attributes.
  *  </li>
  * </ol>
  *
  * @access public
  * @see Zend_Gdata_Photos_UserFeed
  * @param Zend_Gdata_Photos_UserFeed $zgpuf
  * @throws Exception
  */
 public function getUserAlbums(Zend_Gdata_Photos_UserFeed $zgpuf = null)
 {
     if ($zgpuf != null && !$zgpuf instanceof Zend_Gdata_Photos_UserFeed) {
         throw new Exception("Invalid parameter. Must be an instance of Zend_Gdata_Photos_UserFeed");
     } elseif ($zgpuf instanceof Zend_Gdata_Photos_UserFeed) {
         foreach ($zgpuf as $gallery) {
             $gPicasa = new CW_Google_Picasa_Gallery($gallery->getGphotoId(), $gallery->getGphotoName(), $gallery->getPublished(), $gallery->getGphotoAccess(), $gallery->getUpdated(), $gallery->getSummary(), $gallery->getGphotoLocation(), $gallery->mediaGroup->thumbnail[0]->url, $gallery->getGphotoNumPhotos());
             $this->setGalleryAttrs($gPicasa);
         }
     } elseif ($this->getUserFeedInstance() instanceof Zend_Gdata_Photos_UserFeed) {
         foreach ($this->getUserFeedInstance() as $gallery) {
             $gPicasa = new CW_Google_Picasa_Gallery($gallery->getGphotoId(), $gallery->getGphotoName(), $gallery->getPublished(), $gallery->getGphotoAccess(), $gallery->getUpdated(), $gallery->getSummary(), $gallery->getGphotoLocation(), $gallery->mediaGroup->thumbnail[0]->url, $gallery->getGphotoNumPhotos());
             $this->setGalleryAttrs($gPicasa);
         }
     } else {
         $query = new Zend_Gdata_Photos_UserQuery();
         $query->setUser($this->getUser());
         $query->setKind("album");
         $this->setUserFeedInstance($this->getGphotoService()->getUserFeed(null, $query));
         foreach ($this->getUserFeedInstance() as $gallery) {
             $gPicasa = new CW_Google_Picasa_Gallery($gallery->getGphotoId(), $gallery->getGphotoName(), $gallery->getPublished(), $gallery->getGphotoAccess(), $gallery->getUpdated(), $gallery->getSummary(), $gallery->getGphotoLocation(), $gallery->mediaGroup->thumbnail[0]->url, $gallery->getGphotoNumPhotos());
             $this->setGalleryAttrs($gPicasa);
         }
     }
     return $this->getGalleryAttrs();
 }