summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/controllers/BootmenuController.php22
-rw-r--r--application/forms/BootmenuEntriesAdd.php28
-rw-r--r--application/forms/BootmenuEntriesEdit.php24
-rw-r--r--application/models/BootMenuEntriesMapper.php21
-rw-r--r--application/views/scripts/bootmenu/index.phtml20
5 files changed, 77 insertions, 38 deletions
diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php
index 1b4bbfb..b7909b4 100644
--- a/application/controllers/BootmenuController.php
+++ b/application/controllers/BootmenuController.php
@@ -12,9 +12,10 @@ class BootmenuController extends Zend_Controller_Action
{
$bootmenumapper = new Application_Model_BootMenuMapper();
$bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper();
-
+ $bootosmapper = new Application_Model_BootOsMapper();
+
$this->view->bootmenulist = $bootmenumapper->fetchAll();
-
+
$bootmenuentries = array();
foreach ($this->view->bootmenulist as $bootmenu){
$bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID());
@@ -31,8 +32,8 @@ class BootmenuController extends Zend_Controller_Action
// $bootoslist = $this->arrayDiff($bootosmapper->fetchAll(), $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID));
if (!isset($_POST["addbootmenuentry"])){
- $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll()));
-
+ $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder')));
+ $addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder')));
} else {
$addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd($_POST);
@@ -41,9 +42,14 @@ class BootmenuController extends Zend_Controller_Action
$bootmenuentry = new Application_Model_BootMenuEntries($_POST);
$bootmenuentry->setBootmenuID($bootmenuID);
+
$bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper();
-
+
try {
+ if($bootmenuentry->getOrder() < $this->_request->getParam('maxorder')){
+ $bootmenuentry->setOrder($bootmenuentry->getOrder());
+ $bootmenuentrymapper->order($bootmenuentry);
+ }
$bootmenuentrymapper->save($bootmenuentry);
}catch(Zend_Exception $e)
{
@@ -92,7 +98,6 @@ class BootmenuController extends Zend_Controller_Action
public function editbootmenuAction()
{
$bootmenuID = $this->_request->getParam('bootmenuID');
-
if (!isset($_POST["editbootmenu"])){
$bootmenuID = $this->_request->getParam('bootmenuID');
if (!isset($bootmenuID) || !is_numeric($bootmenuID)){
@@ -148,7 +153,7 @@ class BootmenuController extends Zend_Controller_Action
$bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper();
$bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry);
- $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll()));
+ $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder')));
$editbootmenuentryForm->populate($bootmenuentry->toArray());
}
@@ -188,9 +193,10 @@ class BootmenuController extends Zend_Controller_Action
$this->_redirect('/bootmenu');
} else {
$bootmenuentry = new Application_Model_BootMenuEntries();
- $bootmenuentry->setID($bootmenuentryID);
$bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper();
+ $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry);
$bootmenuentrymapper->delete($bootmenuentry);
+ $bootmenuentrymapper->orderremove($bootmenuentry);
}
$this->_redirect('/bootmenu');
}
diff --git a/application/forms/BootmenuEntriesAdd.php b/application/forms/BootmenuEntriesAdd.php
index c18b54c..93b87f1 100644
--- a/application/forms/BootmenuEntriesAdd.php
+++ b/application/forms/BootmenuEntriesAdd.php
@@ -3,6 +3,7 @@
class Application_Form_BootmenuEntriesAdd extends Zend_Form
{
private $bootoslist;
+ private $maxorder;
public function init()
{
@@ -21,8 +22,8 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
$bootosfield = $this->createElement('select','bootosID');
$bootosfield ->setLabel('BootOs:');
- foreach($this->bootoslist as $bootos){
- $bootosfield->addMultiOption($bootos->getID(), $bootos->getTitle());
+ foreach($this->bootoslist as $bootos => $b){
+ $bootosfield->addMultiOption($b->getID(), $b->getTitle());
}
$bootosfield->setRegisterInArrayValidator(false);
$this->addElement($bootosfield);
@@ -45,15 +46,15 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
'label' => 'ConfigID:',
'value' => '1',
));
-
- $this->addElement('text', 'order', array(
- 'filters' => array('StringTrim'),
- 'validators' => array(
- array('StringLength', false, array(0, 50)),
- ),
- 'required' => true,
- 'label' => 'order:',
- ));
+
+ $orderfield = $this->createElement('select','order');
+ $orderfield ->setLabel('Order:');
+
+ for ($i = 0; $i <= $this->maxorder; $i++) {
+ $orderfield->addMultiOption($i, $i);
+ }
+ $orderfield->setRegisterInArrayValidator(false);
+ $this->addElement($orderfield);
$this->addElement('submit', 'addbootmenuentry', array(
'required' => false,
@@ -71,6 +72,11 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
$this->bootoslist = $bootoslist;
}
+
+ public function setMaxorder($maxorder){
+ $this->maxorder = $maxorder;
+
+ }
diff --git a/application/forms/BootmenuEntriesEdit.php b/application/forms/BootmenuEntriesEdit.php
index added01..042ae12 100644
--- a/application/forms/BootmenuEntriesEdit.php
+++ b/application/forms/BootmenuEntriesEdit.php
@@ -4,11 +4,17 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
{
private $bootoslist;
-
+ private $maxorder;
+
public function setBootoslist($bootoslist){
$this->bootoslist = $bootoslist;
}
+
+ public function setMaxorder($maxorder){
+ $this->maxorder = $maxorder;
+
+ }
public function init()
{
@@ -52,14 +58,14 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
'value' => '1',
));
- $this->addElement('text', 'order', array(
- 'filters' => array('StringTrim'),
- 'validators' => array(
- array('StringLength', false, array(0, 50)),
- ),
- 'required' => true,
- 'label' => 'order:',
- ));
+ $orderfield = $this->createElement('select','order');
+ $orderfield ->setLabel('Order:');
+
+ for ($i = 0; $i <= $this->maxorder; $i++) {
+ $orderfield->addMultiOption($i, $i);
+ }
+ $orderfield->setRegisterInArrayValidator(false);
+ $this->addElement($orderfield);
$this->addElement('submit', 'editbootmenuentry', array(
'required' => false,
diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php
index 346664c..a837dca 100644
--- a/application/models/BootMenuEntriesMapper.php
+++ b/application/models/BootMenuEntriesMapper.php
@@ -11,7 +11,8 @@ class Application_Model_BootMenuEntriesMapper
$db = Zend_Db_Table::getDefaultAdapter();
$select = $this->getDbTable()->select()
->from($this->_dbTable)
- ->where($criteria . ' = ?', $value);
+ ->where($criteria . ' = ?', $value)
+ ->order('order');
$stmt = $select->query();
$resultSet = $stmt->fetchAll();
@@ -67,6 +68,24 @@ class Application_Model_BootMenuEntriesMapper
}
}
+ public function order(Application_Model_BootMenuEntries $botmenuentries)
+ {
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` + 1 WHERE `order` >= ". $botmenuentries->getOrder() . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID());
+ }
+
+ public function orderremove(Application_Model_BootMenuEntries $botmenuentries)
+ {
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $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)
+ {
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $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()) ) {
diff --git a/application/views/scripts/bootmenu/index.phtml b/application/views/scripts/bootmenu/index.phtml
index a5c4fec..25edc53 100644
--- a/application/views/scripts/bootmenu/index.phtml
+++ b/application/views/scripts/bootmenu/index.phtml
@@ -10,7 +10,7 @@ tr.bootentry{background-color:#E0ECF8;}
<table border=1>
<tr>
-<!--<th>ID</th>-->
+ <th>ID</th>
<th>Title</th>
<th>GroupID</th>
<th>MembershipID</th>
@@ -18,7 +18,7 @@ tr.bootentry{background-color:#E0ECF8;}
</tr>
<?php foreach ($this->bootmenulist as $bootmenu): ?>
<tr class=bootmenu>
- <!--<td><?php echo $this->escape($bootmenu->getID()); ?></td>-->
+ <td><?php echo $this->escape($bootmenu->getID()); ?></td>
<td><?php echo $this->escape($bootmenu->getTitle()); ?></td>
<td><?php echo $this->escape($bootmenu->getGroupID()); ?></td>
<td><?php echo $this->escape($bootmenu->getMembershipID()); ?></td>
@@ -43,16 +43,17 @@ tr.bootentry{background-color:#E0ECF8;}
array(
'controller' => 'bootmenu',
'action' => 'addbootmenuentry',
- 'bootmenuID' => $bootmenu->getID()
+ 'bootmenuID' => $bootmenu->getID(),
+ 'maxorder' => count($this->bootmenuentrylist[$bootmenu->getID()])
),
'default',
true) ?>">Add Entry</a></td>
</tr>
<tr>
<th></th>
-<!--<th>ID</th>-->
+ <th>ID</th>
<th>Title</th>
-<!--<th>BootmenuID</th>-->
+<!-- <th>BootmenuID</th>-->
<th>BootOSID</th>
<th>kcl</th>
<th>ConfigID</th>
@@ -60,10 +61,10 @@ tr.bootentry{background-color:#E0ECF8;}
</tr>
<?php foreach ($this->bootmenuentrylist[$bootmenu->getID()] as $bootmenuentry): ?>
<tr class=bootentry><td class=nostyle></td>
- <!--<td><?php echo $this->escape($bootmenuentry->getID()); ?></td>-->
+ <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()); ?></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->getkcl()); ?></td>
<td><?php echo $this->escape($bootmenuentry->getConfigID()); ?></td>
<td><?php echo $this->escape($bootmenuentry->getOrder()); ?></td>
@@ -72,7 +73,8 @@ tr.bootentry{background-color:#E0ECF8;}
'controller' => 'bootmenu',
'action' => 'editbootmenuentry',
'bootmenuentryID' => $bootmenuentry->getID(),
- 'bootmenuID' => $bootmenu->getID()
+ 'bootmenuID' => $bootmenu->getID(),
+ 'maxorder' => count($this->bootmenuentrylist[$bootmenu->getID()])
),
'default',
true, false) ?>">Edit Entry</a></td>