예제 #1
0
 function getData($number)
 {
     global $wpdb;
     $data = array();
     $pictures = $wpdb->get_results("SELECT a.*, b.path FROM " . $wpdb->base_prefix . "ngg_pictures AS a LEFT JOIN " . $wpdb->base_prefix . "ngg_gallery AS b ON a.galleryid = b.gid WHERE a.galleryid = '" . intval($this->_data->get('nggsourcegallery', 0)) . "'");
     $i = 0;
     if (class_exists('nggGallery') && !class_exists('C_Component_Registry')) {
         // legacy
         foreach ($pictures as $p) {
             $data[$i]['alt_text'] = $p->alttext;
             $data[$i]['image'] = nggGallery::get_image_url($p->pid, $p->path, $p->filename);
             $data[$i]['thumbnail'] = nggGallery::get_thumbnail_url($p->pid, $p->path, $p->filename);
             $i++;
         }
     } else {
         $storage = C_Component_Registry::get_instance()->get_utility('I_Gallery_Storage');
         foreach ($pictures as $p) {
             $data[$i]['alt_text'] = $p->alttext;
             $data[$i]['image'] = $storage->get_image_url($p);
             $data[$i]['thumbnail'] = $storage->get_thumbnail_url($p);
             $i++;
         }
     }
     return $data;
 }
function oo_get_first_gallery_image($galleryid, $class = '')
{
    global $wpdb;
    global $ngg_options;
    if (!$galleryid) {
        return;
    }
    if (!$wpdb->nggallery) {
        return;
    }
    if (!$ngg_options) {
        $ngg_options = get_option('ngg_options');
    }
    $picturelist = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE t.gid = '{$galleryid}' AND tt.exclude != 1 ORDER BY tt.{$ngg_options['galSort']} {$ngg_options['galSortDir']} LIMIT 1");
    if ($class) {
        $myclass = ' class="' . $class . '" ';
    }
    if ($picturelist) {
        $pid = $picturelist[0]->pid;
        if (is_callable(array('nggGallery', 'get_image_url'))) {
            // new NextGen 1.0+
            $out = '<img alt="' . __('property photo') . '" src="' . nggGallery::get_image_url($pid) . '" ' . $myclass . '/>';
        } else {
            // backwards compatibility - NextGen below 1.0
            $out = '<img alt="' . __('property photo') . '" src="' . nggallery::get_image_url($pid) . '" ' . $myclass . '/>';
        }
        return $out;
    }
}