diff options
| author | Simon | 2011-04-01 13:56:31 +0200 |
|---|---|---|
| committer | Simon | 2011-04-01 13:56:31 +0200 |
| commit | 0033cec593e82c39cac9b1d0de5c1f9f6f7209e1 (patch) | |
| tree | de1f68c58cdf0d0ab97c425251bf0d9923f0d9af /application/modules/user | |
| parent | Pagination in Bootiso (diff) | |
| download | pbs2-0033cec593e82c39cac9b1d0de5c1f9f6f7209e1.tar.gz pbs2-0033cec593e82c39cac9b1d0de5c1f9f6f7209e1.tar.xz pbs2-0033cec593e82c39cac9b1d0de5c1f9f6f7209e1.zip | |
pagination in Bootos & Bootiso
Diffstat (limited to 'application/modules/user')
5 files changed, 62 insertions, 30 deletions
diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php index 39341e9..a30ba05 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -64,6 +64,24 @@ class user_BootosController extends Zend_Controller_Action $this->view->bootoslist = $this->bootosMapper->findBy("groupID", $groupID); $this->view->update = array(); + + // Pagination + $perpage = 5; + $req_page = $this->_request->getParam('page'); + $all = count($this->view->bootoslist); + $numpages = ceil($all/$perpage); + if($req_page < 0 || !is_numeric($req_page) ) + $req_page = 0; + if($req_page >= $numpages) + $req_page = $numpages-1; + $startitem = $req_page * $perpage; + + $pagination = new Pbs_Pagination(); + $this->view->pagination = $pagination->pagination('/user/bootos/index',$req_page,$numpages); + $this->view->page = $req_page; + $this->view->bootoslist = array_slice($this->view->bootoslist,$startitem,$perpage); + + $update = $this->_request->getParam('checkupdate'); if(count($this->view->bootoslist)>0){ @@ -80,10 +98,11 @@ class user_BootosController extends Zend_Controller_Action public function createbootosAction() { + $page = $this->_request->getParam('page'); //TODO ACL Darf er BootISOs erstellen? if(false) - $this->_redirect('/user/bootos/index/addresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/addresult/forbidden'); $groupID = $this->membership->getGroupID(); @@ -139,12 +158,12 @@ class user_BootosController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/addresult/error'); + $this->_redirect('/user/bootos/index/page/'.$page.'/addresult/error'); //TODO Delete File & delete bootiso from DB } - $this->_redirect('/user/bootos/index/addresult/ok'); + $this->_redirect('/user/bootos/index/page/'.$page.'/addresult/ok'); } } @@ -153,10 +172,11 @@ class user_BootosController extends Zend_Controller_Action public function checkupdateAction($bootos) { + $page = $this->_request->getParam('page'); //TODO ACL Is he allowed to update Preboots? if(false) - $this->_redirect('/user/preboot/index/updateresult/forbidden'); + $this->_redirect('/user/preboot/index/page/'.$page.'/updateresult/forbidden'); $bootosID = $bootos->getID(); @@ -190,19 +210,20 @@ class user_BootosController extends Zend_Controller_Action public function updatebootosAction() { + $page = $this->_request->getParam('page'); //TODO ACL Is he allowed to update Preboots? if(false) - $this->_redirect('/user/bootiso/index/updateresult/forbidden'); + $this->_redirect('/user/bootiso/index/page/'.$page.'/updateresult/forbidden'); $bootosID = $this->_request->getParam('bootosID'); if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/updateresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/updateresult/forbidden'); $bootos = $this->bootosMapper->find($bootosID); if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/updateresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/updateresult/forbidden'); $initpath = "../resources/bootos/".$bootosID."/initramfs/"; $kernelpath = "../resources/bootos/".$bootosID."/kernel/"; @@ -213,25 +234,27 @@ class user_BootosController extends Zend_Controller_Action exec("wget -O '".$path_tmp."initramfs".$hash."' ".escapeshellcmd($bootos->getPath_init())." 2>&1 | grep 'saved'", $status2); if(!array_pop($status) || !array_pop($status2)){ - $this->_redirect('/user/bootos/index/updateresult/404'); + $this->_redirect('/user/bootos/index/page/'.$page.'/updateresult/404'); //TODO Delete Files in tmp } exec("mv ../resources/bootos/kernel$hash $kernelpath"."kernel"); exec("mv ../resources/bootos/initramfs$hash $initpath"."initramfs"); - $this->_redirect('/user/bootos/index/updateresult/ok'); + $this->_redirect('/user/bootos/index/page/'.$page.'/updateresult/ok'); } public function editbootosAction() { + $page = $this->_request->getParam('page'); + //TODO ACL Is he allowed to edit Preboots? if(false) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); $bootosID = $this->_request->getParam('bootosID'); if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); $groupID = $this->membership->getGroupID(); @@ -247,7 +270,7 @@ class user_BootosController extends Zend_Controller_Action $bootos = $this->bootosMapper->find($bootosID); if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); $bootosForm = new user_Form_Bootos(array('action' => 'editbootos', 'groupdepth' => $childgroups, 'configlist'=>$configlist, 'rights' => 'meta')); $bootosForm->populate($bootos->toArray()); @@ -274,13 +297,13 @@ class user_BootosController extends Zend_Controller_Action $bootos->getPublic() != $bootosold->getPublic() ){ //TODO ACL Is he allowed to edit this? if(false) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); } if($bootos->getPath_kernel() != $bootosold->getPath_kernel() || $bootos->getPath_init() != $bootosold->getPath_init()){ //TODO ACL Is he allowed to edit the Kernel/Init Path? if(false) - $this->_redirect('/user/bootos/index/modifyresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); $path_tmp = "../resources/bootos/"; @@ -314,11 +337,11 @@ class user_BootosController extends Zend_Controller_Action { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/modifyresult/error'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/error'); //TODO Delete Folder + Preboot } - $this->_redirect('/user/bootos/index/modifyresult/ok'); + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/ok'); } } @@ -329,21 +352,22 @@ class user_BootosController extends Zend_Controller_Action public function deletebootosAction() { + $page = $this->_request->getParam('page'); //TODO ACL Is he allowed to delete Bootos? if(false) - $this->_redirect('/user/bootos/index/deleteresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/forbidden'); try{ $bootosID = $this->_request->getParam('bootosID'); if (!is_numeric($bootosID)) - $this->_redirect('/user/bootos/index/deleteresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/forbidden'); $bootos = new Application_Model_BootOs(); $this->bootosMapper->find($bootosID, $bootos); if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/deleteresult/forbidden'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/forbidden'); $this->bootosMapper->delete($bootos); exec("rm -r ../resources/bootos/".$bootosID); @@ -351,9 +375,9 @@ class user_BootosController extends Zend_Controller_Action }catch(Zend_Exception $e){ echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; - $this->_redirect('/user/bootos/index/deleteresult/error'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/error'); } - $this->_redirect('/user/bootos/index/deleteresult/ok'); + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/ok'); } diff --git a/application/modules/user/forms/Bootiso.php b/application/modules/user/forms/Bootiso.php index f20179f..d080ac2 100644 --- a/application/modules/user/forms/Bootiso.php +++ b/application/modules/user/forms/Bootiso.php @@ -112,7 +112,7 @@ class user_Form_Bootiso extends Zend_Form )); $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/bootiso"' + 'onclick' => 'self.location="/user/bootiso/page/'.$this->page.'"' )); $this->addElement('hidden','page', array( diff --git a/application/modules/user/forms/Bootos.php b/application/modules/user/forms/Bootos.php index 5fa890a..3e45f05 100644 --- a/application/modules/user/forms/Bootos.php +++ b/application/modules/user/forms/Bootos.php @@ -7,6 +7,7 @@ class user_Form_Bootos extends Zend_Form private $action; private $rights; private $groupdepth; + private $page; public function setRights($rights){ $this->rights = $rights; @@ -22,6 +23,9 @@ class user_Form_Bootos extends Zend_Form public function setGroupdepth($groupdepth){ $this->groupdepth = $groupdepth; } + public function setPage($page){ + $this->page = $page; + } public function init() { @@ -139,7 +143,7 @@ class user_Form_Bootos extends Zend_Form )); $this->addElement('button', 'Cancel', array( - 'onclick' => 'self.location="/user/bootos"' + 'onclick' => 'self.location="/user/bootos/page/'.$this->page.'"' )); ?> diff --git a/application/modules/user/views/scripts/bootiso/index.phtml b/application/modules/user/views/scripts/bootiso/index.phtml index ce0d8ce..c41d8d2 100644 --- a/application/modules/user/views/scripts/bootiso/index.phtml +++ b/application/modules/user/views/scripts/bootiso/index.phtml @@ -36,7 +36,7 @@ 'action' => 'downloadbootiso', 'prebootID' => $bootiso->getprebootID(), 'bootisoID' => $bootiso->getID(), - 'page' => $this->page + 'page' => $this->page ), 'default', true, false) ?>"><img src='/media/img/download.png' alt='Download BootMedium' /></a></td> @@ -46,7 +46,7 @@ 'controller' => 'bootiso', 'action' => 'editbootiso', 'bootisoID' => $bootiso->getID(), - 'page' => $this->page + 'page' => $this->page ), 'default', true, false) ?>"><img src='/media/img/edit.png' alt='Edit BootISO' /></a></td> @@ -56,7 +56,7 @@ 'controller' => 'bootiso', 'action' => 'deletebootiso', 'bootisoID' => $bootiso->getID(), - 'page' => $this->page + 'page' => $this->page ), 'default', true) ?>"><img src='/media/img/delete.png' alt='Delete BootISO'/></a></td> diff --git a/application/modules/user/views/scripts/bootos/index.phtml b/application/modules/user/views/scripts/bootos/index.phtml index 53d219f..92e6bbb 100644 --- a/application/modules/user/views/scripts/bootos/index.phtml +++ b/application/modules/user/views/scripts/bootos/index.phtml @@ -1,7 +1,7 @@ <h1>BootOS</h1> <?php if($this->notification != ''){echo $this->notification;} ?> <?php echo $this->formButton('checkupdate', 'Check for Updates', array( - 'onclick' => 'self.location="/user/bootos/index/checkupdate/true"', + 'onclick' => 'self.location="/user/bootos/index/page/'.$this->page.'/checkupdate/true"', 'class' => 'updatebutton', ))?> <?php echo $this->formButton('createbootos', 'Create BootOS', array( @@ -47,7 +47,8 @@ 'module' => 'user', 'controller' => 'bootos', 'action' => 'updatebootos', - 'bootosID' => $bootos->getID() + 'bootosID' => $bootos->getID(), + 'page' => $this->page ), 'default', true, false) ?>"><img src='/media/img/update.png' alt='Updates available' /></a></td> @@ -60,7 +61,8 @@ 'module' => 'user', 'controller' => 'bootos', 'action' => 'editbootos', - 'bootosID' => $bootos->getID() + 'bootosID' => $bootos->getID(), + 'page' => $this->page ), 'default', true, false) ?>"><img src='/media/img/edit.png' alt='Edit BootOS' /></a></td> @@ -70,13 +72,15 @@ 'module' => 'user', 'controller' => 'bootos', 'action' => 'deletebootos', - 'bootosID' => $bootos->getID() + 'bootosID' => $bootos->getID(), + 'page' => $this->page ), 'default', true) ?>"><img src='/media/img/delete.png' alt='Delete BootOS' /></a></td> </tr> <?php endforeach; ?> </table> +<?php echo $this->pagination; ?> |
