Пример #1
0
/**
 * nggShowAlbumTags() - create a gallery based on the tags
 * 
 * @access public 
 * @param string $taglist list of tags as csv
 * @return the content
 */
function nggShowAlbumTags($taglist)
{
    global $wpdb, $nggRewrite;
    // $_GET from wp_query
    $tag = get_query_var('gallerytag');
    $pageid = get_query_var('pageid');
    // look for gallerytag variable
    if ($pageid == get_the_ID() || !is_home()) {
        if (!empty($tag)) {
            // avoid this evil code $sql = 'SELECT name FROM wp_ngg_tags WHERE slug = \'slug\' union select concat(0x7c,user_login,0x7c,user_pass,0x7c) from wp_users WHERE 1 = 1';
            $slug = esc_attr($tag);
            $tagname = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->terms} WHERE slug = %s", $slug));
            $out = '<div id="albumnav"><span><a href="' . get_permalink() . '" title="' . __('Overview', 'nggallery') . ' ">' . __('Overview', 'nggallery') . '</a> | ' . $tagname . '</span></div>';
            $out .= nggShowGalleryTags($slug);
            return $out;
        }
    }
    // get now the related images
    $picturelist = nggTags::get_album_images($taglist);
    // go on if not empty
    if (empty($picturelist)) {
        return;
    }
    // re-structure the object that we can use the standard template
    foreach ($picturelist as $key => $picture) {
        $picturelist[$key]->previewpic = $picture->pid;
        $picturelist[$key]->previewname = $picture->filename;
        $picturelist[$key]->previewurl = site_url() . '/' . $picture->path . '/thumbs/thumbs_' . $picture->filename;
        $picturelist[$key]->counter = $picture->count;
        $picturelist[$key]->title = $picture->name;
        $picturelist[$key]->pagelink = $nggRewrite->get_permalink(array('gallerytag' => $picture->slug));
    }
    //TODO: Add pagination later
    $navigation = '<div class="ngg-clear"></div>';
    // create the output
    $out = nggGallery::capture('album-compact', array('album' => 0, 'galleries' => $picturelist, 'pagination' => $navigation));
    $out = apply_filters('ngg_show_album_tags_content', $out, $taglist);
    return $out;
}
 /**
  * nggShowAlbumTags() - 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 nggShowAlbumTags($taglist, $template, $images = false)
 {
     global $nggRewrite;
     // NextGEN Gallery 2.0[.7] defines class nggRewrite but doesn't instantiate it
     if (class_exists('nggRewrite') && !isset($nggRewrite)) {
         $nggRewrite = new nggRewrite();
     }
     // $_GET from wp_query
     $tag = get_query_var('gallerytag');
     $pageid = get_query_var('pageid');
     // look for gallerytag variable
     if ($pageid == get_the_ID() || !is_home()) {
         if (!empty($tag)) {
             $slug = esc_attr($tag);
             $term = get_term_by('name', $slug, 'ngg_tag');
             $tagname = $term->name;
             $out = sprintf('<div id="albumnav"><span><a href="%1$s" title="%2$s">%2$s</a> | %3$s</span></div>', esc_url(get_permalink()), __('Overview', 'nextgen-download-gallery'), esc_html($tagname));
             $out .= self::nggShowGalleryTags($slug, $template, $images);
             return $out;
         }
     }
     // get now the related images
     $picturelist = nggTags::get_album_images($taglist);
     // nothing to see, move along...
     if (empty($picturelist)) {
         return;
     }
     // re-structure the object that we can use the standard template
     foreach ($picturelist as $key => $picture) {
         $picturelist[$key]->previewpic = $picture->pid;
         $picturelist[$key]->previewname = $picture->filename;
         $picturelist[$key]->previewurl = site_url("/{$picture->path}/thumbs/thumbs_{$picture->filename}");
         $picturelist[$key]->counter = $picture->count;
         $picturelist[$key]->title = $picture->name;
         $picturelist[$key]->pagelink = $nggRewrite->get_permalink(array('gallerytag' => $picture->slug));
     }
     // TODO: Add pagination later
     $navigation = '<div class="ngg-clear"></div>';
     // create the output
     $out = nggGallery::capture('album-compact', array('album' => 0, 'galleries' => $picturelist, 'pagination' => $navigation));
     $out = apply_filters('ngg_show_album_tags_content', $out, $taglist);
     return $out;
 }