margin-top: 10px; border-top: 1px solid #000;"> <div style="margin-bottom: 10px; padding: 5px;"> <h2>Enter links to photo pages on Flickr (one per line)</h2> Example: http://www.flickr.com/photos/bees/61752182/ <textarea name="bulkLoader" id="bulkLoader" rows="5" cols="50"></textarea> <input type="button" value="Go" onclick="return checkPhotos()" /> </div> <ul id="bulkList"> <?php if (isset($module->details['photos'])) { require_once "lib/phpFlickr/phpFlickr.php"; $f = new phpFlickr("91463f56021a88799ecbf0eb105a08fd ", NULL, false); foreach (split(",", $module->details['photos']) as $photoID) { $photo = $f->photos_getInfo($photoID); if ($f->getErrorCode()) { continue; } else { ?> <li><input type="checkbox" name="modules[id<?php echo $module->lens_module_id; ?> ][details][photos][]" value="<?php echo $photo['id']; ?> " checked="checked" /> <img src="http://static.flickr.com/<?php echo $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret']; ?> _s.jpg" align="middle" style="border:1px solid black; padding:1px; margin-right: 10px"> <?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 */ //f1a96744921d43a0 require_once "/phpFlickr.php"; $f->setProxy("localhost", "8080"); $f = new phpFlickr("\nbf5d0953f69b3386edc3760d784955f5", "16d906ea4207bafc"); //var_dump($f); $f->getErrorCode(); $f->getErrorMsg(); $recent = $f->photos_getRecent(); var_dump($recent); foreach ((array) $recent['photo'] as $photo) { $owner = $f->people_getInfo($photo['owner']); echo "<a href='http://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'] . "/'>"; echo $photo['title']; echo "</a> Owner: "; echo "<a href='http://www.flickr.com/people/" . $photo['owner'] . "/'>"; echo $owner['username']; echo "</a><br>"; }
function fjgwpp_createGallery($action, $atts) { global $fjgwpp_imagesHeight_default; global $fjgwpp_maxPhotosPP_default; global $fjgwpp_lastRow_default; global $fjgwpp_fixedHeight_default; global $fjgwpp_pagination_default; global $fjgwpp_lightbox_default; global $fjgwpp_captions_default; global $fjgwpp_showDescriptions_default; global $fjgwpp_randomize_default; global $fjgwpp_margins_default; global $fjgwpp_openOriginals_default; global $fjgwpp_bcontextmenu_default; global $fjgwpp_flickrAPIWrapperVersion_default; static $shortcode_unique_id = 0; $ris = ""; $page_num = get_query_var('page') ? get_query_var('page') : 1; $flickrGalID = 'flickrGal' . $shortcode_unique_id; //Options----------------------- extract(shortcode_atts(array('user_id' => fjgwpp_getOption('userID'), 'id' => NULL, 'tags' => NULL, 'tags_mode' => 'any', 'images_height' => fjgwpp_getOption('imagesHeight', $fjgwpp_imagesHeight_default), 'max_num_photos' => fjgwpp_getOption('maxPhotosPP', $fjgwpp_maxPhotosPP_default), 'last_row' => fjgwpp_getOption('lastRow', $fjgwpp_lastRow_default), 'fixed_height' => fjgwpp_getOption('fixedHeight', $fjgwpp_fixedHeight_default) == 1, 'lightbox' => fjgwpp_getOption('lightbox', $fjgwpp_lightbox_default), 'captions' => fjgwpp_getOption('captions', $fjgwpp_captions_default) == 1, 'show_descriptions' => fjgwpp_getOption('showDescriptions', $fjgwpp_showDescriptions_default) == 1, 'randomize' => fjgwpp_getOption('randomize', $fjgwpp_randomize_default) == 1, 'pagination' => fjgwpp_getOption('pagination', $fjgwpp_pagination_default), 'margins' => fjgwpp_getOption('margins', $fjgwpp_margins_default), 'open_originals' => fjgwpp_getOption('openOriginals', $fjgwpp_openOriginals_default) == 1, 'block_contextmenu' => fjgwpp_getOption('bcontextmenu', $fjgwpp_bcontextmenu_default) == 1, 'flickrAPIWrapperVersion' => fjgwpp_getOption('flickrAPIWrapperVersion', $fjgwpp_flickrAPIWrapperVersion_default) == 0), $atts)); //Trim string options $user_id = trim($user_id); $id = trim($id); $lightbox = trim($lightbox); $last_row = trim($last_row); if ($flickrAPIWrapperVersion == 0) { require_once "phpFlickr/phpFlickr.php"; } else { require_once "phpFlickr_a" . $flickrAPIWrapperVersion . "/phpFlickr.php"; } //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 = trim(fjgwpp_getOption('APIKey')); //Flickr API Key $flickrAPISecret = trim(fjgwpp_getOption('APISecret')); //Flickr API Secret $flickrAPIToken = trim(fjgwpp_getOption('APIToken')); //Flickr API Token if ($flickrAPISecret && $flickrAPIToken) { // fully authenticated call $f = new phpFlickr($flickrAPIKey, $flickrAPISecret); $f->setToken($flickrAPIToken); $f->auth("read"); } else { // standard call $f = new phpFlickr($flickrAPIKey); } $upload_dir = wp_upload_dir(); $f->enableCache("fs", $upload_dir['basedir'] . "/phpFlickrCache"); $photos_url = array(); $photos = array(); $photos_main_index = ''; $maximum_pages_nums = 10; //TODO configurable? //Errors----------------------- if ($action === 'phs' || $action === 'gal' || $action === 'tag') { if (!isset($user_id) || strlen($user_id) == 0) { return fjgwpp_formatError(__('You must specify the user_id for this action, using the "user_id" attribute', 'fjgwpp')); } } if ($action === 'gal') { if (!isset($id) || strlen($id) == 0) { return fjgwpp_formatError(__('You must specify the id of the gallery, using the "id" attribute', 'fjgwpp')); } } if ($action === 'set') { if (!isset($id) || strlen($id) == 0) { return fjgwpp_formatError(__('You must specify the id of the set, using the "id" attribute', 'fjgwpp')); } } if ($action === 'tag') { if (!isset($tags) || strlen($tags) == 0) { return fjgwpp_formatError(__('You must specify the tags using the "tags" attribute', 'fjgwpp')); } if ($tags_mode !== 'any' && $tags_mode !== 'all') { return fjgwpp_formatError(__('You must specify a valid tags_mode: "any" or "all"', 'fjgwpp')); } } if ($action === 'grp') { if (!isset($id) || strlen($id) == 0) { return fjgwpp_formatError(__('You must specify the id of the group, using the "id" attribute', 'fjgwpp')); } } if ($pagination !== 'none' && $pagination !== 'prevnext' && $pagination !== 'numbers') { return fjgwpp_formatError(__('The pagination attribute can be only "none", "prevnext" or "numbers".', 'fjgwpp')); } if ($last_row !== 'hide' && $last_row !== 'justify' && $last_row !== 'nojustify') { return fjgwpp_formatError(__('The last_row attribute can be only "hide", "justify" or "nojustify".', 'fjgwpp')); } if ($lightbox !== 'none' && $lightbox !== 'colorbox' && $lightbox !== 'swipebox') { return fjgwpp_formatError(__('The lightbox attribute can be only "none", "colorbox" or "swipebox".', 'fjgwpp')); } //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, NULL, $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 fjgwpp_formatFlickrAPIError($f->getErrorMsg()); } $gallery_info = $f->urls_lookupGallery($photos_url[$user_id] . 'galleries/' . $id); if ($f->getErrorCode() != NULL) { return fjgwpp_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 fjgwpp_formatFlickrAPIError($f->getErrorMsg()); } $photos_pool = $photos[$photos_main_index]; if (count((array) $photos_pool['photo']) == 0) { return __('No photos', 'fjgwpp'); } //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 Justified Gallery Wordpress Plugin by Miro Mannino -->' . "\n" . '<div id="' . $flickrGalID . '" class="justified-gallery" >'; $r = 0; $use_large_thumbnails = true; foreach ($photos_pool['photo'] as $photo) { if (!isset($photo['url_l'])) { $use_large_thumbnails = false; } fjgwpp_entryLink($id, $f, $ris, $photo, $photos_pool, $photos_url, $lightbox, $open_originals, $flickrGalID, $action); $ris .= '<img alt="' . htmlspecialchars($photo['title'], ENT_QUOTES, 'UTF-8') . '" src="' . $f->buildPhotoURL($photo, $imgSize) . '" data-safe-src="' . $f->buildPhotoURL($photo, $imgSize) . '" />'; if ($captions) { $ris .= '<div class="caption">' . '<div class="photo-title' . ($show_descriptions ? ' photo-title-with-desc' : '') . '">' . htmlspecialchars($photo['title'], ENT_QUOTES, 'UTF-8') . '</div>'; if ($show_descriptions && isset($photo['description']) && isset($photo['description']['_content'])) { $ris .= '<div class="photo-desc">' . fjgwpp_filterDescription($photo['description']['_content']) . '</div>'; } $ris .= '</div>'; } $ris .= '</a>'; //end link } $ris .= '</div>' . '<script type="text/javascript">'; $ris .= 'function fjgwppInit_' . $flickrGalID . '() { jQuery("#' . $flickrGalID . '")'; if ($lightbox === 'colorbox') { $ris .= '.on(\'jg.rowflush jg.complete\', function() { jQuery(this).find("> a").colorbox({ title:function() { var tit= \'<div class="boxTitle">\'+jQuery(this).find(\'.photo-title\').html()+\'</div>\'; var cap =\'<div class="boxCaption">\'+jQuery(this).find(\'.photo-desc\').html()+\'</div>\'; return tit+cap; }, maxWidth : "85%", maxHeight : "85%", current : "",'; if ($block_contextmenu) { $ris .= 'onComplete: function() { fjgwppDisableContextMenu(jQuery("#colorbox .cboxPhoto")); }'; } $ris .= '}); })'; } else { if ($lightbox === 'swipebox') { $ris .= '.on(\'jg.complete\', function() { jQuery("#' . $flickrGalID . '").find("> a").swipebox('; if ($block_contextmenu) { $ris .= '{ afterOpen : function () { setTimeout(function() { fjgwppDisableContextMenu(jQuery("#swipebox-overlay .slide img")); }, 100); } }'; } $ris .= '); })'; } } $ris .= '.justifiedGallery({' . '\'lastRow\': \'' . $last_row . '\', ' . '\'rowHeight\':' . $images_height . ', ' . '\'fixedHeight\':' . ($fixed_height ? 'true' : 'false') . ', ' . '\'captions\':' . ($captions ? 'true' : 'false') . ', ' . '\'randomize\':' . ($randomize ? 'true' : 'false') . ', ' . '\'margins\':' . $margins . ', ' . '\'sizeRangeSuffixes\': { \'lt100\':\'_t\', \'lt240\':\'_m\', \'lt320\':\'_n\', \'lt500\':\'\', \'lt640\':\'_z\',' . ($use_large_thumbnails ? '\'lt1024\':\'_b\'' : '\'lt1024\':\'_z\'') . '}});'; if ($block_contextmenu) { $ris .= 'fpDisableContextMenu(jQuery("#' . $flickrGalID . '").find("> a"));'; } $ris .= '}' . 'if (typeof fjgwpp_galleriesInit_functions === "undefined") fjgwpp_galleriesInit_functions = [];' . 'fjgwpp_galleriesInit_functions.push(fjgwppInit_' . $flickrGalID . ');' . '</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', 'fjgwpp') . '</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>', 'fjgwpp') . '</a>' . '</div>'; } $ris .= '</div>'; } } } } $shortcode_unique_id++; return $ris; }
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; }
} function flickrsync_vardump($var) { ob_start(); var_dump($var); flickrsync_log_mesmo(ob_get_clean()); } flickrsync_log('iniciando'); $f = new phpFlickr(FLICKR_API_KEY, FLICKR_API_SECRET); flickrsync_log('instanciado'); $f->setToken(FLICKR_API_AUTH_TOKEN); flickrsync_log('setado token'); $f->auth(); flickrsync_log('autenticado'); //change this to the permissions you will need // $f->auth("read"); //echo "Copy this token into your code: " . $_SESSION['phpFlickr_auth_token']; echo 'listanddo flickr'; //Parameterless searches have been disabled. Please use flickr.photos.getRecent instead. $photos = $f->photos_search(array('user_id' => FLICKR_USER_ID)); //$photos = $this->phpFlickr->photos_getRecent(); if (false === $photos) { print_r($f->getErrorCode()); echo "\n"; print_r($f->getErrorMsg()); echo "\n"; } var_dump($photos); print_r($photos); echo ob_get_clean(); exit;