function flickr_show_set($set_id, $size = 's', $start = 0, $limit = 0, $bigsize = '') { global $FLICKR_API_KEY; $f = new phpFlickr($FLICKR_API_KEY); $set = $f->photosets_getPhotos($set_id); $start = $start; $limit = $limit > 0 ? $limit : count($set['photo']); flickr_output_from_set($set, $size, $start, $limit, $bigsize); }
<?php if (!(($key + 1) % 3)) { echo "</tr>\n<tr>"; } } else { echo "<td>No matching pictures were found.</td>"; } } echo "</tr></table>"; } else { print "No matching pictures were found."; } } elseif ($this->attributes['details']['show'] == "photosets") { if (isset($this->attributes['details']['photoset'])) { echo "<table cellpadding='3' style='border: none; width: 100%'>\n<tr>"; $photos = $f->photosets_getPhotos($this->attributes['details']['photoset'], "owner_name,owner"); $isError = $f->getErrorMsg(); if (!$isError) { foreach ($photos['photo'] as $key => $photo) { if ($key >= $this->attributes['details']['max_photoset']) { break; } $myPhoto = $f->photos_getInfo($photo['id']); ?> <td style="vertical-align: top; text-align: center; width: 33%"> <a href="http://www.flickr.com/photos/<?php echo $myPhoto['owner']['nsid']; ?> /<?php echo $photo['id']; ?>
<div id="overview"> <?php the_content('Read more on "' . the_title('', '', false) . '" »'); ?> </div> <?php $flickr_photoset_id = '72157626966312775'; $flickr_api_key = '2d589541fd6f617409903e97d0e10bbe'; $flickr_username = '******'; $flickr_gallery = new phpFlickr($flickr_api_key); $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'];
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="<?php echo $f->buildPhotoURL($photo, $flickrThumb); ?> " data-large="<?php echo $f->buildPhotoURL($photo, 'large');
if (isset($_GET['start'])) { $page['start'] = intval($_GET['start']); } else { $page['start'] = 0; } if (isset($_GET['display'])) { $page['display'] = $_GET['display'] == 'all' ? 500 : intval($_GET['display']); } else { $page['display'] = 20; } // get photos if ($_GET['album'] == 'not_in_set') { $all_photos = $flickr->photos_getNotInSet(NULL, NULL, NULL, NULL, 'photos', NULL, NULL, 500); $all_photos = $all_photos['photos']['photo']; } else { $all_photos = $flickr->photosets_getPhotos($_GET['album'], NULL, NULL, 500, NULL, 'photos'); $all_photos = $all_photos['photoset']['photo']; } // get existing photos $query = ' SELECT id, file FROM ' . IMAGES_TABLE . ' WHERE file LIKE "' . $flickr_prefix . '%" ;'; $existing_photos = simple_hash_from_query($query, 'id', 'file'); $existing_photos = array_map(create_function('$p', 'return preg_replace("#^' . $flickr_prefix . '([0-9]+)\\.([a-z]{3,4})$#i", "$1", $p);'), $existing_photos); // remove existing photos $duplicates = 0; foreach ($all_photos as $i => $photo) { if (in_array($photo['id'], $existing_photos)) { unset($all_photos[$i]);
<a href="http://www.lomodroid.com/">HOME</a> <a href="http://www.flickr.com/groups/lomodroid/">FLICKR</a> <a href="http://twitter.com/lomodroid">TWITTER</a> </div> </div> <div id="rhs-header-container" class="unit"> <img id="robot" src="lomodroid_robot.gif"/> </div> </div> </div> <div class="main-content-container"> <ul id="photo-list"> <?php $photos = $f->photosets_getPhotos($photoset_id, null, null, 7); foreach ($photos['photoset']['photo'] as $photo) { // 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' 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 class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a> <a href="http://www.addthis.com/bookmark.php?v=250&username=lomodroid" class="addthis_button_compact">Share</a> </div> <script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=lomodroid"></script> </div>
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; }
$f = new phpFlickr("26b2abba37182aca62fe0eb2c7782050"); $set_id = get_input("set_id"); $album_id = get_input("album_id"); $page_pp = get_input("page"); $return_url = get_input("return_url"); $user = get_loggedin_user(); $flickr_id = get_metadata_byname($user->guid, "flickr_id"); if (empty($flickr_id)) { register_error(elgg_echo('flickr:errorusername2')); forward($return_url); die; //just in case } // Get the friendly URL of the user's photos $photos_url = $f->urls_getUserPhotos($flickr_id->value); $photos = $f->photosets_getPhotos($set_id, null, null, 10, $page_pp); $photos_to_upload = array(); foreach ($photos["photoset"]["photo"] as $photo) { //check if we already have this image $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) {
define('UID', ''); // === S T E P 3 === // Download and include the phpFlickr project from http://code.google.com/p/phpflickr/ require 'phpFlickr/phpFlickr.php'; // === S T E P 4 === // Run the script via the command line using: "php download-all.php" // Connect to Flickr $f = new phpFlickr(API_KEY, API_SECRET, true); $f->setToken(API_TOKEN); // Get all of our photosets $sets = $f->photosets_getList(UID); foreach ($sets['photoset'] as $set) { echo "### " . $set['title'] . "\n"; @mkdir("photos/{$set['title']}", 0777, true); // Get all the photos in this set $photos = $f->photosets_getPhotos($set['id']); // And download each one... foreach ($photos['photoset']['photo'] as $photo) { $url = null; $sizes = $f->photos_getSizes($photo['id']); foreach ($sizes as $size) { if ($size['label'] == 'Original') { $url = $size['source']; } } if (!is_null($url)) { $dir = escapeshellarg("photos/{$set['title']}"); $filename = parse_url($url, PHP_URL_PATH); // Only download if file does not exist... if (!file_exists("photos/{$set['title']}/{$filename}")) { shell_exec("cd {$dir}; /usr/bin/curl -O {$url}");
/** * Create the Slider PRO */ function slider_pro($id, $atts = null, $content = null) { global $sliderpro_slider_settings, $sliderpro_unique_id, $sliderpro_used_ids, $sliderpro_scripts_to_load, $sliderpro_custom_scripts_to_load, $sliderpro_styles_to_load, $sliderpro_sliders_js, $sliderpro_lightbox_loaded, $sliderpro_videojs_loaded, $sliderpro_js_properties, $sliderpro_flickr_sizes; // assign an ID for this slider // it will either be the based on the ID that the slider has in the database // or, if that ID is already used in the same page, another unique ID will be assign $current_id = in_array($id, $sliderpro_used_ids) || $id == -1 ? $sliderpro_unique_id-- : $id; array_push($sliderpro_used_ids, $current_id); // if id is -1, it means that an id was not specified and the slider will be created // based on shortcode data if ($id == -1) { $slides = array(); $available_settings = array(); foreach ($sliderpro_slider_settings as $key => $value) { $available_settings[$key] = $value['default_value']; } // merge the values specified in the shortcode with the default ones $slider_settings = $atts ? array_merge($available_settings, $atts) : $available_settings; } else { // if an id was specified, load the slider $slider = sliderpro_get_slider($id); // if the slider does not exist, display a message if (!$slider) { return "A slider with the ID of {$id} was not found."; } // merge the values specified in the shortcode with the values specified for the slider in the admin area $slider_settings = $atts ? array_merge($slider['settings'], $atts) : $slider['settings']; // load the slider's slides $slides = sliderpro_get_slides($id); } // analyze the shortcode's content, if any if ($content) { // create an array that will hold extra slides $slides_extra = array(); // counter for the slides for which an index was not specified and will be added at the end of the other slides $end_counter = 1; // get all the added slides $slides_sc = do_shortcode($content); $slides_sc = str_replace('<br />', '', $slides_sc); $slides_sc = explode('%sp_sep%', $slides_sc); // loop through all the slides added within the shortcode // and add the slide to the slides_extra array foreach ($slides_sc as $slide_sc) { $slide_sc = unserialize(trim($slide_sc)); if ($slide_sc) { $index = $slide_sc['settings']['index']; if (!is_numeric($index)) { $index .= "_{$end_counter}"; $end_counter++; } $slides_extra[$index] = $slide_sc; } } // loop through all the existing slides and override the settings and/or the content // if it's the case foreach ($slides as &$slide_r) { $slide_settings = unserialize($slide_r['settings']); $slide_content = unserialize($slide_r['content']); if (isset($slides_extra[$slide_r['position']])) { $slide_extra = $slides_extra[$slide_r['position']]; if ($slide_extra['settings']) { $slide_settings = array_merge($slide_settings, $slide_extra['settings']); } if ($slide_extra['content']) { $slide_content = array_merge($slide_content, $slide_extra['content']); } unset($slides_extra[$slide_r['position']]); } $slide_r['settings'] = $slide_settings; $slide_r['content'] = $slide_content; } // add the extra slides at the end of the initial slides $extra_slides_counter = count($slides); foreach ($slides_extra as $slide_end) { $extra_slides_counter++; $slide_end['visibility'] = isset($slide_end['settings']['visibility']) ? $slide_end['settings']['visibility'] : 'enabled'; $slide_end['position'] = $extra_slides_counter; array_push($slides, $slide_end); } } else { foreach ($slides as &$slide_s) { $slide_settings = unserialize($slide_s['settings']); $slide_content = unserialize($slide_s['content']); $slide_s['settings'] = $slide_settings; $slide_s['content'] = $slide_content; } } $dynamic_slides = array(); $posts_terms_pattern = sliderpro_regex(array('sp_image', 'sp_image_alt', 'sp_image_title', 'sp_image_caption', 'sp_image_description', 'sp_comments_number', 'sp_comments_link', 'sp_title', 'sp_content', 'sp_excerpt', 'sp_author_name', 'sp_author_posts', 'sp_date', 'sp_link', 'sp_custom')); $gallery_terms_pattern = sliderpro_regex(array('sp_image', 'sp_image_alt', 'sp_image_title', 'sp_image_caption', 'sp_image_description')); $flickr_terms_pattern = sliderpro_regex(array('sp_image', 'sp_image_title', 'sp_image_description', 'sp_image_link', 'sp_image_set', 'sp_date', 'sp_user', 'sp_user_link', 'sp_user_photos', 'sp_user_sets')); foreach ($slides as $slide) { // check if the slide is set to automatically fetch post dara if (sliderpro_get_slide_setting($slide['settings'], 'slide_type', 'dynamic') == 'posts') { if (isset($slide['visibility']) && $slide['visibility'] == 'disabled') { continue; } $slide_settings = $slide['settings']; $slide_content = $slide['content']; foreach ($slide_content as $key => $value) { $slide_content[$key] = sliderpro_decode($value, true, true); } // construct the argument of the Query object $dynamic_slide_args = array(); $dynamic_posts_types_raw = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_types', 'dynamic'); if ($dynamic_posts_types_raw != '') { $dynamic_post_types = explode(';', $dynamic_posts_types_raw); $dynamic_slide_args['post_type'] = $dynamic_post_types; } $dynamic_posts_taxonomies_raw = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_taxonomies', 'dynamic'); if ($dynamic_posts_taxonomies_raw != '') { $tax_query = array(); $dynamic_taxonomies = explode(';', $dynamic_posts_taxonomies_raw); foreach ($dynamic_taxonomies as $item_raw) { $item = explode('|', $item_raw); $tax_item['taxonomy'] = $item[0]; $tax_item['terms'] = $item[1]; $tax_item['field'] = 'slug'; array_push($tax_query, $tax_item); } $tax_query['relation'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_relation', 'dynamic'); $dynamic_slide_args['tax_query'] = $tax_query; } $dynamic_posts_featured = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_featured', 'dynamic'); if ($dynamic_posts_featured) { $dynamic_slide_args['meta_query'] = array(array('key' => '_sliderpro-featured', 'value' => true)); } $dynamic_slide_args['posts_per_page'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_maximum', 'dynamic'); $dynamic_slide_args['offset'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_offset', 'dynamic'); $dynamic_slide_args['orderby'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_orderby', 'dynamic'); $dynamic_slide_args['order'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_order', 'dynamic'); $slide_dynamic_terms = array(); $has_image = false; // get all the dynamic terms used in the content fields foreach ($slide_content as $key => $value) { if ($value != '') { $matches = array(); preg_match_all('/' . $posts_terms_pattern . '/s', $value, $matches); // check if a match is found if (!empty($matches)) { // loop through all terms found in the field foreach ($matches[0] as $counter => $match_item) { // check if the exact term is not already added to the collection if (!isset($slide_dynamic_terms[$match_item])) { // get the array of arguments specified for the term/tag $args = explode('|', trim($matches[3][$counter])); // create an array of argument pairs (name => value) $arg_pair = array('term_name' => $matches[2][$counter]); // check if an image exists in the content fields if ($matches[2][$counter] == 'sp_image') { $has_image = true; } foreach ($args as $arg) { if ($arg != '') { $arg_item = explode('=', $arg); $arg_pair[trim($arg_item[0])] = substr(trim($arg_item[1]), 1, -1); } } // associate the term found with its array of argument pairs $slide_dynamic_terms[$match_item] = $arg_pair; } } } } } // start the Query $query = new WP_Query($dynamic_slide_args); while ($query->have_posts()) { $query->the_post(); $dynamic_slide = array(); // each dynamic slide will initially contain the main slide's content and settings $dynamic_slide['settings'] = $slide_settings; $dynamic_slide['content'] = $slide_content; $dynamic_slide['position'] = $slide['position']; $dynamic_slide['visibility'] = $slide['visibility']; // the image id will be used for multiple terms $image_id; // contains data like image alt, image title, image caption and image description $image_data; // if an image exists, get the ID and meta data of the image if ($has_image) { if (has_post_thumbnail()) { $image_id = get_post_thumbnail_id(); } else { $children_args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => get_the_ID(), 'numberposts' => 1, 'orderby' => 'menu_order', 'order' => 'ASC'); $image_item = get_children($children_args, ARRAY_A); if ($image_item) { $image_item = array_values($image_item); } $image_id = $image_item[0]['ID']; } $image_data = get_post($image_id, ARRAY_A); $image_alt_data = get_post_meta($image_id, '_wp_attachment_image_alt'); $image_data['alt'] = !empty($image_alt_data) ? $image_alt_data[0] : ''; } // loop through all content fields foreach ($dynamic_slide['content'] as $field_name => &$field_content) { if ($field_content != '') { // loop through all terms that were find in the content fields foreach ($slide_dynamic_terms as $term => $term_data) { // check if the term is in the current field if (strpos($field_content, $term) !== false) { // check the type of the term $replace = ''; if ($term_data['term_name'] == 'sp_image') { $image_size = isset($term_data['size']) ? $term_data['size'] : 'full'; $image_src = wp_get_attachment_image_src($image_id, $image_size); $replace = sliderpro_get_real_path($image_src[0]); } else { if ($term_data['term_name'] == 'sp_image_alt') { $replace = $image_data['alt']; } else { if ($term_data['term_name'] == 'sp_image_title') { $replace = $image_data['post_title']; } else { if ($term_data['term_name'] == 'sp_image_caption') { $replace = $image_data['post_excerpt']; } else { if ($term_data['term_name'] == 'sp_image_description') { $replace = $image_data['post_content']; } else { if ($term_data['term_name'] == 'sp_title') { $replace = get_the_title(); } else { if ($term_data['term_name'] == 'sp_link') { $replace = get_post_permalink(get_the_ID()); } else { if ($term_data['term_name'] == 'sp_date') { $date_format = isset($term_data['format']) ? $term_data['format'] : get_option('date_format'); $replace = get_the_date($date_format); } else { if ($term_data['term_name'] == 'sp_author_name') { $replace = get_the_author(); } else { if ($term_data['term_name'] == 'sp_author_posts') { $replace = get_author_posts_url(get_the_author_meta('ID')); } else { if ($term_data['term_name'] == 'sp_comments_number') { $more = isset($term_data['more']) ? $term_data['more'] : false; $one = isset($term_data['one']) ? $term_data['one'] : false; $zero = isset($term_data['zero']) ? $term_data['zero'] : false; $number = get_comments_number(); if ($number > 1) { $replace = str_replace('%', $number, $more === false ? __('% Comments') : $more); } else { if ($number == 0) { $replace = $zero === false ? __('No Comments') : $zero; } else { $replace = $one === false ? __('1 Comment') : $one; } } } else { if ($term_data['term_name'] == 'sp_comments_link') { $replace = get_comments_link(); } else { if ($term_data['term_name'] == 'sp_excerpt') { $excerpt = isset($term_data['limit']) ? substr(get_the_excerpt(), 0, $term_data['limit']) : get_the_excerpt(); if (isset($term_data['more_text'])) { $more_text = $term_data['more_text']; $more_link = isset($term_data['more_link']) ? $term_data['more_link'] : get_post_permalink(get_the_ID()); $excerpt .= '<a href="' . $more_link . '">' . $more_text . '</a>'; } $replace = $excerpt; } else { if ($term_data['term_name'] == 'sp_content') { global $more; $more = 0; $content = isset($term_data['more_text']) ? get_the_content($term_data['more_text']) : get_the_content(); if (isset($term_data['filters'])) { $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); } $replace = $content; } else { if ($term_data['term_name'] == 'sp_custom') { $replace = ''; if (isset($term_data['name'])) { $values = get_post_meta(get_the_ID(), $term_data['name']); $index = isset($term_data['index']) ? $term_data['index'] : 0; $replace = isset($values[$index]) ? $values[$index] : ''; } } } } } } } } } } } } } } } } // replace all the current terms in the field with the corresponding content $field_content = str_replace($term, $replace, $field_content); } } // end terms loop } } // end fields loop array_push($dynamic_slides, $dynamic_slide); unset($dynamic_slide); } // end while wp_reset_postdata(); unset($slide_dynamic_terms); } else { if (sliderpro_get_slide_setting($slide['settings'], 'slide_type', 'dynamic') == 'gallery') { if (isset($slide['visibility']) && $slide['visibility'] == 'disabled') { continue; } $slide_settings = $slide['settings']; $slide_content = $slide['content']; foreach ($slide_content as $key => $value) { $slide_content[$key] = sliderpro_decode($value, true, true); } $gallery_post_id; $dynamic_gallery_post = sliderpro_get_slide_setting($slide_settings, 'dynamic_gallery_post', 'dynamic'); $dynamic_gallery_maximum = sliderpro_get_slide_setting($slide_settings, 'dynamic_gallery_maximum', 'dynamic'); $dynamic_gallery_offset = sliderpro_get_slide_setting($slide_settings, 'dynamic_gallery_offset', 'dynamic'); global $post; // if the post is set to '-1' only display the content if it's inside a post // don't diplay it if it's in the Preview window if ($dynamic_gallery_post == -1 && !isset($post)) { continue; } else { $gallery_post_id = $dynamic_gallery_post == -1 ? get_the_ID() : $dynamic_gallery_post; } // get the images from the post's gallery $children_args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $gallery_post_id, 'numberposts' => $dynamic_gallery_maximum, 'orderby' => 'menu_order', 'order' => 'ASC'); $gallery_images = array_splice(array_values(get_children($children_args, ARRAY_A)), $dynamic_gallery_offset); $slide_dynamic_terms = array(); // get all the dynamic terms used in the content fields foreach ($slide_content as $key => $value) { if ($value != '') { $matches = array(); preg_match_all('/' . $gallery_terms_pattern . '/s', $value, $matches); // check if a match is found if (!empty($matches)) { // loop through all terms found in the field foreach ($matches[0] as $counter => $match_item) { // check if the exact term is not already added to the collection if (!isset($slide_dynamic_terms[$match_item])) { // get the array of arguments specified for the term/tag $args = explode('|', trim($matches[3][$counter])); // create an array of argument pairs (name => value) $arg_pair = array('term_name' => $matches[2][$counter]); foreach ($args as $arg) { if ($arg != '') { $arg_item = explode('=', $arg); $arg_pair[trim($arg_item[0])] = substr(trim($arg_item[1]), 1, -1); } } // associate the term found with its array of argument pairs $slide_dynamic_terms[$match_item] = $arg_pair; } } } } } foreach ($gallery_images as $image) { $dynamic_slide = array(); // each dynamic slide will initially contain the main slide's content and settings $dynamic_slide['settings'] = $slide_settings; $dynamic_slide['content'] = $slide_content; $dynamic_slide['position'] = $slide['position']; $dynamic_slide['visibility'] = $slide['visibility']; // loop through all content fields foreach ($dynamic_slide['content'] as $field_name => &$field_content) { if ($field_content != '') { // loop through all terms that were find in the content fields foreach ($slide_dynamic_terms as $term => $term_data) { // check if the term is in the current field if (strpos($field_content, $term) !== false) { // check the type of the term $replace = ''; if ($term_data['term_name'] == 'sp_image') { $image_size = isset($term_data['size']) ? $term_data['size'] : 'full'; $image_src = wp_get_attachment_image_src($image['ID'], $image_size); $replace = sliderpro_get_real_path($image_src[0]); } else { if ($term_data['term_name'] == 'sp_image_alt') { $image_alt = get_post_meta($image['ID'], '_wp_attachment_image_alt'); $replace = !empty($image_alt) ? $image_alt[0] : ''; } else { if ($term_data['term_name'] == 'sp_image_title') { $replace = $image['post_title']; } else { if ($term_data['term_name'] == 'sp_image_caption') { $replace = $image['post_excerpt']; } else { if ($term_data['term_name'] == 'sp_image_description') { $replace = $image['post_content']; } } } } } // replace all the current terms in the field with the corresponding content $field_content = str_replace($term, $replace, $field_content); } } // end terms loop } } // end fields loop array_push($dynamic_slides, $dynamic_slide); unset($dynamic_slide); } unset($slide_dynamic_terms); } else { if (sliderpro_get_slide_setting($slide['settings'], 'slide_type', 'dynamic') == 'flickr') { if (isset($slide['visibility']) && $slide['visibility'] == 'disabled') { continue; } $slide_settings = $slide['settings']; $slide_content = $slide['content']; foreach ($slide_content as $key => $value) { $slide_content[$key] = sliderpro_decode($value, true, true); } // instantiate the Flickr object global $sliderpro_flickr; if (!isset($sliderpro_flickr)) { include_once 'includes/flickr/phpFlickr.php'; $sliderpro_flickr = new phpFlickr(sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_api_key', 'dynamic')); $sliderpro_flickr->enableCache("fs", WP_PLUGIN_DIR . '/slider-pro/includes/flickr/cache'); } $dynamic_flickr_data_type = sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_data_type', 'dynamic'); $dynamic_flickr_data_id = sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_data_id', 'dynamic'); $dynamic_flickr_maximum = sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_maximum', 'dynamic'); $flickr_response; $flickr_array_name; if ($dynamic_flickr_data_type == 'set') { $flickr_response = $sliderpro_flickr->photosets_getPhotos($dynamic_flickr_data_id, 'description,date_upload,owner_name'); $flickr_array_name = 'photoset'; } else { if ($dynamic_flickr_data_type == 'username') { $flickr_response = $sliderpro_flickr->people_getPublicPhotos($dynamic_flickr_data_id, NULL, 'description,date_upload,owner_name'); $flickr_array_name = 'photos'; } } $slide_dynamic_terms = array(); // get all the dynamic terms used in the content fields foreach ($slide_content as $key => $value) { if ($value != '') { $matches = array(); preg_match_all('/' . $flickr_terms_pattern . '/s', $value, $matches); // check if a match is found if (!empty($matches)) { // loop through all terms found in the field foreach ($matches[0] as $counter => $match_item) { // check if the exact term is not already added to the collection if (!isset($slide_dynamic_terms[$match_item])) { // get the array of arguments specified for the term/tag $args = explode('|', trim($matches[3][$counter])); // create an array of argument pairs (name => value) $arg_pair = array('term_name' => $matches[2][$counter]); foreach ($args as $arg) { if ($arg != '') { $arg_item = explode('=', $arg); $arg_pair[trim($arg_item[0])] = substr(trim($arg_item[1]), 1, -1); } } // associate the term found with its array of argument pairs $slide_dynamic_terms[$match_item] = $arg_pair; } } } } } foreach ($flickr_response[$flickr_array_name]['photo'] as $image) { $dynamic_slide = array(); // each dynamic slide will initially contain the main slide's content and settings $dynamic_slide['settings'] = $slide_settings; $dynamic_slide['content'] = $slide_content; $dynamic_slide['position'] = $slide['position']; $dynamic_slide['visibility'] = $slide['visibility']; $image_owner = $dynamic_flickr_data_type == 'set' ? $flickr_response['photoset']['owner'] : $image['owner']; // loop through all content fields foreach ($dynamic_slide['content'] as $field_name => &$field_content) { if ($field_content != '') { // loop through all terms that were find in the content fields foreach ($slide_dynamic_terms as $term => $term_data) { // check if the term is in the current field if (strpos($field_content, $term) !== false) { // check the type of the term $replace = ''; if ($term_data['term_name'] == 'sp_image') { $image_size = isset($term_data['size']) ? $term_data['size'] : ''; if ($image_size != '') { $image_size = isset($sliderpro_flickr_sizes[$image_size]) ? '_' . $sliderpro_flickr_sizes[$image_size] : ''; } $replace = 'http://farm' . $image['farm'] . '.staticflickr.com/' . $image['server'] . '/' . $image['id'] . '_' . $image['secret'] . $image_size . '.jpg'; } else { if ($term_data['term_name'] == 'sp_image_title') { $replace = $image['title']; } else { if ($term_data['term_name'] == 'sp_image_description') { $replace = $image['description']; } else { if ($term_data['term_name'] == 'sp_image_link') { $replace = 'http://www.flickr.com/photos/' . $image_owner . '/' . $image['id']; } else { if ($term_data['term_name'] == 'sp_image_set' && $dynamic_flickr_data_type == 'set') { $replace = 'http://www.flickr.com/photos/' . $image_owner . '/sets/' . $flickr_response['photoset']['id']; } else { if ($term_data['term_name'] == 'sp_date') { $replace = date('F j Y', $image['dateupload']); } else { if ($term_data['term_name'] == 'sp_user') { $replace = $image['ownername']; } else { if ($term_data['term_name'] == 'sp_user_link') { $replace = 'http://www.flickr.com/people/' . $image_owner . '/'; } else { if ($term_data['term_name'] == 'sp_user_photos') { $replace = 'http://www.flickr.com/photos/' . $image_owner . '/'; } else { if ($term_data['term_name'] == 'sp_user_sets') { $replace = 'http://www.flickr.com/photos/' . $image_owner . '/sets/'; } } } } } } } } } } // replace all the current terms in the field with the corresponding content $field_content = str_replace($term, $replace, $field_content); } } // end terms loop } } // end fields loop array_push($dynamic_slides, $dynamic_slide); unset($dynamic_slide); } unset($slide_dynamic_terms); } } } // end if } // end foreach // insert the dynamic slides if (!empty($dynamic_slides)) { $dynamic_slides = array_reverse($dynamic_slides); $position_to_remove = -1; foreach ($dynamic_slides as $dynamic_slide) { // remove the 'static' slides that were set to be dynamic if ($dynamic_slide['position'] != $position_to_remove) { $position_to_remove = $dynamic_slide['position']; array_splice($slides, $position_to_remove - 1, 1); } // add the dynamic slides array_splice($slides, $position_to_remove - 1, 0, array($dynamic_slide)); } } // string that will contain the javascript properties of the slider $slider_js_properties = ""; // if a value is different from the default value, add it to the string foreach ($sliderpro_slider_settings as $name => $value) { if (isset($slider_settings[$name]) && isset($sliderpro_js_properties[$name])) { if ($slider_settings[$name] != $value['default_value']) { if ($slider_js_properties != "") { $slider_js_properties .= ", " . PHP_EOL; } $slider_js_properties .= SP_IND_3 . sliderpro_get_js_property_name($name) . ": " . sliderpro_get_js_property_value($slider_settings[$name]); } } } // decide what javascript files will need to be included in public view // based on the sliders' settings if (!in_array('slider', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'slider'); } if (sliderpro_get_setting($slider_settings, 'enable_custom_js') && !in_array($current_id, $sliderpro_custom_scripts_to_load)) { array_push($sliderpro_custom_scripts_to_load, $current_id); } if (sliderpro_get_setting($slider_settings, 'timer_animation') && !in_array('excanvas', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'excanvas'); } if (sliderpro_get_setting($slider_settings, 'thumbnail_mouse_wheel') && !in_array('mousewheel', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'mousewheel'); } if (sliderpro_get_setting($slider_settings, 'lightbox') && !in_array('lightbox', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'lightbox'); } if (sliderpro_get_setting($slider_settings, 'css3_transitions') && !in_array('css3_transitions', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'css3_transitions'); } if (sliderpro_get_setting($slider_settings, 'youtube_controller') && !in_array('youtube_controller', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'youtube_controller'); } if (sliderpro_get_setting($slider_settings, 'vimeo_controller') && !in_array('vimeo_controller', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'vimeo_controller'); } if (sliderpro_get_setting($slider_settings, 'html5_controller') && !in_array('html5_controller', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'html5_controller'); } if (sliderpro_get_setting($slider_settings, 'videojs_controller') && !in_array('videojs_controller', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'videojs_controller'); } if (sliderpro_get_setting($slider_settings, 'jwplayer_controller') && !in_array('jwplayer_controller', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'jwplayer_controller'); $sliderpro_scripts_to_load['jwplayer_path'] = sliderpro_get_setting($slider_settings, 'jwplayer_path'); } if (sliderpro_get_setting($slider_settings, 'effect_type') == 'swipe' && !in_array('touch_swipe', $sliderpro_scripts_to_load)) { array_push($sliderpro_scripts_to_load, 'touch_swipe'); } // string that will contain the javascript properties of the slides $slides_js_properties = ""; $index = 0; // loop through all the slides foreach ($slides as $slide) { $slide_settings = $slide['settings']; $slide_js_properties = ""; // if a setting was marked to override the global setting, add that property to the string foreach ($slide_settings as $name => $value) { if (isset($sliderpro_js_properties[$name])) { if ($slide_js_properties != "") { $slide_js_properties .= ", "; } $slide_js_properties .= sliderpro_get_js_property_name($name) . ": " . sliderpro_get_js_property_value($slide_settings[$name]); } } if ($slide_js_properties != "") { if ($slides_js_properties != "") { $slides_js_properties .= ", " . PHP_EOL; } $slides_js_properties .= SP_IND_4 . $index . ': {' . $slide_js_properties . '}'; } $index++; } // create the Javascript output $js_string = ''; $js_string .= PHP_EOL . '<script type="text/javascript">' . PHP_EOL; // append the lightbox css to the header if it's going to be used if (sliderpro_get_setting($slider_settings, 'lightbox') && !$sliderpro_lightbox_loaded) { $sliderpro_lightbox_loaded = true; $js_string .= SP_IND_1 . 'jQuery("<link>").attr({rel: "stylesheet", type: "text/css", media: "all", href: "' . plugins_url('/slider-pro/css/slider/prettyPhoto.css') . '"}).appendTo(jQuery("head"));' . PHP_EOL . PHP_EOL; } // append the VideoJS css to the header if it's going to be used if (sliderpro_get_setting($slider_settings, 'videojs_controller') && !$sliderpro_videojs_loaded) { $sliderpro_lightbox_loaded = true; $js_string .= SP_IND_1 . 'jQuery("<link>").attr({rel: "stylesheet", type: "text/css", media: "all", href: "' . plugins_url('/slider-pro/css/slider/video-js.min.css') . '"}).appendTo(jQuery("head"));' . PHP_EOL . PHP_EOL; } $js_string .= SP_IND_1 . 'jQuery(document).ready(function() {' . PHP_EOL; $js_string .= SP_IND_2 . 'jQuery("#slider-pro-' . $current_id . '").advancedSlider({' . PHP_EOL; $js_string .= $slider_js_properties; if ($slides_js_properties != '') { if ($slider_js_properties != '') { $js_string .= ', ' . PHP_EOL; } $js_string .= SP_IND_3 . 'slideProperties: {' . PHP_EOL . $slides_js_properties . PHP_EOL . SP_IND_3 . '}' . PHP_EOL; } else { $js_string .= PHP_EOL; } $js_string .= SP_IND_2 . '});' . PHP_EOL; $js_string .= SP_IND_1 . '});' . PHP_EOL; $js_string .= '</script>' . PHP_EOL; // to be printed in foother $sliderpro_sliders_js .= $js_string; $slider_classes = sliderpro_get_setting($slider_settings, 'custom_class') != '' ? 'advanced-slider ' . sliderpro_get_setting($slider_settings, 'custom_class') : 'advanced-slider'; // create the HTML output $html_string = ''; $html_string .= '<div class="' . $slider_classes . '" id="slider-pro-' . $current_id . '" tabindex="0">' . PHP_EOL; $html_string .= SP_IND_1 . '<ul class="slides">' . PHP_EOL; $slider_width = sliderpro_get_setting($slider_settings, 'width'); $slider_height = sliderpro_get_setting($slider_settings, 'height'); foreach ($slides as $slide) { if (isset($slide['visibility']) && $slide['visibility'] == 'disabled') { continue; } $slide_content = $slide['content']; $slide_settings = $slide['settings']; $slide_width = sliderpro_get_setting($slider_settings, 'slide_resizing_width') == 'auto' ? strpos($slider_width, '%') ? 500 : $slider_width : sliderpro_get_setting($slider_settings, 'slide_resizing_width'); $slide_height = sliderpro_get_setting($slider_settings, 'slide_resizing_height') == 'auto' ? strpos($slider_height, '%') ? 300 : $slider_height : sliderpro_get_setting($slider_settings, 'slide_resizing_height'); $timthumb_image_path = get_option('slider_pro_enable_timthumb') && sliderpro_get_setting($slider_settings, 'slide_resizing_resize') ? esc_attr(plugins_url('/slider-pro/includes/timthumb/timthumb.php') . '?q=' . sliderpro_get_setting($slider_settings, 'slide_resizing_quality') . '&w=' . $slide_width . '&h=' . $slide_height . '&a=' . sliderpro_get_setting($slider_settings, 'slide_resizing_align') . '&zc=' . sliderpro_get_setting($slider_settings, 'slide_resizing_crop') . '&src=') : ''; $timthumb_thumbnails_path = get_option('slider_pro_enable_timthumb') && sliderpro_get_setting($slider_settings, 'thumbnail_resizing_resize') ? esc_attr(plugins_url('/slider-pro/includes/timthumb/timthumb.php') . '?q=' . sliderpro_get_setting($slider_settings, 'thumbnail_resizing_quality') . '&w=' . sliderpro_get_setting($slider_settings, 'thumbnail_width') . '&h=' . sliderpro_get_setting($slider_settings, 'thumbnail_height') . '&a=' . sliderpro_get_setting($slider_settings, 'thumbnail_resizing_align') . '&zc=' . sliderpro_get_setting($slider_settings, 'thumbnail_resizing_crop') . '&src=') : ''; $lazy_loaded_image = $slide_content['image'] != '' && sliderpro_get_setting($slider_settings, 'lazy_loading') ? 'data-image="' . $timthumb_image_path . $slide_content['image'] . '"' : ''; $html_string .= SP_IND_2 . '<li class="slide" ' . $lazy_loaded_image . '>' . PHP_EOL; // get the link specified for the slide $slide_link_path = sliderpro_get_slide_content($slide_content, 'slide_link_path'); if ($slide_link_path != '') { $slide_link_target = sliderpro_get_slide_setting($slide_settings, 'slide_link_target', 'extra'); $slide_link_title = sliderpro_get_slide_content($slide_content, 'slide_link_title', true); $slide_link_title = $slide_link_title != '' ? ' title="' . $slide_link_title . '"' : ''; $slide_lightbox_content = sliderpro_get_slide_setting($slide_settings, 'slide_link_lightbox', 'extra') ? sliderpro_get_setting($slider_settings, 'lightbox_gallery') ? ' rel="slider-lightbox[slider-pro-slide-' . $current_id . ']"' : ' rel="slider-lightbox"' : ''; $html_string .= SP_IND_3 . '<a' . $slide_lightbox_content . ' href="' . $slide_link_path . '" target="' . $slide_link_target . '"' . $slide_link_title . ' tabindex="-1">' . PHP_EOL; } // get the slide image $slide_image = sliderpro_get_slide_content($slide_content, 'image'); if ($slide_image != '') { $slide_image = $lazy_loaded_image == '' ? $timthumb_image_path . $slide_image : ''; $slide_title = sliderpro_get_slide_content($slide_content, 'title', true); $slide_title = $slide_title != '' ? ' title="' . $slide_title . '"' : ''; $image_indentation = $slide_link_path != '' ? SP_IND_4 : SP_IND_3; $slide_alt = sliderpro_get_slide_content($slide_content, 'alt', true); $html_string .= $image_indentation . '<img class="image" src="' . $slide_image . '" alt="' . $slide_alt . '"' . $slide_title . '/>' . PHP_EOL; } // end the slide link if ($slide_link_path != '') { $html_string .= SP_IND_3 . '</a>' . PHP_EOL; } // get the slide caption $slide_caption = sliderpro_get_slide_content($slide_content, 'caption'); if ($slide_caption != '') { $html_string .= SP_IND_3 . '<div class="caption">' . do_shortcode(sliderpro_decode($slide_caption, true, true)) . '</div>' . PHP_EOL; } // get the slide inline HTML content $slide_html = sliderpro_get_slide_content($slide_content, 'html'); if ($slide_html != '') { $html_string .= SP_IND_3 . '<div class="html">' . do_shortcode(sliderpro_decode($slide_html, true, true)) . '</div>' . PHP_EOL; } // get the thumbnail type $thumbnail_type = sliderpro_get_setting($slider_settings, 'thumbnail_type'); if ($thumbnail_type != 'none') { // get the thumbnail image $thumbnail_path = sliderpro_get_slide_content($slide_content, 'thumbnail_image') != '' ? $slide_content['thumbnail_image'] : $slide_content['image']; if ($thumbnail_path != '') { $thumbnail_title = sliderpro_get_slide_content($slide_content, 'thumbnail_title', true); $thumbnail_title = $thumbnail_title != '' ? ' title="' . $thumbnail_title . '"' : ''; $thumbnail_link_path = sliderpro_get_slide_content($slide_content, 'thumbnail_link_path'); $thumbnail_indentation = $thumbnail_link_path != '' ? SP_IND_4 : SP_IND_3; // get the thumbnail link if ($thumbnail_link_path != '') { $thumbnail_link_target = sliderpro_get_slide_setting($slide_settings, 'thumbnail_link_target'); $thumbnail_link_title = sliderpro_get_slide_content($slide_content, 'thumbnail_link_title', true); $thumbnail_link_title = $thumbnail_link_title != '' ? ' title="' . $thumbnail_link_title . '"' : ''; $thumbnail_lightbox_content = sliderpro_get_slide_setting($slide_settings, 'thumbnail_link_lightbox', 'extra') ? sliderpro_get_setting($slider_settings, 'lightbox_gallery') ? ' rel="slider-lightbox[slider-pro-thumbnail-' . $current_id . ']"' : ' rel="slider-lightbox"' : ''; $html_string .= SP_IND_3 . '<a' . $thumbnail_lightbox_content . ' href="' . $thumbnail_link_path . '" target="' . $thumbnail_link_target . '"' . $thumbnail_link_title . ' tabindex="-1">' . PHP_EOL; } $thumbnail_alt = sliderpro_get_slide_content($slide_content, 'thumbnail_alt', true); $html_string .= $thumbnail_indentation . '<img class="thumbnail" src="' . $timthumb_thumbnails_path . $thumbnail_path . '" alt="' . $thumbnail_alt . '"' . $thumbnail_title . '/>' . PHP_EOL; // end the thumbnail link if ($thumbnail_link_path != '') { $html_string .= SP_IND_3 . '</a>' . PHP_EOL; } } } $html_string .= SP_IND_2 . '</li>' . PHP_EOL; } $html_string .= SP_IND_1 . '</ul>' . PHP_EOL; $html_string .= '</div>'; return PHP_EOL . PHP_EOL . $html_string . PHP_EOL . PHP_EOL; }
if ($NV_imgheight >= '350') { $img_size = "large"; } elseif ($NV_imgheight >= '150') { $img_size = "medium"; } else { $img_size = "small"; } require_once NV_FILES . "/adm/inc/phpFlickr/phpFlickr.php"; $f = new phpFlickr('7caca0370ede756c26832c28b266ead5'); // API //$f->enableCache("fs", "cache"); $user = of_get_option('flickr_userid'); if (is_array($NV_flickrset)) { $NV_flickrset = implode($NV_flickrset, ','); } $photos = $f->photosets_getPhotos($NV_flickrset); $post_count = count($photos); // count query /* ------------------------------------ :: BLACK AND WHITE EFFECT ------------------------------------ */ if ($NV_imageeffect == 'shadowblackwhite' || $NV_imageeffect == 'frameblackwhite' || $NV_imageeffect == 'blackwhite') { $NV_blackwhite = 'blackwhite'; if ($NV_imageeffect == 'shadowblackwhite') { $NV_imageeffect = 'shadow'; } if ($NV_imageeffect == 'frameblackwhite') { $NV_imageeffect = 'frame'; } if ($NV_imageeffect == 'blackwhite') { $NV_imageeffect = 'none';
$f = new phpFlickr($apiKey); $page = $_GET['page']; if ($page == null) { $page = 'home'; } $setId = $_GET['setId']; if ($page == "blog") { $setId = $blog; } if ($page == "about") { $setId = $about; } $collections = $f->collections_getTree($collectionId, $user); if ($setId) { $photos = $f->photosets_getPhotos($setId); $info = $f->photosets_getInfo($setId); $title = $info['title']; $description = $info['description']; foreach ($photos['photoset']['photo'] as $photo) { $photoURL[] = "http://www.flickr.com/photos/" . $user . "/" . $photo['id']; $photoLink[] = $f->buildPhotoURL($photo, 'large'); $info = $f->photos_getInfo($photo['id']); $pTitle[] = $info['title']; $pDescription[] = $info['description']; } } foreach ($collections['collections']['collection'] as $collection) { if ($collection['id'] != $collectionId) { $workId[] = $collection['set'][0]['id']; $workTitle[] = $collection['title'];
function getFlickrPhotos($target) { global $blogURL, $pluginURL, $configVal; requireModel('reader.common'); requireComponent('Textcube.Model.Paging'); requireComponent('Textcube.Function.misc'); $data = misc::fetchConfigVal($configVal); $flickruserid = isset($data['flickruserid']) ? $data['flickruserid'] : ""; require_once "lib/phpFlickr.php"; $flickr_api_key = "d1038f051000214af2bf694014ca8f98"; //It's key for plugin. It does not change. $f = new phpFlickr($flickr_api_key); $listLength = isset($_GET['length']) ? $_GET['length'] : 16; $searchKey = isset($_GET['search']) && !empty($_GET['search']) ? urldecode($_GET['search']) : ""; $photoSets = isset($_GET['photoSets']) && !empty($_GET['photoSets']) ? $_GET['photoSets'] : ""; $personMode = isset($_GET['person']) ? $_GET['person'] : "my"; $page = isset($_GET['page']) ? $_GET['page'] : 1; $zoomStyle = "flickr"; ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link type="text/css" rel="stylesheet" href="<?php echo $pluginURL; ?> /style/default.css" /> </head> <script type="text/javascript"> //<![CDDA[ function insertPhoto(_link, _src_m, _src_l, _title, _style){ var linkTag_A = '', linkTag_B = '', imgTag = ''; linkTag_A = '<a href="' + _link + '" title="' + _title + '" target="_blank">'; linkTag_B = '</a>'; imgTag = '<img src="' + _src_m + '" border="0" />'; var isWYSIWYG = false; try{ if(parent.editor.editMode == 'WYSIWYG') isWYSIWYG = true; } catch(e){ } if(isWYSIWYG) { parent.editor.command('Raw', (linkTag_A + imgTag), linkTag_B); }else{ parent.insertTag(parent.editor.textarea, (linkTag_A + imgTag), linkTag_B); } } //]]> </script> <body style="margin:0;padding:0;border:none;background-color:#ffffff;"> <div id="photosBody" style="height:200px;width:100%;overflow-x:hidden;overflow-y:auto;background-color:#fff;"> <?php if ($personMode == "my" && !empty($flickruserid) && empty($searchKey)) { if (!empty($photoSets)) { $photoset = $f->photosets_getPhotos($photoSets, "owner_name", NULL, $listLength, $page); $photos['photos'] = $photoset['photoset']; } else { $photos = $f->people_getPublicPhotos($flickruserid, NULL, NULL, $listLength, $page); } foreach ($photos['photos']['photo'] as $photo) { $_output = getFlickrPhotosInfo($photo, $zoomStyle, $flickruserid); echo $_output; } } else { if (($personMode == "my" || $personMode == "all") && !empty($searchKey)) { if ($personMode == "my" && !empty($flickruserid)) { $searchArray = array("user_id" => $flickruserid, "text" => $searchKey, "sort" => "date-posted-desc", "per_page" => $listLength, "page" => $page); } else { $searchArray = array("text" => $searchKey, "sort" => "date-posted-desc", "per_page" => $listLength, "page" => $page); } $photos['photos'] = $f->photos_search($searchArray); if ($photos['photos']['total'] > 0) { foreach ($photos['photos']['photo'] as $photo) { $_output = getFlickrPhotosInfo($photo, $zoomStyle); echo $_output; } } else { echo '<p style="margin-top:30px; text-align:center; font-size:9pt;">Flickr did not find any photos. Please input title, description or tags.</p>'; } } else { if ($personMode == "all" && empty($searchKey)) { $photos['photos'] = $f->photos_getRecent(NULL, $listLength, $page); foreach ($photos['photos']['photo'] as $photo) { $_output = getFlickrPhotosInfo($photo, $zoomStyle); echo $_output; } } else { echo '<p style="margin-top:30px; text-align:center; font-size:9pt;">Flickr did not find any photos.', !$nickName ? '(Input title, description or tags.)' : '', '</p>'; } } } $pageLink = '?person=' . $personMode . '&photoSets=' . $photoSets . '&length=' . $listLength . '&search=' . rawurlencode($searchKey); //$photos['total'] = $photos['total'] > 996 ? 996 : $photos['total']; $paging = HC_getFetchWithPaging($photos['photos']['total'], $page, $listLength, "{$blogURL}/plugin/flickrPhotos", $pageLink . "&page="); $pagingTemplate = '[##_paging_rep_##]'; $pagingItemTemplate = '<a [##_paging_rep_link_##] class="num">[##_paging_rep_link_num_##]</a>'; $prev_page = isset($paging['prev']) ? " href=\"{$pageLink}&page={$paging['prev']}\" " : ''; $next_page = isset($paging['next']) ? " href=\"{$pageLink}&page={$paging['next']}\" " : ''; $no_more_prev = isset($paging['prev']) ? '' : 'no-more-prev'; $no_more_next = isset($paging['next']) ? '' : 'no-more-next'; $target = '<div class="paging-list"><a ' . $prev_page . ' class="prev ' . $no_more_prev . '">prev </a>'; $target .= '<span class="numbox">' . str_repeat("\t", 12) . Paging::getPagingView($paging, $pagingTemplate, $pagingItemTemplate) . '</span>'; $target .= '<a ' . $next_page . ' class="next ' . $no_more_next . '"> next</a>'; $target .= '<div class="totalResults">'; $target .= 'Total ' . $photos['photos']['total'] . ' photos.'; $target .= '</div></div>'; echo $target; ?> </div> </body> </html> <?php }
function UserSets_Get_Photos($photosets_id, $path) { $o = new phpFlickr('6791ccf468e1c2276c1ba1e0c41683a4'); $extras = 'url_o,url_l'; $d = $o->photosets_getPhotos($photosets_id, $extras); $total_pages = $d['photoset']['pages']; $total_photos = $d['photoset']['total']; print "total photos : {$total_photos} \ntotal_pages : {$total_pages} \n"; #print_r($d); for ($index_page = 1; $index_page <= $total_pages; $index_page++) { print "page : {$index_page} \n"; $key = new phpFlickr('6791ccf468e1c2276c1ba1e0c41683a4'); $extras = 'url_o,url_l'; $set_data = $key->photosets_getPhotos($photosets_id, $extras, NULL, NULL, $index_page); for ($index = 0; $index <= 500; $index++) { if (!empty($set_data['photoset']['photo'][$index]['url_m'])) { #print_r( "photo $index : ". $set_data['photoset']['photo'][$index]['url_o'] ."\n"); $downfile = $set_data['photoset']['photo'][$index]['url_m']; system("wget -nc {$downfile} -P {$path}"); } elseif (!empty($set_data['photoset']['photo'][$index]['url_z'])) { #print_r( "photo $index : ".$set_data['photoset']['photo'][$index]['url_l'] ."\n"); $downfile = $set_data['photoset']['photo'][$index]['url_z']; system("wget -nc {$downfile} -P {$path}"); } # else{ # print ("orignal and large size is not available \n"); # } } } }
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; }
<?php if (!isset($_GET['id'])) { 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++;
echo $_POST['photosDescr'][$key]; ?> </p> </td> <?php if (!(($key + 1) % 3)) { echo "</tr>\n<tr>"; } } echo "</table>"; } elseif ($_POST['method'] == "savePhotosets") { echo "Title: " . $_POST['title'] . "<br />"; echo "Subtitle: " . $_POST['subtitle'] . "<br />"; echo "Description: " . $_POST['description'] . "<br />"; echo "<table cellpadding='3' style='border: none; width: 100%'>\n<tr>"; $photos = $f->photosets_getPhotos($_POST['photoset'], "owner_name"); foreach ($photos['photo'] as $key => $photo) { if ($key >= $_POST['maximum_photos']) { break; } ?> <td style="vertical-align: top; text-align: center; width: 33%"> <a target="_blank" href="http://www.flickr.com/photos/<?php echo $_POST['owner']; ?> /<?php echo $photo['id']; ?> "> <img style="padding: 1px; border: 1px solid black;" alt="<?php echo $photo['title'] . " by " . $photo['ownername'];