function view($id, $params) { global $my, $mainframe, $database, $option, $priTask, $subTask; global $WBG_CONFIG, $wbGalleryDB_cat; $limit = (int) mosGetParam($_REQUEST, 'limit', $params->get('list_limit', $mainframe->getCfg('list_limit', 15))); $limitstart = (int) mosGetParam($_REQUEST, 'limitstart', 0); $page = (int) mosGetParam($_REQUEST, 'page', 0); // No ID.. Do we have a Parameter? if (!$id) { $id = $params->get('cid', 0); } // Ahh.. Page Defined... SEF is Talking if ($page) { $limitstart = $limit * ($page - 1); } // Load Category $row = new wbGalleryDB_cat($database); $row->load($id); if ($row->id && $row->access > $my->gid) { mosNotAuth(); return; } // Load Sub Categories $query = "\r\n SELECT c.*, COUNT(DISTINCT sc.id) AS total_subcats\r\n FROM #__wbgallery_cat AS c\r\n LEFT JOIN #__wbgallery_cat AS sc ON (sc.parent_id = c.id AND c.published = 1)\r\n WHERE c.parent_id = " . (int) $id . "\r\n AND c.published = 1\r\n AND c.access <= " . (int) $my->gid . "\r\n GROUP BY c.id\r\n ORDER BY c.ordering ASC\r\n "; $database->setQuery($query); $subcats = $database->loadObjectList(); echo $database->getErrorMsg(); // Load Sub Category Thumbnails ( if not already found ) for ($i = 0; $i < count($subcats); $i++) { if (!$sc->file) { $imgData = $wbGalleryDB_cat->getSubCatImg($subcats[$i]->id); $subcats[$i]->img_id = $imgData->img_id; $subcats[$i]->img_file = $imgData->img_file; $subcats[$i]->img_name = $imgData->img_name; } } // Count Images $database->setQuery("\r\n SELECT COUNT(DISTINCT i.id)\r\n FROM #__wbgallery_img AS i\r\n WHERE i.cat_id = " . (int) $id . "\r\n AND i.published = 1\r\n "); $total = $database->loadResult(); // Load Images $database->setQuery("\r\n SELECT i.*\r\n FROM #__wbgallery_img AS i\r\n WHERE i.cat_id = " . (int) $id . "\r\n AND i.published = 1\r\n ORDER BY i.ordering ASC\r\n LIMIT {$limitstart}, {$limit}\r\n "); $images = $database->loadObjectList(); echo $database->getErrorMsg(); // Page Navigation require_once $mainframe->getCfg('absolute_path') . '/includes/pageNavigation.php'; $pageNav = new mosPageNav($total, $limitstart, $limit); wbGallery_cat_html::view($row, $subcats, $images, $pageNav, $params); }
function edit($id) { global $my, $mainframe, $database, $option, $priTask, $subTask; global $WBG_CONFIG, $wbGalleryDB_cat; $row = new wbGalleryDB_cat($database); $row->load($id); if (!$row->id) { $row->published = 1; } $lists = array(); $catTree = $wbGalleryDB_cat->getCategoryTree(); $tList = array(mosHTML::makeOption('0', 'No Parent...', 'id', 'name')); $tList = array_merge($tList, $catTree); $lists['parent_id'] = mosHTML::selectList($tList, 'parent_id', '', 'id', 'name', (int) $row->parent_id); $lists['published'] = mosHTML::yesnoRadioList('published', '', (int) $row->published); $lists['access'] = mosAdminMenus::Access($row); wbGallery_cat_html::edit($row, $lists); }