Alexander Nicolaysen Sørnes : objectManager: Restructure some form processing code
Chris Morgan
cmorgan at winehq.org
Mon Nov 5 20:31:57 CST 2007
Module: appdb
Branch: master
Commit: 5db7f0f7fb4f6b77715c5bb467193e67e82aa68b
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=5db7f0f7fb4f6b77715c5bb467193e67e82aa68b
Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date: Mon Nov 5 17:41:11 2007 +0100
objectManager: Restructure some form processing code
---
objectManager.php | 42 ++++++++++++++++++++++++++++++------------
1 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/objectManager.php b/objectManager.php
index 4b74ac2..46894d8 100644
--- a/objectManager.php
+++ b/objectManager.php
@@ -75,15 +75,28 @@ $oOtherObject = new $sClass($oObject->getId());
on failure */
$sErrors = $oObject->processForm($aClean);
-if(isset($aClean['sAction']) && $aClean['sAction'] == "add")
- $oObject->handle_anonymous_submission();
-
-/* Provided the necessary values are present, an object's children may be moved
- without any confirmation */
-if($oObject->getId() && $aClean['sAction'] == "moveChildren" && $aClean['iNewId'])
- $oObject->move_children($aClean['iNewId']);
+if(array_key_exists("sAction", $aClean))
+ $sAction = $aClean['sAction'];
+else
+ $sAction = "";
-$sAction = $aClean['sAction'];
+/* Handle things that need to be done before showing any output */
+if($sAction)
+{
+ switch($aClean['sAction'])
+ {
+ case 'add':
+ $oObject->handle_anonymous_submission();
+ break;
+
+ case 'moveChildren':
+ /* Provided the necessary values are present, an object's children may be moved
+ without any confirmation */
+ if($oObject->getId() && $aClean['iNewId'])
+ $oObject->move_children($aClean['iNewId']);
+ break;
+ }
+}
/* If no action is specified, use a default depending on other parameters */
if(!$sAction)
@@ -119,12 +132,17 @@ if($oObject->getId() && $sAction != "add")
$oObject->view($_SERVER['REQUEST_URI'], $aClean);
break;
}
-} else if ($sAction == "add")
-{
- $oObject->add_entry($aClean, $sErrors);
} else
{
- $oObject->display_table($aClean);
+ switch($sAction)
+ {
+ case 'add':
+ $oObject->add_entry($aClean, $sErrors);
+ break;
+
+ default:
+ $oObject->display_table($aClean);
+ }
}
apidb_footer();
More information about the wine-cvs
mailing list