/**
 * Copyright (c) 2011, cheshirewebsolutions.com, Ian Kennerley (info@cheshirewebsolutions.com).
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
function cws_flickr_shortcode_photoset($atts)
{
    $options = get_option('cws_flickr_options');
    // Create instance of CWS_FlickrApi class
    $my_photo_set = new CWS_FlickrApi();
    return $photoset = $my_photo_set->get_photo_set_display($atts['photoset_id']);
}
 function widget($args, $instance)
 {
     global $key;
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $photoset_id = apply_filters('widget_title', $instance['photo_set_id']);
     $show_photoset_ttl = apply_filters('widget_title', $instance['show_photoset_ttl']);
     if (!isset($title)) {
         $title = "'Flickr Slideshow";
     }
     echo $args['before_widget'];
     echo $args['before_title'] . "<span>{$title}</span>" . $args['after_title'];
     // Create instance of FlickrAPI class
     if ($my_flickr = new CWS_FlickrApi()) {
         $options = get_option('cws_flickr_options');
         $my_slider = $my_flickr->get_slider_display($photoset_id, $size, $show_photoset_ttl);
         echo $my_slider;
         echo $args['after_widget'];
     }
     if (is_active_widget(false, false, $this->id_base, true)) {
         // Enqueue Flexslider Files
         wp_enqueue_style('flex-style', WPFLICKR_PLUGIN_URL . 'inc/slider/css/flexslider.css');
         wp_enqueue_script('flex-script', WPFLICKR_PLUGIN_URL . 'inc/slider/js/jquery.flexslider-min.js', array('jquery'), false, true);
         wp_enqueue_script('flex-init', WPFLICKR_PLUGIN_URL . 'inc/slider/js/flexslider-init.js', array('flex-script'), false, true);
     }
 }
/**
 * Copyright (c) 2011, cheshirewebsolutions.com, Ian Kennerley (info@cheshirewebsolutions.com).
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
function cws_flickr_shortcode_recent($atts)
{
    // Allowed Sizes...
    $allowed_sizes = array('Square', 'Large Square', 'Thumbnail', 'Small', 'Small 320', 'Medium', 'Medium 640', 'Medium 800', 'Large', 'Large 1600', 'Large 2048');
    // Get any specific image size if shortcode has passed any
    if (isset($atts['size'])) {
        $size = 'Square';
        if (in_array($atts['size'], $allowed_sizes)) {
            $size = $atts['size'];
        }
    }
    $options = get_option('cws_flickr_options');
    // Create instance of CWS_FlickrApi class
    $my_flickr = new CWS_FlickrApi();
    // Call recent_images
    return $recent_images = $my_flickr->get_recent_images_display($size);
}
 function widget($args, $instance)
 {
     global $key;
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $photoset_id = apply_filters('widget_title', $instance['photo_set_id']);
     $show_photoset_ttl = apply_filters('widget_title', $instance['show_photoset_ttl']);
     if (!isset($title)) {
         $title = "'Flickr Random Photo";
     }
     echo $args['before_widget'];
     echo $args['before_title'] . "<span>{$title}</span>" . $args['after_title'];
     // Create instance of FlickrAPI class
     if ($my_flickr = new CWS_FlickrApi()) {
         $options = get_option('cws_flickr_options');
         // Call user albums
         if (isset($photoset_id) && $photoset_id != '') {
             $my_photo_random = $my_flickr->get_photo_random_display($photoset_id, $size, $show_photoset_ttl);
         }
         echo $my_photo_random;
         echo $args['after_widget'];
     }
 }
/**
 * Copyright (c) 2011, cheshirewebsolutions.com, Ian Kennerley (info@cheshirewebsolutions.com).
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
function cws_flickr_shortcode_photoset_strips($atts)
{
    // Create instance of CWS_FlickrApi class
    $my_photo_set = new CWS_FlickrApi();
    return $photostrip = $my_photo_set->get_photo_strip_display($atts['photoset_id'], 'url_sq');
}