/** * nggShowRandomRecent($type, $maxImages, $template, $galleryId) - return recent or random images * * @access public * @param string $type 'id' (for latest addition to DB), 'date' (for image with the latest date), 'sort' (for image sorted by user order) or 'random' * @param integer $maxImages of images * @param string $template (optional) name for a template file, look for gallery-$template * @param int $galleryId Limit to a specific gallery * @return the content */ function nggShowRandomRecent($type, $maxImages, $template = '', $galleryId = 0) { // $_GET from wp_query $pid = get_query_var('pid'); $pageid = get_query_var('pageid'); // get now the recent or random images switch ($type) { case 'random': $picturelist = nggdb::get_random_images($maxImages, $galleryId); break; case 'id': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'id'); break; case 'date': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'date'); break; case 'sort': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'sort'); break; default: // default is by pid $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'id'); } // look for ImageBrowser if we have a $_GET('pid') if ($pageid == get_the_ID() || !is_home()) { if (!empty($pid)) { $out = nggCreateImageBrowser($picturelist); return $out; } } // go on if not empty if (empty($picturelist)) { return; } // show gallery if (is_array($picturelist)) { $out = nggCreateGallery($picturelist, false, $template); } $out = apply_filters('ngg_show_images_content', $out, $picturelist); return $out; }
<?php require_once './wp-content/plugins/nextgen-gallery/ngg-config.php'; require_once './inc/php/cfg.php'; if (!empty($_GET['pid'])) { $foto = nggdb::find_image($_GET['pid']); if (empty($foto) or $foto->exclude == 1) { $fotos = nggdb::get_random_images(); $foto = $fotos[0]; } $tags = wp_get_object_terms($_GET['pid'], 'ngg_tag'); } else { if ($_SESSION['last_pid'] > 0) { $pid = mt_rand(1, $_SESSION['last_pid']); header("Location: /foto/{$pid}.html"); } else { header('Location: /'); } } $foto_url = str_replace($cfg['trueurl'], $cfg['baseurl'], $foto->imageURL); //输出页头keywords if (!empty($tags)) { $key_arr = array(); foreach ($tags as $tag) { $key_arr[] = $tag->slug; $keywords = implode(',', $key_arr); } } else { $keywords = $cfg['keywords']; } //输出keywords