function pathway(&$row, $level = 0) { global $mainframe, $database, $option, $wbgItemid; global $wbGalleryDB_cat, $wbGallery_menuParamsCache, $WBG_LANG; if (!is_object($row) || !$row->id) { if (is_object($wbGallery_menuParamsCache)) { $page_title = $wbGallery_menuParamsCache->get('wbg_title'); } if (!strlen($page_title)) { $page_title = $WBG_LANG->_('VIEW_CATEGORY_GEN'); } $mainframe->appendPathWay($page_title, 'index.php?option=' . $option . '&Itemid=' . $wbgItemid); return; } $p_row = new wbGalleryDB_cat($database); if ($row->cat_id) { $p_row->load($row->cat_id); } elseif ($row->parent_id) { $p_row->load($row->parent_id); } if ($p_row->id) { $this->pathway($p_row, $level + 1); } if (defined('_JEXEC')) { if ($row->cat_id) { // is image $mainframe->appendPathWay($row->name, sefRelToAbs('index.php?option=' . $option . '&id=' . $row->id . '&Itemid=' . $wbgItemid)); } else { // is category $mainframe->appendPathWay($row->name, sefRelToAbs('index.php?option=' . $option . '&cid=' . $row->id . '&Itemid=' . $wbgItemid)); } } elseif ($level) { $mainframe->appendPathWay('<a href="' . sefRelToAbs('index.php?option=' . $option . '&cid=' . $row->id . '&Itemid=' . $wbgItemid) . '">' . $row->name . '</a>'); } else { $mainframe->appendPathWay($row->name); } }
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 view($id, $params) { global $my, $mainframe, $database, $option, $priTask, $subTask; global $WBG_CONFIG, $wbGalleryDB_cat; if (!$id) { $id = $params->get('id', 0); } // Load Image $row = new wbGalleryDB_img($database); $row->load($id); if (!$row->id) { echo "<script> alert('Image Not Found'); window.history.go(-1); </script>\n"; exit; } // Track Hit $row->hit(); // Load Category if ($row->cat_id != '0') { $cat = new wbGalleryDB_cat($database); $cat->load($row->cat_id); if (!$cat->id) { echo "<script> alert('Category Not Found'); window.history.go(-1); </script>\n"; exit; } if ($cat->access > $my->gid) { mosNotAuth(); exit; } } // Load Prev / Next $neighbors = $row->getNeighbors(); // Load Related Images $database->setQuery("\r\r\n SELECT i.*\r\r\n FROM #__wbgallery_img AS i\r\r\n WHERE i.cat_id = " . (int) $row->cat_id . "\r\r\n AND i.id != " . (int) $row->id . "\r\r\n AND i.published = 1\r\r\n ORDER BY i.hits DESC\r\r\n , i.ordering ASC\r\r\n LIMIT 0, " . $params->get('related_list_limit', $mainframe->getCfg('list_limit', 15)) . "\r\r\n "); $related = $database->loadObjectList(); echo $database->getErrorMsg(); wbGallery_img_html::view($row, $cat, $neighbors, $related, $params); }
function move($cid, $redirect = true) { global $my, $mainframe, $database, $option, $priTask, $subTask; global $WBG_CONFIG, $wbGalleryDB_cat; $row = new wbGalleryDB_img($database); $cat = new wbGalleryDB_cat($database); $moveid = mosGetParam($_REQUEST, 'moveid', 0); if ($moveid) { $cat->load($moveid); } if ($moveid != $cat->id) { echo "<script> alert('The Destination Category is Not Valid'); </script>\n"; return $this->manage(); } if (!count($cid)) { echo "<script> alert('Please Select Image(s) to move.'); </script>\n"; return $this->manage(); } foreach ($cid as $id) { $row->load($id); $row->cat_id = $moveid; $row->store(); } if ($redirect) { mosRedirect('index2.php?option=' . $option . '&task=image', 'Selected items have been moved'); } else { return true; } }
function order($cid) { global $my, $mainframe, $database, $option, $priTask, $subTask; global $WBG_CONFIG, $wbGalleryDB_cat; $order = mosGetParam($_POST, 'order', array(0)); $row = new wbGalleryDB_cat($database); $conditions = array(); for ($i = 0, $n = count($cid); $i < $n; $i++) { $row->load($cid[$i]); if ($row->ordering != $order[$i]) { $row->ordering = $order[$i]; if (!$row->store()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; exit; } $found = false; $condition = "parent_id = '" . $row->parent_id . "'"; for ($j = 0, $k = count($conditions); $j < $k; $j++) { $cond = $conditions[$j]; if ($cond[1] == $condition) { $found = true; break; } } if (!$found) { $conditions[] = array($row->id, $condition); } } } for ($i = 0, $n = count($conditions); $i < $n; $i++) { $condition = $conditions[$i]; $row->load($condition[0]); $row->updateOrder($condition[1]); } mosRedirect('index2.php?option=' . $option . '&task=category'); }