incrementAlbumVisits($alb_id); $info[1] = $gallery->fetchAlbumNumbering($alb_id); $category =$info[1]['kategorie']; $showingAlbumOnly = true; $nazev = $info[1]['album']; } if ($category) { $info[0] = $gallery->fetchCategoryNumbering($category); $nazev = $info[0]['album']; } if ($info) ksort($info); if (!$nazev) $nazev = 'Fotogalerie'; $r.='

'.$nazev.'

'; // unset($info[1]); # Odstrelime nepotrebny, nemame dualni galerii if ($alb_id || $category) { foreach($info as $num => $itm) { $mod1=$itm['mod1']; // Drobeckova navigace if (kernel::$request[2]) { $r.='
'; $r.='Galerie'; if ($itm['grandparent_id']) { if($itm['cat']) $pos = get_position($itm['grandparent_id'],0,1); else $pos = get_position($itm['grandparent_id']); krsort($pos); foreach($pos as $position) { if ($itm['cat']) pageLoader::$pageVars['menuItems'][$position['id']] = array ($position['parent_id'],$position['nazev']); $r.=' » '.$position['nazev'].''; } #kernel::say(pageLoader::$pageVars['menuItems']); } if ($itm['parent_id']) { if ($itm['cat']) pageLoader::$pageVars['menuItems'][$itm['parent_id']] = array ($itm['grandparent_id'],$itm['parent']); $r.=' » '.$itm['parent'].''; } if ($itm['album']) { if ($itm['cat']) pageLoader::$pageVars['menuItems'][$itm['id']] = array ($itm['parent_id'],$itm['album']); $r.=' » '.$itm['album']; } $r.='
'; } if ($num == count($info)-1) { // Zabraneni zdvojeni sipek, kdyz mame kategorii i album $r.='
'; if ($itm['prev']['id']) $r.=' '; if ($itm['parent_id']) $r.=' '; elseif (kernel::$request[1]) $r.=' '; if ($itm['next']['id']) $r.=' '; $r.='
'; } } } } if (!kernel::$request[1]) $root = true; $closed=true;$first=true; $i=0; if ($category!==false && !$preview && !$showingAlbumOnly) { // Vypsani podkategorii while($itm = $gallery->fetchSubCategories($category)) { $subCategoryDisplayed = true; if ($closed) { $r_cats.='
'; $closed=false; } if (!$r_catsoot && $first) { $first=false; } $r_cats.="
"; $nazev = $itm['id']; if ($itm['nazev']) $nazev.='-'.seoize($itm['nazev']); if ($itm['thumb']) $r_cats.=''; else $r_cats.=""; $itm['nazev'] = str_replace('_',' ',$itm['nazev']); $itm['nazev'] = wordwrap($itm['nazev'], 17, " ", true); $r_cats.='

'.$itm['nazev'].'

'; $r_cats.='
'; ++$i; if ($i%4 == 0) { $closed=true; $r_cats.='
'; } } } if (!$closed) { $r_cats.=''; $closed = true; } if ($subCategoryDisplayed) { $r.='

Podkategorie

'.$r_cats.'
'; $r.='

Nejnovější alba v podkategoriích

'; $limit=28; // Zde je bug, protoze kdyz nebudou alba v nejhlubsi kategorii tak se nezobrazi vic nez 20 polozek } $r.="
"; $closed=true;$first=true; $i=0; if ($preview) $limit = 4; if (kernel::$request[1]=='album') unset($category); while ($itm = $gallery->fetchAlbums($alb_id,$limit,$category)) { // Vypsani alb $anything = true; if ($closed) { $r.='
'; $closed=false; } if (!$root && $first) { $first=false; } $r.="
"; $nazev = $itm['id']; if ($itm['nazev']) $nazev.='-'.seoize($itm['nazev']); if ($itm['thumb']) $r .=""; else $r.=""; $itm['nazev'] = str_replace('_',' ',$itm['nazev']); $itm['nazev'] = wordwrap($itm['nazev'], 17, " ", true); $r.="

