Ejemplo n.º 1
0
 /**
  * get_constructor_slideshow
  *
  * @access  public
  * @param   boolean  $in In or Out of content container
  * @return  rettype  return
  */
 function getSlideshow($in = false)
 {
     if (!$this->_options['slideshow']['flag']) {
         return false;
     }
     if (is_page() && !$this->_options['slideshow']['onpage']) {
         return false;
     }
     if (is_single() && !$this->_options['slideshow']['onsingle']) {
         return false;
     }
     if (is_archive() && !$this->_options['slideshow']['onarchive']) {
         return false;
     }
     if ($in && $this->_options['slideshow']['layout'] == 'over') {
         return false;
     }
     if (!$in && $this->_options['slideshow']['layout'] == 'in') {
         return false;
     }
     $size = $this->getSlideshowSize();
     echo '<div id="slideshow" style="height:' . $size['height'] . 'px;width:' . $size['width'] . 'px">';
     // switch statement for true
     switch (true) {
         case isset($this->_options['slideshow']['id']) && $this->_options['slideshow']['id'] != '' && function_exists('nggShowSlideshow'):
             echo nggShowSlideshow((int) $this->_options['slideshow']['id'], $size['width'], $size['height']);
             break;
         default:
             $this->getDefaultSlideshow($size['width'], $size['height']);
             break;
     }
     echo '</div>';
 }
Ejemplo n.º 2
0
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args Widget arguments.
  * @param array $instance Saved values from the database.
  */
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', empty($instance['title']) ? __('Slideshow', 'nggallery') : $instance['title'], $instance, $this->id_base);
     try {
         $out = nggShowSlideshow($instance['galleryid'], $instance);
     } catch (NGG_Not_Found $e) {
         $out = $e->getMessage();
     }
     if (!empty($out)) {
         echo $args['before_widget'];
         if ($title) {
             echo $args['before_title'] . $title . $args['after_title'];
         }
         echo '<div class="ngg_slideshow widget">' . $out . '</div>';
         echo $args['after_widget'];
     }
 }
Ejemplo n.º 3
0
/**
 * nggShowGallery() - return a gallery  
 * 
 * @access public 
 * @param int | string ID or slug from a gallery
 * @param string $template (optional) name for a template file, look for gallery-$template
 * @param int $images (optional) number of images per page
 * @return the content
 */
function nggShowGallery($galleryID, $template = '', $images = false)
{
    global $nggRewrite;
    $ngg_options = nggGallery::get_option('ngg_options');
    //Set sort order value, if not used (upgrade issue)
    $ngg_options['galSort'] = $ngg_options['galSort'] ? $ngg_options['galSort'] : 'pid';
    $ngg_options['galSortDir'] = $ngg_options['galSortDir'] == 'DESC' ? 'DESC' : 'ASC';
    // get gallery values
    //TODO: Use pagination limits here to reduce memory needs
    $picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
    if (!$picturelist) {
        return __('[Gallery not found]', 'nggallery');
    }
    // If we have we slug instead the id, we should extract the ID from the first image
    if (!is_numeric($galleryID)) {
        $first_image = current($picturelist);
        $galleryID = intval($first_image->gid);
    }
    // $_GET from wp_query
    $show = get_query_var('show');
    $pid = get_query_var('pid');
    $pageid = get_query_var('pageid');
    // set $show if slideshow first
    if (empty($show) and $ngg_options['galShowOrder'] == 'slide') {
        if (is_home()) {
            $pageid = get_the_ID();
        }
        $show = 'slide';
    }
    // filter to call up the imagebrowser instead of the gallery
    // use in your theme : add_action( 'ngg_show_imagebrowser_first', create_function('', 'return true;') );
    if (apply_filters('ngg_show_imagebrowser_first', false, $galleryID) && $show != 'thumbnails') {
        $out = nggShowImageBrowser($galleryID, $template);
        return $out;
    }
    // go on only on this page
    if (!is_home() || $pageid == get_the_ID()) {
        // 1st look for ImageBrowser link
        if (!empty($pid) && $ngg_options['galImgBrowser'] && $template != 'carousel') {
            $out = nggShowImageBrowser($galleryID, $template);
            return $out;
        }
        // 2nd look for slideshow
        if ($show == 'slide') {
            $args['show'] = "gallery";
            $out = '<div class="ngg-galleryoverview">';
            $out .= '<div class="slideshowlink"><a class="slideshowlink" href="' . $nggRewrite->get_permalink($args) . '">' . nggGallery::i18n($ngg_options['galTextGallery']) . '</a></div>';
            $out .= nggShowSlideshow($galleryID, $ngg_options['irWidth'], $ngg_options['irHeight']);
            $out .= '</div>' . "\n";
            $out .= '<div class="ngg-clear"></div>' . "\n";
            return $out;
        }
    }
    // get all picture with this galleryid
    if (is_array($picturelist)) {
        $out = nggCreateGallery($picturelist, $galleryID, $template, $images);
    }
    $out = apply_filters('ngg_show_gallery_content', $out, intval($galleryID));
    return $out;
}
Ejemplo n.º 4
0
/**
 * nggShowGallery() - return a gallery  
 * 
 * @access public 
 * @param int $galleryID
 * @param string $template (optional) name for a template file, look for gallery-$template
 * @param int $images (optional) number of images per page
 * @return the content
 */
