* @copyright (cc) creative commons - attribution-shareAlike 3.0 unported * @version 1.0 * @package app * @subpackage controllers */ class gallery extends controller { /** * index function * display galleries and/or images */ public function index() { $html["title"] = 'portfolio'; $html["meta"] = ''; $html["sidebar"] = $this->view("blog/sidebar_qr", array(), true); $html["selected"] = 'gallery'; $html["script"] = $this->view('initShadowboxJS', array(), true); $html["jsfiles"] = ''; $gm = $this->model("galleryModel"); if(isset(library::catalog()->url[1])) { if(!isset(library::catalog()->url[2])) { //---display category $cat = $gm->getCat(library::catalog()->url[1]); if(!isset($cat[0])) { throw new Exception("invalid category", statusCodes::HTTP_NOT_FOUND); } else { $body = '

'.$cat[0]['name'].'

'.$cat[0]['excerpt'].'

'; $subCats = $gm->getSubCats($cat[0]['gallery_cat_id']); if(isset($subCats[0])) { foreach ($subCats as $kitten) { $body .= '
'.$kitten['name'].'
'.$kitten['excerpt'].'

'; } } } } else { if(!isset(library::catalog()->url[3])) { //---display project $proj = $gm->getCat(library::catalog()->url[2]); if(!isset($proj[0])) { throw new Exception("invalid project", statusCodes::HTTP_NOT_FOUND); } else { $body = '

'.$proj[0]['name'].'


'.html_entity_decode($proj[0]['description']).'

'; $imgs = $gm->getCatImgs($proj[0]['gallery_cat_id']); if(isset($imgs)) { foreach ($imgs as $img) { $extension_pos = strrpos($img['filename'], '.'); $thumb = substr($img['filename'], 0, $extension_pos) . '_thumb' . substr($img['filename'], $extension_pos); $body .= '
'.$img['title'].
 more info
'; } } } } else { //---display image $img = $gm->getImg(library::catalog()->url[3]); if(!isset($img[0])) { throw new Exception("invalid image", statusCodes::HTTP_NOT_FOUND); } else { $html["sidebar"] = ''; $body = '

'.$img[0]['title'].' '.$img[0]['subtitle'].'

'.html_entity_decode($img[0]['description']).'
'.$img[0]['title'].
'; } } } } else { //---list projects $mainCats = $gm->getMainCats(); $body = ''; if(!isset($mainCats[0])) { $body = 'no categories to display.'; } else { foreach ($mainCats as $cat) { $body .= '

'.$cat['name'].'

'.$cat['excerpt'].'

'; $subCats = $gm->getSubCats($cat['gallery_cat_id']); if(isset($subCats[0])) { foreach ($subCats as $kitten) { $body .= '
'.$kitten['name'].'
'.$kitten['excerpt'].'

'; } } } } } $post = array( 'mainCat' => '', 'url' => '', 'title' => 'Gallery', 'subtitle' => '', 'content' => $body, 'comments' => 0 ); $html["body"] = $this->view("post", $post, true); $this->view("pixelgraff", $html); } } ?>