{$itm['nazev']}

"; $r.='

Zobrazeno: '.$itm['views'].'x'; if (is_admin()) { $r.='

'; if (!$itm['parent_id']) $r.='< '; $r.='S E'; if (!$itm['parent_id']) $r.=' >
('.($itm['id']+$itm['priority']).')'; $r.='

'; } $r.='
'; ++$i; if ($i%4 == 0) { $closed=true; $r.='
'; } } if (!$closed) { $r.='
'; $closed = true; } $i = 0;$first_pict=true; if (!$root) { while($itm = $gallery->fetchItems($alb_id,$limit)) { #Vypsani samotnych obrazku v albu if (!$preview && $first_pict && !$first) { $r.='

Obrázky

'; $first_pict=false; } if ($closed) { $r.='
'; $closed=false; } $r.="
"; $nazev = $itm['id']; if ($itm['nazev']) $nazev.='-'.seoize($itm['nazev']); $itm['nazev'] = str_replace('_',' ',$itm['nazev']); if ($itm['thumb']) $r.=''; else $r.=""; $itm['nazev'] = wordwrap($itm['nazev'], 17, " ", true); $r.='

'.$itm['nazev'].'

'; if (is_admin() || userAuth::$user['id'] == ($itm['user_id'])) $r.='

S E

