Module: appdb Branch: master Commit: 2772130cba777553c5f8abeec082f28d52e7a089 URL: http://source.winehq.org/git/appdb.git/?a=commit;h=2772130cba777553c5f8abeec...
Author: Alexander Nicolaysen Sørnes alex@thehandofagony.com Date: Thu Aug 6 13:47:35 2009 +0200
category: Make currently viewed category the default parent for new categories
---
include/category.php | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/include/category.php b/include/category.php index 45b8010..daab5be 100644 --- a/include/category.php +++ b/include/category.php @@ -313,12 +313,28 @@ class Category { return 0; }
- function outputEditor() + function objectGetCustomVars($sAction) + { + switch($sAction) + { + case 'add': + return array('iParentId'); + + default: + return null; + } + } + + function outputEditor($aValues = null) { $aCategories = category::getOrderedList(true); $aCatNames = array(); $aCatIds = array();
+ $iParentId = $this->iParentId; + if(!$iParentId && $aValues) + $iParentId = getInput('iParentId', $aValues); + foreach($aCategories as $oCategory) { $aCatNames[] = $oCategory->sName; @@ -341,7 +357,7 @@ class Category { <tr> <td width="15%" class="box-label"><b>Parent</b></td> <td class="box-body"> - ".html_select("iParentId",$aCatIds,$this->iParentId, $aCatNames)." + ".html_select("iParentId",$aCatIds,$iParentId, $aCatNames)." </td> </tr> </table>"; @@ -394,7 +410,7 @@ class Category { $oM = new objectManager('category', '', $this->iCatId); $oM->setReturnTo($this->objectMakeUrl()); echo "<p>\n"; - echo '<a href="'.$oM->makeUrl('add', null, 'Add Category').'">Add</a>'; + echo '<a href="'.$oM->makeUrl('add', null, 'Add Category')."&iParentId={$this->iCatId}">Add</a>";; if($this->iCatId) // We can't edit the 'Main' category { echo ' ';