From d5b6e16ccddf759414fd4d54e3850f5d38922680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Thu, 15 May 2014 15:13:30 +0200 Subject: [PATCH] fixed paging --- application/core/Admin/AdminLists.php | 30 +++++++++------------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/application/core/Admin/AdminLists.php b/application/core/Admin/AdminLists.php index dabf39cd..ec2866a6 100644 --- a/application/core/Admin/AdminLists.php +++ b/application/core/Admin/AdminLists.php @@ -81,11 +81,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight(); // get Admins - $admins = $this->maniaControl->authenticationManager->getAdmins(); - $pagesId = ''; - if (count($admins) > self::MAX_PLAYERS_PER_PAGE) { - $pagesId = 'AdminListPages'; - } + $admins = $this->maniaControl->authenticationManager->getAdmins(); //Create ManiaLink $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); @@ -94,7 +90,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $script->addFeature($paging); // Main frame - $frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $pagesId); + $frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $paging); $maniaLink->add($frame); // Start offsets @@ -112,21 +108,18 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Actions" => $x + 120); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); - $i = 1; - $y = $y - 10; - $pageFrames = array(); + $i = 1; + $y = $y - 10; + $pageFrame = null; + foreach ($admins as $admin) { - if (!isset($pageFrame)) { + if ($i % self::MAX_PLAYERS_PER_PAGE === 1) { $pageFrame = new Frame(); $frame->add($pageFrame); - if (!empty($pageFrames)) { - $pageFrame->setVisible(false); - } - array_push($pageFrames, $pageFrame); - $y = $height / 2 - 10; - $paging->addPage($pageFrame); - } + $paging->addPage($pageFrame); + $y = $height / 2 - 10; + } $playerFrame = new Frame(); $pageFrame->add($playerFrame); @@ -192,9 +185,6 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $y -= 4; $i++; - if (($i - 1) % self::MAX_PLAYERS_PER_PAGE == 0) { - unset($pageFrame); - } } // Render and display xml