From 8f5309d8b3764d463f2a1c5da34eeb59261c2260 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Tue, 8 Mar 2011 20:57:39 +0100 Subject: BootMenu Order fertig --- application/controllers/BootmenuController.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index b7909b4..41cee9d 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -14,12 +14,14 @@ class BootmenuController extends Zend_Controller_Action $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); $bootosmapper = new Application_Model_BootOsMapper(); + $this->view->bootosmapper = $bootosmapper; $this->view->bootmenulist = $bootmenumapper->fetchAll(); $bootmenuentries = array(); foreach ($this->view->bootmenulist as $bootmenu){ $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); } + $this->view->bootmenuentrylist = $bootmenuentries; } @@ -143,18 +145,18 @@ class BootmenuController extends Zend_Controller_Action $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); $bootmenuID = $this->_request->getParam('bootmenuID'); $bootosmapper = new Application_Model_BootOsMapper(); + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); if (!isset($_POST["editbootmenuentry"])){ $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){ $this->_redirect('/bootmenu'); } else { - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); - + $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'))); - $editbootmenuentryForm->populate($bootmenuentry->toArray()); } }else{ @@ -170,7 +172,13 @@ class BootmenuController extends Zend_Controller_Action $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); try { + if($bootmenuentry->getOrder() < $this->_request->getParam('oldorder')) + $bootmenuentrymapper->orderbefore($bootmenuentry, $this->_request->getParam('oldorder')); + else + $bootmenuentrymapper->orderafter($bootmenuentry, $this->_request->getParam('oldorder')); + $bootmenuentrymapper->save($bootmenuentry); + }catch(Zend_Exception $e) { echo "Caught exception: " . get_class($e) . "
"; -- cgit v1.2.3-55-g7522