当前位置: 首页>>代码示例>>PHP>>正文


PHP nggdb::get_random_images方法代码示例

本文整理汇总了PHP中nggdb::get_random_images方法的典型用法代码示例。如果您正苦于以下问题:PHP nggdb::get_random_images方法的具体用法?PHP nggdb::get_random_images怎么用?PHP nggdb::get_random_images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nggdb的用法示例。


在下文中一共展示了nggdb::get_random_images方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nggShowRandomRecent

/**
 * 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;
}
开发者ID:popovdenis,项目名称:kmst,代码行数:51,代码来源:nggfunctions.php

示例2: header

<?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
开发者ID:pravinhirmukhe,项目名称:flow1,代码行数:31,代码来源:foto.php


注:本文中的nggdb::get_random_images方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。