'; $r.='
'; ++$i; if ($i%4 == 0) { $closed=true; $r.='
'; } } if (!$closed) { $r.=''; $closed = true; } } $i=0; if (!$alb_nazev) $alb_nazev=kernel::$request[2]; else $alb_nazev=$alb_id.'-'.seoize($alb_nazev); if (!$preview && can_insert() && (!$root || is_admin())) { $r.='
Vložit nový obrázek'; $r.="
"; } $r.=""; if (!$anything && $preview) return false; else return $r; } class gallery { var $slideshow,$next,$prev,$up,$paging,$result,$resultCat,$albDirectory,$lang; function __construct($lang = '') { $this->result = array (); $this->lang = $lang; }/* * Kod pro 3 vrstvou galerii, pouze kategorie -> album -> obrazky * function fetchCats() { if (!$this->result['cats']) $this->result['cats'] = $this->queryCats(); return db::fetch_assoc($this->result['cats']); } function queryCats() { $q['select']='gal_kategorie'; $q['data']='gal_kategorie.*, gal_polozky.thumb'; $q['join'][] = array ( 'side'=>'left', 'table'=>'gal_alba', 'joint1'=>'gal_kategorie.id', 'joint2'=>'gal_alba.kat_id' ); $q['join'][] = array ( 'side'=>'left', 'table'=>'gal_polozky', 'joint1'=>'gal_alba.id', 'joint2'=>'gal_polozky.alb_id' ); $q['group'][]='gal_kategorie.id'; $result = db::query($q); return $result; } function fetchCatNumbering($katId) { $katId=intval($katId); $q['select']='gal_kategorie'; $q['data']='id,nazev'; $q['where'][0]='id <= '.$katId; $q['order']='id DESC'; $q['limit']=2; $result = db::query($q); $row=db::fetch_assoc($result); $row['prev']=db::fetch_assoc($result); $q['where'][0]='id>'.$katId; $row['next']=db::oneAssoc($q); return $row; }*/ function fetchAlbums($parentId,$limit=0,$categoryId) { if ($categoryId) return $this->fetchAlbumsFromCategory($categoryId,$limit); else return $this->fetchAlbumsFromAlbum($parentId,$limit); } function fetchSubCategories($parentId) { if(!$this->result['cats'][$parentId]) $this->result['cats'][$parentId]=$this->querySubCategories($parentId,$limit); if (!$this->result['cats'][$parentId]) return false; if ($row = db::fetch_assoc($this->result['cats'][$parentId])) { return $this->checkCategoryRow($row); } else return false; } function fetchAlbumsFromAlbum($parentId,$limit=0) { if(!$this->result['albs'][$parentId]) $this->result['albs'][$parentId]=$this->queryAlbums($parentId,$limit); if (!$this->result['albs'][$parentId]) return false; if ($row = db::fetch_assoc($this->result['albs'][$parentId])) { return $this->checkAlbumRow($row); } else return false; } function fetchAlbumsFromCategory($categoryId,$limit=0) { if(!$this->resultCat['albs'][$categoryId]) $this->resultCat['albs'][$categoryId]=$this->queryAlbumsFromCategory($categoryId,$limit); if (!$this->resultCat['albs'][$categoryId]) return false; if ($row = db::fetch_assoc($this->resultCat['albs'][$categoryId])) { return $this->checkAlbumRow($row); } else return false; } function checkCategoryRow(&$row) { if (@file_exists('./user/img/'.$row['static_thumb']) && $row['static_thumb']) $row['thumb'] = $row['static_thumb']; if (!$row['thumb']) { #Album neobsahuje zadne obrazky, takze kouknem jestli nejaky z jeho podalb neobsahuje obrazky if ($row['thumb'] = $this->getCategoryThumb($row['id'])) { $q['update']='kategorie'; $q['data']="static_thumb = '".$row['thumb']."'"; $q['where']='id = '.$row['id']; $q['limit']=1; db::query($q); } } if ($this->lang && $row['nazev_'.$this->lang]) $row['nazev'] = $row['nazev_'.$this->lang]; return $row; } function checkAlbumRow(&$row) { if (@file_exists('./user/img/'.$row['static_thumb']) && $row['static_thumb']) $row['thumb'] = $row['static_thumb']; if (!$row['thumb']) { #Album neobsahuje zadne obrazky, takze kouknem jestli nejaky z jeho podalb neobsahuje obrazky if ($row['thumb'] = $this->getAlbumThumb($row['id'])) { $q['update']='gal_alba'; $q['data']="static_thumb = '".$row['thumb']."'"; $q['where']='id = '.$row['id']; $q['limit']=1; db::query($q); } } if ($this->lang && $row['nazev_'.$this->lang]) $row['nazev'] = $row['nazev_'.$this->lang]; return $row; } function getCategoryThumb($categoryId) { $result = $this->queryAlbumsFromCategory($categoryId); if (db::num_rows($result) > 0) { while($row = db::fetch_assoc($result)) { if ($row['thumb']) return $row['thumb']; } db::data_seek($result,0); while($row = db::fetch_assoc($result)) { if ($thumb = $this->getAlbumThumb($row['id'])) return $thumb; } } return false; } function getAlbumThumb ($albumId) { $result = $this->queryAlbums($albumId); if (db::num_rows($result) > 0) { while($row = db::fetch_assoc($result)) { if ($row['thumb']) return $row['thumb']; } db::data_seek($result,0); while($row = db::fetch_assoc($result)) { if ($thumb = $this->getAlbumThumb($row['id'])) return $thumb; } } return false; } function queryAlbums($parentId,$limit=0) { $parentId = intval($parentId); $q['select']='gal_alba'; $q['data']='gal_alba.*, gal_polozky.thumb'; $q['join'][] = array ( 'side'=>'left', 'table'=>'gal_polozky', 'joint1'=>'gal_alba.id', 'joint2'=>'gal_polozky.alb_id', ); $q['limit'] = $limit; $q['where']='parent_id = '.$parentId; $q['group'][]='gal_alba.id'; if ($parentId) #Abecedni razeni v podkategoriich $q['order']='gal_alba.nazev ASC'; else #Root prioritne+id $q['order']='gal_alba.id + gal_alba.priority ASC'; $result = db::query($q); return $result; } function querySubCategories($parentId) { $parentId = intval($parentId); $q['select']='kategorie,gal_alba_j_kategorie,gal_alba'; $q['data']='kategorie.*, gal_polozky.thumb'; $q['join'][] = array ( 'side'=>'left', 'table'=>'gal_polozky', 'joint1'=>'gal_alba.id', 'joint2'=>'gal_polozky.alb_id', ); $q['limit'] = $limit; $q['where'][]='kategorie.parent_id = '.$parentId; $q['where'][]='kategorie.id = gal_alba_j_kategorie.kategorie_id'; $q['where'][]='gal_alba_j_kategorie.album_id = gal_alba.id'; $q['group'][]='kategorie.id'; if ($parentId) #Abecedni razeni v podkategoriich $q['order']='gal_alba.nazev ASC'; else #Root prioritne+id $q['order']='gal_alba.id + gal_alba.priority ASC'; $result = db::query($q); return $result; } function queryAlbumsFromCategory($categoryId,$limit=0) { $categoryId = intval($categoryId); $q['select']='gal_alba_j_kategorie, gal_alba'; $q['data']='gal_alba.*, gal_polozky.thumb'; $q['join'][] = array ( 'side'=>'left', 'table'=>'gal_polozky', 'joint1'=>'gal_alba.id', 'joint2'=>'gal_polozky.alb_id', ); $q['limit'] = $limit; $q['where'][]='album_id = gal_alba.id'; $q['where'][]='kategorie_id = '.$categoryId; $q['group'][]='gal_alba.id'; $q['order']='gal_alba.id DESC'; $result = db::query($q); return $result; } function fetchAlbumNumbering($albId) { $albId=intval($albId); // Zjisteni informaci o soucasnem albu $q['select']='gal_alba'; $q['data']='gal_alba.parent_id,gal_alba.nazev AS album,gal_alba.nazev_de, parent.nazev AS parent, parent.parent_id AS grandparent_id'; $q['where'][0]='gal_alba.id = '.$albId; $q['join'][]= array ( 'table' => 'gal_alba AS parent', 'side' => 'left', 'joint1' => 'gal_alba.parent_id', 'joint2' => 'parent.id' ); $q['limit']=1; if (!($row = db::oneAssoc($q))) $row['parent_id'] = 0; elseif ($row['parent_id']==0) { // Jsme v albu, ktere je v kategorii $q['select']='gal_alba'; $q['data']='gal_alba.id,gal_alba_j_kategorie.kategorie_id AS parent_id'; $q['where'][0]='gal_alba.id = '.$albId; $q['join'][]= array ( 'table' => 'gal_alba_j_kategorie', 'side' => 'left', 'joint1' => 'gal_alba.id', 'joint2' => 'gal_alba_j_kategorie.album_id' ); $q['limit']=1; } else { $q['select']='gal_alba'; $q['data']='gal_alba.id,gal_alba.nazev,gal_alba.nazev_de'; $q['where'][0]='gal_alba.parent_id = '.$row['parent_id']; $q['where'][1]='gal_alba.id<'.$albId; $q['order']='id DESC'; $row['prev']=db::oneAssoc($q); $q['where'][1]='gal_alba.id>'.$albId; $q['order']='id ASC'; $row['next']=db::oneAssoc($q); } if ($this->lang) { if ($row['nazev_'.$this->lang]) $row['album'] = $row['nazev_'.$this->lang]; if ($row['next']['nazev_'.$this->lang]) $row['next']['nazev'] = $row['next']['nazev_'.$this->lang]; if ($row['prev']['nazev_'.$this->lang]) $row['prev']['nazev'] = $row['prev']['nazev_'.$this->lang]; } // Zjistime kategorii unset($q); $q['select'] = 'gal_alba_j_kategorie'; $q['where'] = 'album_id = '.$albId; $q['data']='MAX(kategorie_id) as kategorie'; list($row['kategorie']) = db::oneRow($q); $row['alb']=true; $row['mod1']='album'; return $row; } function fetchCategoryNumbering($catId) { $albId=intval($catId); // Zjisteni informaci o soucasne kategorii $q['select']='kategorie'; $q['data']='kategorie.parent_id,kategorie.nazev AS album,kategorie.nazev_de, parent.nazev AS parent, parent.parent_id AS grandparent_id'; $q['where'][0]='kategorie.id = '.$albId; $q['join'][]= array ( 'table' => 'kategorie AS parent', 'side' => 'left', 'joint1' => 'kategorie.parent_id', 'joint2' => 'parent.id' ); $q['limit']=1; if (!($row = db::oneAssoc($q))) $row['parent_id'] = 0; else { $q['select']='kategorie'; $q['data']='kategorie.id,kategorie.nazev,kategorie.nazev_de'; $q['where'][0]='kategorie.parent_id = '.$row['parent_id']; $q['where'][1]='kategorie.id<'.$albId; $q['order']='id DESC'; $row['prev']=db::oneAssoc($q); $q['where'][1]='kategorie.id>'.$albId; $q['order']='id ASC'; $row['next']=db::oneAssoc($q); } if ($this->lang) { if ($row['nazev_'.$this->lang]) $row['album'] = $row['nazev_'.$this->lang]; if ($row['next']['nazev_'.$this->lang]) $row['next']['nazev'] = $row['next']['nazev_'.$this->lang]; if ($row['prev']['nazev_'.$this->lang]) $row['prev']['nazev'] = $row['prev']['nazev_'.$this->lang]; } $row['cat']=true; $row['mod1']='kategorie'; return $row; } function fetchItems($albId,$limit=0) { if(!$this->result['itms'][$albId]) $this->result['itms'][$albId]=$this->queryItems($albId,$limit); if (!$this->result['itms'][$albId]) return false; return db::fetch_assoc($this->result['itms'][$albId]); } function queryItems($albId,$limit=0) { $albId = intval($albId); if ($albId) { $q['select']='gal_polozky'; $q['data']='gal_polozky.*'; $q['where'][]='alb_id = '.$albId; $q['order']='nazev ASC'; $q['limit'] = $limit; $result = db::query($q); return $result; } } function incrementAlbumVisits($albId) { if ($albId && !kernel::$bot) { $q['update'] = 'gal_alba'; $q['data']='`views` = `views` + 1 '; $q['where']='id='.intval($albId); $q['limit']=1; db::query($q); } } function displayItem($imageId) { $q['select']='gal_alba,gal_polozky'; $q['data']='gal_polozky.*,gal_alba.nazev AS album,gal_alba.parent_id,auth_user.name AS user'; $q['where'][]='gal_polozky.id='.intval($imageId); $q['where'][]='gal_polozky.alb_id = gal_alba.id'; $q['join'][] = array ( 'side'=>'left', 'table'=>'auth_user', 'joint1'=>'gal_polozky.user_id', 'joint2'=>'auth_user.id' ); $q['limit']=1; if ($row = db::oneAssoc($q)) { ++$row['views']; # Zvyseni poctu views o aktualniho navstevnika unset($q); if (!kernel::$bot) { $q['update'] = 'gal_polozky'; $q['data']='`views` = `views` + 1 '; $q['where']='gal_polozky.id='.intval($imageId); $q['limit']=1; db::query($q); unset($q); } #Zjisteni predchoziho a nasledujiciho $q['where'][0]='id>'.intval($imageId); $q['select']='gal_polozky'; $q['where'][1]='alb_id='.$row['alb_id']; $q['data']='id,nazev'; $q['order']='id ASC'; $q['limit']=1; $row['next'] = db::oneAssoc($q); $q['where'][0]='id<'.intval($imageId); $q['where'][1]='alb_id='.$row['alb_id']; $q['data']='id,nazev'; $q['order']='id DESC'; $row['prev'] = db::oneAssoc($q); return $row; } else return false; } function createAlbum($parentId,$data,$file,$category = 0) { #kernel::say("ALBUM");kernel::say($data);kernel::say($file);kernel::say("/ALBUM"); $parentId = intval($parentId); $albId = $this->createAlbumEntry($parentId,$data,$category); if ($this->is_zip($file)) { #Jedna se o .zip, takze predame prislusne fci $this->createAlbumFromZip($albId,$data,$file); } elseif ($this->is_image($file)) { if ($file['type']=='image/pjpeg') $file['type']='image/jpeg'; $this->createItem($albId,$data,$file); } return $albId; } function is_image($file) { if (is_array($file)) { if ($file['type'] == 'image/png' || $file['type'] == 'image/jpeg' || $file['type'] == 'image/pjpeg') return true; if ($file['type'] == 'application/msword' || $file['type'] == 'application/vnd.ms-excel' || $file['type'] == 'application/vnd.ms-powerpoint' || $file['type'] == 'application/pdf') return 2; $file = $file['name']; } if (!is_array($file)) { # $file je pouze nazev, takze jenom primitivne checknem aspon koncovku list($name,$ext) = explode_filename($file); $ext = strtolower($ext); if ($ext == '.png') return true; elseif($ext == '.jpg' || $ext == '.jpeg') return true; elseif($ext == '.doc' || $ext == '.docx') return 'application/msword'; elseif($ext == '.xls' || $ext == '.xlsx') return 'application/vnd.ms-excel'; elseif($ext == '.ppt' || $ext == '.pptx') return 'application/vnd.ms-powerpoint'; elseif($ext == '.pdf') return 'application/pdf'; } return false; } function is_zip($file) { if ($file['type']=='application/zip' || $file['type']=='application/x-zip-compressed') return true; else { list($name,$ext) = explode_filename($file['name']); $ext = strtolower($ext); if ($ext == '.zip') return true; } return false; } function createItem($albId,$data,$file) { $isImage = $this->is_image($file); # Vrati True pri image, 2 nebo MIMEtype pri podporovanem souboru if ($isImage) $this->createItemEntry($albId,$data,$file,$isImage); elseif ($this->is_zip($file)) { #Jedna se o .zip, takze predame prislusne fci $this->createAlbumFromZip($albId,$data,$file); } } function createItemEntry($albId,$data,$file,$type) { #kernel::say("ITEM");kernel::say($data);kernel::say($file);kernel::say("/ITEM"); # Ulozime full verzi if (!$this->albDirectory[$albId]) { #Musime si zjistit adresar do ktereho ukladat $q['select'] ='gal_alba'; $q['data']='gal_alba.directory AS alb'; $q['where']='gal_alba.id = '.$albId; $q['limit']=1; $row = db::oneAssoc($q); $this->albDirectory[$albId]=$row['kat'].'/'.$row['alb']; unset($q); } $dir = './user/img/gallery/'.$this->albDirectory[$albId].'/'; if (!is_dir($dir)) mkdir($dir); $fullname = $dir.get_safe_filename($file['name'],1); list($thumbname,$ext) = explode_filename($fullname); $thumbname='.'.$thumbname; #Kompenzace za odstraneni "." $middlename=$thumbname.'-md'.$ext; $thumbname.='-th'.$ext; if (is_uploaded_file($file['tmp_name'])) move_uploaded_file($file['tmp_name'],$fullname); else copy($file['tmp_name'],$fullname); // Vytvorime zmenseninu, pokud mame obrazek if ($type === true) { $image = new image($fullname); $image->maxX=112; $image->maxY=78; $image->withBars=array(244,244,244); $image->saveResized($thumbname); $image->withBars=false; #$image->expandable=false; $image->maxX=517; $image->maxY=false; $image->saveResized($middlename); $fullname=str_replace('./user/img/','',$fullname); $middlename=str_replace('./user/img/','',$middlename); $thumbname=str_replace('./user/img/','',$thumbname); } elseif ($type) { # Jedna se o soubor, nastavime cestu k obrazku $fullname=str_replace('./user/img/','',$fullname); unset($middlename); # Podle absentujiciho middlename zjistime, ze se jedna o soubor ke stazeni $thumbname='system/files/'.str_replace('.','',$ext).'.gif'; #Podle koncovky urcime obrazek } if ($data['nazev-img']) $nazev = $data['nazev-img']; else $nazev = $file['name']; $q['insert']='gal_polozky'; $q['data']= array ( 'alb_id' => $albId, 'full' => $fullname, 'middle' => $middlename, 'thumb' => $thumbname, 'nazev' => $nazev, 'popis' => $data['popis-img'], 'user_id' => userAuth::$user['id'], ); db::query($q); } function createAlbumFromZip($albId,$data,$file) { $zip = zip_open($file['tmp_name']); if (is_resource($zip)) { while ($r = zip_read($zip)) { $image['name'] = zip_entry_name($r); if (strpos($image['name'],'/') !== false) { #Odstranime adresar $temp = explode('/',$image['name']); if ($temp[count($temp)-1] == '') { continue; } $image['name'] = $temp[count($temp)-1]; } if ($image['type'] = $this->is_image($image['name'])) { $entry = zip_entry_read($r,zip_entry_filesize($r)); $image['tmp_name'] = tempnam('/tmp','phpzip'); $f = fopen($image['tmp_name'], "w"); fwrite($f,$entry); fclose($f); $this->createItem($albId,array('nazev-img'=>'','popis-img'=>''),$image); } } zip_close($zip); } } function createAlbumEntry ($parentId,$data,$category = 0) { // Zjistime si nazev a vytvorime adresar s albem $q['select']='gal_alba'; $q['data']='nazev,directory'; $q['where']='parent_id = '.$parentId; $q['limit']=1; $row = db::oneAssoc($q); $dir = get_safe_dirname($data['nazev'],1); if (!is_dir('./user/img/gallery/'.$row['directory'].'/'.$dir)) mkdir('./user/img/gallery/'.$row['directory'].'/'.$dir); unset($q); if (!$data['nazev_de']) $data['nazev_de'] = $data['nazev']; $q['insert']='gal_alba'; $q['data']=array( 'parent_id' => $parentId, 'nazev' => $data['nazev'], 'nazev_de' => $data['nazev_de'], 'user_id' => userAuth::$user['id'], 'directory' => $dir, ); $id = db::query($q); if ($category) { // Udelame zebricek kategorie nahoru a vlozime cat_ladder ($category,$cats); unset($q); $q['insert'] = 'gal_alba_j_kategorie'; $q['data'] = array ('album_id' => $id); foreach($cats as $cat => $dummy) { $q['data']['kategorie_id'] = $cat; db::query($q); } } $this->albDirectory[$id] = $row['directory'].'/'.$dir; return $id; } function deleteAlbum($albId) { $q['select']='gal_alba'; $q['data']='id'; $q['where']='parent_id = '.$albId; $result = db::query($q); while($row = db::fetch_assoc($result)) { $this->deleteAlbum($row['id']); } unset($q); $q['select']='gal_polozky'; $q['data']=array('thumb','id'); $q['where']='alb_id = '.$albId; $result = db::query($q); while($row = db::fetch_assoc($result)) { if (file_exists($row['thumb']) && !is_dir($row['thumb'])) { $dir = explode('/',$row['thumb']); unset($dir[count($dir)-1]); $dir = join('/',$dir); if (is_dir($dir)) @unlink($dir); } }; unset($q); $q['delete']='gal_polozky'; $q['where']='alb_id = '.$albId; db::query($q); unset($q); $q['delete']='gal_alba'; $q['where']='id = '.$albId; db::query($q); return true; } function editAlbum($albId,$data) { $q['update']='gal_alba'; if (!$data['nazev_de']) $data['nazev_de'] = $data['nazev']; $q['data']=array ( 'nazev' => $data['nazev'], 'nazev_de' => $data['nazev_de'] ); $q['where']='id = '.$albId; db::query($q); } function deleteItem($itemId) { $q['delete']='gal_polozky'; $q['where']='id = '.$itemId; $q['limit']=1; db::query($q); return true; } function editItem($itemId,$data) { $q['update']='gal_polozky'; $q['data']=array ('nazev' => $data['nazev'], 'popis' => $data['popis']); $q['where']='id = '.$itemId; db::query($q); } } ?>