Alexander Nicolaysen Sørnes : category: Order cat list on add/edit form
Alexander Nicolaysen Sørnes
asornes at winehq.org
Sat Jul 4 05:39:53 CDT 2009
Module: appdb
Branch: master
Commit: 8060eab22a49167dd290db0037df262eae56b192
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=8060eab22a49167dd290db0037df262eae56b192
Author: Alexander Nicolaysen Sørnes <alexander at linux-xqqm.site>
Date: Thu Jul 2 23:27:50 2009 +0200
category: Order cat list on add/edit form
---
include/category.php | 31 ++++++++++++++++++-------------
1 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/include/category.php b/include/category.php
index c0c6bc1..dc51bd4 100644
--- a/include/category.php
+++ b/include/category.php
@@ -160,11 +160,20 @@ class Category {
}
/* Get all category objects, ordered and with category names indented
- according to subcategory level */
- static function getOrderedList()
+ according to subcategory level.
+ Optionally includes the 'Main' top category. */
+ static function getOrderedList($bIncludeMain = false)
{
$oCat = new category();
- return $oCat->getSubCatList(0);
+
+ if(!$bIncludeMain)
+ return $oCat->getSubCatList(0);
+
+ $oCat->sName = 'Main';
+ $aCats = array($oCat);
+ $aCats += $oCat->getSubCatList(1);
+
+ return $aCats;
}
function objectGetMail($sAction, $bMailSubmitter, $bParentAction)
@@ -278,18 +287,14 @@ class Category {
function outputEditor()
{
- $sQuery = "SELECT catId, catName FROM appCategory WHERE catId!='?'";
- $hResult = query_parameters($sQuery, $this->iCatId);
-
- /* Add the virtual 'Main' category */
- $aCatIds = array(0);
- $aCatNames = array('Main');
+ $aCategories = category::getOrderedList(true);
+ $aCatNames = array();
+ $aCatIds = array();
- /* Add the rest from the database */
- while($oRow = query_fetch_object($hResult))
+ foreach($aCategories as $oCategory)
{
- $aCatIds[] = $oRow->catId;
- $aCatNames[] = $oRow->catName;
+ $aCatNames[] = $oCategory->sName;
+ $aCatIds[] = $oCategory->objectGetId();
}
echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
More information about the wine-cvs
mailing list