예제 #1
0
/**
 * nggShowAlbum() - return a album based on the id
 * 
 * @access public 
 * @param int | string $albumID
 * @param string (optional) $template
 * @param string (optional) $gallery_template
 * @return the content
 */
function nggShowAlbum($albumID, $template = 'extend', $gallery_template = '')
{
    // $_GET from wp_query
    $gallery = get_query_var('gallery');
    $album = get_query_var('album');
    // in the case somebody uses the '0', it should be 'all' to show all galleries
    $albumID = $albumID == 0 ? 'all' : $albumID;
    // first look for gallery variable
    if (!empty($gallery)) {
        // subalbum support only one instance, you can't use more of them in one post
        //TODO: causes problems with SFC plugin, due to a second filter callback
        if (isset($GLOBALS['subalbum']) || isset($GLOBALS['nggShowGallery'])) {
            return;
        }
        // if gallery is submit , then show the gallery instead
        $out = nggShowGallery($gallery, $gallery_template);
        $GLOBALS['nggShowGallery'] = true;
        return $out;
    }
    if (empty($gallery) && isset($GLOBALS['subalbum'])) {
        return;
    }
    //redirect to subalbum only one time
    if (!empty($album)) {
        $GLOBALS['subalbum'] = true;
        $albumID = $album;
    }
    // lookup in the database
    $album = nggdb::find_album($albumID);
    // still no success ? , die !
    if (!$album) {
        return __('[Album not found]', 'nggallery');
    }
    // ensure to set the slug for "all" albums
    $album->slug = $albumID == 'all' ? $album->id : $album->slug;
    if (is_array($album->gallery_ids)) {
        $out = nggCreateAlbum($album->gallery_ids, $template, $album);
    }
    $out = apply_filters('ngg_show_album_content', $out, $album->id);
    return $out;
}
예제 #2
0
/**
 * nggShowAlbum() - return a album based on the id
 * 
 * @access public 
 * @param int | string $albumID
 * @param string (optional) $template
 * @return the content
 */
function nggShowAlbum($albumID, $template = 'extend')
{
    // $_GET from wp_query
    $gallery = get_query_var('gallery');
    $album = get_query_var('album');
    // in the case somebody uses the 'all' keyword, it should be '0' to show all galleries
    $albumID = $albumID == 'all' ? 0 : $albumID;
    // first look for gallery variable
    if (!empty($gallery)) {
        if ($albumID != $album && $albumID != 0) {
            return;
        }
        // if gallery is is submit , then show the gallery instead
        $galleryID = (int) $gallery;
        $out = nggShowGallery($galleryID);
        return $out;
    }
    // lookup in the database
    $album = nggdb::find_album($albumID);
    // still no success ? , die !
    if (!$album) {
        return __('[Album not found]', 'nggallery');
    }
    $mode = ltrim($mode, ',');
    if (is_array($album->gallery_ids)) {
        $out = nggCreateAlbum($album->gallery_ids, $template, $album);
    }
    $out = apply_filters('ngg_show_album_content', $out, intval($album->id));
    return $out;
}