function nggShowGallery($galleryID, $template = '', $images = false)
{
    global $nggRewrite;
    $ngg_options = nggGallery::get_option('ngg_options');
    $galleryID = (int) $galleryID;
    //Set sort order value, if not used (upgrade issue)
    $ngg_options['galSort'] = $ngg_options['galSort'] ? $ngg_options['galSort'] : 'pid';
    $ngg_options['galSortDir'] = $ngg_options['galSortDir'] == 'DESC' ? 'DESC' : 'ASC';
    // get gallery values
    $picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
    if (!$picturelist) {
        return __('[Gallery not found]', 'nggallery');
    }
    // $_GET from wp_query
    $show = get_query_var('show');
    $pid = get_query_var('pid');
    $pageid = get_query_var('pageid');
    // set $show if slideshow first
    if (empty($show) and $ngg_options['galShowOrder'] == 'slide') {
        if (is_home()) {
            $pageid = get_the_ID();
        }
        $show = 'slide';
    }
    // go on only on this page
    if (!is_home() || $pageid == get_the_ID()) {
        // 1st look for ImageBrowser link
        if (!empty($pid) && $ngg_options['galImgBrowser'] && $template != 'carousel') {
            $out = nggShowImageBrowser($galleryID, $template);
            return $out;
        }
        // 2nd look for slideshow
        if ($show == 'slide') {
            $args['show'] = "gallery";
            $out = '<div class="ngg-galleryoverview">';
            $out .= '<div class="slideshowlink"><a class="slideshowlink" href="' . $nggRewrite->get_permalink($args) . '">' . nggGallery::i18n($ngg_options['galTextGallery']) . '</a></div>';
            $out .= nggShowSlideshow($galleryID, $ngg_options['irWidth'], $ngg_options['irHeight']);
            $out .= '</div>' . "\n";
            $out .= '<div class="ngg-clear"></div>' . "\n";
            return $out;
        }
    }
    // get all picture with this galleryid
    if (is_array($picturelist)) {
        $out = nggCreateGallery($picturelist, $galleryID, $template, $images);
    }
    $out = apply_filters('ngg_show_gallery_content', $out, intval($galleryID));
    return $out;
}
Ejemplo n.º 5
0
 function show_slideshow($atts)
 {
     global $wpdb;
     extract(shortcode_atts(array('id' => 0, 'w' => '', 'h' => ''), $atts));
     if (!is_numeric($id)) {
         $id = $wpdb->get_var($wpdb->prepare("SELECT gid FROM {$wpdb->nggallery} WHERE name = '%s' ", $id));
     }
     if (!empty($id)) {
         $out = nggShowSlideshow($id, $w, $h);
     } else {
         $out = __('[Gallery not found]', 'nggallery');
     }
     return $out;
 }
Ejemplo n.º 6
0
 function show_slideshow($atts)
 {
     global $wpdb;
     extract(shortcode_atts(array('id' => 0, 'w' => '', 'h' => ''), $atts));
     $galleryID = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE gid = '{$id}' ");
     if (!$galleryID) {
         $galleryID = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE name = '{$id}' ");
     }
     if ($galleryID) {
         $out = nggShowSlideshow($galleryID, $w, $h);
     } else {
         $out = __('[Gallery not found]', 'nggallery');
     }
     return $out;
 }
Ejemplo n.º 7
0
 /**
  * Render a slideshow.
  *
  * @since 1.9.25 Don't use extract anymore. @see https://core.trac.wordpress.org/ticket/22400
  * @param $atts array The shortcode attributes.
  *
  * @return string The output that will be displayed on the page.
  */
 function show_slideshow($atts)
 {
     $data = shortcode_atts(array('id' => 'random', 'w' => null, 'h' => null, 'dots' => null), $atts);
     array_map('esc_attr', $data);
     if (isset($data['w']) || isset($data['h'])) {
         $data['autodim'] = false;
         $data['width'] = $data['w'];
         $data['height'] = $data['h'];
     } else {
         unset($data['w'], $data['h']);
     }
     if ($data['dots'] == null) {
         unset($data['dots']);
     } else {
         $data['nav_dots'] = $data['dots'];
     }
     try {
         return nggShowSlideshow($data['id'], $data);
     } catch (NGG_Not_Found $e) {
         return $e->getMessage();
     }
 }