/** * get images from flickr * @author - Henry Addo * @access - public * @return - Array of images */ public function get_images() { $username = ""; $photo_urls = "http://www.flickr.com/photos/eyedol/"; $tags = "tedglobal2007"; // create instance of phpFlickr class $flickr = new phpFlickr(''); //enable caching $flickr->enableCache(""); //authenticate //$flickr->auth(); //get token //$token = $token['user']['nsid']; // get NSID of the username $nsid = $token['user']['nsid']; $user = $flickr->people_findByUsername($username); //get the friendly URL of the the users' photos $photos_url = $flickr->urls_getUserPhotos($username); // get 20 images of public images of the user //$photos = $flickr->photos_search( array( 'tags'=>$tags, //'per_page'=> 200 ) ); $photos = $flickr->people_getPublicPhotos($username, NULL, 36); // loop through the photos foreach ((array) $photos['photo'] as $photo) { $this->images[] = "<li><a href=\"#\">\n <img alt='{$photo['title']}' title='{$photo['title']}'\n src=\"" . $flickr->buildPhotoURL($photo, 'Square') . "\" \n onclick=\"get_image_id('" . $flickr->buildPhotoURL($photo) . "','{$photo['title']}')\"/></a></li>"; $owner = $flickr->people_getInfo($photo[owner]); $this->owner = $owner['username']; } return $this->images; }
public function getFotos() { $f = new phpFlickr("f8dfa483443f9424a79d73c50344b90c"); //Clase de Api, conseguir en: http://www.flickr.com/services/api/keys/ $nsid = "139950084@N02"; //NSID Usuario, conseguir en: http://idgettr.com/ //Incluir tag, ordenamieno, privacidad, y numero de imagenes a mostrar $tagsList = $f->tags_getListUser($nsid); $j = 0; foreach ($tagsList as $tagl) { $photos = $f->photos_search(array("tags" => $tagl['_content'], "user_id" => $nsid, "sort" => "date-posted-desc", "privacy_filter" => "1")); //$photoList[$tagl['_content']] = $photos['photo']; $i = 0; $photoList[$j]['tag'] = $tagl['_content']; foreach ($photos['photo'] as $photo) { $photoList[$j]['photos'][$i]['id'] = $photo['id']; $photoList[$j]['photos'][$i]['url'] = $f->buildPhotoURL($photo, "Medium 640"); $i++; } $j++; /* if (is_array($photos['photo'])){ $i = 0; foreach ($photos['photo'] as $photo){ $photoList[$tagl['_content']][$i] = $f->buildPhotoURL($photo, "Medium 640"); } }*/ } return $photoList; }
function searchFlickrPhotoDetail($id, $type) { $retval = array(); $data = array(); $f = new phpFlickr('5bc169cff7b9121c0c93f9b8804b1116'); $photo = $f->photos_getInfo($id); $tags = ''; foreach ($photo['tags']['tag'] as $tag) { $tags .= $tag['raw'] . ','; //$tag['raw'] } $notes = array(); foreach ($photo['notes']['note'] as $note) { $notes[] = $note['_content']; } $urls = array(); foreach ($photo['urls']['url'] as $url) { $urls = $url['_content']; } $data = array('title' => $photo['title'], 'description' => $photo['description'], 'image' => $f->buildPhotoURL($photo), 'date' => $photo['dates']['taken'], 'author' => $photo['owner']['username'], 'authorUrl' => 'http://flickr.com/photos/' . $photo['owner']['nsid'], 'tags' => $tags, 'note' => $notes, 'url' => $urls); $retval['status'] = 'OK'; $retval['statusmsg'] = 'OK'; $retval['data'] = $data; return $retval; }
function flickr_stream($username, $api_key) { require_once "phpflickr/phpFlickr.php"; $phpFlickrObj = new phpFlickr($api_key); $phpFlickrObj->enableCache("fs", TEMPLATEPATH . "/cache"); $user = $phpFlickrObj->people_findByUsername($username); $user_url = $phpFlickrObj->urls_getUserPhotos($user['id']); $photos = $phpFlickrObj->people_getPublicPhotos($user['id'], NULL, NULL, 9); foreach ($photos['photos']['photo'] as $photo) { echo '<a href="' . $user_url . $photo['id'] . '" title="' . $photo['title'] . ' (on Flickr)" target="_blank">'; echo '<img style="width: 64px; height: 64px; margin: 1px; padding: 2px; border: 3px solid #ddd; background: #fff;" class="wp-image" alt="' . $photo['title'] . '" src="' . $phpFlickrObj->buildPhotoURL($photo, "square") . '" />'; echo '</a>'; } }
function display() { $flickr = new phpFlickr(ModUtil::getVar('Content', 'flickrApiKey')); $flickr->enableCache("fs", System::getVar('temp')); // Find the NSID of the username $person = $flickr->people_findByUsername($this->userName); // Get the photos //$photos = $flickr->people_getPublicPhotos($person['id'], NULL, $this->photoCount); $photos = $flickr->photos_search(array('user_id' => $person['id'], 'tags' => $this->tags, 'per_page' => $this->photoCount)); $photoData = array(); foreach ((array) $photos['photo'] as $photo) { $photoData[] = array('title' => DataUtil::formatForDisplayHTML($this->decode($photo['title'])), 'src' => $flickr->buildPhotoURL($photo, "Square"), 'url' => "http://www.flickr.com/photos/{$photo['owner']}/{$photo['id']}"); } $this->view->assign('photos', $photoData); return $this->view->fetch($this->getTemplate()); }
function jeg_get_flickr_photo($flickrapi, $flickrid, $totalimage) { require_once JEG_PLUGIN_DIR . "util/phpFlickr/phpFlickr.php"; $f = new phpFlickr($flickrapi); $result = $f->people_getPublicPhotos($flickrid, null, null, $totalimage, null); $photos = array(); if (empty($result)) { echo $f->getErrorMsg(); } else { $photosUrl = $f->urls_getUserPhotos($flickrid); foreach ($result['photos']['photo'] as $photo) { $photos[] = array('s' => $f->buildPhotoURL($photo, 'square'), 'url' => $photosUrl . $photo['id'], 'title' => $photo['title']); } } return $photos; }
function displayFlickrPhotos() { if (isset($_GET['q']) && isset($_GET['maxResults'])) { $flickrKey = 'b1a69066d658530df604321f514b72d0'; $flickrSecret = '9e0e977d109675fa'; require_once 'phpFlickr.php'; $f = new phpFlickr($flickrKey); $recent = $f->photos_search(array("tags" => $_GET['q'], "tag_mode" => "any", "per_page" => $_GET['maxResults'], "extras" => "url_sq")); $url = array(); $urls = array(); if (count($recent['photo']) < 1) { echo '<h5>There are no Results Found</h5>'; } else { foreach ($recent['photo'] as $photo) { $urls[] = $f->buildPhotoURL($photo, "Medium"); } foreach ($urls as $url) { echo '<img src="' . $url . '">'; } } } }
<?php /* Last updated with phpFlickr 1.3.2 * * This example file shows you how to call the 100 most recent public * photos. It parses through them and prints out a link to each of them * along with the owner's name. * * Most of the processing time in this file comes from the 100 calls to * flickr.people.getInfo. Enabling caching will help a whole lot with * this as there are many people who post multiple photos at once. * * Obviously, you'll want to replace the "<api key>" with one provided * by Flickr: http://www.flickr.com/services/api/key.gne */ require_once "phpFlickr.php"; $f = new phpFlickr("3077891bafd02f95795c02a20be57144"); $recent = $f->people_getPublicPhotos('31446365@N05', null, null, 2); $photos = array(); if (empty($recent)) { echo $f->getErrorMsg(); } else { foreach ($recent['photos']['photo'] as $photo) { $photos[] = array('s' => $f->buildPhotoURL($photo, 'square'), 'o' => $f->buildPhotoURL($photo, 'original'), 'title' => $photo['title']); } }
function flickrbadge($params = array()) { $defaults = array('key' => false, 'username' => false, 'limit' => 10, 'format' => 'square', 'cache' => true, 'refresh' => 60 * 60 * 2); $options = array_merge($defaults, $params); // check the cache dir $cacheDir = c::get('root.cache') . '/flickrbadge'; dir::make($cacheDir); // disable the cache if adding the cache dir failed if (!is_dir($cacheDir) || !is_writable($cacheDir)) { $options['cache'] = false; } if (!$options['key']) { return false; } if (!$options['username']) { return false; } $cacheID = 'flickrbadge/data.' . md5(serialize($options)) . '.php'; if ($options['cache']) { $cache = cache::modified($cacheID) < time() - $options['refresh'] ? false : cache::get($cacheID); } else { $cache = false; } if (!empty($cache)) { return $cache; } $flickr = new phpFlickr($options['key']); $userCacheID = 'flickrbadge/user.' . md5($options['username']) . '.php'; $userCache = $options['cache'] ? cache::get($userCacheID) : false; $user = false; $url = false; if (!empty($userCache)) { $user = a::get($userCache, 'user'); $url = a::get($userCache, 'url'); } if (!$user || !$url) { $user = $flickr->people_findByUsername($options['username']); $url = $flickr->urls_getUserPhotos($user['id']); if ($options['cache']) { cache::set($userCacheID, array('user' => $user, 'url' => $url)); } } $photos = $flickr->people_getPublicPhotos($user['id'], NULL, NULL, $options['limit']); $result = array(); foreach ($photos['photos']['photo'] as $photo) { $photoCacheID = 'flickrbadge/photo.' . $photo['id'] . '.php'; $info = $options['cache'] ? cache::get($photoCacheID) : false; if (empty($info)) { $info = $flickr->photos_getInfo($photo['id']); if ($options['cache']) { cache::set($photoCacheID, $info); } } $info = a::get($info, 'photo', array()); $dates = a::get($info, 'dates', array()); $tags = array(); foreach ((array) $info['tags']['tag'] as $t) { if (!empty($t['raw']) && !$t['machine_tag']) { $tags[] = $t['raw']; } } $result[] = new obj(array('url' => $url . $photo['id'], 'title' => a::get($info, 'title', $photo['title']), 'description' => @$info['description'], 'src' => $flickr->buildPhotoURL($photo, $options['format']), 'taken' => isset($dates['taken']) ? strtotime($dates['taken']) : false, 'posted' => isset($dates['posted']) ? $dates['posted'] : false, 'lastupdate' => isset($dates['lastupdate']) ? $dates['lastupdate'] : false, 'views' => a::get($info, 'views', 0), 'comments' => a::get($info, 'comments', 0), 'tags' => $tags)); } $result = new obj($result); if ($options['cache']) { cache::set($cacheID, $result); } return $result; }
function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $s_flickr_title = empty($instance['s_flickr_title']) ? '' : apply_filters('widget_s_flickr_title', $instance['s_flickr_title']); $s_flickr_choice = empty($instance['s_flickr_choice']) ? '14897087@N04' : apply_filters('widget_s_flickr_choice', $instance['s_flickr_choice']); $s_flickr_noi = empty($instance['s_flickr_noi']) ? 6 : apply_filters('widget_s_flickr_noi', $instance['s_flickr_noi']); $s_flickr_tou = empty($instance['s_flickr_tou']) ? 'user' : apply_filters('widget_s_flickr_tou', $instance['s_flickr_tou']); $loop_q = ''; if ($s_flickr_tou == 'user' && vp_option('vpt_option.flickr_key') != '') { $flickr_key_opt = esc_attr(vp_option('vpt_option.flickr_key')); require_once locate_template('/inc/phpFlickr.php'); $f = new phpFlickr($flickr_key_opt); $photos = $f->people_getPublicPhotos($s_flickr_choice, NULL, NULL, $s_flickr_noi); $loop_q = $photos['photos']['photo']; } else { if ($s_flickr_tou == 'all_tag' && vp_option('vpt_option.flickr_key') != '') { $flickr_key_opt = esc_attr(vp_option('vpt_option.flickr_key')); require_once locate_template('/inc/phpFlickr.php'); $f = new phpFlickr($flickr_key_opt); $photos = $f->photos_search(array('tags' => $s_flickr_choice, 'tag_mode' => 'any', 'per_page' => $s_flickr_noi, 'sort' => 'relevance')); $loop_q = $photos['photo']; } } if ($s_flickr_title != '') { echo $before_title . $s_flickr_title . $after_title; } if (!empty($photos)) { $fancybox_uid = k_rnd_key(6); echo '<ul class="list-unstyled clear-margins">'; foreach ($loop_q as $photo) { echo '<li><a href="' . $f->buildPhotoURL($photo, 'large') . '" title="' . $photo['title'] . '" class="swipebox" rel="flickrgal-' . $fancybox_uid . '"><img src="' . $f->buildPhotoURL($photo, 'square') . '" alt="' . $photo['title'] . '" /></a></li>'; } echo '</ul>'; } else { echo '<p>' . __('No photos matching given criteria.', 'kazaz') . '</p>'; } echo $after_widget; }
function getPhotosetData($photoset, $params) { $data = array(); if (empty($photoset)) return $data; $photos = null; $photoset = AriUtils2::getParam($photoset, 'photoset', $photoset); if ($photoset) $photos = AriUtils2::getParam($photoset, 'photo'); if (empty($photos)) return $data; $photosetId = AriUtils2::getParam($photoset, 'id', null); $thumbSize = AriUtils2::getParam($params, 'thumbSize', 'thumbnail'); $imgSize = $params['imgSize']; foreach ($photos as $photo) { $thumbUrl = @phpFlickr::buildPhotoURL($photo, $thumbSize); $title = str_replace('"', '"', AriUtils2::getParam($photo, 'title', '')); $data[$photo['id']] = array( 'photosetId' => $photosetId, 'dateUpload' => AriUtils2::getParam($photo, 'dateupload'), 'lastUpdate' => AriUtils2::getParam($photo, 'lastupdate'), 'imgUrl' => @phpFlickr::buildPhotoURL($photo, $imgSize), 'thumbUrl' => @phpFlickr::buildPhotoURL($photo, $thumbSize), 'Title' => $title, 'w' => $this->getPhotoWidth($photo, $thumbSize), 'h' => $this->getPhotoHeight($photo, $thumbSize) ); } return $data; }
$flickr_gallery->enableCache('fs', 'cache'); $flickr_gallery_people = $flickr_gallery->people_findByUsername($flickr_username); $flickr_gallery_user_id = $flickr_gallery_people['id']; $flickr_gallery_photos = $flickr_gallery->photosets_getPhotos($flickr_photoset_id, null, null); ?> <div id="slider" class="flickr-gallery"> <h2>Interior Design Gallery</h2> <div class="infiniteCarousel"> <div class="wrapper"> <ul> <?php foreach ($flickr_gallery_photos['photoset']['photo'] as $photo) { ?> <li><a href="<?php echo $flickr_gallery->buildPhotoURL($photo, 'Large'); ?> " rel="facebox" title="<?php echo $photo['title']; ?> "><img class="photo" src="<?php echo $flickr_gallery->buildPhotoURL($photo, 'Square'); ?> " width="140" height="100" /></a></li> <?php } ?> </ul> </div> </div> </div>
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { // called when admin sidebar is being "built" case 'backend_sidebar_entries_images': ?> <li class="serendipitySideBarMenuLink serendipitySideBarMenuMediaLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=flickr"> <?php echo PLUGIN_EVENT_FLICKR_NAME; ?> </a></li><?php break; // called when admin sidebar is been "drawn" // called when admin sidebar is been "drawn" case 'backend_sidebar_entries_event_display_flickr': // he, is user allowed to import images ?!? if (!serendipity_checkPermission('adminImagesAdd')) { // TODO: add a message to the user ?!? break; } // if method is POST, we must have a valid form token ! if ($_SERVER['REQUEST_METHOD'] == 'POST' && !serendipity_checkFormToken()) { // TODO: add a message to the user ?!? break; } ?> <?php echo PLUGIN_EVENT_FLICKR_IMPORT_BLAHBLAH; ?> <script type="text/javascript"> function flickr_showPage(p) { var f = document.getElementById('flickr_uploadform'); f.elements['serendipity[flickr_page]'].value = p; f.submit(); } function flickr_doImport(url) { var f = document.getElementById('flickr_uploadform'); f.elements['serendipity[adminModule]'].value = 'images'; f.elements['serendipity[adminAction]'].value = 'add'; f.elements['serendipity[imageurl]'].value = url; f.submit(); } function flickr_toggleExtended() { var d = document.getElementById('flickr_extendedCriteria'); d.style.display = (d.style.display != '') ? '' : 'none'; } </script> <h3><? echo PLUGIN_EVENT_FLICKR_IMPORT; ?></h3> <form action="?" method="POST" id="flickr_uploadform" enctype="multipart/form-data" onsubmit=""> <?php echo serendipity_setFormToken(); ?> <?php // these two fields will only be used when an image has been chosen for dl ?> <input type="hidden" name="serendipity[imageurl]" value="" /> <input type="hidden" name="serendipity[imageimporttype]" value="image" /> <input type="hidden" name="serendipity[action]" value="admin" /> <input type="hidden" name="serendipity[adminModule]" value="event_display" /> <input type="hidden" name="serendipity[adminAction]" value="flickr" /> <input type="hidden" name="serendipity[flickr_page]" value="1" /> Flickr username: <input class="input_textbox" name="serendipity[flickr_username]" value="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_username']) : htmlspecialchars($serendipity['POST']['flickr_username'], ENT_COMPAT, LANG_CHARSET); ?> " /> <input type="submit" value="<?php echo GO; ?> " class="serendipityPrettyButton input_button" /><br /><br /> <a style="border: 0pt none ; text-decoration: none;" href="#" onclick="flickr_toggleExtended(); return false" title="<?php echo TOGGLE_OPTION; ?> "> <img border="0" src="<?php echo serendipity_getTemplateFile('img/plus.png'); ?> " /> <?php echo TOGGLE_ALL; ?> </a> <div id="flickr_extendedCriteria" <?php echo strlen($serendipity['POST']['flickr_username']) ? '' : 'style="display:none;"'; ?> > <p><?php echo PLUGIN_EVENT_FLICKR_TAGS; ?> <input class="input_textbox" name="serendipity[flickr_tags]" value="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_tags']) : htmlspecialchars($serendipity['POST']['flickr_tags'], ENT_COMPAT, LANG_CHARSET); ?> " /> <?php echo PLUGIN_EVENT_FLICKR_KEYWORDS; ?> <input class="input_textbox" name="serendipity[flickr_keywords]" value="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_keywords']) : htmlspecialchars($serendipity['POST']['flickr_keywords'], ENT_COMPAT, LANG_CHARSET); ?> " size="30" /></p> <?php echo SORT_BY; ?> <select id="flickr_sort" name="serendipity[flickr_sort]"> <option value=""></option> <? // See API for details (http://www.flickr.com/services/api/flickr.photos.search.html) $flickr_goodSortOrders = array( 'date-posted-asc'=>'By date of post, ascending', 'date-posted-desc'=>'By date of post, descending', 'date-taken-asc'=>'By date of take, ascending', 'date-taken-desc'=>'By date of take, descending', 'interestingness-asc'=>'By interestingness, ascending', 'interestingness-desc'=>'By interestingness, ascending', 'relevance'=>'By revelance' ); // compute sort order $sortOrder = (isset($serendipity['POST']['flickr_keywords']) && array_key_exists($serendipity['POST']['flickr_keywords'], $flickr_goodSortOrders) ? (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_keywords']) : htmlspecialchars($serendipity['POST']['flickr_keywords'], ENT_COMPAT, LANG_CHARSET)) : ''); // display possible options for sort order foreach($flickr_goodSortOrders as $value => $description) { echo '<option value="'.$value.'"'; if($sortOrder == $value) echo(' selected="true"'); echo '>'.$description.'</option>'; } ?> </select> </div> </form> <?php // in the second step, we show latest photos (thumbs) for given username if ($serendipity['POST']['adminAction'] == 'flickr') { // make use of phpFlikr lib (http://www.phpflickr.com/) require_once dirname(__FILE__) . '/phpFlickr/phpFlickr.php'; $f = new phpFlickr($this->get_config('api_key')); $i = 0; if (!empty($serendipity['POST']['flickr_username'])) { // Find the NSID of the username inputted via the form $nsid = $f->people_findByUsername($serendipity['POST']['flickr_username']); // Get the friendly URL of the user's photos $photos_url = $f->urls_getUserPhotos($nsid); echo '<h4 style="margin-bottom: 0; padding-bottom: 0;">Photos of <em>'; echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_username']) : htmlspecialchars($serendipity['POST']['flickr_username'], ENT_COMPAT, LANG_CHARSET)) . '</em> at '; echo '<a href="' . $photos_url . '" target="_blank">' . $photos_url . '</a></h4>'; // default page is number one if (empty($serendipity['POST']['flickr_page']) || !is_numeric($serendipity['POST']['flickr_page'])) { $serendipity['POST']['flickr_page'] = 1; } // make sure page is a number between 1 and 500 (range allowed by flickr API) $serendipity['POST']['flickr_page'] = min(500, max(1, (int) $serendipity['POST']['flickr_page'])); echo '<h5 style="margin-top: 0; padding-top: 0;">Displaying page ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_page']) : htmlspecialchars($serendipity['POST']['flickr_page'], ENT_COMPAT, LANG_CHARSET)) . '</h5>'; // Search is made depending on selected criterias $searchCriteria = array(); // make sure sort order is non empty AND valid if (isset($serendipity['POST']['flickr_sort']) && strlen(trim($serendipity['POST']['flickr_sort'])) && array_key_exists($serendipity['POST']['flickr_keywords'], $flickr_goodSortOrders)) { $searchCriteria['sort'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_sort']) : htmlspecialchars($serendipity['POST']['flickr_sort'], ENT_COMPAT, LANG_CHARSET); } // TODO: clean up tags of unwanted characters (keep only [a-zA-Z0-9_-]) if (isset($serendipity['POST']['flickr_tags']) && strlen(trim($serendipity['POST']['flickr_tags']))) { $searchCriteria['tags'] = implode(',', explode(' ', function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_tags']) : htmlspecialchars($serendipity['POST']['flickr_tags'], ENT_COMPAT, LANG_CHARSET))); } // TODO: cleanup keywords if (isset($serendipity['POST']['flickr_keywords']) && strlen(trim($serendipity['POST']['flickr_keywords']))) { $searchCriteria['text'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_keywords']) : htmlspecialchars($serendipity['POST']['flickr_keywords'], ENT_COMPAT, LANG_CHARSET); } if (count($searchCriteria)) { // It seems the user wants an advanced search $searchCriteria['user_id'] = $nsid; $photos = $f->photos_search($searchCriteria); } else { // No extra criteria, get the user's next 12 public photos (+1 to show > next or not !) $photos = $f->people_getPublicPhotos($nsid, NULL, 13, $serendipity['POST']['flickr_page']); // Get user's tags (if any) /*$tags = $f->tags_getListUser($nsid); if(is_array($tags['tags']['tag'])) { echo implode(',', $tags['tags']['tag']); echo "<br />\n"; }*/ } // Loop through the photos and output the html foreach ($photos['photo'] as $photo) { echo '<a title="Add to library" href="javascript:flickr_doImport(\'' . $f->buildPhotoURL($photo, 'Original') . '\');" '; echo 'onclick="return confirm(\'Import this photo into the media library ?\');">'; echo '<img border="0" alt="' . $photo['title'] . '" src=' . $f->buildPhotoURL($photo, 'Square') . ' />'; echo '</a>'; // break before the 13th photo (if any) if (++$i == 12) { break; } // If it reaches the sixth photo, insert a line break if ($i % 6 == 0) { echo "<br />\n"; } } // end foreach echo "<br />\n"; // navigate through pages of photos if ($serendipity['POST']['flickr_page'] > 1) { echo '<a href="javascript:flickr_showPage(' . (int) ($serendipity['POST']['flickr_page'] - 1) . ');">Previous</a>'; } echo ' '; if (count($photos['photo']) > 12) { echo '<a href="javascript:flickr_showPage(' . (int) ($serendipity['POST']['flickr_page'] + 1) . ');">Next</a>'; } } // end if } // end if return true; break; default: return false; break; } } else { return false; } }
//Incluyendo el API de Flickr $f = new phpFlickr("03e1411633d36816cc74fb82204549ec"); //Clase de Api, conseguir en: http://www.flickr.com/services/api/keys/ $nsid = ""; //NSID Usuario, conseguir en: http://idgettr.com/ //Incluir tag, ordenamieno, privacidad, y numero de imagenes a mostrar $photos = $f->photos_search(array("tags" => "mozilla-hispano", "user_id" => $nsid, "sort" => "date-posted-desc", "privacy_filter" => "1", "per_page" => "10")); $url = "//www.flickr.com/photos/" . $photo['id'] . "/"; //Url de la Imgen Original if (is_array($photos['photo'])) { echo "<div><ul>"; $sw = 1; foreach ($photos['photo'] as $photo) { if ($sw == 1) { $salida = "<li class='foto'>"; $salida .= "<a href='" . $f->buildPhotoURL($photo, "medium") . "' title='" . $photo['title'] . "' class='thickbox' rel='mozilla-hispano'><img alt='" . $photo['title'] . "' title='" . $photo['title'] . "' " . "src='" . $f->buildPhotoURL($photo, "square") . "' /></a>"; $sw = 0; } else { $salida .= "<a href='" . $f->buildPhotoURL($photo, "medium") . "' title='" . $photo['title'] . "' class='thickbox' rel='mozilla-hispano'><img alt='" . $photo['title'] . "' title='" . $photo['title'] . "' " . "src='" . $f->buildPhotoURL($photo, "square") . "' /></a>"; echo $salida . "</li>"; $sw = 1; } } echo "</ul></div>"; } ?> </div><!-- Fotos --> <p class="all-photos"><a href="//api.flickr.com/services/feeds/photos_public.gne?tags=mozilla-hispano&lang=es-us&format=rss_200"><img width="12" height="12" alt="" src="postload.php?url=http://api.flickr.com/services/feeds/photos_public.gne?tags=mozilla-hispano&lang=es-us&format=rss_200"/> RSS de las fotos</a></p> <p class="all-photos"><a href="http://www.flickr.com/photos/tags/mozilla-hispano/">Ver todas las fotos</a></p> </div>
{ mkdir($cacheFolderPath); } $lifetime = 860 * 860; // 60 * 60=One hour $f->enableCache("fs", "$cacheFolderPath", "$lifetime"); } ?> <?php if ($flickrCaption == "1") : ?> <div id="gallery"> <div class="photosets"> <?php $photos = $f->photosets_getPhotos($flickrSet, NULL, NULL, $flickrNumber); ?> <?php foreach ($photos['photoset']['photo'] as $photo): $d = $f->photos_getInfo($photo['id']); ?> <div class="photos"> <ul> <li> <a href="#"><img src="<?= $f->buildPhotoURL($photo, $flickrThumb) ?>" data-large="<?= $f->buildPhotoURL($photo, 'large') ?>" alt="<?= $photo['title'] ?>" data-description= "<?= $photo['title'] ?>" data-href="<?= $f->buildPhotoURL($photo, 'large') ?>" /></a> </a> </div> <?php endforeach ; ?> </div> </li> </ul> </div> </div> </div> </div> </div> </div> <?php elseif ($flickrCaption == "2") : ?> <div id="gallery"> <div class="photosets">
/* Last updated with phpFlickr 1.3.2 * * This example file shows you how to call the 100 most recent public * photos. It parses through them and prints out a link to each of them * along with the owner's name. * * Most of the processing time in this file comes from the 100 calls to * flickr.people.getInfo. Enabling caching will help a whole lot with * this as there are many people who post multiple photos at once. * * Obviously, you'll want to replace the "<api key>" with one provided * by Flickr: http://www.flickr.com/services/api/key.gne */ require_once "vendor/phpFlickr.php"; $f = new phpFlickr("f8dfa483443f9424a79d73c50344b90c"); //$f = new phpFlickr("f8dfa483443f9424a79d73c50344b90c"); //Clase de Api, conseguir en: http://www.flickr.com/services/api/keys/ $nsid = "139950084@N02"; //NSID Usuario, conseguir en: http://idgettr.com/ //Incluir tag, ordenamieno, privacidad, y numero de imagenes a mostrar $photos = $f->photos_search(array("tags" => "", "user_id" => $nsid, "sort" => "date-posted-desc", "privacy_filter" => "1", "per_page" => "20")); $url = "http://www.flickr.com/photos/" . $nsid . "/"; //Url de la Imgen Original if (is_array($photos['photo'])) { foreach ($photos['photo'] as $photo) { //$f->photos->getSizes(); $salida = "<div class='caja'>"; $salida .= "<a href='" . $url . $photo['id'] . "'><img alt='" . $photo['title'] . "' title='" . $photo['title'] . "' " . "src='" . $f->buildPhotoURL($photo, "Medium 640") . "' /></a>"; echo $salida . "</div>"; } }
<?php $f = new phpFlickr(get_option('colabs_api_flickr'), get_option('colabs_secret_flickr')); $recent = $f->people_getPublicPhotos(get_option('colabs_username_flickr'), NULL, NULL, get_option('colabs_piccount_flickr'), $paged); foreach ($recent['photos']['photo'] as $photo) { $title = $photo['title']; $urlimg = $f->buildPhotoURL($photo, "small"); $urlimgori = $f->buildPhotoURL($photo, "large"); $info = $f->photos_getInfo($photo['id']); $date = date(get_option('date_format'), $info['photo']['dateuploaded']); $view = $info['photo']['views']; echo '<li class="gallery-item"> <a href="' . $urlimgori . '" title="' . $title . '" rel="lightbox"> ' . colabs_image('width=280&link=img&return=true&src=' . $urlimg) . ' </a> <div class="like"> <p class="entry-likes"> <span>' . $view . ' </span> <i class="icon-heart"></i> </p> </div> <div class="time"> <p class="entry-time"> <i class="icon-time"></i> <span>' . $date . '</span> </p> </div> </li>'; }
$meta = get_metadata_byname($user->guid, $photo["id"]); /* if ($meta->value == 1) { //we've downloaded this already register_error( elgg_echo( 'flickr:errorimageimport' )); continue; } */ /* Disabled By Rijo Joy */ //store this so we don't download the same photo multiple times create_metadata($user->guid, $photo["id"], "1", "text", $user->guid, ACCESS_PUBLIC); $photo_info = $f->photos_getInfo($photo["id"], $photo["secret"]); $tags = array(); foreach ($photo_info["tags"]["tag"] as $tag) { $tags[] = $tag["raw"]; } $tags = implode(", ", $tags); $image_url = $f->buildPhotoURL($photo); $photos_to_upload[$photo_info["id"] . ".jpg"] = array("url" => $image_url, "tags" => $tags, "title" => $photo_info["title"], "description" => $photo_info["description"], "flickr_page" => "{$photos_url}{$photo['id']}"); $body .= "<div class='tidypics_album_images'>"; $body .= "{$photo_info['title']}<br />Views: {$photo_info['views']}<br />"; $body .= "<a href={$photos_url}{$photo['id']}>"; $body .= "<img border='0' alt='{$photo['title']}' " . "src='{$image_url}' />"; $body .= "</a>"; } // echo "<pre>"; var_dump( $photos_to_upload );; die; /** * Elgg multi-image uploader action * * This will upload up to 10 images at at time to an album */ global $CONFIG; include dirname(dirname(__FILE__)) . "/lib/resize.php";
<?php require_once "phpFlickr.php"; $phpFlickrObj = new phpFlickr('665302ccbe82f5ae7aa2328d7ce4f886'); $user = $phpFlickrObj->people_findByUsername('codemastersnake'); $user_url = $phpFlickrObj->urls_getUserPhotos($user['id']); $photos = $phpFlickrObj->people_getPublicPhotos($user['id'], NULL, NULL, 4); foreach ($photos['photos']['photo'] as $photo) { echo '<a href="' . $user_url . $photo['id'] . '" title="' . $photo['title'] . ' (on Flickr)" target="_blank">'; echo '<img style="border:1px solid" alt="' . $photo['title'] . '" src="' . $phpFlickrObj->buildPhotoURL($photo, "square") . '" />'; echo '</a>'; }
<div id="gallery"> <div class="photosets"> <?php $photos = $f->photosets_getPhotos($flickrSet, NULL, NULL, $flickrNumber); ?> <?php foreach ($photos['photoset']['photo'] as $photo) { $d = $f->photos_getInfo($photo['id']); ?> <div class="photos"> <ul> <li> <a href="#"><img src="<?php echo $f->buildPhotoURL($photo, $flickrThumb); ?> " data-large="<?php echo $f->buildPhotoURL($photo, 'large'); ?> " alt="<?php echo $photo['title']; ?> " data-description= "<?php echo $photo['title']; ?> " data-href="<?php echo $f->buildPhotoURL($photo, 'large'); ?> " /></a> </a>
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); if (empty($title)) { $title = false; } $flickr_api = $instance['flickr_api']; $flickr_id = $instance['flickr_id']; $number = absint($instance['number']); require_once get_template_directory() . "/includes/widgets/phpFlickr/phpFlickr.php"; $f = new phpFlickr($flickr_api); //Insert API key here $f->enableCache("fs", get_template_directory() . "/includes/widgets/cache/"); if (!empty($flickr_id)) { echo $before_widget; if ($title) { echo $before_title; echo $title; echo $after_title; } $apikey = $f->people_findByUsername($flickr_api); $person = $f->people_findByUsername($flickr_id); $photos_url = $f->urls_getUserPhotos($person['id']); $photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, $number); echo "<ul class='flickr_images clearfix'>"; foreach ((array) $photos['photos']['photo'] as $photo) { $photo_url = $f->buildPhotoURL($photo, "Large"); echo "<li><a class='view flickr-img-link' rel='flickr-gallery' target='_blank' href={$photo_url}>"; echo "<img class='flickr' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Small") . ">"; echo "</a></li>"; } echo "</ul>"; echo $after_widget; } }
// Get the friendly URL of the user's photos (this is the one you can define, not the random numbers with the at sign in it $photos_url = $f->urls_getUserPhotos($person['id']); //set the number of photos per page $photos_per_page = 16; //set page if there is one, otherwise get the first page if (0) { //$page = $_GET['page']; } else { $page = 1; } // Get the user photos based on photos per page and page $photos = $f->people_getPublicPhotos($person['id'], NULL, $photos_per_page, $page); //loop photos and titles out foreach ((array) $photos['photo'] as $photo) { //Now for an item. $photo_html .= '<div class="left"><a href="' . $photos_url . $photo[id] . '"><img border="0" alt="' . $photo[title] . '" src="' . $f->buildPhotoURL($photo, "square") . '" /></a><br /><p>' . $photo[title] . '</p></div>'; } //work out HTML for pagination for ($i = 1; $i < $photos['pages'] + 1; $i++) { if ($page != $i) { $pages_html .= '<a href="?page=' . $i . '">' . $i . '</a> '; } else { $pages_html .= $i . ' '; } } //end the php code and build html return ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
public function getItems() { jimport('joomla.filesystem.folder'); $api_key = '2a4dbf07ad5341b2b06d60c91d44e918'; $cache_path = JPATH_ROOT . '/cache/test/flickr'; $nsid = ''; $photos = array(); // create cache folder if not exist JFolder::create($cache_path, 0755); if (!class_exists('phpFlickr')) { require_once 'api/phpFlickr.php'; } $f = new phpFlickr($api_key); $f->enableCache('fs', $cache_path, $this->get('cache_time')); //enable caching if ($this->get('flickr_search_from') == 'user') { $username = $this->get('flickr_search_from'); if ($username != NULL) { $person = $f->people_findByUsername($username); $nsid = $person['id']; } else { return ''; } $photos = $f->people_getPublicPhotos($nsid, NULL, NULL, $this->get('item_count')); $source = $photos['photos']['photo']; } if ($this->get('flickr_search_from') == 'tags' or $this->get('flickr_search_from') == 'text') { $tags = $this->get('flickr_attrs'); if (!empty($tags)) { $attrs = ''; if ($this->get('flickr_search_from') == 'tags') { $attrs = 'tags'; } if ($this->get('flickr_search_from') == 'text') { $attrs = 'text'; } $photos = $f->photos_search(array($attrs => $tags, 'per_page' => $this->get('item_count'))); $source = $photos['photo']; } else { return ''; } } if ($this->get('flickr_search_from') == 'recent') { $photos = $f->photos_getRecent(NULL, $this->get('item_count')); $source = $photos['photo']; } //$extras = 'description,date_upload,owner_name,tags'; $items = array(); $i = 0; if (count($source) > 0) { foreach ($source as $photo) { $id = $photo['id']; $obj = new stdClass(); $info = $f->photos_getInfo($id); $nsid = $info['owner']['username']; $obj->title = $info['title']; $obj->image = $f->buildPhotoURL($photo, '_b'); $obj->link = $info['urls']['url'][0]['_content']; $obj->introtext = $info['description']; $obj->date = date('Y.M.d : H:i:s A', $info['dateuploaded']); $items[$i] = $obj; $i++; } } //return $items; var_dump($f); }
require_once "phpFlickr.php"; $f = new phpFlickr("cdebb75fb498222416d23dce91618f9a", "065215435996f0d9"); $photoset_id = "72157624682260557"; $secret = "065215435996f0d9"; $page = strip_tags($_GET["p"]); //$photos = $f->photosets_getPhotos($photoset_id, null, null, 7, $page ); $photos = $f->people_getPublicPhotos('50369640@N04', null, null, 7, $page); //function people_getPublicPhotos ($user_id, $safe_search = NULL, $extras = NULL, $per_page = NULL, $page = NULL) // changed by b3d $arr_photos = array($photos['photoset']['photo']); foreach ($arr_photos as $photo) { //foreach ($photos['photoset']['photo'] as $photo) { // end b3d // Build image and link tags for each photo $photoInfo = $f->photos_getInfo($photo[id]); echo "<li><a href=http://www.flickr.com/photos/" . $photoInfo['owner']['username'] . "/{$photo['id']}>"; echo "<img border='0' width='768' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Large") . "><div class='metaContainer'><span>" . $photoInfo['title'] . "</span>"; echo ' </a> <div class="addthis_toolbox addthis_default_style shareBox"> <a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4cd4693368857545" class="addthis_button_compact">Share</a> <span class="addthis_separator">|</span> <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a> <a class="addthis_button_bookmark"></a> <a class="addthis_button_print"></a> </div> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cd4693368857545"></script> </div> </li>'; }
unset($argst); $argst = array("text" => "" . $defwords . "", "min_taken_date" => "" . $fsdate . "", "max_taken_date" => "" . $fedate . "", "per_page" => "20", "sort" => "relevance", "page" => "1"); //print_r($argst); $triathlondaily = $f->photos_search($argst); //print_r($triathlondaily); for ($x = 0; $x <= 15; $x++) { $photosre = ''; $photosre = $triathlondaily[photo][$x]; $photo_id = ''; $photo_id = $triathlondaily[photo][$x][id]; //echo $photo_id; // need to find photo username to get data to allow form piciture flickr url $photoid = $f->photos_getInfo($photo_id, $secret); //print_r($photoid); //echo $photoid[urls][url][$x][_content]; $image = $f->buildPhotoURL($photosre, $size = "Thumbnail"); $imgtoday[$x][url] = $photoid[urls][url][0][_content]; $imgtoday[$x][title] = $photoid[title]; $imgtoday[$x][image] = $image; //print_r($imgtoday); } //closes forloop /*<div class="rphoto"><a href="<?php echo $photoid[urls][url][0][_content]?>" title="<?php echo $photoid[title]?>"><img src="<?php echo $image ?>" border ="1" /></a></div> */ if ($imgtoday) { $db->query = "INSERT INTO " . RSSDATA . ".imagesource (idstart, orderid, imgurl, title, sourceurl, enddate) VALUES "; foreach ($imgtoday as $key => $meimg) { $smeurl = mysql_real_escape_string($meimg[url]); $smetitle = mysql_real_escape_string($meimg[title]); $smeimg = mysql_real_escape_string($meimg[image]); $db->query .= "('{$idstart}', '{$key}', '{$smeurl}', '{$smetitle}', '{$smeimg}', '{$fedate}'),";
// remove existing photos $duplicates = 0; foreach ($all_photos as $i => $photo) { if (in_array($photo['id'], $existing_photos)) { unset($all_photos[$i]); $duplicates++; } } if ($duplicates > 0) { $page['infos'][] = '<a href="admin.php?page=batch_manager&filter=prefilter-flickr">' . l10n_dec('One picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates) . '</a>'; } // displayed photos $page_photos = array_slice($all_photos, $page['start'], $page['display']); $all_elements = array_map(create_function('$p', 'return \'"\'.$p["id"].\'"\';'), $all_photos); foreach ($page_photos as &$photo) { $photo['thumb'] = $flickr->buildPhotoURL($photo, "thumbnail"); $photo['src'] = $flickr->get_biggest_size($photo['id'], "medium_800"); $photo['url'] = $flickr_root_url . $photo['id']; } unset($photo); $template->assign(array('nb_thumbs_set' => count($all_photos), 'nb_thumbs_page' => count($page_photos), 'thumbnails' => $page_photos, 'all_elements' => $all_elements, 'album' => $_GET['album'], 'F_ACTION' => FLICKR_ADMIN . '-import&action=import_set', 'U_DISPLAY' => $self_url)); // get piwigo categories $query = ' SELECT id, name, uppercats, global_rank FROM ' . CATEGORIES_TABLE . ' ;'; display_select_cat_wrapper($query, array(), 'category_parent_options'); // get navbar $nav_bar = create_navigation_bar($self_url, count($all_elements), $page['start'], $page['display']); $template->assign('navbar', $nav_bar); break;
$photos_url = $f->urls_getUserPhotos($flickr_user["id"]); if (!empty($flickr_user)) { $recent = $f->people_getPublicPhotos($flickr_user['id'], NULL, NULL, 5); } else { echo "user not found"; die; } //echo "<pre>"; var_dump( $recent ); echo "</pre>"; //echo "<pre>"; var_dump( $user ); echo "</pre>"; $body = elgg_view_title("Flickr photos for {$flickr_user['username']}"); $count = 0; foreach ($recent['photos']['photo'] as $photo) { $photo_info = $f->photos_getInfo($photo["id"], $photo["secret"]); $body .= "<div class='tidypics_album_images'>"; $body .= "{$photo_info['title']}<br />Views: {$photo_info['views']}<br />"; $body .= "<a href={$photos_url}{$photo['id']}>"; $body .= "<img border='0' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Square") . ">"; $body .= "</a>"; $tag_count = 0; $body .= "<br /><div style='font-size: 8px;'>Tags:<br />"; foreach ($photo_info["tags"]["tag"] as $tag) { if ($tag_count) { $body .= ", "; } $body .= "{$tag['_content']}"; $tag_count++; } $body .= "</div></div>"; $count++; } page_draw("Flickr photos for {$flickr_user['username']}", elgg_view_layout("two_column_left_sidebar", '', $body));
} /* ------------------------------------ :: GRID ONLY *END* ------------------------------------ */ foreach ($photos['photoset']['photo'] as $photo) { $photodata = $f->photos_getInfo($photo['id']); if ('video' == $photodata['photo']['media']) { $sizes = $f->photos_getSizes($photo['id']); $NV_movieurl = $sizes[6]["source"]; // Movie File URL $NV_videotype = 'swf'; $NV_previewimgurl = ''; } else { $NV_previewimgurl = $f->buildPhotoURL($photo, $img_size); // Preview Image URL } $NV_posttitle = $photo['title']; $NV_description = $photo['description']; $NV_disablegallink = ''; $NV_galexturl = 'http://www.flickr.com/photos/' . $user; $NV_disablereadmore = 'yes'; $slide_id = ''; $slide_id = "slide-" . $post->ID; if (empty($NV_customlayer)) { $NV_customlayer = ''; } // Check is Timthumb is Enabled or Disabled if (of_get_option('timthumb_disable') != 'disable' && empty($NV_customlayer)) { require_once NV_FILES . '/adm/functions/BFI_Thumb.php';
header('Location:index.php'); } require_once "phpFlickr/phpFlickr.php"; $f = new phpFlickr("44449d9d74ed80abe095ab2a6f137dbe", "abde3a1309b8d8e1"); $photos = $f->photosets_getPhotos($_GET['id']); if (sizeof($photos['photoset']['photo']) <= 0) { header('Location:index.php'); } $p = $f->photosets_getInfo($photos['photoset']['id']); $set_title = $p['title']; include "header.php"; //include "sidebar.php"; ?> <div id="main_left"> <img src="<?php echo $f->buildPhotoURL($photos['photoset']['photo'][0], 'medium'); ?> " /> </div> <div id="main_right"> <ul id="gallery" class="gallery"> <?php $i = 0; foreach ((array) $photos['photoset']['photo'] as $photo) { //echo 'photo:'.$photo.'<hr />'; echo "<li><a href='" . $f->buildPhotoURL($photo, "medium") . "' title='" . $photo['title'] . "'>"; echo "<img alt='" . $photo['title'] . "' " . "src='" . $f->buildPhotoURL($photo, "square") . "' /></a></li>"; $i++; } ?> </ul>
function flickrps_createGallery($action, $atts) { global $flickr_photostream_imagesHeight_default; global $flickr_photostream_maxPhotosPP_default; global $flickr_photostream_lastRow_default; global $flickr_photostream_fixedHeight_default; global $flickr_photostream_pagination_default; global $flickr_photostream_lightbox_default; global $flickr_photostream_captions_default; global $flickr_photostream_randomize_default; global $flickr_photostream_margins_default; global $flickr_photostream_openOriginals_default; global $flickr_photostream_bcontextmenu_default; static $shortcode_unique_id = 0; $ris = ""; require_once "phpFlickr/phpFlickr.php"; $page_num = get_query_var('page') ? get_query_var('page') : 1; //Options----------------------- extract(shortcode_atts(array('user_id' => get_option('$flickr_photostream_userID'), 'id' => NULL, 'tags' => NULL, 'tags_mode' => 'any', 'images_height' => get_option('$flickr_photostream_imagesHeight', $flickr_photostream_imagesHeight_default), 'max_num_photos' => get_option('$flickr_photostream_maxPhotosPP', $flickr_photostream_maxPhotosPP_default), 'last_row' => get_option('$flickr_photostream_lastRow', $flickr_photostream_lastRow_default), 'fixed_height' => get_option('$flickr_photostream_fixedHeight', $flickr_photostream_fixedHeight_default) == 1, 'lightbox' => get_option('$flickr_photostream_lightbox', $flickr_photostream_lightbox_default), 'captions' => get_option('$flickr_photostream_captions', $flickr_photostream_captions_default) == 1, 'randomize' => get_option('$flickr_photostream_randomize', $flickr_photostream_randomize_default) == 1, 'pagination' => get_option('$flickr_photostream_pagination', $flickr_photostream_pagination_default), 'margins' => get_option('$flickr_photostream_margins', $flickr_photostream_margins_default), 'open_originals' => get_option('$flickr_photostream_openOriginals', $flickr_photostream_openOriginals_default) == 1, 'block_contextmenu' => get_option('$flickr_photostream_bcontextmenu', $flickr_photostream_bcontextmenu_default) == 1), $atts)); //LEGACY for the old options if ($pagination === '1') { $pagination = 'prevnext'; } else { if ($pagination !== 'none' && $pagination !== 'prevnext' && $pagination !== 'numbers') { $pagination = 'none'; } } if ($lightbox === '1') { $lightbox = 'colorbox'; } if ($lightbox === '0') { $lightbox = 'none'; } $images_height = (int) $images_height; if ($images_height < 30) { $images_height = 30; } $max_num_photos = (int) $max_num_photos; if ($max_num_photos < 1) { $max_num_photos = 1; } $margins = (int) $margins; if ($margins < 0) { $margins = 1; } if ($margins > 30) { $margins = 30; } if ($pagination === 'none') { $page_num = 1; } //----------------------------- //Inizialization--------------- $flickrAPIKey = get_option('$flickr_photostream_APIKey'); //Flickr API Key $f = new phpFlickr($flickrAPIKey); $upload_dir = wp_upload_dir(); $f->enableCache("fs", $upload_dir['basedir'] . "/phpFlickrCache"); $photos_url = array(); $photos = array(); $photos_main_index = ''; $target_blank = true; //TODO in the settings page? $maximum_pages_nums = 10; //TODO configurable? //Errors----------------------- if ($action === 'phs' || $action === 'gal' || $action === 'tag') { if (!isset($user_id) || strlen($user_id) == 0) { return flickrps_formatError(__('You must specify the user_id for this action, using the "user_id" attribute', 'flickr-photostream')); } } if ($action === 'gal') { if (!isset($id) || strlen($id) == 0) { return flickrps_formatError(__('You must specify the id of the gallery, using the "id" attribute', 'flickr-photostream')); } } if ($action === 'set') { if (!isset($id) || strlen($id) == 0) { return flickrps_formatError(__('You must specify the id of the set, using the "id" attribute', 'flickr-photostream')); } } if ($action === 'tag') { if (!isset($tags) || strlen($tags) == 0) { return flickrps_formatError(__('You must specify the tags using the "tags" attribute', 'flickr-photostream')); } if ($tags_mode !== 'any' && $tags_mode !== 'all') { return flickrps_formatError(__('You must specify a valid tags_mode: "any" or "all"', 'flickr-photostream')); } } if ($action === 'grp') { if (!isset($id) || strlen($id) == 0) { return flickrps_formatError(__('You must specify the id of the group, using the "id" attribute', 'flickr-photostream')); } } if ($pagination !== 'none' && $pagination !== 'prevnext' && $pagination !== 'numbers') { return flickrps_formatError(__('The pagination attribute can be only "none", "prevnext" or "numbers".', 'flickr-photostream')); } if ($last_row !== 'hide' && $last_row !== 'justify' && $last_row !== 'nojustify') { return flickrps_formatError(__('The last_row attribute can be only "hide", "justify" or "nojustify".', 'flickr-photostream')); } if ($lightbox !== 'none' && $lightbox !== 'colorbox' && $lightbox !== 'swipebox') { return flickrps_formatError(__('The lightbox attribute can be only "none", "colorbox" or "swipebox".', 'flickr-photostream')); } //Photo loading---------------- $extras = "description, original_format, url_l, url_z"; if ($action === 'set') { //Show the photos of a particular photoset $photos = $f->photosets_getPhotos($id, $extras, 1, $max_num_photos, $page_num, NULL); $photos_main_index = 'photoset'; } else { if ($action === 'gal') { //Show the photos of a particular gallery $photos_url[$user_id] = $f->urls_getUserPhotos($user_id); if ($f->getErrorCode() != NULL) { return flickrps_formatFlickrAPIError($f->getErrorMsg()); } $gallery_info = $f->urls_lookupGallery($photos_url[$user_id] . 'galleries/' . $id); if ($f->getErrorCode() != NULL) { return flickrps_formatFlickrAPIError($f->getErrorMsg()); } $photos = $f->galleries_getPhotos($gallery_info['gallery']['id'], $extras, $max_num_photos, $page_num); $photos_main_index = 'photos'; } else { if ($action === 'tag') { $photos = $f->photos_search(array('user_id' => $user_id, 'tags' => $tags, 'tag_mode' => $tags_mode, 'extras' => $extras, 'per_page' => $max_num_photos, 'page' => $page_num)); $photos_main_index = 'photos'; } else { if ($action === 'grp') { //Show the photos of a particular group pool //groups_pools_getPhotos ($group_id, $tags = NULL, $user_id = NULL, $jump_to = NULL, $extras = NULL, $per_page = NULL, $page = NULL) { $photos = $f->groups_pools_getPhotos($id, $tags, NULL, NULL, $extras, $max_num_photos, $page_num); $photos_main_index = 'photos'; } else { //Show the classic photostream $photos = $f->people_getPublicPhotos($user_id, NULL, $extras, $max_num_photos, $page_num); //Need the authentication (TODO) //$photos = $f->people_getPhotos($user_id, // array("privacy_filter" => "1", "extras" => "description", "per_page" => $max_num_photos, "page" => $page_num)); $photos_main_index = 'photos'; } } } } if ($f->getErrorCode() != NULL) { return flickrps_formatFlickrAPIError($f->getErrorMsg()); } if (count((array) $photos[$photos_main_index]['photo']) == 0) { return __('No photos', 'flickr-photostream'); } //we calculate that the aspect ratio has an average of 4:3 if ($images_height <= 75) { $imgSize = "thumbnail"; //thumbnail (longest side:100) } else { if ($images_height <= 180) { $imgSize = "small"; //small (longest side:240) } else { //if <= 240 $imgSize = "small_320"; //small (longest side:320) } } $ris .= '<!-- Flickr Photostream by Miro Mannino -->' . "\n" . '<div id="flickrGal' . $shortcode_unique_id . '" class="justified-gallery" >'; $r = 0; $use_large_thumbnails = true; $photo_array = $photos[$photos_main_index]['photo']; foreach ($photo_array as $photo) { if (!isset($photo['url_l'])) { $use_large_thumbnails = false; } if ($lightbox !== 'none') { $ris .= '<a href="'; if ($open_originals) { if (isset($photo['originalsecret'])) { $ris .= $f->buildPhotoURL($photo, "original"); } else { if (isset($photo['url_l'])) { $ris .= $photo['url_l']; } else { $ris .= $photo['url_z']; } } } else { if (isset($photo['url_l'])) { $ris .= $photo['url_l']; } else { $ris .= $photo['url_z']; } } $ris .= '" rel="flickrGal' . $shortcode_unique_id . '" title="' . $photo['title'] . '">'; } else { //If it is a gallery the photo has an owner, else is the photoset owner (or the photostream owner) $photo_owner = isset($photo['owner']) ? $photo['owner'] : $photos[$photos_main_index]['owner']; //Save the owner url if (!isset($photos_url[$photo_owner])) { $photos_url[$photo_owner] = $f->urls_getUserPhotos($photo_owner); if ($f->getErrorCode() != NULL) { return flickrps_formatFlickrAPIError($f->getErrorMsg()); } } if ($action === 'set') { $photos_url_in = '/in/set-' . $id . '/lightbox'; } else { $photos_url_in = '/in/photostream/lightbox'; } $ris .= '<a href="' . $photos_url[$photo_owner] . $photo['id'] . $photos_url_in . '" '; if ($target_blank) { $ris .= 'target="_blank" '; } $ris .= 'title="' . $photo['title'] . '">'; } $ris .= '<img alt="' . htmlspecialchars($photo['title'], ENT_QUOTES, 'UTF-8') . '" src="' . $f->buildPhotoURL($photo, $imgSize) . '" data-safe-src="' . $f->buildPhotoURL($photo, $imgSize) . '" /></a>'; } $ris .= '</div>' . '<script type="text/javascript">'; if ($block_contextmenu) { $ris .= ' function fpDisableContextMenu(imgs) { function absorbEvent_(event) { var e = event || window.event; e.preventDefault && e.preventDefault(); e.stopPropagation && e.stopPropagation(); e.cancelBubble = true; e.returnValue = false; return false; } imgs.on("contextmenu", absorbEvent_); imgs.on("ontouchstart", absorbEvent_); imgs.on("ontouchmove", absorbEvent_); imgs.on("ontouchend", absorbEvent_); imgs.on("ontouchcancel", absorbEvent_); }'; } $ris .= 'jQuery(document).ready(function(){ jQuery("#flickrGal' . $shortcode_unique_id . '")'; if ($lightbox === 'colorbox') { $ris .= '.on(\'jg.rowflush\', function() { jQuery(this).find("> a").colorbox({ maxWidth : "85%", maxHeight : "85%", current : "",'; if ($block_contextmenu) { $ris .= ' onComplete: function() { fpDisableContextMenu(jQuery("#colorbox .cboxPhoto")); }'; } $ris .= '}); })'; } else { if ($lightbox === 'swipebox') { $ris .= ' .on(\'jg.complete\', function() { jQuery("#flickrGal' . $shortcode_unique_id . '").find("> a").swipebox({ afterOpen : function () { setTimeout(function() { fpDisableContextMenu(jQuery("#swipebox-overlay .slide img")); }, 100); } }); })'; } } $ris .= '.justifiedGallery({' . '\'lastRow\': \'' . $last_row . '\', ' . '\'rowHeight\':' . $images_height . ', ' . '\'fixedHeight\':' . ($fixed_height ? 'true' : 'false') . ', ' . '\'captions\':' . ($captions ? 'true' : 'false') . ', ' . '\'randomize\':' . ($randomize ? 'true' : 'false') . ', ' . '\'margins\':' . $margins; if (!$use_large_thumbnails) { $ris .= ', \'sizeRangeSuffixes\': { \'lt100\':\'_t\', \'lt240\':\'_m\', \'lt320\':\'_n\', \'lt500\':\'\', \'lt640\':\'_z\', \'lt1024\':\'_z\' }'; } $ris .= '});'; if ($block_contextmenu) { $ris .= 'fpDisableContextMenu(jQuery("#flickrGal' . $shortcode_unique_id . '").find("> a"));'; } $ris .= ' });' . '</script>'; //Navigation--------------------- if ($pagination !== 'none') { $num_pages = $photos[$photos_main_index]['pages']; if ($num_pages > 1) { $permalink = get_permalink(); if ($pagination === 'numbers') { $ris .= '<div class="page-links">' . '<span class="page-links-title">Pages:</span> '; $low_num = $page_num - floor($maximum_pages_nums / 2); $high_num = $page_num + ceil($maximum_pages_nums / 2) - 1; if ($low_num < 1) { $high_num += 1 - $low_num; $low_num = 1; } if ($high_num > $num_pages) { $high_num = $num_pages; } if ($low_num > 1) { $ris .= '<a href="' . add_query_arg('page', $low_num - 1, $permalink) . '"><span>...</span></a> '; } for ($i = $low_num; $i <= $high_num; $i++) { if ($i == $page_num) { $ris .= '<span>' . $i . '</span> '; } else { $ris .= '<a href="' . add_query_arg('page', $i, $permalink) . '"><span>' . $i . '</span></a> '; } } if ($high_num < $num_pages) { $ris .= '<a href="' . add_query_arg('page', $high_num + 1, $permalink) . '"><span>...</span></a> '; } $ris .= '</div>'; } else { if ($pagination === 'prevnext') { $ris .= '<div>'; if ($page_num < $num_pages) { $ris .= '<div class="nav-previous">' . '<a href="' . add_query_arg('page', (int) $page_num + 1, $permalink) . '">' . __('<span class="meta-nav">←</span> Older photos', 'flickr-photostream') . '</a>' . '</div>'; } if ($page_num > 1) { //a link to the newer photos $ris .= '<div class="nav-next">' . '<a href="' . add_query_arg('page', (int) $page_num - 1, $permalink) . '">' . __('Newer photos <span class="meta-nav">→</span>', 'flickr-photostream') . '</a>' . '</div>'; } $ris .= '</div>'; } } } } $shortcode_unique_id++; return $ris; }