Пример #1
0
/**
 * nggShowImageBrowser()
 *
 * @access public
 * @param int|string $galleryID or gallery name
 * @param string $template (optional) name for a template file, look for imagebrowser-$template
 * @return the content
 */
function nggShowImageBrowser($galleryID, $template = '')
{
    global $wpdb;
    $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 the pictures
    $picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
    if (is_array($picturelist)) {
        $out = nggCreateImageBrowser($picturelist, $template);
    } else {
        $out = __('[Gallery not found]', 'nggallery');
    }
    $out = apply_filters('ngg_show_imagebrowser_content', $out, $galleryID);
    return $out;
}
Пример #2
0
/**
 * 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;
}
Пример #3
0
/**
 * nggShowGalleryTags() - create a gallery based on the tags
 * 
 * @access public 
 * @param string $taglist list of tags as csv
 * @return the content
 */
function nggShowGalleryTags($taglist)
{
    // $_GET from wp_query
    $pid = get_query_var('pid');
    $pageid = get_query_var('pageid');
    // get now the related images
    $picturelist = nggTags::find_images_for_tags($taglist, 'ASC');
    // look for ImageBrowser if we have a $_GET('pid')
    if ($pageid == get_the_ID() || !is_home()) {
        if (!empty($pid)) {
            foreach ($picturelist as $picture) {
                $picarray[] = $picture->pid;
            }
            $out = nggCreateImageBrowser($picarray);
            return $out;
        }
    }
    // go on if not empty
    if (empty($picturelist)) {
        return;
    }
    // show gallery
    if (is_array($picturelist)) {
        $out = nggCreateGallery($picturelist, false);
    }
    $out = apply_filters('ngg_show_gallery_tags_content', $out, $taglist);
    return $out;
}
 /**
  * nggShowGalleryTags() - create a gallery based on the tags
  * copyright (c) Photocrati Media 2012, modified to permit a template specification
  * @param string $taglist list of tags as csv
  * @param string $template the template to use, if any
  * @param int $images how many images per page, defaults to all
  * @return string
  */
 protected static function nggShowGalleryTags($taglist, $template, $images = false)
 {
     // $_GET from wp_query
     $pid = get_query_var('pid');
     $pageid = get_query_var('pageid');
     // record taglist and set filter to override gallery title with taglist
     self::$taglist = $taglist;
     add_filter('ngg_gallery_object', array(__CLASS__, 'nggGalleryObjectTagged'));
     // NextGEN Gallery 2 can show gallery of tags with template
     if (defined('NEXTGEN_GALLERY_PLUGIN_VERSION')) {
         $params = array('display_type' => 'photocrati-nextgen_basic_thumbnails', 'tag_ids' => $taglist, 'template' => $template);
         $registry = C_Component_Registry::get_instance();
         $renderer = $registry->get_utility('I_Displayed_Gallery_Renderer');
         $out = $renderer->display_images($params);
     } else {
         // get the related images
         $picturelist = nggTags::find_images_for_tags($taglist, 'ASC');
         // look for ImageBrowser if we have a $_GET('pid')
         if ($pageid == get_the_ID() || !is_home()) {
             if (!empty($pid)) {
                 $out = nggCreateImageBrowser($picturelist, $template);
                 return $out;
             }
         }
         // nothing to see, move along...
         if (empty($picturelist)) {
             return;
         }
         // show gallery
         if (is_array($picturelist)) {
             // process gallery using selected template
             $out = nggCreateGallery($picturelist, false, $template, $images);
         }
     }
     // remove filter for gallery title
     remove_filter('ngg_gallery_object', array(__CLASS__, 'nggGalleryObjectTagged'));
     $out = apply_filters('ngg_show_gallery_tags_content', $out, $taglist);
     return $out;
 }