function ws_images_addFlickr($photo, &$service) { if (!is_admin()) { return new PwgError(403, 'Forbidden'); } global $conf; if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key'])) { return new PwgError(null, l10n('Please fill your API keys on the configuration tab')); } include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; include_once PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'; include_once FLICKR_PATH . 'include/functions.inc.php'; if (test_remote_download() === false) { return new PwgError(null, l10n('No download method available')); } // init flickr API include_once FLICKR_PATH . 'include/phpFlickr/phpFlickr.php'; $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']); $flickr->enableCache('fs', FLICKR_FS_CACHE); // user $u = $flickr->test_login(); if ($u === false or empty($_SESSION['phpFlickr_auth_token'])) { return new PwgError(403, l10n('API not authenticated')); } // photos infos $photo_f = $flickr->photos_getInfo($photo['id']); $photo = array_merge($photo, $photo_f['photo']); $photo['url'] = $flickr->get_biggest_size($photo['id'], 'original'); $photo['path'] = FLICKR_FS_CACHE . 'flickr-' . $u['username'] . '-' . $photo['id'] . '.' . get_extension($photo['url']); // copy file if (download_remote_file($photo['url'], $photo['path']) == false) { return new PwgError(null, l10n('Can\'t download file')); } // category if (!preg_match('#^[0-9]+$#', $photo['category'])) { $categories_names = explode(',', $photo['category']); $photo['category'] = array(); foreach ($categories_names as $category_name) { $query = ' SELECT id FROM ' . CATEGORIES_TABLE . ' WHERE LOWER(name) = "' . strtolower($category_name) . '" ;'; $result = pwg_query($query); if (pwg_db_num_rows($result)) { list($cat_id) = pwg_db_fetch_row($result); $photo['category'][] = $cat_id; } else { $cat = create_virtual_category($category_name); $photo['category'][] = $cat['id']; } } } else { $photo['category'] = array($photo['category']); } // add photo $photo['image_id'] = add_uploaded_file($photo['path'], basename($photo['path']), $photo['category']); // do some updates if (!empty($photo['fills'])) { $photo['fills'] = rtrim($photo['fills'], ','); $photo['fills'] = explode(',', $photo['fills']); $updates = array(); if (in_array('fill_name', $photo['fills'])) { $updates['name'] = pwg_db_real_escape_string($photo['title']); } if (in_array('fill_posted', $photo['fills'])) { $updates['date_available'] = date('Y-m-d H:i:s', $photo['dates']['posted']); } if (in_array('fill_taken', $photo['fills'])) { $updates['date_creation'] = $photo['dates']['taken']; } if (in_array('fill_author', $photo['fills'])) { $updates['author'] = pwg_db_real_escape_string($photo['owner']['username']); } if (in_array('fill_description', $photo['fills'])) { $updates['comment'] = pwg_db_real_escape_string(@$photo['description']); } if (in_array('fill_geotag', $photo['fills']) and !empty($photo['location'])) { $updates['latitude'] = pwg_db_real_escape_string($photo['location']['latitude']); $updates['longitude'] = pwg_db_real_escape_string($photo['location']['longitude']); } if (in_array('level', $photo['fills']) && !$photo['visibility']['ispublic']) { $updates['level'] = 8; if ($photo['visibility']['isfamily']) { $updates['level'] = 4; } if ($photo['visibility']['isfriend']) { $updates['level'] = 2; } } if (count($updates)) { single_update(IMAGES_TABLE, $updates, array('id' => $photo['image_id'])); } if (!empty($photo['tags']['tag']) and in_array('fill_tags', $photo['fills'])) { $raw_tags = array_map(create_function('$t', 'return $t["_content"];'), $photo['tags']['tag']); $raw_tags = implode(',', $raw_tags); set_tags(get_tag_ids($raw_tags), $photo['image_id']); } } return l10n('Photo "%s" imported', $photo['title']); }
function __construct($params, $cacheDir = null, $ext = null) { if (is_null($cacheDir)) { $cacheDir = JPATH_ROOT . DS . 'cache'; if (!is_null($ext)) { $extCacheDir = $cacheDir . DS . $ext; if (file_exists($extCacheDir) && is_dir($extCacheDir)) $cacheDir = $extCacheDir; } } $this->_cacheDir = $cacheDir; $apiKey = $params['apikey']; $secretKey = !empty($params['secret']) ? $params['secret'] : null; $cachePeriod = @intval($params['cachePeriod'], 10); $flickr = new phpFlickr($apiKey, $secretKey); if (!empty($params['token'])) $flickr->setToken($params['token']); if ($cachePeriod > 0 && $this->_cacheDir) $flickr->enableCache('fs', $this->_cacheDir, $cachePeriod); $this->_flickr =& $flickr; }
/** * get images from flickr * @author - Henry Addo * @access - public * @return - Array of images */ public function get_images() { $username = ""; $photo_urls = "http://www.flickr.com/photos/eyedol/"; $tags = "tedglobal2007"; // create instance of phpFlickr class $flickr = new phpFlickr(''); //enable caching $flickr->enableCache(""); //authenticate //$flickr->auth(); //get token //$token = $token['user']['nsid']; // get NSID of the username $nsid = $token['user']['nsid']; $user = $flickr->people_findByUsername($username); //get the friendly URL of the the users' photos $photos_url = $flickr->urls_getUserPhotos($username); // get 20 images of public images of the user //$photos = $flickr->photos_search( array( 'tags'=>$tags, //'per_page'=> 200 ) ); $photos = $flickr->people_getPublicPhotos($username, NULL, 36); // loop through the photos foreach ((array) $photos['photo'] as $photo) { $this->images[] = "<li><a href=\"#\">\n <img alt='{$photo['title']}' title='{$photo['title']}'\n src=\"" . $flickr->buildPhotoURL($photo, 'Square') . "\" \n onclick=\"get_image_id('" . $flickr->buildPhotoURL($photo) . "','{$photo['title']}')\"/></a></li>"; $owner = $flickr->people_getInfo($photo[owner]); $this->owner = $owner['username']; } return $this->images; }
function flickrUser($userName) { global $site; $f = new phpFlickr($site["flickr"]["key"]); $f->enableCache("fs", $site["path"] . $site["folder"] . $site["flickr"]["cache"], $site["flickr"]["cacheduration"]); $user = $f->people_findByUsername($userName); return $user; }
function flickr_stream($username, $api_key) { require_once "phpflickr/phpFlickr.php"; $phpFlickrObj = new phpFlickr($api_key); $phpFlickrObj->enableCache("fs", TEMPLATEPATH . "/cache"); $user = $phpFlickrObj->people_findByUsername($username); $user_url = $phpFlickrObj->urls_getUserPhotos($user['id']); $photos = $phpFlickrObj->people_getPublicPhotos($user['id'], NULL, NULL, 9); foreach ($photos['photos']['photo'] as $photo) { echo '<a href="' . $user_url . $photo['id'] . '" title="' . $photo['title'] . ' (on Flickr)" target="_blank">'; echo '<img style="width: 64px; height: 64px; margin: 1px; padding: 2px; border: 3px solid #ddd; background: #fff;" class="wp-image" alt="' . $photo['title'] . '" src="' . $phpFlickrObj->buildPhotoURL($photo, "square") . '" />'; echo '</a>'; } }
function display() { $flickr = new phpFlickr(ModUtil::getVar('Content', 'flickrApiKey')); $flickr->enableCache("fs", System::getVar('temp')); // Find the NSID of the username $person = $flickr->people_findByUsername($this->userName); // Get the photos //$photos = $flickr->people_getPublicPhotos($person['id'], NULL, $this->photoCount); $photos = $flickr->photos_search(array('user_id' => $person['id'], 'tags' => $this->tags, 'per_page' => $this->photoCount)); $photoData = array(); foreach ((array) $photos['photo'] as $photo) { $photoData[] = array('title' => DataUtil::formatForDisplayHTML($this->decode($photo['title'])), 'src' => $flickr->buildPhotoURL($photo, "Square"), 'url' => "http://www.flickr.com/photos/{$photo['owner']}/{$photo['id']}"); } $this->view->assign('photos', $photoData); return $this->view->fetch($this->getTemplate()); }
function getFlickrConnection() { if (FLICKR_KEY) { $flickr = new phpFlickr(FLICKR_KEY); if (false !== $flickr->test_echo()) { $cache = dirname(__FILE__) . '/cache'; if (file_exists($cache)) { $flickr->enableCache("fs", $cache); } return $flickr; } else { throw new \RuntimeException('Flickr API Key has been defined but is invalid.'); } } else { throw new \RuntimeException('Flickr API Key has not been defined.'); } }
public function index() { $this->template->content = new View('flickrwijit_front'); //fetch flickrwijit settings from db $flickrwijit_settings = ORM::factory('flickrwijit', 1); // include phpflickr library include Kohana::find_file('libraries/phpflickr', 'phpFlickr'); $f = new phpFlickr(Kohana::config('flickrwijit.flick_api_key')); //enable caching if ($flickrwijit_settings->enable_cache == 1) { $f->enableCache("fs", "application/cache"); } $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page'), 'total_items' => $flickrwijit_settings->num_of_photos)); //print_r($pagination); $photos = $f->photos_search(array('page' => $pagination->current_page, 'tags' => $flickrwijit_settings->flickr_tag, 'per_page' => (int) Kohana::config('settings.items_per_page'), 'user_id' => $flickrwijit_settings->flickr_id)); $this->template->content->image_width = $flickrwijit_settings->image_width; $this->template->content->image_height = $flickrwijit_settings->image_height; $this->template->content->num_of_photos = $flickrwijit_settings->num_of_photos; $this->template->content->f = $f; $this->template->content->photos = $photos; $this->template->content->pagination = $pagination; }
sharing_display('', true); } ?> <?php get_template_part('partial', 'links'); ?> </div> <?php $key = get_field('flickr_key'); if (!$key) { $key = '2926a701327d02571c68efacf6406bf0'; } $username = get_field('flickr_user'); // $page = isset($_GET['page']) ? $_GET['page'] : 1; $f = new phpFlickr($key); $f->enableCache('fs', TEMPLATEPATH . '/inc/cache'); $result = $f->people_findByUsername($username); $nsid = $result['id']; // $photos = $f->people_getPublicPhotos( $nsid, NULL, NULL, 100, $page ); $photos = $f->favorites_getPublicList($nsid, NULL, NULL, NULL, NULL, NULL, $page); // $pages = $photos[photos][pages]; // $total = $photos[photos][total]; ?> <div class="content"> <div class="gallery"> <?php foreach ($photos['photos']['photo'] as $photo) { ?> <div class="gallery-item"><a href="<?php echo $f->buildPhotoURL($photo, 'large'); ?>
<?php //include("phpflickr/auth.php"); //include("phpflickr/example.php"); //include("phpflickr/getToken.php"); include "phpflickr/phpFlickr.php"; $FLICKR_KEY = "SET_VALUE"; $FLICKR_SHARED_SECRET = "SET_VALUE"; $FLICKR_AUTH_TOKEN = "SET_VALUE"; $FLICKR_USER = "******"; $FLICKR = new phpFlickr($FLICKR_KEY, $FLICKR_SHARED_SECRET, true); $FLICKR->enableCache("fs", "cache"); function splitDescription($details) { return explode("---", $details); } function getDescription($split) { return $split[0]; } function splitDetails($details) { $result = null; $split = explode(";", $details[1]); foreach ($split as $part) { $components = explode(":", $part, 2); if (count($components) > 1) { $result[trim($components[0])] = trim($components[1]); } } return $result;
<img src="http://placehold.it/360x460" /> </div> <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');
public function getItems() { jimport('joomla.filesystem.folder'); $api_key = '2a4dbf07ad5341b2b06d60c91d44e918'; $cache_path = JPATH_ROOT . '/cache/test/flickr'; $nsid = ''; $photos = array(); // create cache folder if not exist JFolder::create($cache_path, 0755); if (!class_exists('phpFlickr')) { require_once 'api/phpFlickr.php'; } $f = new phpFlickr($api_key); $f->enableCache('fs', $cache_path, $this->get('cache_time')); //enable caching if ($this->get('flickr_search_from') == 'user') { $username = $this->get('flickr_search_from'); if ($username != NULL) { $person = $f->people_findByUsername($username); $nsid = $person['id']; } else { return ''; } $photos = $f->people_getPublicPhotos($nsid, NULL, NULL, $this->get('item_count')); $source = $photos['photos']['photo']; } if ($this->get('flickr_search_from') == 'tags' or $this->get('flickr_search_from') == 'text') { $tags = $this->get('flickr_attrs'); if (!empty($tags)) { $attrs = ''; if ($this->get('flickr_search_from') == 'tags') { $attrs = 'tags'; } if ($this->get('flickr_search_from') == 'text') { $attrs = 'text'; } $photos = $f->photos_search(array($attrs => $tags, 'per_page' => $this->get('item_count'))); $source = $photos['photo']; } else { return ''; } } if ($this->get('flickr_search_from') == 'recent') { $photos = $f->photos_getRecent(NULL, $this->get('item_count')); $source = $photos['photo']; } //$extras = 'description,date_upload,owner_name,tags'; $items = array(); $i = 0; if (count($source) > 0) { foreach ($source as $photo) { $id = $photo['id']; $obj = new stdClass(); $info = $f->photos_getInfo($id); $nsid = $info['owner']['username']; $obj->title = $info['title']; $obj->image = $f->buildPhotoURL($photo, '_b'); $obj->link = $info['urls']['url'][0]['_content']; $obj->introtext = $info['description']; $obj->date = date('Y.M.d : H:i:s A', $info['dateuploaded']); $items[$i] = $obj; $i++; } } //return $items; var_dump($f); }
$_youtube_video_height = $params->get('youtube_video_height', '385'); // default 385 pixel if ($_useFlickr == 1) { $_flickr_apikey = $params->get('flickr_apikey', ''); require_once JPATH_COMPONENT . DS . 'includes/phpflickr/phpFlickr.php'; $f = new phpFlickr($_flickr_apikey); if ($_flickr_cache_mode == 1) { $config = new JConfig(); $_host = $config->host; $_db = $config->db; $_dbprefix = $config->dbprefix; $_user = $config->user; $_password = $config->password; $_flickr_connect = "mysql://" . $_user . ":" . $_password . "@" . $_host . "/" . $_db; $_flickr_cache_table = $_dbprefix . "discussions_flickr_cache"; $f->enableCache("db", $_flickr_connect, $_flickr_cache_time, $_flickr_cache_table); } } if ($_imagesDisplayMode == 1) { // Slimbox $assets = JURI::root() . "components/com_discussions/assets"; $document->addStyleSheet($assets . '/css/slimbox.css'); } // website root directory $_root = JURI::root(); ?> <!-- Javascript functions --> <?php
* * This example file shows you how to call the 100 most recent public * photos. It parses through them and prints out a link to each of them * along with the owner's name. * * Most of the processing time in this file comes from the 100 calls to * flickr.people.getInfo. Enabling caching will help a whole lot with * this as there are many people who post multiple photos at once. * * Obviously, you'll want to replace the "<api key>" with one provided * by Flickr: http://www.flickr.com/services/api/key.gne */ require_once "phpFlickr.php"; $f = new phpFlickr("a28fe4e32f1304273f5562dc12f9559a"); $lifetime = 60 * 60; // One hour $f->enableCache("fs", "../resources/cache", $lifetime); $photos = $f->photos_search(array("tags" => "hongkong, girl", "tag_mode" => "all", "per_page" => "20")); foreach ($photos['photo'] as $photo) { echo "<img src='https://farm" . $photo['farm'] . ".staticflickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . ".jpg'></img>"; $owner = $f->people_getInfo($photo['owner']); echo "<p>" . $owner['username']['_content'] . "</p>"; /* $photoInfo = $f->photos_getInfo($photo['id']); echo "<p>"; foreach ($photoInfo['photo']['tags']['tag'] as $tag) { echo $tag['_content']." "; } echo "</p>";*/ // https://farm{farm-id}.staticflickr.com/{server-id}/{id}_{secret}.jpg echo "<br><br>"; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); if (empty($title)) { $title = false; } $flickr_api = $instance['flickr_api']; $flickr_id = $instance['flickr_id']; $number = absint($instance['number']); require_once get_template_directory() . "/includes/widgets/phpFlickr/phpFlickr.php"; $f = new phpFlickr($flickr_api); //Insert API key here $f->enableCache("fs", get_template_directory() . "/includes/widgets/cache/"); if (!empty($flickr_id)) { echo $before_widget; if ($title) { echo $before_title; echo $title; echo $after_title; } $apikey = $f->people_findByUsername($flickr_api); $person = $f->people_findByUsername($flickr_id); $photos_url = $f->urls_getUserPhotos($person['id']); $photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, $number); echo "<ul class='flickr_images clearfix'>"; foreach ((array) $photos['photos']['photo'] as $photo) { $photo_url = $f->buildPhotoURL($photo, "Large"); echo "<li><a class='view flickr-img-link' rel='flickr-gallery' target='_blank' href={$photo_url}>"; echo "<img class='flickr' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Small") . ">"; echo "</a></li>"; } echo "</ul>"; echo $after_widget; } }
$f->setToken("{$flickrToken}"); } if ($flickrPrivate == "privatephotosetNo") { $f = new phpFlickr("{$flickrAPI}"); } $ph_sets = $f->photosets_getList(); if ($flickrCache == "1") { $cacheFolderPath = JPATH_SITE . DS . 'cache' . DS . 'ResponsivePhotoGallery-' . $moduleTitle . ''; if (file_exists($cacheFolderPath) && is_dir($cacheFolderPath)) { // all OK } else { 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) {
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title'); $username = $this->get_config('email'); $num = $this->get_config('perpage'); $choices = $this->get_config('numberOfChoices'); //added 110730 by artodeto $useChoices = $this->get_config('useChoices'); //added 110730 by artodeto $apiKey = $this->get_config('apikey'); $apiSecret = $this->get_config('apisecret'); $sourceimgtype = $this->get_config('sourceimgtype'); $targetimgtype = $this->get_config('targetimgtype'); $errors = array(); /* Get image data from flickr */ $f = new phpFlickr($apiKey, $apiSecret); $f->enableCache("fs", $serendipity['serendipityPath'] . 'templates_c/', $this->get_config('cachetimeout')); if (stristr($username, '@')) { $nsid = $f->people_findByEmail($username); } else { $nsid = $f->people_findByUsername($username); } if ($nsid === false) { $errors[] = PLUGIN_SIDEBAR_FLICKR_ERROR_WRONGUSER; } /* Can't find user */ $photos_url = $f->urls_getUserPhotos($nsid['nsid']); if ($useChoices === true) { $photos = $f->photos_search(array("user_id" => $nsid['nsid'], "per_page" => $choices, "sort" => "date-posted-desc", "extras" => "date_taken")); } else { $photos = $f->photos_search(array("user_id" => $nsid['nsid'], "per_page" => $num, "sort" => "date-posted-desc", "extras" => "date_taken")); } if ($photos[total] > 0 && $f) { $sizelist = array("0" => "Square", "1" => "Thumbnail", "2" => "Small", "3" => "Medium", "4" => "Large", "5" => "Original"); if ($useChoices === true) { //added 110730 by artodeto shuffle($photos['photo']); array_splice($photos['photo'], $num); } foreach ($photos['photo'] as $photo) { if ($photo['ispublic'] !== 1) { continue; } $imgdate = strftime("%d.%m.%y %H:%M", strtotime($photo['datetaken'])); $imgtitle = $photo['title']; /* Choose available image size */ $sizes_available = $f->photos_getSizes($photo[id]); $photosize = $sourceimgtype; $imgsrcdata = NULL; while ($imgsrcdata == NULL && $photosize >= 0) { $imgsrcdata = getsizedata($sizes_available, $sizelist[$photosize]); $photosize--; } /* If updating from previous versions, $targetimgtype could be -1. So we set it to the next legal value 2. */ $photosize = max($targetimgtype, 2); $imgtrgdata = NULL; while ($imgtrgdata == NULL && $photosize >= 0) { $imgtrgdata = getsizedata($sizes_available, $sizelist[$photosize]); $photosize--; } $img_width = $imgsrcdata['width']; $img_height = $imgsrcdata['height']; $img_url = $imgsrcdata['source']; if ($this->get_config('targetlink') == "JPG") { $link_url = $imgtrgdata['source']; } else { $link_url = $imgtrgdata['url']; } if ($this->get_config('showdate') || $this->get_config('showtitle')) { unset($info); if ($this->get_config('showdate')) { $info .= '<span class="serendipity_plugin_flickr_date">' . $imgdate . '</span>'; } if ($this->get_config('showtitle')) { $info .= '<span class="serendipity_plugin_flickr_title">' . $imgtitle . '</span>'; } if ($this->get_config('lightbox') != '') { $lightbox = 'rel="' . $this->get_config('lightbox') . '" '; } $images .= sprintf('<dd style="width:%spx;"><a %shref="%s" ><img src="%s" width="%s" height="%s" title="%s" alt="%s"/></a></dd><dt style="width:%spx;margin-left:-%spx;">%s</dt>' . "\n", $img_width, $lightbox, $link_url, $img_url, $img_width, $img_height, $photo[title], $photo[title], $img_width, $img_width + 5, $info); } else { $images .= sprintf('<dd style="width:%spx;"><a href="%s"><img src="%s" width="%s" height="%s" alt="%s"/></a></dd>' . "\n", $img_width, $link_url, $img_url, $img_width, $img_height, $photo[title]); } $i++; } } else { $errors[] = PLUGIN_SIDEBAR_FLICKR_ERROR_NOIMG; /* No images available */ } $content = '<dl class="serendipity_plugin_flickr">' . "\n"; $content .= "\n" . $images; $content .= '</dl>'; $footer = array(); if ($this->get_config('showrss')) { $rssicon = serendipity_getTemplateFile('img/xml.gif'); $footer[] = '<a class="serendipity_xml_icon" href="http://api.flickr.com/services/feeds/photos_public.gne?id=' . $nsid['nsid'] . '&format=rss_200"><img src="' . $rssicon . '" alt="XML" style="border: 0px" /></a>' . "\n" . '<a href="http://api.flickr.com/services/feeds/photos_public.gne?id=' . $nsid['nsid'] . '&format=rss_200">' . PLUGIN_SIDEBAR_FLICKR_LINK_SHOWRSS . '</a>'; } if ($this->get_config('showphotostream')) { $footer[] = '<a href="http://www.flickr.com/photos/' . $username . '/">' . PLUGIN_SIDEBAR_FLICKR_LINK_PHOTOSTREAM . '</a>'; } if (count($footer) > 0) { $content .= '<p class="serendipity_plugin_flickr_links">'; $content .= join("<br />\n", $footer) . "\n"; $content .= '</p>'; } if (count($errors) > 0) { $content .= '<p class="serendipity_plugin_flickr_errors">'; $content .= join("<br />\n", $errors) . "\n"; $content .= '</p>'; } echo $content; }
/** * Initializes the phpFlickr object. Called on WP's init hook. * */ function init() { load_plugin_textdomain('flickr-gallery', 'wp-content/plugins/' . basename(dirname(__FILE__)) . '/i18n'); if (get_option('fg-API-key')) { global $phpFlickr; include_once dirname(__FILE__) . '/phpFlickr.php'; $phpFlickr = new phpFlickr(get_option('fg-API-key'), get_option('fg-secret') ? get_option('fg-secret') : null); if (get_option('fg-token')) { $phpFlickr->setToken(get_option('fg-token')); } if (function_exists('curl_init')) { $phpFlickr->custom_post = array('DC_FlickrGallery', 'curl_post'); } elseif (class_exists('WP_Http')) { $phpFlickr->custom_post = array('DC_FlickrGallery', 'wp_http_post'); } if (get_option('fg-db-cache') == 1) { $phpFlickr->enableCache('custom', array(array('DC_FlickrGallery', 'cache_get'), array('DC_FlickrGallery', 'cache_set'))); } wp_enqueue_script('jquery-ui-tabs'); // wp_enqueue_script('jquery-flightbox', DC_FlickrGallery::getURL() . 'flightbox/jquery.flightbox.js', array(), CM_FLICKR_GALLERY_VERSION); // wp_enqueue_style('flickr-gallery', DC_FlickrGallery::getURL() . 'flickr-gallery.css', array(), CM_FLICKR_GALLERY_VERSION, 'all'); if (DC_FlickrGallery::get_major_version() >= 2.8) { wp_enqueue_style('fg-jquery-ui', DC_FlickrGallery::getURL() . 'tab-theme/jquery-ui-1.7.3.css', array(), '1.7.3', 'all'); } else { wp_enqueue_style('fg-jquery-ui', DC_FlickrGallery::getURL() . 'tab-theme/jquery-ui-1.5.2.css', array(), '1.5.2', 'all'); } // wp_enqueue_style('jquery-flightbox', DC_FlickrGallery::getURL() . 'flightbox/jquery.flightbox.css', array(), CM_FLICKR_GALLERY_VERSION, 'all'); } if ($_GET['action'] == 'flickr-gallery-photoset') { DC_FlickrGallery::ajax_photoset($_GET['id'], $_GET['page']); } elseif ($_POST['action'] == 'flickr-gallery-page') { DC_FlickrGallery::ajax_pagination(); } elseif ($_POST['action'] == 'flickr-gallery-sizes') { DC_FlickrGallery::ajax_sizes(); } if (is_admin() && $_GET['page'] == 'flickr-gallery/flickr-gallery.php') { wp_enqueue_script('jquery-form'); } if (!is_admin() && (get_option('fg-flightbox') === false || get_option('fg-flightbox'))) { wp_enqueue_script('jquery-flightbox', DC_FlickrGallery::getURL() . 'flightbox/jquery.flightbox.js', array(), CM_FLICKR_GALLERY_VERSION); wp_enqueue_style('flickr-gallery', DC_FlickrGallery::getURL() . 'flickr-gallery.css', array(), CM_FLICKR_GALLERY_VERSION, 'all'); wp_enqueue_style('jquery-flightbox', DC_FlickrGallery::getURL() . 'flightbox/jquery.flightbox.css', array(), CM_FLICKR_GALLERY_VERSION, 'all'); add_action('wp_head', array('DC_FlickrGallery', 'header')); add_action('wp_footer', array('DC_FlickrGallery', 'footer')); } }
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 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; }
if($flickrPrivate =="privatephotosetNo") { $f = new phpFlickr("$flickrAPI"); } $ph_sets = $f->photosets_getList(); if($flickrCache =="1") { $cacheFolderPath = JPATH_SITE.DS.'cache'.DS.'ResponsivePhotoGallery-'.$moduleTitle.''; if (file_exists($cacheFolderPath) && is_dir($cacheFolderPath)) { // all OK } else { mkdir($cacheFolderPath); } $lifetime = 860 * 860; // 60 * 60=One hour $f->enableCache("fs", "$cacheFolderPath", "$lifetime"); } ?> <?php if ($flickrCaption == "1") : ?> <div id="gallery"> <div class="photosets"> <?php $photos = $f->photosets_getPhotos($flickrSet, NULL, NULL, $flickrNumber); ?> <?php foreach ($photos['photoset']['photo'] as $photo): $d = $f->photos_getInfo($photo['id']); ?> <div class="photos"> <ul> <li> <a href="#"><img src="<?= $f->buildPhotoURL($photo, $flickrThumb) ?>" data-large="<?= $f->buildPhotoURL($photo, 'large') ?>" alt="<?= $photo['title'] ?>" data-description= "<?= $photo['title'] ?>" data-href="<?= $f->buildPhotoURL($photo, 'large') ?>" /></a> </a> </div> <?php endforeach ; ?> </div>
/** * 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; }
defined('FLICKR_PATH') or die('Hacking attempt!'); set_time_limit(600); include_once FLICKR_PATH . 'include/functions.inc.php'; // check API parameters and connect to flickr if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key'])) { $_SESSION['page_warnings'][] = l10n('Please fill your API keys on the configuration tab'); redirect(FLICKR_ADMIN . '-config'); } else { if (!test_remote_download()) { $page['errors'][] = l10n('No download method available'); $_GET['action'] = 'error'; } else { // init flickr API include_once FLICKR_PATH . 'include/phpFlickr/phpFlickr.php'; $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']); $flickr->enableCache('fs', FLICKR_FS_CACHE); // must authenticate $u = $flickr->test_login(); if (($u === false or empty($_SESSION['phpFlickr_auth_token'])) and @$_GET['action'] != 'login') { $_GET['action'] = 'init_login'; } // generate token after authentication if (!empty($_GET['frob'])) { $flickr->auth_getToken($_GET['frob']); $_GET['action'] = 'logged'; } } } if (!isset($_GET['action'])) { $_GET['action'] = 'main'; }
if (!class_exists('phpFlickr')) { require_once fenchurch_flickr_library_path() . '/phpFlickr.php'; } ?> <div class="flickr"> <?php $url_elements = parse_url($node->field_flickr[0]['embed']); $flickr_path = explode('/', $url_elements['path']); if (module_exists('keys')) { $flickr_api_key = keys_get_key('flickr_theme_helper'); } $f = new phpFlickr($flickr_api_key, NULL, FALSE); if (module_exists('fenchurch')) { $f->enableCache('db', fenchurch_flickr_cache_db_url(), variable_get('fenchurch_flickr_cache_lifetime', 64000)); } $flickr_photo_info = $f->photos_getInfo($flickr_path[3]); ?> <?php print $node->field_flickr[0]['view']; ?> <?php if ($node->location) { $photo_latitude = $node->location['latitude']; $photo_longitude = $node->location['longitude']; if (function_exists('theme_gmap') && $page) { $photo_markers = array('id' => 'photo_markers', 'zoom' => 11, 'width' => '500px', 'height' => '200px', 'type' => 'Map', 'text' => $node->title, 'latitude' => $photo_latitude, 'longitude' => $photo_longitude, 'markers' => array(array('markername' => '', 'latitude' => $photo_latitude, 'longitude' => $photo_longitude))); print theme('gmap', array('#settings' => $photo_markers));