Пример #1
0
 public function getAlbumPhotos($albumName)
 {
     $album = $this->getAlbumByName($albumName);
     $query = $this->gData->newAlbumQuery();
     $query->setUser('default');
     $query->setAlbumId($album->getGphotoId());
     return $this->gData->getAlbumFeed($query);
 }
Пример #2
0
 /**
  * Obtener las fotos de un album especifico.
  *
  * @param  integer          $albumId Id Album
  * @return Zend_Gdata_Photos_AlbumFeed
  */
 public function getPhotos($albumId)
 {
     $query = new Zend_Gdata_Photos_AlbumQuery();
     $query->setAlbumId($albumId);
     $albumFeed = $this->_photos->getAlbumFeed($query);
     return $albumFeed;
 }
Пример #3
0
 function getAlbum($user, $pass, $albumName)
 {
     $service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
     $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
     $photos = new Zend_Gdata_Photos($client);
     $query = new Zend_Gdata_Photos_AlbumQuery();
     $query->setUser($user);
     $query->setAlbumName($albumName);
     $albumFeed = $photos->getAlbumFeed($query);
     $ret = array();
     foreach ($albumFeed as $entry) {
         if ($entry instanceof Zend_Gdata_Photos_PhotoEntry) {
             $thumb = $entry->getMediaGroup()->getThumbnail();
             $ret[] = array("url" => $thumb[1]->getUrl(), "id" => $entry->getGphotoId());
         }
     }
     return $ret;
 }
Пример #4
0
 function getAlbumFeed($album)
 {
     // Get plugin info
     $plugin =& JPluginHelper::getPlugin('system', 'gdata');
     $params = new JParameter($plugin->params);
     plgSystemGdata::gimport('Zend.Gdata.ClientLogin');
     plgSystemGdata::gimport('Zend.Gdata.Photos');
     plgSystemGdata::gimport('Zend.Gdata.AuthSub');
     $username = $params->get('domain_admin_email');
     $pass = $params->get('domain_admin_password');
     $serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
     $client = Zend_Gdata_ClientLogin::getHttpClient($username, $pass, $serviceName);
     // update the second argument to be CompanyName-ProductName-Version
     $gp = new Zend_Gdata_Photos($client, "Google-DevelopersGuide-1.0");
     // Creates a Zend_Gdata_Photos_AlbumQuery
     $query = $gp->newAlbumQuery();
     $query->setUser($username);
     $query->setAlbumName($album);
     $albumFeed = $gp->getAlbumFeed($query);
     return $albumFeed;
 }
Пример #5
0
/**
 * Outputs an HTML unordered list (ul), with each list item representing a
 * photo in the user's album feed.
 *
 * @param  Zend_Http_Client $client  The authenticated client object
 * @param  string           $user    The user's account name
 * @param  integer          $albumId The album's id
 * @return void
 */
function outputAlbumFeed($client, $user, $albumId)
{
    $photos = new Zend_Gdata_Photos($client);
    $query = new Zend_Gdata_Photos_AlbumQuery();
    $query->setUser($user);
    $query->setAlbumId($albumId);
    $albumFeed = $photos->getAlbumFeed($query);
    echo "<h2>Album Feed for: " . $albumFeed->getTitle() . "</h2>";
    echo "<ul class='albums'>\n";
    foreach ($albumFeed as $entry) {
        if ($entry instanceof Zend_Gdata_Photos_PhotoEntry) {
            echo "\t<li class='albums'>";
            echo "<a href='" . getCurrentScript() . "?command=retrievePhotoFeed&user="******"&album=" . $albumId . "&photo=" . $entry->getGphotoId() . "'>";
            $thumb = $entry->getMediaGroup()->getThumbnail();
            echo "<img class='thumb' src='" . $thumb[1]->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='" . $albumId . "' />";
            echo "<input type='hidden' name='photo' value='" . $entry->getGphotoId();
            echo "' /><input type='hidden' name='command' value='deletePhoto' />";
            echo "<input type='submit' value='Delete' /></form>";
            echo "</li>\n";
        }
    }
    echo "</ul><br />\n";
    echo "<h3>Add a Photo</h3>";
    ?>
    <form enctype="multipart/form-data" method="POST" action="<?php 
    echo getCurrentScript();
    ?>
">
        <input type="hidden" name="MAX_FILE_SIZE" value="20971520" />
        <input type="hidden" name="command" value="addPhoto" />
        <input type="hidden" name="user" value="<?php 
    echo $user;
    ?>
" />
        <input type="hidden" name="album" value="<?php 
    echo $albumId;
    ?>
" />
        Please select a photo to upload: <input name="photo" type="file" /><br />
        <input type="submit" name="Upload" />
    </form>
<?php 
    displayBackLink();
}
Пример #6
0
<?php

