ob_start();
$Page = new Common_Page();
$idd= $Page->getPageId();
$address = $Page-> getPageURL($idd);
$galleryid = Tools_Http::Get('gid',true);
$imgindex= Tools_Http::Get('img',true);
$Gallery = new Projects_Gallery();
echo 'gal_id'.$galleryid;
function show_galleries($galleries) {
global $Gallery,$DB,$type,$L;
$Gallery = new Projects_Gallery();
$DB = Core_Database::getInstance();
ob_start();
?>
foreach ($galleries as $gall) {
if ($gall['car_make']) {
$make = $DB->getRow('goods_cars',$gall['car_make']);
$thumb = '/images/cars/'.$make['icon'];
} else {
$images = $Gallery -> getImages($gall['id'], 1);
if (!empty($images)) {
$count = count($images);
$thumb = $images[0]['picture_2'];
} else {
if($gall['icon'])
$thumb = $dest = '/images/worksgallery/'.$gall['icon'];
else $thumb='';
}
}
$style= 'width:140px';
if($thumb && file_exists($_SERVER['DOCUMENT_ROOT'].$thumb)) {
$size = getimagesize($_SERVER['DOCUMENT_ROOT'].$thumb);
if($size[0]>$size[1]) {
$style='width:140px';
}
if($size[0]<$size[1] || $size[0]==$size[1] ) {
$style='height:120px';
}
}
$link = '?'.Tools_Http::replaceUrl($_GET, 'gid', $gall['id']);
$data=explode(' ',$gall['created']);
if(!$type)
$link .=$gall['type']=='gallery' ? '&gallery' : '';
if ($thumb) {
?>
}
}
?>
$data =ob_get_contents();
ob_end_clean();
return $data;
}
/*
if (!$galleryid) {
$gid = $page['galleryid'];
$gallery = $Gallery -> getGallery($gid);
if ($gallery['parentid'] > 0) {
$galleryid = $gid;
}
}
*/
if ($galleryid) {
$gallery = $Gallery -> getGallery($galleryid,$type);
$images = $Gallery->getImages($galleryid,-1,$type);
if(empty($images)){
?>
$galleries = $Gallery -> getGalleryListFront($galleryid);
echo show_galleries($galleries);
} else {
$gallery_name = $Gallery->getGalleryName($galleryid,$type);
$gallery_name = $L->StrT('worksgallery','title', $galleryid, $gallery_name);
if($gallery['parentid'])
$gallery_parent_name = $Gallery->getGalleryName($gallery['parentid'],$type);
else $gallery_parent_name='';
$gallery_parent_name = $L->StrT('worksgallery','title', $galleryid, $gallery_parent_name);
?>
$i=0;
foreach ($images as $image) {
$link = $image['picture_1'];
$thumb = $image['picture_2'];
$odd = (($i+1)%4)==0?'last':'';
?>
$i++;
}
?>
}
} else {
$gid = 0;
echo show_galleries($galleries);
} else {
$images = $Gallery->getImages($gid,'-1',$type);
?>
$i=0;
foreach ($images as $image) {
$link = $image['picture_1'];
$thumb = $image['picture_2'];
$odd = (($i+1)%4)==0?'last':'';
?>
$i++;
}
?>
}
}
$data =ob_get_contents();
ob_end_clean();
$m_return = $data;
?>