Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
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>';
    }
}
Ejemplo n.º 3
0
function jeg_get_flickr_photo($flickrapi, $flickrid, $totalimage)
{
    require_once JEG_PLUGIN_DIR . "util/phpFlickr/phpFlickr.php";
    $f = new phpFlickr($flickrapi);
    $result = $f->people_getPublicPhotos($flickrid, null, null, $totalimage, null);
    $photos = array();
    if (empty($result)) {
        echo $f->getErrorMsg();
    } else {
        $photosUrl = $f->urls_getUserPhotos($flickrid);
        foreach ($result['photos']['photo'] as $photo) {
            $photos[] = array('s' => $f->buildPhotoURL($photo, 'square'), 'url' => $photosUrl . $photo['id'], 'title' => $photo['title']);
        }
    }
    return $photos;
}
Ejemplo n.º 4
0
 function afsp_flickr_embed($photo)
 {
     // define outputs
     $flickr_gallery = '';
     $flickr_nav = '';
     $flickr_display = '';
     // define access
     $api = '238309aa246837711a82e3616d5666b1';
     $username = $photo;
     require_once get_template_directory() . '/inc/flickr/phpFlickr.php';
     $photo_count = 20;
     $nav_width = 100 / $photo_count . '%';
     $f = new phpFlickr($api);
     $user = $f->people_findByUsername($username);
     $nsid = $user['nsid'];
     $photos = $f->people_getPublicPhotos($nsid, 1, '', $photo_count);
     $flickr_gallery .= '<div class="gallery gallery--flickr js-flickity" data-flickity-options=\'{ "wrapAround": true, "pageDots": false, "autoPlay": true }\'>';
     foreach ($photos['photos']['photo'] as $photo) {
         $src = 'https://farm' . $photo['farm'] . '.staticflickr.com/' . $photo['server'] . '/' . $photo['id'] . '_' . $photo['secret'] . '_c.jpg';
         $flickr_gallery .= '<div class="gallery-cell gallery-cell__carousel">';
         $flickr_gallery .= '<a target="_blank" href="https://www.flickr.com/photos/' . $nsid . '/' . $photo['id'] . '">';
         $flickr_gallery .= '<img src="' . $src . '" />';
         $flickr_gallery .= '</a>';
         $flickr_gallery .= '</div>';
     }
     $flickr_gallery .= '</div>';
     $flickr_nav .= '<div class="gallery-nav gallery-nav--flickr js-flickity" data-flickity-options=\'{"asNavFor": ".gallery--flickr", "contain": true, "prevNextButtons": false, "pageDots": false}\'>';
     foreach ($photos['photos']['photo'] as $photo) {
         $src = 'https://farm' . $photo['farm'] . '.staticflickr.com/' . $photo['server'] . '/' . $photo['id'] . '_' . $photo['secret'] . '_c.jpg';
         $flickr_nav .= '<div class="gallery-cell" style="width:' . $nav_width . ';">';
         $flickr_nav .= '<img src="' . $src . '" />';
         $flickr_nav .= '</div>';
     }
     $flickr_nav .= '</div>';
     $flickr_display .= $flickr_gallery;
     $flickr_display .= $flickr_nav;
     echo $flickr_display;
 }
Ejemplo n.º 5
0
 public function retornaGaleriaflickr()
 {
     $site = site_dados();
     require_once "flickr/phpFlickr.php";
     $f = new phpFlickr("KEY", "SECRET");
     $person = $f->people_findByUsername($flickr_channel);
     // Get the friendly URL of the user's photos
     $photos_url = $f->urls_getUserPhotos($person['id']);
     // Get the user's first 36 public photos
     $photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, 9);
     $i = 0;
     foreach ((array) $photos['photos']['photo'] as $photo) {
         $retorno[$i]['photo'] = $photo;
         $retorno[$i]['photos_url'] = $photos_url;
         $retorno[$i]['url']['square'] = $f->buildPhotoURL($photo, "square");
         $retorno[$i]['url']['thumbnail'] = $f->buildPhotoURL($photo, "thumbnail");
         $retorno[$i]['url']['small'] = $f->buildPhotoURL($photo, "small");
         $retorno[$i]['url']['medium'] = $f->buildPhotoURL($photo, "medium");
         $retorno[$i]['url']['large'] = $f->buildPhotoURL($photo, "large");
         $retorno[$i]['url']['original'] = $f->buildPhotoURL($photo, "original");
         $i++;
     }
     return $retorno;
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                // called when admin sidebar is being "built"
                case 'backend_sidebar_entries_images':
                    ?>
<li class="serendipitySideBarMenuLink serendipitySideBarMenuMediaLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=flickr">
                        <?php 
                    echo PLUGIN_EVENT_FLICKR_NAME;
                    ?>
