Rename Categories class get function to getCategories

This commit is contained in:
DariusIII
2016-02-16 16:20:04 +01:00
parent 05b80a88c3
commit 259b272e5d
3 changed files with 18 additions and 16 deletions
+1
View File
@@ -1,4 +1,5 @@
2016-02-16 DariusIII
Chg: Rename Categories class get function to getCategories
Fix: Prevent errors when pagertotalcount is not set
Chg: Move showApiError function to Utility class, adjust pages that use it.
2016-02-13 DariusIII
+16 -15
View File
@@ -404,7 +404,7 @@ class Category
*/
public function getForSelect($blnIncludeNoneSelected = true)
{
$categories = $this->get();
$categories = $this->getCategories();
$temp_array = [];
if ($blnIncludeNoneSelected) {
@@ -418,27 +418,28 @@ class Category
}
/**
* Get a list of categories.
* Get array of categories in DB.
*
* @param bool $activeonly
* @param array $excludedcats
*
* @return array
*/
public function get($activeonly = false, $excludedcats = [])
public function getCategories($activeonly = false, $excludedcats = [])
{
$exccatlist = "";
if (count($excludedcats) > 0)
$exccatlist = " and c.id not in (" . implode(",", $excludedcats) . ")";
$act = "";
if ($activeonly)
$act = sprintf(" where c.status = %d ", Category::STATUS_ACTIVE);
if ($exccatlist != "")
$act .= $exccatlist;
return $this->pdo->query("select c.id, concat(cp.title, ' > ',c.title) as title, cp.id as parentid, c.status from category c inner join category cp on cp.id = c.parentid " . $act . " ORDER BY c.id", true);
return $this->pdo->query(
"SELECT c.id, CONCAT(cp.title, ' > ',c.title) AS title, cp.id AS parentid, c.status, c.minsize
FROM category c
INNER JOIN category cp ON cp.id = c.parentid " .
($activeonly ?
sprintf(
" WHERE c.status = %d %s ",
Category::STATUS_ACTIVE,
(count($excludedcats) > 0 ? " AND c.id NOT IN (" . implode(",", $excludedcats) . ")" : '')
) : ''
) .
" ORDER BY c.id"
);
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ if (!isset($_GET["t"]) && !isset($_GET["show"]) && !isset($_GET["anidb"])) {
}
$page->smarty->assign([
'categorylist' => $category->get(true, $page->userdata["categoryexclusions"]),
'categorylist' => $category->getCategories(true, $page->userdata["categoryexclusions"]),
'parentcategorylist' => $category->getForMenu($page->userdata["categoryexclusions"])
]
);