error_reporting(E_ALL);
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_Photos');
// Album and User
$sUserID = "100211726914724722900";
$sAlbumName = "jujuNew";
$serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$gp = new Zend_Gdata_Photos();
$query = $gp->newAlbumQuery();
$query->setUser($sUserID);
$query->setAlbumName($sAlbumName);
$query->setImgMax("800");
$query->setThumbSize("160");
$albumFeed = $gp->getAlbumFeed($query);
$sPrintThumbs = "";
foreach ($albumFeed as $albumEntry) {
    if ($albumEntry->getMediaGroup()->getThumbnail() != null) {
        // Load Thumbnail Info
        $mediaThumbnailArray = $albumEntry->getMediaGroup()->getThumbnail();
        $ThumbnailUrl = $mediaThumbnailArray[0]->getUrl();
        $ThumbnailHeight = $mediaThumbnailArray[0]->getHeight();
        $ThumbnailWidth = $mediaThumbnailArray[0]->getWidth();
        // Load Picture Info
        $mediaArray = $albumEntry->getMediaGroup()->getContent();
        $ImageUrl = $mediaArray[0]->getUrl();
        $sImageTitle = $albumEntry->getMediaGroup()->getDescription()->text;
        $url = $albumEntry->getLink('alternate')->href;
        $sLinkString = <<<LTEXT
<a href="{$ImageUrl}" title="{$sImageTitle}"><img src="{$ThumbnailUrl}" width="{$ThumbnailWidth}" height="{$ThumbnailHeight}" /></a>
Пример #7
0
 /**
  * getAjaxMorePicasaPhotos
  * 
  * Will get the next 25 photos for the given album id, starting with given index.
  * Then calls js to get next 25.
  * 
  * @return string
  */
 function getAjaxMorePicasaPhotos()
 {
     $token = $_POST['picasa_session_token'];
     $albumId = $_POST['albumId'];
     $startIndex = $_POST['start_index'];
     $photos = '';
     $httpClient = Zend_Gdata_AuthSub::getHttpClient($token);
     $picasaService = new Zend_Gdata_Photos($httpClient, "Google-DevelopersGuide-1.0");
     try {
         $feed = $picasaService->getUserFeed("default");
     } catch (Zend_Gdata_App_Exception $e) {
         echo '
             <p class="error-alert">
                 ' . T_('Could not get Picasa data.') . '
             </p>';
         logError(__FILE__ . ' [' . __LINE__ . '] - Could not get user picasa data. - ' . $e->getMessage());
         return;
     }
     try {
         $query = new Zend_Gdata_Photos_AlbumQuery();
         $query->setUser($feed->getTitle());
         $query->setAlbumId($albumId);
         $query->setStartIndex($startIndex);
         $query->setMaxResults(25);
         $albumFeed = $picasaService->getAlbumFeed($query);
     } catch (Zend_Gdata_App_Exception $e) {
         echo '
             <p class="error-alert">
                 ' . T_('Could not get Picasa album data.') . '
             </p>';
         logError(__FILE__ . ' [' . __LINE__ . '] - Could not get user picasa album data. - ' . $e->getMessage());
         return;
     }
     $count = 0;
     foreach ($albumFeed as $photo) {
         // Skip videos
         $mediaContent = $photo->getMediaGroup()->getContent();
         foreach ($mediaContent as $content) {
             if ($content->getMedium() == 'video') {
                 continue 2;
             }
         }
         $thumb = $photo->getMediaGroup()->getThumbnail();
         $sourceId = $photo->getGphotoId()->text;
         $thumbnail = $thumb[1]->getUrl();
         $w = $photo->getGphotoWidth()->text;
         $h = $photo->getGphotoHeight()->text;
         $width = '100%;';
         $height = 'auto;';
         if ($w > $h) {
             $width = 'auto;';
             $height = '100%;';
         }
         $_SESSION['picasa_photos'][$sourceId] = array('thumbnail' => $thumbnail, 'width' => $width, 'height' => $height);
         $photos .= '<li>';
         $photos .= '<label for="picasa' . $startIndex . '">';
         $photos .= '<img src="' . $thumbnail . '" style="width:' . $width . ' height:' . $height . '"/>';
         $photos .= '<span style="display:none"></span>';
         $photos .= '</label>';
         $photos .= '<input type="checkbox" id="picasa' . $startIndex . '" name="photos[]" value="' . $sourceId . '"/>';
         $photos .= '</li>';
         $startIndex++;
         $count++;
     }
     if ($count >= 25) {
         $photos .= '<script type="text/javascript">loadMorePicasaPhotos(' . $startIndex . ', "' . $token . '", "' . T_('Could not get additional photos.') . '");</script>';
     } else {
         $_SESSION['picasa_album_done'] = 1;
     }
     echo $photos;
 }
Пример #8
0
 /**
  * setFormData 
  * 
  * Saves all the data passed in from the form upload.
  * 
  * @param array $formData
  * 
  * @return void
  */
 public function setFormData($formData)
 {
     $this->formData = $formData;
     $token = getUserPicasaSessionToken($this->fcmsUser->id);
     $albumId = $formData['albums'];
     $user = $formData['picasa_user'];
     $httpClient = Zend_Gdata_AuthSub::getHttpClient($token);
     $picasaService = new Zend_Gdata_Photos($httpClient, "Google-DevelopersGuide-1.0");
     $thumbSizes = '150c,600';
     if ($this->usingFullSizePhotos) {
         $thumbSizes .= ',d';
     }
     try {
         $query = new Zend_Gdata_Photos_AlbumQuery();
         $query->setUser($user);
         $query->setAlbumId($albumId);
         $query->setParam('thumbsize', $thumbSizes);
         $albumFeed = $picasaService->getAlbumFeed($query);
     } catch (Zend_Gdata_App_Exception $e) {
         $this->fcmsError->add(array('type' => 'operation', 'message' => T_('Could not get Picasa data.'), 'error' => $e->getMessage(), 'file' => __FILE__, 'line' => __LINE__));
         return false;
     }
     $this->albumFeed = $albumFeed;
 }
Пример #9
0
function add_embpicasa_shortcode($atts, $content = null)
{
    extract(shortcode_atts(array("id" => ''), $atts));
    // do not display anything if there is no "id"
    if (empty($id)) {
        return '';
    }
    $options = get_option('embpicasa_options');
    // do not display anything in loop if "Show only on single post"
    if (!is_single() && $options['embpicasa_options_single_only'] == 'yes') {
        return '';
    }
    if (!empty($options['embpicasa_options_login']) && !empty($options['embpicasa_options_password'])) {
        try {
            set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__) . '/library'), get_include_path())));
            require_once 'Zend/Loader.php';
            Zend_Loader::loadClass('Zend_Gdata');
            Zend_Loader::loadClass('Zend_Gdata_Query');
            Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
            Zend_Loader::loadClass('Zend_Gdata_Photos');
            Zend_Loader::loadClass('Zend_Gdata_Photos_UserQuery');
            Zend_Loader::loadClass('Zend_Gdata_Photos_AlbumQuery');
            Zend_Loader::loadClass('Zend_Gdata_Photos_PhotoQuery');
            $client = Zend_Gdata_ClientLogin::getHttpClient($options['embpicasa_options_login'], $options['embpicasa_options_password'], Zend_Gdata_Photos::AUTH_SERVICE_NAME);
            $service = new Zend_Gdata_Photos($client);
            $photos = array();
            $query = new Zend_Gdata_Photos_AlbumQuery();
            $query->setAlbumId($id);
            // http://code.google.com/intl/ru/apis/picasaweb/docs/1.0/reference.html
            $thumb_suffix = $options['embpicasa_options_thumb_crop'] == 'no' ? 'u' : 'c';
            $full_suffix = $options['embpicasa_options_full_crop'] == 'no' ? 'u' : 'c';
            $query->setThumbsize($options['embpicasa_options_thumb_size'] . $thumb_suffix);
            $query->setImgMax($options['embpicasa_options_full_size'] . $full_suffix);
            $results = $service->getAlbumFeed($query);
            while ($results != null) {
                foreach ($results as $entry) {
                    foreach ($results as $photo) {
                        $photos[] = array('thumbnail' => $photo->mediaGroup->thumbnail[0]->url, 'fullsize' => $photo->mediaGroup->content[0]->url, 'title' => $photo->mediaGroup->description->text);
                    }
                }
                try {
                    $results = $results->getNextFeed();
                } catch (Exception $e) {
                    $results = null;
                }
            }
            $plugin_template = dirname(__FILE__) . '/loop-picasa.php';
            $theme_template = get_theme_root() . '/' . get_template() . '/loop-picasa.php';
            $template_path = file_exists($theme_template) ? $theme_template : $plugin_template;
            ob_start();
            include $template_path;
            $html = ob_get_contents();
            ob_end_clean();
            return $html;
        } catch (Exception $ex) {
            return '<p style="color:red">' . $ex->getMessage() . '</p>';
        }
    } else {
        return '';
        //empty login or password
    }
}
Пример #10
0
        public function __construct() {
            require_once 'Zend/Loader.php';
            Zend_Loader::loadClass('Zend_Gdata_Photos');
            Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
            Zend_Loader::loadClass('Zend_Gdata_AuthSub'); 

            $serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
            $username = '******';
            $password = '******';
            $client = Zend_Gdata_ClientLogin::getHttpClient( $username, $password, $serviceName );

            $gp = new Zend_Gdata_Photos( $client, 'Dionyziz-Life-1.0' );

            $query = $gp->newAlbumQuery();

            $query->setUser( 'default' );
            $query->setAlbumName( 'Sikinos' );

            $albumFeed = $gp->getAlbumFeed( $query );

            $i = 0;
            foreach ( $albumFeed as $albumEntry ) {
                try { 
                    $albumid = $albumEntry->getGphotoAlbumId();

                    $exif = $albumEntry->getExifTags();
                    $time = $exif->getTime();
                    if ( $time == null ) {
                        echo "Photo does not contain time information.\n";
                        continue;
                    }
                    $timestamp = $time->getText();

                    $mediaContentArray = $albumEntry->getMediaGroup()->getContent();
                    $contentUrl = $mediaContentArray[ 0 ]->getUrl();
                    $mediaThumbnailArray = $albumEntry->getMediaGroup()->getThumbnail();
                    if ( $mediaThumbnailArray == null ) {
                        echo "Photo does not contain thumbnail.\n";
                        continue;
                    }
                    $maxwidth = 0;
                    $maxid = 0;
                    foreach ( $mediaThumbnailArray as $id => $thumb ) {
                        if ( $thumb->getWidth() > $maxwidth ) {
                            $maxwidth = $thumb->getWidth();
                            $maxid = $id;
                            $thumbnailUrl = $thumb->getUrl();
                        }
                    }

                    // echo "Importing image " . $contentUrl . " from Picasa... ";
                    // $diff = 1310008564116;
                    $link = $albumEntry->getAlternateLink()->getHref();
                    $parts = explode( '/', $link );
                    $userid = $parts[ 3 ];
                    $parts = explode( '#', $link );
                    $photoid = $parts[ 1 ];
                    $link = 'https://plus.google.com/photos/' . $userid . '/albums/' . $albumid . '/' . $photoid;
                    // echo( $link . ': ' . date( "Y-m-d H:i:s", $timestamp - $diff ) . "\n" );
                    Post::update( 
                        Post::create( 'picasa:' . $contentUrl . ' ' . $thumbnailUrl . ' ' . $link, 1, 'photo', 'public' ),
                        date( "Y-m-d H:i:s", $timestamp / 1000 )
                    );
                    ++$i;
                    echo $i . ' / ' . count( $albumFeed ) . "\n";
                }
                catch ( Exception $e ) {
                    echo "Failed to retrieve photo EXIF information.\n";
                }
            }
        }