</a></li><?php 
                    break;
                    // called when admin sidebar is been "drawn"
                // called when admin sidebar is been "drawn"
                case 'backend_sidebar_entries_event_display_flickr':
                    // he, is user allowed to import images ?!?
                    if (!serendipity_checkPermission('adminImagesAdd')) {
                        // TODO: add a message to the user ?!?
                        break;
                    }
                    // if method is POST, we must have a valid form token !
                    if ($_SERVER['REQUEST_METHOD'] == 'POST' && !serendipity_checkFormToken()) {
                        // TODO: add a message to the user ?!?
                        break;
                    }
                    ?>
                <?php 
                    echo PLUGIN_EVENT_FLICKR_IMPORT_BLAHBLAH;
                    ?>
                <script type="text/javascript">
                function flickr_showPage(p) {
                    var f = document.getElementById('flickr_uploadform');
                    f.elements['serendipity[flickr_page]'].value = p;
                    f.submit();
                }
                function flickr_doImport(url) {
                    var f = document.getElementById('flickr_uploadform');
                    f.elements['serendipity[adminModule]'].value = 'images';
                    f.elements['serendipity[adminAction]'].value = 'add';
                    f.elements['serendipity[imageurl]'].value = url;
                    f.submit();
                }
                function flickr_toggleExtended() {
                    var d = document.getElementById('flickr_extendedCriteria');
                    d.style.display = (d.style.display != '') ? '' : 'none';
                }
                </script>
                <h3><? echo PLUGIN_EVENT_FLICKR_IMPORT; ?></h3>
                <form action="?" method="POST" id="flickr_uploadform" enctype="multipart/form-data" onsubmit="">
                    <?php 
                    echo serendipity_setFormToken();
                    ?>
                    <?php 
                    // these two fields will only be used when an image has been chosen for dl
                    ?>
                    <input type="hidden" name="serendipity[imageurl]" value="" />
                    <input type="hidden" name="serendipity[imageimporttype]" value="image" />

                    <input type="hidden" name="serendipity[action]"      value="admin" />
                    <input type="hidden" name="serendipity[adminModule]" value="event_display" />
                    <input type="hidden" name="serendipity[adminAction]" value="flickr" />

                    <input type="hidden" name="serendipity[flickr_page]" value="1" />
                    Flickr username: <input class="input_textbox" name="serendipity[flickr_username]" value="<?php 
                    echo function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_username']) : htmlspecialchars($serendipity['POST']['flickr_username'], ENT_COMPAT, LANG_CHARSET);
                    ?>
" />
                    <input type="submit" value="<?php 
                    echo GO;
                    ?>
" class="serendipityPrettyButton input_button" /><br /><br />
                    <a style="border: 0pt none ; text-decoration: none;" href="#" onclick="flickr_toggleExtended(); return false"
                         title="<?php 
                    echo TOGGLE_OPTION;
                    ?>
">
                    <img border="0" src="<?php 
                    echo serendipity_getTemplateFile('img/plus.png');
                    ?>
" /> <?php 
                    echo TOGGLE_ALL;
                    ?>
</a>
                    <div id="flickr_extendedCriteria" <?php 
                    echo strlen($serendipity['POST']['flickr_username']) ? '' : 'style="display:none;"';
                    ?>
>
                        <p><?php 
                    echo PLUGIN_EVENT_FLICKR_TAGS;
                    ?>
 <input class="input_textbox" name="serendipity[flickr_tags]" value="<?php 
                    echo function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_tags']) : htmlspecialchars($serendipity['POST']['flickr_tags'], ENT_COMPAT, LANG_CHARSET);
                    ?>
" />
                        <?php 
                    echo PLUGIN_EVENT_FLICKR_KEYWORDS;
                    ?>
 <input class="input_textbox" name="serendipity[flickr_keywords]" value="<?php 
                    echo function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_keywords']) : htmlspecialchars($serendipity['POST']['flickr_keywords'], ENT_COMPAT, LANG_CHARSET);
                    ?>
