| // | Author: Florentin Mocuta | // +---------------------------------------------------------------------------+ // $Id: ManagerTemplate.html,v 1.2 2005/04/17 02:15:02 demian Exp $ require_once SGL_MOD_DIR . '/navigation/classes/MenuBuilder.php'; require_once SGL_CORE_DIR . '/Category.php'; /** * A simple Photo Gallery Module * * @package gallery * @author Rares Benea * @author Florentin Mocuta * @version $Revision: 1.0 $ */ class GalleryMgr extends SGL_Manager { function GalleryMgr() { SGL::logMessage(null, PEAR_LOG_DEBUG); parent::SGL_Manager(); $this->pageTitle = 'Photo Gallery'; $this->template = 'galleryList.html'; $this->_aActionsMapping = array( 'list' => array('list'), 'details' => array('details'), ); } function validate($req, &$input) { SGL::logMessage(null, PEAR_LOG_DEBUG); $this->validated = true; $input->error = array(); $input->pageTitle = $this->pageTitle; $input->masterTemplate = $this->masterTemplate; $input->template = $this->template; $input->action = ($req->get('action')) ? $req->get('action') : 'list'; $input->gallery = (object)$req->get('gallery'); $input->galleryID = $req->get('frmGalleryID'); $input->catID = (int) $req->get('frmCatID'); $input->from = ($req->get('frmFrom')) ? $req->get('frmFrom') : 0; $input->totalItems = $req->get('totalItems'); if ($input->catID < 1) { $input->catID = $this->conf['GalleryMgr']['defaultCatID']; }; if (SGL_Session::getRoleId() == SGL_ADMIN) { $input->isAdmin = true; } // if errors have occured if (isset($aErrors) && count($aErrors)) { SGL::raiseMsg('Please fill in the indicated fields'); $input->error = $aErrors; $input->template = 'galleryAdd.html'; $this->validated = false; } } function display(&$output) { SGL::logMessage(null, PEAR_LOG_DEBUG); $cat = & new SGL_Category(); $output->path = $cat->getBreadCrumbs($output->catID, true, 'linkCrumbsAlt1'); $output->currentCat = $cat->getLabel($output->catID); } function _cmd_list(& $input, & $output) { SGL::logMessage(null, PEAR_LOG_DEBUG); $whereClause = ''; if ($input->catID) { $whereClause = ' WHERE category_id = "'.$input->catID.'" '; }if ($output->catID > 1) { $output->currentCat = $output->catID; } elseif (!empty($output->gallery->category_id)) { $output->currentCat = $output->gallery->category_id; } else { $output->currentCat = 0; } $query = " SELECT * FROM {$this->conf['table']['gallery']} $whereClause ORDER BY item_order DESC"; $limit = $_SESSION['aPrefs']['resPerPage']; $pagerOptions = array( 'mode' => 'Sliding', 'delta' => 3, 'perPage' => $limit, 'totalItems'=> $input->totalItems, ); $aPagedData = SGL_DB::getPagedData($this->dbh, $query, $pagerOptions); if (is_a($aPagedData, DB_Error)) { SGL::raiseError('Error in : Get the paged data.', DB_Error); return; } if (is_array($aPagedData['data']) && count($aPagedData['data'])) { $output->pager = ($aPagedData['totalItems'] <= $limit) ? false : true; $output->totalItems = $aPagedData['totalItems']; if ($output->catID > 1) { $output->currentCat = $output->catID; } elseif (!empty($output->gallery->category_id)) { $output->currentCat = $output->gallery->category_id; } else { $output->currentCat = 0; } $currentPage = $aPagedData['page_numbers']['current']; foreach($aPagedData['data'] as $key => $value) { $aPagedData['data'][$key]['detailsPage'] = ($currentPage - 1) * $limit + $key + 1; } } if ($input->catID) { $output->catFilter = true; } $output->aPagedData = $aPagedData; $output->thumbPath = $this->conf['imageUpload']['thumb']; $output->imagePath = $this->conf['imageUpload']['directory']; } function _cmd_details(& $input, & $output) { SGL::logMessage(null, PEAR_LOG_DEBUG); $output->template = 'galleryDetails.html'; $whereClause = ''; if ($input->catID) { $whereClause = ' WHERE category_id = "'.$input->catID.'" '; } $query = " SELECT * FROM {$this->conf['table']['gallery']} $whereClause ORDER BY item_order DESC"; $limit = 1; $pagerOptions = array( 'mode' => 'Sliding', 'delta' => 3, 'perPage' => $limit, 'totalItems'=> $input->totalItems, ); $aPagedData = SGL_DB::getPagedData($this->dbh, $query, $pagerOptions); $output->aPagedData = $aPagedData; $output->topCat = $input->catID; if (is_array($aPagedData['data']) && count($aPagedData['data'])) { $output->pager = ($aPagedData['totalItems'] <= $limit) ? false : true; $output->totalItems = $aPagedData['totalItems']; } $output->thumbPath = $this->conf['imageUpload']['thumb']; $output->imagePath = $this->conf['imageUpload']['directory']; } } ?>