/** * 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; }
function show_imagebrowser($atts) { global $wpdb; extract(shortcode_atts(array('id' => 0, 'template' => ''), $atts)); $out = nggShowImageBrowser($id, $template); return $out; }
/** * 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; }
<?php require_once 'ngg-config.php'; // check if we have all needed parameter if (!isset($_GET['galleryid']) || !is_numeric($_GET['galleryid']) || (!isset($_GET['p']) || !is_numeric($_GET['p'])) || !isset($_GET['type'])) { die('Insufficient parameters.'); } switch ($_GET['type']) { case 'gallery': // get the navigation page set_query_var('nggpage', intval($_GET['nggpage'])); // get the current page/post id set_query_var('pageid', intval($_GET['p'])); set_query_var('show', 'gallery'); $GLOBALS['id'] = intval($_GET['p']); echo nggShowGallery(intval($_GET['galleryid'])); break; case 'browser': // which image should be shown ? set_query_var('pid', intval($_GET['pid'])); // get the current page/post id set_query_var('pageid', intval($_GET['p'])); $GLOBALS['id'] = intval($_GET['p']); echo nggShowImageBrowser(intval($_GET['galleryid'])); break; default: echo 'Wrong request type specified.'; }