" size="30" /></p>
                        <?php 
                    echo SORT_BY;
                    ?>
 <select id="flickr_sort" name="serendipity[flickr_sort]">
                        <option value=""></option>
                        <?
                            // See API for details (http://www.flickr.com/services/api/flickr.photos.search.html)
                            $flickr_goodSortOrders = array(
                                'date-posted-asc'=>'By date of post, ascending',
                                'date-posted-desc'=>'By date of post, descending',
                                'date-taken-asc'=>'By date of take, ascending',
                                'date-taken-desc'=>'By date of take, descending',
                                'interestingness-asc'=>'By interestingness, ascending',
                                'interestingness-desc'=>'By interestingness, ascending',
                                'relevance'=>'By revelance'
                            );

                            // compute sort order
                            $sortOrder = (isset($serendipity['POST']['flickr_keywords']) &&
                                array_key_exists($serendipity['POST']['flickr_keywords'], $flickr_goodSortOrders) ?
                                (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_keywords']) : htmlspecialchars($serendipity['POST']['flickr_keywords'], ENT_COMPAT, LANG_CHARSET)) : '');

                            // display possible options for sort order
                            foreach($flickr_goodSortOrders as $value => $description) {
                                echo '<option value="'.$value.'"';
                                if($sortOrder == $value) echo(' selected="true"');
                                echo '>'.$description.'</option>';
                            }
                        ?>
                        </select>
                    </div>
                </form>
                <?php 
                    // in the second step, we show latest photos (thumbs) for given username
                    if ($serendipity['POST']['adminAction'] == 'flickr') {
                        // make use of phpFlikr lib (http://www.phpflickr.com/)
                        require_once dirname(__FILE__) . '/phpFlickr/phpFlickr.php';
                        $f = new phpFlickr($this->get_config('api_key'));
                        $i = 0;
                        if (!empty($serendipity['POST']['flickr_username'])) {
                            // Find the NSID of the username inputted via the form
                            $nsid = $f->people_findByUsername($serendipity['POST']['flickr_username']);
                            // Get the friendly URL of the user's photos
                            $photos_url = $f->urls_getUserPhotos($nsid);
                            echo '<h4 style="margin-bottom: 0; padding-bottom: 0;">Photos of <em>';
                            echo (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_username']) : htmlspecialchars($serendipity['POST']['flickr_username'], ENT_COMPAT, LANG_CHARSET)) . '</em> at ';
                            echo '<a href="' . $photos_url . '" target="_blank">' . $photos_url . '</a></h4>';
                            // default page is number one
                            if (empty($serendipity['POST']['flickr_page']) || !is_numeric($serendipity['POST']['flickr_page'])) {
                                $serendipity['POST']['flickr_page'] = 1;
                            }
                            // make sure page is a number between 1 and 500 (range allowed by flickr API)
                            $serendipity['POST']['flickr_page'] = min(500, max(1, (int) $serendipity['POST']['flickr_page']));
                            echo '<h5 style="margin-top: 0; padding-top: 0;">Displaying page ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_page']) : htmlspecialchars($serendipity['POST']['flickr_page'], ENT_COMPAT, LANG_CHARSET)) . '</h5>';
                            // Search is made depending on selected criterias
                            $searchCriteria = array();
                            // make sure sort order is non empty AND valid
                            if (isset($serendipity['POST']['flickr_sort']) && strlen(trim($serendipity['POST']['flickr_sort'])) && array_key_exists($serendipity['POST']['flickr_keywords'], $flickr_goodSortOrders)) {
                                $searchCriteria['sort'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_sort']) : htmlspecialchars($serendipity['POST']['flickr_sort'], ENT_COMPAT, LANG_CHARSET);
                            }
                            // TODO: clean up tags of unwanted characters (keep only [a-zA-Z0-9_-])
                            if (isset($serendipity['POST']['flickr_tags']) && strlen(trim($serendipity['POST']['flickr_tags']))) {
                                $searchCriteria['tags'] = implode(',', explode(' ', function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_tags']) : htmlspecialchars($serendipity['POST']['flickr_tags'], ENT_COMPAT, LANG_CHARSET)));
                            }
                            // TODO: cleanup keywords
                            if (isset($serendipity['POST']['flickr_keywords']) && strlen(trim($serendipity['POST']['flickr_keywords']))) {
                                $searchCriteria['text'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['flickr_keywords']) : htmlspecialchars($serendipity['POST']['flickr_keywords'], ENT_COMPAT, LANG_CHARSET);
                            }
                            if (count($searchCriteria)) {
                                // It seems the user wants an advanced search
                                $searchCriteria['user_id'] = $nsid;
                                $photos = $f->photos_search($searchCriteria);
                            } else {
                                // No extra criteria, get the user's next 12 public photos (+1 to show > next or not !)
                                $photos = $f->people_getPublicPhotos($nsid, NULL, 13, $serendipity['POST']['flickr_page']);
                                // Get user's tags (if any)
                                /*$tags = $f->tags_getListUser($nsid);
                                  if(is_array($tags['tags']['tag'])) {
                                      echo implode(',', $tags['tags']['tag']);
                                      echo "<br />\n";
                                  }*/
                            }
                            // Loop through the photos and output the html
                            foreach ($photos['photo'] as $photo) {
                                echo '<a title="Add to library" href="javascript:flickr_doImport(\'' . $f->buildPhotoURL($photo, 'Original') . '\');" ';
                                echo 'onclick="return confirm(\'Import this photo into the media library ?\');">';
                                echo '<img border="0" alt="' . $photo['title'] . '" src=' . $f->buildPhotoURL($photo, 'Square') . ' />';
                                echo '</a>';
                                // break before the 13th photo (if any)
                                if (++$i == 12) {
                                    break;
                                }
                                // If it reaches the sixth photo, insert a line break
                                if ($i % 6 == 0) {
                                    echo "<br />\n";
                                }
                            }
                            // end foreach
                            echo "<br />\n";
                            // navigate through pages of photos
                            if ($serendipity['POST']['flickr_page'] > 1) {
                                echo '<a href="javascript:flickr_showPage(' . (int) ($serendipity['POST']['flickr_page'] - 1) . ');">Previous</a>';
                            }
                            echo '&nbsp;&nbsp;';
                            if (count($photos['photo']) > 12) {
                                echo '<a href="javascript:flickr_showPage(' . (int) ($serendipity['POST']['flickr_page'] + 1) . ');">Next</a>';
                            }
                        }
                        // end if
                    }
                    // end if
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
Ejemplo n.º 7
0
<?php

/* Last updated with phpFlickr 1.3.2
 *
 * This example file shows you how to call the 100 most recent public
 * photos.  It parses through them and prints out a link to each of them
 * along with the owner's name.
 *
 * Most of the processing time in this file comes from the 100 calls to
 * flickr.people.getInfo.  Enabling caching will help a whole lot with
 * this as there are many people who post multiple photos at once.
 *
 * Obviously, you'll want to replace the "<api key>" with one provided 
 * by Flickr: http://www.flickr.com/services/api/key.gne
 */
require_once "phpFlickr.php";
$f = new phpFlickr("3077891bafd02f95795c02a20be57144");
$recent = $f->people_getPublicPhotos('31446365@N05', null, null, 2);
$photos = array();
if (empty($recent)) {
    echo $f->getErrorMsg();
} else {
    foreach ($recent['photos']['photo'] as $photo) {
        $photos[] = array('s' => $f->buildPhotoURL($photo, 'square'), 'o' => $f->buildPhotoURL($photo, 'original'), 'title' => $photo['title']);
    }
}
Ejemplo n.º 8
0
} else {
    $temp_user = get_loggedin_user();
}
$flickr_username = get_metadata_byname($temp_user->guid, "flickr_username");
if (empty($flickr_username)) {
    register_error("No Flickr username set");
    echo "<pre>No flickr username set: {$temp_user->guid}";
    die;
    forward("/");
    die;
}
$flickr_user = $f->people_findByUsername($flickr_username->value);
// Get the friendly URL of the user's photos
$photos_url = $f->urls_getUserPhotos($flickr_user["id"]);
if (!empty($flickr_user)) {
    $recent = $f->people_getPublicPhotos($flickr_user['id'], NULL, NULL, 5);
} else {
    echo "user not found";
    die;
}
//echo "<pre>"; var_dump( $recent ); echo "</pre>";
//echo "<pre>"; var_dump( $user ); echo "</pre>";
$body = elgg_view_title("Flickr photos for {$flickr_user['username']}");
$count = 0;
foreach ($recent['photos']['photo'] as $photo) {
    $photo_info = $f->photos_getInfo($photo["id"], $photo["secret"]);
    $body .= "<div class='tidypics_album_images'>";
    $body .= "{$photo_info['title']}<br />Views: {$photo_info['views']}<br />";
    $body .= "<a href={$photos_url}{$photo['id']}>";
    $body .= "<img border='0' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Square") . ">";
    $body .= "</a>";
Ejemplo n.º 9
0
function getMyRecent($userid = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
{
    global $photos;
    $f = new phpFlickr("6cb8b950ac1b34c2300dc789c8da52af");
    $photos = $f->people_getPublicPhotos($userid, $extras, $per_page, $page);
    //print_r($photos);
    //return $return;
    //print_r($return);
}
Ejemplo n.º 10
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $username = esc_attr($instance['username']);
        $api_key = esc_attr($instance['api_key']);
        $nos = esc_attr($instance['nos']);
        echo $before_widget;
        include HPATH . "/lib/phpFlickr.php";
        if ($title != "") {
            echo $before_title . " " . $title . $after_title;
        }
        if (!$api_key) {
            echo '<h4> No API KEY ADDED </h4>';
        } else {
            $f = new phpFlickr($api_key);
            $person = $f->people_findByUsername($username);
            $photos_url = $f->urls_getUserPhotos($person['id']);
            $photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, 16);
            ?>
        <div class="flickr-pictures clearfix">
        <?php 
            $i = 0;
            foreach ((array) $photos['photos']['photo'] as $photo) {
                if ($i >= $nos) {
                    break;
                }
                $theImageSrc = $f->buildPhotoURL($photo, "thumbnail");
                $lb = $f->buildPhotoURL($photo, "large");
                echo "<a href='" . $lb . "' class='lightbox' rel='prettyPhoto[pp_gal]' title='{$photo['title']}' ><img src='" . $theImageSrc . "' alt=\"" . $photos_url . $photo["id"] . "\" title='' /></a>";
                $i++;
            }
            ?>
        </div>



        <?php 
        }
        echo $after_widget;
    }
Ejemplo n.º 11
0
<?php

require_once "phpFlickr/phpFlickr.php";
$f = new phpFlickr("44449d9d74ed80abe095ab2a6f137dbe", "abde3a1309b8d8e1");
/*
$f->enableCache(
	"db",
	"mysql://[username]:[password]@[server]/[database]"
);
*/
$photos_url = $f->urls_getUserPhotos('28973605@N00');
$photos = $f->people_getPublicPhotos('28973605@N00', NULL, NULL, 11);
$sets = $f->photosets_getList('28973605@N00');
?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="./css/reset-min.css" type="text/css" media="screen" /> 
<link rel="stylesheet" href="./css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="./css/jquery.lightbox-0.5.css" type="text/css" media="screen" />
<title>上禾友</title>
<script type="text/javascript" src="./js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="./js/jquery.lightbox-0.5.min.js"></script>
<script type="text/javascript">
(function() {
	$(document).ready(function() {
		$('#gallery a').lightBox({fixedNavigation:true});
		$('.setBox a.more').click(function() {
			alert($(this).attr('set_id'));
			return false;
Ejemplo n.º 12
0
								<div class="entry-top">
								<a href="' . $urlimgori . '" title="' . $title . '" rel="lightbox">
								' . colabs_image('width=280&link=img&return=true&src=' . $urlimg) . '
								</a>
								</div>';
            echo '<h3 class="entry-title"><a href="' . $urlimgori . '" target="_blank">' . $title . '</a></h3>
									<p class="entry-likes"><i class="icon-heart "></i> <span>' . $likes . '</span> Loves</p>
								';
            echo '</div>
								</article>';
            $piccounter++;
        }
    }
} elseif (get_post_meta($post->ID, 'meta_style_gallery', true) == 'flickr') {
    $f = new phpFlickr(get_option('colabs_api_flickr'), get_option('colabs_secret_flickr'));
    $recent = $f->people_getPublicPhotos(get_post_meta($post->ID, 'colabs_username_flickr', true), NULL, NULL, get_post_meta($post->ID, 'colabs_piccount_flickr', true), $paged);
    foreach ($recent['photos']['photo'] as $photo) {
        $title = $photo['title'];
        $urlimg = $f->buildPhotoURL($photo, "small");
        $urlimgori = $f->buildPhotoURL($photo, "large");
        $info = $f->photos_getInfo($photo['id']);
        $date = date(get_option('date_format'), $info['photo']['dateuploaded']);
        $view = $info['photo']['views'];
        echo '<article class="entry-post">
								<div class="innercontainer">
								<div class="entry-top">
							<a href="' . $urlimgori . '" title="' . $title . '" rel="lightbox">
								' . colabs_image('width=280&link=img&return=true&src=' . $urlimg) . '
							</a>
							</div>
							<h3 class="entry-title"><a href="' . $urlimgori . '" target="_blank">' . $title . '</a></h3>
Ejemplo n.º 13
0
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 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">&larr;</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">&rarr;</span>', 'fjgwpp') . '</a>' . '</div>';
                    }
                    $ris .= '</div>';
                }
            }
        }
    }
    $shortcode_unique_id++;
    return $ris;
}
Ejemplo n.º 15
0
 */
