/** * Build a gallery output * * @access internal * @param array $picturelist * @param bool $galleryID, if you supply a gallery ID, you can add a slideshow link * @param string $template (optional) name for a template file, look for gallery-$template * @return the content */ function nggCreateGallery($picturelist, $galleryID = false, $template = '') { global $nggRewrite; $ngg_options = nggGallery::get_option('ngg_options'); // $_GET from wp_query $nggpage = get_query_var('nggpage'); $pageid = get_query_var('pageid'); if (!is_array($picturelist)) { $picturelist = array($picturelist); } $gallery = new stdclass(); $gallery->ID = (int) $galleryID; $gallery->show_slideshow = false; $maxElement = $ngg_options['galImages']; $thumbwidth = $ngg_options['thumbwidth']; $thumbheight = $ngg_options['thumbheight']; // set thumb size $thumbsize = ''; if ($ngg_options['thumbfix']) { $thumbsize = 'width="' . $thumbwidth . '" height="' . $thumbheight . '"'; } if ($ngg_options['thumbcrop']) { $thumbsize = 'width="' . $thumbwidth . '" height="' . $thumbwidth . '"'; } // show slideshow link if ($galleryID) { if ($ngg_options['galShowSlide'] and NGGALLERY_IREXIST) { $gallery->show_slideshow = true; $gallery->slideshow_link = $nggRewrite->get_permalink(array('show' => "slide")); $gallery->slideshow_link_text = $ngg_options['galTextSlide']; } if ($ngg_options['usePicLens']) { $gallery->show_piclens = true; $gallery->piclens_link = "javascript:PicLensLite.start({feedUrl:'" . htmlspecialchars(nggMediaRss::get_gallery_mrss_url($gallery->ID)) . "'});"; } } // check for page navigation if ($maxElement > 0) { if (!is_home() || $pageid == get_the_ID()) { if (!empty($nggpage)) { $page = (int) $nggpage; } else { $page = 1; } } else { $page = 1; } $start = $offset = ($page - 1) * $maxElement; $total = count($picturelist); // remove the element if we didn't start at the beginning if ($start > 0) { array_splice($picturelist, 0, $start); } // return the list of images we need array_splice($picturelist, $maxElement); $navigation = nggGallery::create_navigation($page, $total, $maxElement); } else { $navigation = '<div class="ngg-clear"> </div>'; } //var_dump($picturelist); foreach ($picturelist as $key => $picture) { // choose link between imagebrowser or effect $link = $ngg_options['galImgBrowser'] ? $nggRewrite->get_permalink(array('pid' => $picture->pid)) : $picture->imageURL; // get the effect code if ($galleryID) { $thumbcode = $ngg_options['galImgBrowser'] ? '' : $picture->get_thumbcode($picturelist[0]->name); } else { $thumbcode = $ngg_options['galImgBrowser'] ? '' : $picture->get_thumbcode(get_the_title()); } // add a filter for the link $picturelist[$key]->imageURL = apply_filters('ngg_create_gallery_link', $link, $picture); $picturelist[$key]->thumbnailURL = $picture->thumbURL; $picturelist[$key]->size = $thumbsize; $picturelist[$key]->thumbcode = $thumbcode; $picturelist[$key]->description = empty($picture->description) ? ' ' : stripslashes($picture->description); $picturelist[$key]->alttext = empty($picture->alttext) ? ' ' : stripslashes($picture->alttext); } // look for gallery-$template.php or pure gallery.php $filename = empty($template) ? 'gallery' : 'gallery-' . $template; // create the output $out = nggGallery::capture($filename, array('gallery' => $gallery, 'images' => $picturelist, 'pagination' => $navigation)); // apply a filter after the output $out = apply_filters('ngg_gallery_output', $out, $picturelist); return $out; }