public function testGetSizesCacheHit()
 {
     $this->cache->expects($this->once())->method('getItem')->with(1234)->will($this->returnValue(array('Image information')));
     $this->service->expects($this->never())->method('getSizes');
     $result = $this->serviceCache->getSizes(1234);
     $this->assertEquals(array('Image information'), $result);
 }
 function Photos()
 {
     Requirements::javascript("flickrservice/javascript/prototype.js");
     Requirements::javascript("flickrservice/javascript/effects.js");
     Requirements::javascript("flickrservice/javascript/lightwindow.js");
     Requirements::css("flickrservice/css/FlickrGallery.css");
     Requirements::css("flickrservice/css/lightwindow.css");
     if ($pos = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
         $version = substr($_SERVER['HTTP_USER_AGENT'], $pos + 5, 3);
         if ($version < 7) {
             Requirements::css("flickrservice/css/lightwindowIE6.css");
         }
     }
     $flickr = new FlickrService();
     try {
         $photos = $flickr->getPhotos(NULL, $this->User, $this->NumberToShow, 1, $this->Sortby);
     } catch (Exception $e) {
         return false;
     }
     $output = new DataObjectSet();
     foreach ($photos->PhotoItems as $photo) {
         $output->push(new ArrayData(array("Title" => htmlentities($photo->title), "Link" => "http://farm1.static.flickr.com/" . $photo->image_path . ".jpg", "Image" => "http://farm1.static.flickr.com/" . $photo->image_path . "_s.jpg")));
     }
     return $output;
 }
예제 #3
0
 /**
  * @covers FA\Service\ImageService::findAll
  */
 public function testFindAll()
 {
     $imageData = array(array('day' => '1', 'photo_id' => '11'), array('day' => '2', 'photo_id' => '22'), array('day' => '3', 'photo_id' => '33'));
     $imageSizes = array(array('sizes' => array(11)), array('sizes' => array(22)), array('sizes' => array(33)));
     $this->dao->expects($this->once())->method('findAll')->will($this->returnValue($imageData));
     $expected = array();
     // The Flickr service should be called as many times as there are
     // data elements returned from the dao
     foreach ($imageData as $index => $image) {
         $expected[] = array_merge($image, $imageSizes[$index]);
         $this->flickr->expects($this->at($index))->method('getSizes')->with($image['photo_id'])->will($this->returnValue($imageSizes[$index]));
     }
     $result = $this->service->findAll();
     $this->assertEquals($expected, $result);
 }
예제 #4
0
 /**
  * @param  string
  */
 public function __construct($api_key, $shared_secret = null)
 {
     $this->api_key = $api_key;
     $this->shared_secret = $shared_secret;
     #iconv_set_encoding('output_encoding', 'UTF-8');
     #iconv_set_encoding('input_encoding', 'UTF-8');
     #iconv_set_encoding('internal_encoding', 'UTF-8');
     self::$instance = $this;
 }
 function getFlickrPage($page)
 {
     $flickr = new FlickrService();
     switch ($this->Method) {
         case 1:
             $photos = $flickr->getPhotos($this->Tags, $this->User, $this->NumberToShow, $page, $this->Sortby);
             break;
         case 2:
             $photos = $flickr->getPhotos($this->Tags, NULL, $this->NumberToShow, $page, $this->Sortby);
             break;
         case 3:
             $photos = $flickr->getPhotoSet($this->Photoset, $this->User, $this->NumberToShow, $page);
             break;
         case 4:
             $photos = $flickr->getPhotosFromGroupPool($this->GroupID, $this->Tags, $this->User, $this->NumberToShow, $page, $this->SortBy);
             break;
     }
     return $photos;
 }
 /**
  * Sets the Flickr userID
  */
 static function setAPIUserID($userID)
 {
     self::$api_userID = $userID;
 }
