summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael pereira2011-03-08 20:57:39 +0100
committermichael pereira2011-03-08 20:57:39 +0100
commit8f5309d8b3764d463f2a1c5da34eeb59261c2260 (patch)
tree4c9aceb27e40075316ef1124de2071e40e01e404
parentMerge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff)
downloadpbs2-8f5309d8b3764d463f2a1c5da34eeb59261c2260.tar.gz
pbs2-8f5309d8b3764d463f2a1c5da34eeb59261c2260.tar.xz
pbs2-8f5309d8b3764d463f2a1c5da34eeb59261c2260.zip
BootMenu Order fertig
-rw-r--r--application/controllers/BootmenuController.php16
-rw-r--r--application/controllers/BootosController.php2
-rw-r--r--application/forms/BootmenuEntriesAdd.php12
-rw-r--r--application/forms/BootmenuEntriesEdit.php14
-rw-r--r--application/models/BootMenuEntriesMapper.php11
-rw-r--r--application/models/BootOsMapper.php4
-rw-r--r--application/views/scripts/bootmenu/index.phtml7
7 files changed, 45 insertions, 21 deletions
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) . "<br/>";
diff --git a/application/controllers/BootosController.php b/application/controllers/BootosController.php
index 358204b..a644a5c 100644
--- a/application/controllers/BootosController.php
+++ b/application/controllers/BootosController.php
@@ -57,7 +57,7 @@ class BootosController extends Zend_Controller_Action
} else {
$bootos = new Application_Model_BootOs();
$bootosmapper = new Application_Model_BootOsMapper();
- $bootosmapper->find($bootosID, $bootos);
+ $bootos = $bootosmapper->find($bootosID);
$editbootosForm = new Application_Form_BootosEdit();
$editbootosForm->populate($bootos->toArray());
diff --git a/application/forms/BootmenuEntriesAdd.php b/application/forms/BootmenuEntriesAdd.php
index 93b87f1..9caa90f 100644
--- a/application/forms/BootmenuEntriesAdd.php
+++ b/application/forms/BootmenuEntriesAdd.php
@@ -22,9 +22,11 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
$bootosfield = $this->createElement('select','bootosID');
$bootosfield ->setLabel('BootOs:');
- foreach($this->bootoslist as $bootos => $b){
- $bootosfield->addMultiOption($b->getID(), $b->getTitle());
- }
+ if(count($this->bootoslist)>0){
+ foreach($this->bootoslist as $bootos => $b){
+ $bootosfield->addMultiOption($b->getID(), $b->getTitle());
+ }
+ }
$bootosfield->setRegisterInArrayValidator(false);
$this->addElement($bootosfield);
@@ -48,10 +50,10 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
));
$orderfield = $this->createElement('select','order');
- $orderfield ->setLabel('Order:');
+ $orderfield ->setLabel('Position:');
for ($i = 0; $i <= $this->maxorder; $i++) {
- $orderfield->addMultiOption($i, $i);
+ $orderfield->addMultiOption($i, $i+1);
}
$orderfield->setRegisterInArrayValidator(false);
$this->addElement($orderfield);
diff --git a/application/forms/BootmenuEntriesEdit.php b/application/forms/BootmenuEntriesEdit.php
index 042ae12..0aa2cdc 100644
--- a/application/forms/BootmenuEntriesEdit.php
+++ b/application/forms/BootmenuEntriesEdit.php
@@ -33,9 +33,11 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
$bootosfield = $this->createElement('select','bootosID');
$bootosfield ->setLabel('BootOs:');
- foreach($this->bootoslist as $bootos){
- $bootosfield->addMultiOption($bootos->getID(), $bootos->getTitle());
- }
+ if(count($this->bootoslist)>0){
+ foreach($this->bootoslist as $bootos => $b){
+ $bootosfield->addMultiOption($b->getID(), $b->getTitle());
+ }
+ }
$bootosfield->setRegisterInArrayValidator(false);
$this->addElement($bootosfield);
@@ -59,10 +61,10 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
));
$orderfield = $this->createElement('select','order');
- $orderfield ->setLabel('Order:');
+ $orderfield ->setLabel('Position:');
- for ($i = 0; $i <= $this->maxorder; $i++) {
- $orderfield->addMultiOption($i, $i);
+ for ($i = 0; $i < $this->maxorder; $i++) {
+ $orderfield->addMultiOption($i, $i+1);
}
$orderfield->setRegisterInArrayValidator(false);
$this->addElement($orderfield);
diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php
index a837dca..7a2da59 100644
--- a/application/models/BootMenuEntriesMapper.php
+++ b/application/models/BootMenuEntriesMapper.php
@@ -80,12 +80,20 @@ class Application_Model_BootMenuEntriesMapper
$stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` - 1 WHERE `order` > ". $botmenuentries->getOrder() . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID());
}
- public function orderedit(Application_Model_BootMenuEntries $botmenuentries, $oldval)
+ public function orderbefore(Application_Model_BootMenuEntries $botmenuentries, $oldval)
{
$db = Zend_Db_Table::getDefaultAdapter();
+ print_a($botmenuentries, $oldval);
$stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` + 1 WHERE `order` >= ". $botmenuentries->getOrder() . " AND `order` < " . $oldval . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID());
}
+ public function orderafter(Application_Model_BootMenuEntries $botmenuentries, $oldval)
+ {
+ $db = Zend_Db_Table::getDefaultAdapter();
+ print_a($botmenuentries, $oldval);
+ $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` - 1 WHERE `order` <= ". $botmenuentries->getOrder() . " AND `order` > " . $oldval . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID());
+ }
+
public function delete(Application_Model_BootMenuEntries $botmenuentries)
{
if (null === ($id = $botmenuentries->getID()) ) {
@@ -105,6 +113,7 @@ class Application_Model_BootMenuEntriesMapper
$row = $result->current();
$botmenuentries->setID($row->bootmenuentriesID)->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setOrder($row->order);
+
}
public function fetchAll()
diff --git a/application/models/BootOsMapper.php b/application/models/BootOsMapper.php
index 2f43916..a6e9a7f 100644
--- a/application/models/BootOsMapper.php
+++ b/application/models/BootOsMapper.php
@@ -64,8 +64,9 @@ class Application_Model_BootOsMapper
}
}
- public function find($id, Application_Model_BootOs $botos)
+ public function find($id)
{
+ $botos = new Application_Model_BootOs();
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
@@ -74,6 +75,7 @@ class Application_Model_BootOsMapper
$row = $result->current();
$botos->setID($row->bootosID)->setConfigID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_init($row->path_init)->setPath_kernel($row->path_kernel)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public);
+ return $botos;
}
public function fetchAll()
diff --git a/application/views/scripts/bootmenu/index.phtml b/application/views/scripts/bootmenu/index.phtml
index 25edc53..2c02b0c 100644
--- a/application/views/scripts/bootmenu/index.phtml
+++ b/application/views/scripts/bootmenu/index.phtml
@@ -64,17 +64,18 @@ tr.bootentry{background-color:#E0ECF8;}
<td><?php echo $this->escape($bootmenuentry->getID()); ?></td>
<td><?php echo $this->escape($bootmenuentry->getTitle()); ?></td>
<!--<td><?php echo $this->escape($bootmenuentry->getBootmenuID()); ?></td>
- --><td><?php echo "[".$this->escape($bootmenuentry->getBootosID()."]". $this->bootoslist); ?></td>
+ --><td><?php echo "[".$this->escape($bootmenuentry->getBootosID()."] ". $this->bootosmapper->find($bootmenuentry->getBootosID())->getTitle()); ?></td>
<td><?php echo $this->escape($bootmenuentry->getkcl()); ?></td>
<td><?php echo $this->escape($bootmenuentry->getConfigID()); ?></td>
- <td><?php echo $this->escape($bootmenuentry->getOrder()); ?></td>
+ <td><?php echo $this->escape($bootmenuentry->getOrder() + 1); ?></td>
<td><a href="<?php echo $this->url(
array(
'controller' => 'bootmenu',
'action' => 'editbootmenuentry',
'bootmenuentryID' => $bootmenuentry->getID(),
'bootmenuID' => $bootmenu->getID(),
- 'maxorder' => count($this->bootmenuentrylist[$bootmenu->getID()])
+ 'maxorder' => count($this->bootmenuentrylist[$bootmenu->getID()]),
+ 'oldorder' => $bootmenuentry->getOrder()
),
'default',
true, false) ?>">Edit Entry</a></td>