From 624cbcae5c9b5bcedf03c77460b07eb20fbb2366 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 20 Apr 2011 13:08:33 +0200 Subject: Automatischer Start nach x Sekunden hinzugefügt --- application/controllers/ErrorController.php | 4 +- application/models/BootMenu.php | 10 ++++ application/models/BootMenuMapper.php | 26 ++++++++-- .../modules/fbgui/controllers/IndexController.php | 1 + .../modules/fbgui/views/scripts/index/index.phtml | 55 +++++++++++++++++++++- .../user/controllers/BootmenuController.php | 2 +- application/modules/user/forms/Bootmenu.php | 8 ++++ .../user/views/scripts/bootmenu/index.phtml | 3 +- setup/pbs.sql | 2 + 9 files changed, 101 insertions(+), 10 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index efee141..abf3ec1 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -26,13 +26,13 @@ class ErrorController extends Zend_Controller_Action $this->getResponse()->setHttpResponseCode(404); $this->view->message = 'Page not found'; $this->_redirect('/user/'); - #print_a($errors); + # print_a($errors); break; default: // application error $this->getResponse()->setHttpResponseCode(500); $this->view->message = 'Application error - Please contact the admin'; - #print_a($errors); + # print_a($errors); break; } diff --git a/application/models/BootMenu.php b/application/models/BootMenu.php index 82e771a..dae3776 100644 --- a/application/models/BootMenu.php +++ b/application/models/BootMenu.php @@ -16,6 +16,7 @@ class Application_Model_BootMenu protected $_membershipID; protected $_groupID; protected $_title; + protected $_startcounter; protected $_created; protected $_defaultbootmenu; @@ -96,6 +97,15 @@ class Application_Model_BootMenu { return $this->_created; } + public function setStartcounter($_startcounter) + { + $this->_startcounter = $_startcounter; + return $this; + } + public function getStartcounter() + { + return $this->_startcounter; + } public function setCreated($_created) { $this->_created = $_created; diff --git a/application/models/BootMenuMapper.php b/application/models/BootMenuMapper.php index 8b39a5a..6ba72bd 100644 --- a/application/models/BootMenuMapper.php +++ b/application/models/BootMenuMapper.php @@ -84,7 +84,13 @@ class Application_Model_BootMenuMapper public function save(Application_Model_BootMenu $botmenu) { - $data = array('bootmenuID'=> $botmenu->getID() ,'membershipID'=> $botmenu->getMembershipID(), 'groupID'=> $botmenu->getGroupID() ,'title'=> $botmenu->getTitle() ,'created'=> $botmenu->getCreated(), 'defaultbootmenu' => $botmenu->getDefaultbootmenu()); + $data = array('bootmenuID'=> $botmenu->getID() , + 'membershipID'=> $botmenu->getMembershipID(), + 'groupID'=> $botmenu->getGroupID() , + 'title'=> $botmenu->getTitle() , + 'startcounter'=> $botmenu->getStartcounter() , + 'created'=> $botmenu->getCreated(), + 'defaultbootmenu' => $botmenu->getDefaultbootmenu()); if (null === ($id = $botmenu->getID()) ) { unset($data['bootmenuID']); @@ -113,10 +119,22 @@ class Application_Model_BootMenuMapper if($botmenu == null){ $botmenu = new Application_Model_BootMenu(); - $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created)->setDefaultbootmenu($row->defaultbootmenu); + $botmenu->setID($row->bootmenuID) + ->setMembershipID($row->membershipID) + ->setGroupID($row->groupID) + ->setTitle($row->title) + ->setStartcounter($row->startcounter) + ->setCreated($row->created) + ->setDefaultbootmenu($row->defaultbootmenu); return $botmenu; }else{ - $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created)->setDefaultbootmenu($row->defaultbootmenu); + $botmenu->setID($row->bootmenuID) + ->setMembershipID($row->membershipID) + ->setGroupID($row->groupID) + ->setTitle($row->title) + ->setStartcounter($row->startcounter) + ->setCreated($row->created) + ->setDefaultbootmenu($row->defaultbootmenu); } @@ -129,7 +147,7 @@ class Application_Model_BootMenuMapper foreach ($resultSet as $row) { $entry = new Application_Model_BootMenu(); - $entry->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created)->setDefault($row->default); + $entry->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setStartcounter($row->startcounter)->setCreated($row->created)->setDefault($row->default); $entries[] = $entry; } diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index 17d9337..150f1c5 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -117,6 +117,7 @@ class Fbgui_IndexController extends Zend_Controller_Action $bootmenuMapper = new Application_Model_BootMenuMapper(); $bm = $bootmenuMapper->find($bootmenuID); $this->view->title = $bm->getTitle(); + $this->view->startcounter = $bm->getStartcounter(); $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); diff --git a/application/modules/fbgui/views/scripts/index/index.phtml b/application/modules/fbgui/views/scripts/index/index.phtml index 2454d45..8a5f0e6 100644 --- a/application/modules/fbgui/views/scripts/index/index.phtml +++ b/application/modules/fbgui/views/scripts/index/index.phtml @@ -26,6 +26,9 @@ }); $(function() { + $(document).click(function(){ + abortStartcount = true; + }) $(document).keyup(function (event) { if (event.keyCode == 38) { // up @@ -41,9 +44,29 @@ // Down $('#startbutton').click(); } + abortStartcount = true; }); }); + decreaseDown(); }); + function decreaseDown(){ + var act = parseInt($('.startcounter').html()); + if(act == 0){ + start(); + return; + } + var next = act-1; + $('.startcounter').html(next); + if(next == 0){ + start(); + } + if(next > 0 && abortStartcount == false){ + setTimeout('decreaseDown()',1000); + } + if(abortStartcount == true){ + $('.startcounter').parent().fadeOut(); + } + } function start(){ if($('#selectedBootOs').val() != ''){ if($('#selectedBootOs').val() == 'login'){ @@ -79,6 +102,7 @@