saveSortable($gid, $images);
}
}
if ($task == 'photoUpload') {
$gid = Tools_Http::Post('gid',true);
$Gallery = new WorksGallery();
$result = $Gallery->uploadImage($gid, 'photo');
if ($result) {
$error = false;
$msg = $L->Str('%s ielādēts.',1,array($Gallery->getLastLoadedFile()));
} else {
$error = true;
$err = $Gallery->getLastError();
switch ($err) {
case PhotoGallery::image_load_error: { $msg = $L->Str('Kļūda ielādējot failu'); break; }
case PhotoGallery::no_image_selected: { $msg = $L->Str('Nav izvēlēts bildes fails.'); break; }
case PhotoGallery::file_not_image: { $msg = $L->Str('Ielādētais fails nav bilde.'); break; }
}
}
?>
exit;
}
if ($task == 'addGallery') {
$id = Tools_Http::Post('galleryid',true);
$active = Tools_Http::Post('active',true);
$title = Tools_Http::Post('title');
$parentid = Tools_Http::Post('parentid',true);
$car_make = Tools_Http::Post('car_make',true);
$title_lv = Tools_Http::Post('title_lv');
$title_en = Tools_Http::Post('title_en');
$Gallery = new WorksGallery();
$result = $Gallery->createGallery($id, $parentid, $title, $active, $car_make);
if(!$id) $idc = $result;
else $idc = $id;
$L->addValue('worksgallery','title',$idc,'lv',$title_lv);
$L->addValue('worksgallery','title',$idc,'en',$title_en);
if ($_FILES['icon']['name'] && empty($errors)) {
$hash = Tools_Text::getRandomHash(12);
$thumb_file = $hash.'.jpg';
$dest = WEBPATH.'images/worksgallery/';
$upload = Tools_Filesystem::uploadFile ('icon', $dest, $thumb_file);
//echo $dest.$thumb_file;
if (!$upload) {
array_push($errors,'pic');
$err_msg = 'Neizdevās ielādēt bildi.';
} else {
if (getimagesize($dest.$thumb_file)) {
Tools_Image:: imageResize ($dest.$thumb_file,$dest.$thumb_file,150,130,true,100);
chmod($dest.$thumb_file,0777);
if ($id) {
$folderdata = $DB -> getRow('photo_works', $id);
if ($folderdata['icon']) {
unlink($dest.$folderdata['icon']);
}
$DB->Exec("UPDATE photo_works SET icon = '".$thumb_file."' WHERE id = ".$id);
}
$pic_file = $thumb_file;
} else {
unlink ($dest.$thumb_file);
array_push($errors, 'imgilfe');
$err_msg = 'Ielādētais fails nav bilde!';
}
}
}
if (!$id && $result) {
$L->addText ('photo_galleries', 'title', $result);
}
if ($result) {
if ($id) {
echo ''.$L->Str('Galerija saglabāta').'';
} else {
echo ''.$L->Str('Galerija labota.').'';
}
?>
} else {
$code = $Gallery->getLastError();
switch ($code) {
case PhotoGallery::err_no_title: { $err_msg=$L->Str('Ievadiet galerijas nosaukumu!'); break; }
case PhotoGallery::err_no_year: { $err_msg=$L->Str('Ievadiet gadu!'); break; }
}
array_push($errors,'title');
}
}
if (!empty($errors)) {
echo 'ER|'.$err_msg.'|'.implode(',',$errors);
}
?>