$todo = $_REQUEST['todo'];
/************************************************************************************************/
/**
 * Show page with photos
 */
if ($todo == "show") {
    $page = $_REQUEST['page'] == "" ? 1 : $_REQUEST['page'];
    $viewsize = $_REQUEST['viewsize'] == "" ? "thumbnail" : $_REQUEST['viewsize'];
    require_once "phpFlickr.php";
    $f = new phpFlickr($api_key);
    $person = $f->people_findByUsername($username);
    // Get the friendly URL of the user's photos
    $photos_url = $f->urls_getUserPhotos($person['id']);
    // Get person's public photos
    $photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, 18, $page);
    // Loop through the photos and output the html
    //var_dump($f);
    echo '<center id="paging">';
    $paging = 1;
    while ($paging < $photos['photos']['pages'] + 1) {
        if ($paging == $page) {
            echo '<a class="active" href="javascript:getPage(' . $paging . ');">' . $paging . '</a>';
        } else {
            echo '<a class="link" href="javascript:getPage(' . $paging . ');">' . $paging . '</a>';
        }
        $paging++;
    }
    echo '</center>';
    echo '<table width="100%" cellspacing="0" cellpadding="5" border="0">';
    echo '<tr>';
Ejemplo n.º 16
0
$user = "******";
//Find the NSID of the username
$person = $f->people_findByUsername($user);
echo $person;
// Get the friendly URL of the user's photos (this is the one you can define, not the random numbers with the at sign in it
$photos_url = $f->urls_getUserPhotos($person['id']);
//set the number of photos per page
$photos_per_page = 16;
//set page if there is one, otherwise get the first page
if (0) {
    //$page = $_GET['page'];
} else {
    $page = 1;
}
// Get the user photos based on photos per page and page
$photos = $f->people_getPublicPhotos($person['id'], NULL, $photos_per_page, $page);
//loop photos and titles out
foreach ((array) $photos['photo'] as $photo) {
    //Now for an item.
    $photo_html .= '<div class="left"><a href="' . $photos_url . $photo[id] . '"><img border="0" alt="' . $photo[title] . '" src="' . $f->buildPhotoURL($photo, "square") . '" /></a><br /><p>' . $photo[title] . '</p></div>';
}
//work out HTML for pagination
for ($i = 1; $i < $photos['pages'] + 1; $i++) {
    if ($page != $i) {
        $pages_html .= '<a href="?page=' . $i . '">' . $i . '</a>&nbsp;';
    } else {
        $pages_html .= $i . '&nbsp;';
    }
}
//end the php code and build html return
?>
/**
* 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(']]>', ']]&gt;', $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;
}
Ejemplo n.º 18
0
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">&larr;</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">&rarr;</span>', 'flickr-photostream') . '</a>' . '</div>';
                    }
                    $ris .= '</div>';
                }
            }
        }
    }
    $shortcode_unique_id++;
    return $ris;
}
Ejemplo n.º 19
0
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $s_flickr_title = empty($instance['s_flickr_title']) ? '' : apply_filters('widget_s_flickr_title', $instance['s_flickr_title']);
     $s_flickr_choice = empty($instance['s_flickr_choice']) ? '14897087@N04' : apply_filters('widget_s_flickr_choice', $instance['s_flickr_choice']);
     $s_flickr_noi = empty($instance['s_flickr_noi']) ? 6 : apply_filters('widget_s_flickr_noi', $instance['s_flickr_noi']);
     $s_flickr_tou = empty($instance['s_flickr_tou']) ? 'user' : apply_filters('widget_s_flickr_tou', $instance['s_flickr_tou']);
     $loop_q = '';
     if ($s_flickr_tou == 'user' && vp_option('vpt_option.flickr_key') != '') {
         $flickr_key_opt = esc_attr(vp_option('vpt_option.flickr_key'));
         require_once locate_template('/inc/phpFlickr.php');
         $f = new phpFlickr($flickr_key_opt);
         $photos = $f->people_getPublicPhotos($s_flickr_choice, NULL, NULL, $s_flickr_noi);
         $loop_q = $photos['photos']['photo'];
     } else {
         if ($s_flickr_tou == 'all_tag' && vp_option('vpt_option.flickr_key') != '') {
             $flickr_key_opt = esc_attr(vp_option('vpt_option.flickr_key'));
             require_once locate_template('/inc/phpFlickr.php');
             $f = new phpFlickr($flickr_key_opt);
             $photos = $f->photos_search(array('tags' => $s_flickr_choice, 'tag_mode' => 'any', 'per_page' => $s_flickr_noi, 'sort' => 'relevance'));
             $loop_q = $photos['photo'];
         }
     }
     if ($s_flickr_title != '') {
         echo $before_title . $s_flickr_title . $after_title;
     }
     if (!empty($photos)) {
         $fancybox_uid = k_rnd_key(6);
         echo '<ul class="list-unstyled clear-margins">';
         foreach ($loop_q as $photo) {
             echo '<li><a href="' . $f->buildPhotoURL($photo, 'large') . '" title="' . $photo['title'] . '" class="swipebox" rel="flickrgal-' . $fancybox_uid . '"><img src="' . $f->buildPhotoURL($photo, 'square') . '" alt="' . $photo['title'] . '" /></a></li>';
         }
         echo '</ul>';
     } else {
         echo '<p>' . __('No photos matching given criteria.', 'kazaz') . '</p>';
     }
     echo $after_widget;
 }
Ejemplo n.º 20
0
function flickrbadge($params = array())
{
    $defaults = array('key' => false, 'username' => false, 'limit' => 10, 'format' => 'square', 'cache' => true, 'refresh' => 60 * 60 * 2);
    $options = array_merge($defaults, $params);
    // check the cache dir
    $cacheDir = c::get('root.cache') . '/flickrbadge';
    dir::make($cacheDir);
    // disable the cache if adding the cache dir failed
    if (!is_dir($cacheDir) || !is_writable($cacheDir)) {
        $options['cache'] = false;
    }
    if (!$options['key']) {
        return false;
    }
    if (!$options['username']) {
        return false;
    }
    $cacheID = 'flickrbadge/data.' . md5(serialize($options)) . '.php';
    if ($options['cache']) {
        $cache = cache::modified($cacheID) < time() - $options['refresh'] ? false : cache::get($cacheID);
    } else {
        $cache = false;
    }
    if (!empty($cache)) {
        return $cache;
    }
    $flickr = new phpFlickr($options['key']);
    $userCacheID = 'flickrbadge/user.' . md5($options['username']) . '.php';
    $userCache = $options['cache'] ? cache::get($userCacheID) : false;
    $user = false;
    $url = false;
    if (!empty($userCache)) {
        $user = a::get($userCache, 'user');
        $url = a::get($userCache, 'url');
    }
    if (!$user || !$url) {
        $user = $flickr->people_findByUsername($options['username']);
        $url = $flickr->urls_getUserPhotos($user['id']);
        if ($options['cache']) {
            cache::set($userCacheID, array('user' => $user, 'url' => $url));
        }
    }
    $photos = $flickr->people_getPublicPhotos($user['id'], NULL, NULL, $options['limit']);
    $result = array();
    foreach ($photos['photos']['photo'] as $photo) {
        $photoCacheID = 'flickrbadge/photo.' . $photo['id'] . '.php';
        $info = $options['cache'] ? cache::get($photoCacheID) : false;
        if (empty($info)) {
            $info = $flickr->photos_getInfo($photo['id']);
            if ($options['cache']) {
                cache::set($photoCacheID, $info);
            }
        }
        $info = a::get($info, 'photo', array());
        $dates = a::get($info, 'dates', array());
        $tags = array();
        foreach ((array) $info['tags']['tag'] as $t) {
            if (!empty($t['raw']) && !$t['machine_tag']) {
                $tags[] = $t['raw'];
            }
        }
        $result[] = new obj(array('url' => $url . $photo['id'], 'title' => a::get($info, 'title', $photo['title']), 'description' => @$info['description'], 'src' => $flickr->buildPhotoURL($photo, $options['format']), 'taken' => isset($dates['taken']) ? strtotime($dates['taken']) : false, 'posted' => isset($dates['posted']) ? $dates['posted'] : false, 'lastupdate' => isset($dates['lastupdate']) ? $dates['lastupdate'] : false, 'views' => a::get($info, 'views', 0), 'comments' => a::get($info, 'comments', 0), 'tags' => $tags));
    }
    $result = new obj($result);
    if ($options['cache']) {
        cache::set($cacheID, $result);
    }
    return $result;
}
Ejemplo n.º 21
0
<?php

require_once "phpFlickr.php";
$phpFlickrObj = new phpFlickr('665302ccbe82f5ae7aa2328d7ce4f886');
$user = $phpFlickrObj->people_findByUsername('codemastersnake');
$user_url = $phpFlickrObj->urls_getUserPhotos($user['id']);
$photos = $phpFlickrObj->people_getPublicPhotos($user['id'], NULL, NULL, 4);
foreach ($photos['photos']['photo'] as $photo) {
    echo '<a href="' . $user_url . $photo['id'] . '" title="' . $photo['title'] . ' (on Flickr)" target="_blank">';
    echo '<img style="border:1px solid" alt="' . $photo['title'] . '" src="' . $phpFlickrObj->buildPhotoURL($photo, "square") . '" />';
    echo '</a>';
}
Ejemplo n.º 22
0
 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;
     }
 }
<?php

$f = new phpFlickr(get_option('colabs_api_flickr'), get_option('colabs_secret_flickr'));
$recent = $f->people_getPublicPhotos(get_option('colabs_username_flickr'), NULL, NULL, get_option('colabs_piccount_flickr'), $paged);
foreach ($recent['photos']['photo'] as $photo) {
    $title = $photo['title'];
    $urlimg = $f->buildPhotoURL($photo, "small");
    $urlimgori = $f->buildPhotoURL($photo, "large");
    $info = $f->photos_getInfo($photo['id']);
    $date = date(get_option('date_format'), $info['photo']['dateuploaded']);
    $view = $info['photo']['views'];
    echo '<li class="gallery-item">
							<a href="' . $urlimgori . '" title="' . $title . '" rel="lightbox">
								' . colabs_image('width=280&link=img&return=true&src=' . $urlimg) . '
							</a>
							<div class="like">
								<p class="entry-likes">
									<span>' . $view . ' </span> 
									<i class="icon-heart"></i> 
								</p>
							</div>
							<div class="time">
								<p class="entry-time">
									<i class="icon-time"></i> 
									<span>' . $date . '</span> 
								</p>
							</div>
						  </li>';
}
Ejemplo n.º 24
0
 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);
 }
Ejemplo n.º 25
0
<?php

require_once "phpFlickr/phpFlickr.php";
$apiKey = "48792291a85b6bb9c45c7ba86372e720";
$apiSecret = "e519a126d6de492a";
// Create new phpFlickr object
$f = new phpFlickr($apiKey, $apiSecret);
$instList = array("8623220@N02", "24785917@N03", "83979593@N00", "25053835@N03", "26134435@N05", "7167652@N06", "26577438@N06", "26808453@N03", "11334970@N05", "29454428@N08", "30194653@N06", "25786829@N08", "29998366@N02", "30115723@N02", "32300107@N06", "32741315@N06", "32951986@N05", "30835311@N07", "32605636@N06", "31846825@N04", "34586311@N05", "34101160@N07", "34419668@N08", "36038586@N04", "35310696@N04", "37199428@N06");
echo print_r($instList);
$total = 0;
$instCount = 0;
foreach ($instList as $currentInst) {
    $instCount++;
    echo "<p>{$instCount}</p>";
    $instPhotos = $f->people_getPublicPhotos($currentInst);
    //echo print_r($instPhotos);
    $count = $instPhotos['photos']['total'];
    //echo '<p>'.$count.'</p>';
    $total = $total + $count;
}
echo "<p>TOTAL : {$total}</p>";
Ejemplo n.º 26
0
<?php

require_once "phpFlickr.php";
$f = new phpFlickr("cdebb75fb498222416d23dce91618f9a", "065215435996f0d9");
$photoset_id = "72157624682260557";
$secret = "065215435996f0d9";
$page = strip_tags($_GET["p"]);
//$photos = $f->photosets_getPhotos($photoset_id, null, null, 7, $page );
$photos = $f->people_getPublicPhotos('50369640@N04', null, null, 7, $page);
//function people_getPublicPhotos ($user_id, $safe_search = NULL, $extras = NULL, $per_page = NULL, $page = NULL)
// changed by b3d
$arr_photos = array($photos['photoset']['photo']);
foreach ($arr_photos as $photo) {
    //foreach ($photos['photoset']['photo'] as $photo) {
    // end b3d
    // Build image and link tags for each photo
    $photoInfo = $f->photos_getInfo($photo[id]);
    echo "<li><a href=http://www.flickr.com/photos/" . $photoInfo['owner']['username'] . "/{$photo['id']}>";
    echo "<img border='0' width='768' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "Large") . "><div class='metaContainer'><span>" . $photoInfo['title'] . "</span>";
    echo '
								</a>
								<div class="addthis_toolbox addthis_default_style shareBox">
								<a href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4cd4693368857545" class="addthis_button_compact">Share</a>
								<span class="addthis_separator">|</span>
									<a class="addthis_button_facebook"></a>
									<a class="addthis_button_twitter"></a>							
									<a class="addthis_button_bookmark"></a>
									<a class="addthis_button_print"></a>
								</div>
								<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cd4693368857545"></script>
							</div>
Ejemplo n.º 27
0
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $tit = empty($instance['tit']) ? '&nbsp;' : strip_tags(apply_filters('widget_tit', $instance['tit']));
        $count = empty($instance['count']) ? '8' : (int) $instance['count'];
        $cols = empty($instance['cols']) ? '4' : (int) $instance['cols'];
        $par3 = empty($instance['par3']) ? '' : $instance['par3'];
        if (empty($instance['username'])) {
        } else {
            ?>

<li class="cb4_flickr widget"><?php 
            if ($tit) {
                echo '<h3 class="tit">' . $tit . '</h3>';
            }
            ?>
 <?php 
            $username = sanitize_text_field($instance['username']);
            require_once "phpFlickr/phpFlickr.php";
            // Create new phpFlickr object
            $f = new phpFlickr("c9df4cb224dd88f2f63a2cf8ef77ed66");
            /*$f->enableCache(
             "db",
             "mysql://[username]:[password]@[server]/[database]"
             );
             */
            $i = 0;
            // Find the NSID of the username inputted via the form
            $person = $f->people_findByUsername($username);
            // Get the friendly URL of the user's photos
            $photos_url = $f->urls_getUserPhotos($person['id']);
            // Get the user's first $count public photos
            $photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, $count);
            //	$photos = $f->photos_search(array("user_id"=>$person['id'],"per_page"=>$count ));
            // Loop through the photos and output the html
            foreach ((array) $photos['photos']['photo'] as $photo) {
                $i++;
                if ($par3 == 'page') {
                    $link = 'href=' . $photos_url . $photo['id'] . ' target="_blank"';
                } else {
                    $link = 'href="' . $f->buildPhotoURL($photo, "large") . '"  data-rel=pp[flickr]';
                }
                if ($i % $cols == 0) {
                    echo "<div class=\"col{$cols} fade\" style=\"margin-right:0;\"><div class=\"fade_c\"><a " . $link . " class=\"flickr_a\"><i class=\"icon-search\"></i></a></div>";
                } else {
                    echo "<div class=\"col{$cols} fade \"><div class=\"fade_c\"><a " . $link . " class=\"flickr_a\"><i class=\"icon-search\"></i></a></div>";
                }
                if ($cols > 2) {
                    echo "<img alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "thumbnail") . ">";
                } else {
                    echo "<img border='0' alt='{$photo['title']}' " . "src=" . $f->buildPhotoURL($photo, "") . ">";
                }
                echo "</div>";
                // If it reaches the $cols photo, insert a line break
                if ($i % $cols == 0) {
                    if ($cols != 1) {
                        echo "<div class=\"cl\"></div>";
                    }
                }
            }
            ?>
<div class="cl"></div></li>
<?php 
        }
    }