예제 #7
0
 function getLatestFlickrPhotos($num)
 {
     $flickr = new FlickrService();
     $photos = $flickr->getPhotos("", "api", $num, 1, 'date-posted-desc');
     return $photos;
 }
 /**
  * Save the cleanup and redirect
  */
 function uploadimages($data, $form)
 {
     //Check there is a member! IF not return false
     $member = Member::currentUser();
     if (!$member) {
         $form->sessionMessage(_t("Create.CLEANUPCREATTIONERROR", "You Need to be logged in to Edit An Event"), 'bad');
         Director::redirectBack();
     } else {
         //$fri = (!empty($_REQUEST['Friday'])) ? $_REQUEST['Friday'] : null;
         //CLEANUP EVENT WE ARE ADDING IMAGES FO
         $cleanupID = !empty($_REQUEST['CleanUpID']) ? $_REQUEST['CleanUpID'] : null;
         $cleanupgroup = DataObject::get_one('CleanUpGroup', "CleanUpGroup.ID = '{$cleanupID}'");
         if (!$cleanupgroup) {
             $form->sessionMessage(_t("Create.CLEANUPIMAGEUPLOADERROR", "You Need to have a Clean Up Event to add images "), 'bad');
             Director::redirectBack();
         } else {
             $curralbum = DataObject::get_one('ImageGalleryAlbum', "ImageGalleryAlbum.CleanUpGroupID = '{$cleanupgroup->ID}'");
             //add image to flickr
             if (isset($data['ImageID'])) {
                 //Debug::show($data);
                 //Debug::show("Upload attempt: ImageID: " . $data['ImageID'] . "  Title: " . "Photo from Love Your Coast event: " . $cleanupgroup->Title . " . <a href=\"http://www.loveyourcoast.org".$cleanupgroup->Link()."\">Visit this event on LoveYourCoast.org</a>  Caption:  " . $data['Caption'] . "  MT: " . $cleanupgroup->machineTag());
                 $flickr = new FlickrService();
                 $flickr->uploadPhoto($data['ImageID'], "Love Your Coast Event - " . $cleanupgroup->Title, "- " . $data['Caption'] . " -      Visit this event -> http://www.loveyourcoast.org" . $cleanupgroup->Link() . "", $cleanupgroup->machineTag());
             }
             //1) Album Check Existing
             if ($curralbum) {
                 //2) Add Images
                 $imageitem = new ImageGalleryItem();
                 $imageitem->CleanUpGroupID = $cleanupgroup->ID;
                 $form->saveInto($imageitem);
                 $imageitem->ImageGalleryPageID = 13;
                 $imageitem->AlbumID = $curralbum->ID;
                 $imageitem->write();
                 //Should redirect to gallery
                 $folderid = $curralbum->FolderID;
                 $folder = DataObject::get_one('Folder', "ID = '{$folderid}'");
                 $gallerylink = '/lyc2010_live/gallery10/album/' . $folder->Name;
                 Director::redirect($cleanupgroup->Link());
             } else {
                 //1a) Create Album & Folder
                 $album = new ImageGalleryAlbum();
                 $album->AlbumName = $cleanupgroup->Title;
                 $album->CleanUpGroupID = $cleanupgroup->ID;
                 $album->ImageGalleryPageID = 13;
                 $folder = Folder::findOrMake('image-gallery/Gallery10/' . $cleanupgroup->Title);
                 $album->FolderID = $folder->ID;
                 $album->write();
                 //2) Add Images
                 $imageitem = new ImageGalleryItem();
                 $imageitem->CleanUpGroupID = $cleanupgroup->ID;
                 $form->saveInto($imageitem);
                 $imageitem->ImageGalleryPageID = 13;
                 $imageitem->AlbumID = $album->ID;
                 $imageitem->write();
                 //Should redirect to gallery
                 $gallerylink = '/lyc2010_live/gallery10/album/' . $folder->Name;
                 Director::redirect($cleanupgroup->Link());
             }
         }
     }
 }
 function getFlickrPhotos($num)
 {
     $flickr = new FlickrService();
     $photos = $flickr->getPhotosMT($this->machineTag(), "api", $num, 1, 'date-posted-desc');
     return $photos;
 }
<?php

//WARNING THIS IS A MODIFIED FLICKR SERVICE MODULE AND CANT BE REPLACE BY AN UPDATE
//WARNING THIS IS A MODIFIED FLICKR SERVICE MODULE AND CANT BE REPLACE BY AN UPDATE
// TEST ACCOUNT PORCELAINSANDBOX FULL PERMS
//FlickrService::setAPIKey('0ebee44ef342aae5132e7af0774bb822');
//FlickrService::setAPISecret('debdd570e48a5c4a');
//FlickrService::setAPIToken('72157625234038427-8b4d4a488e8a38f9');
// LIVE ACCOUNT LOVEYOURCOAST FULL PERMS
FlickrService::setAPIKey('dd4874143d7466a9d5745f5e37646380');
FlickrService::setAPISecret('149c0975ee9c29b8');
FlickrService::setAPIToken('72157625341560661-78dae2da5bacfb83');
FlickrService::setAPIUserID('54809682@N03');