From e88a313149cb39e187baf74a2fc18cc7c5d86d81 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Thu, 30 Nov 2017 12:59:49 +0100 Subject: [locationinfo] Reworked summary-panel to the new panel uuid stuff. --- modules-available/locationinfo/page.inc.php | 47 ++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 8 deletions(-) (limited to 'modules-available/locationinfo/page.inc.php') diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 30c38362..847dc73a 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -254,11 +254,14 @@ class Page_LocationInfo extends Page $params = $this->preparePanelConfigDefault(); } elseif ($paneltype === 'URL') { $params = $this->preparePanelConfigUrl(); + } elseif ($paneltype === 'SUMMARY') { + $params = $this->preparePanelConfigSummary(); } else { Message::addError('invalid-panel-type', $paneltype); Util::redirect('?do=locationinfo'); } + if ($paneluuid === 'new') { $paneluuid = Util::randomUuid(); $query = "INSERT INTO `locationinfo_panel` (paneluuid, panelname, locationids, paneltype, panelconfig, lastchange) @@ -320,6 +323,16 @@ class Page_LocationInfo extends Page return array('config' => $conf, 'locationids' => []); } + private function preparePanelConfigSummary() + { + // Check locations + $locationids = self::getLocationIdsFromRequest(true); + if (count($locationids) > 4) { + $locationids = array_slice($locationids, 0, 4); + } + return array('locationids' => $locationids); + } + /** * Updates the server settings in the db. */ @@ -832,7 +845,7 @@ class Page_LocationInfo extends Page 'url' => $config['url'], 'ssl_checked' => $config['insecure-ssl'] ? 'checked' : '', )); - } else { // TODO + } else { Render::addTemplate('page-config-panel-summary', array( 'new' => $id === 'new', 'uuid' => $id, @@ -862,19 +875,37 @@ class Page_LocationInfo extends Page Util::redirect($config['url']); } - $data = array( - 'uuid' => $uuid, - 'config' => json_encode($config), - 'language' => $config['language'], - ); - + $data = array(); preg_match('#^(.*)/#', $_SERVER['PHP_SELF'], $script); preg_match('#^([^?]+)/#', $_SERVER['REQUEST_URI'], $request); if ($script[1] !== $request[1]) { $data['dirprefix'] = $script[1] . '/'; } - echo Render::parse('frontend-default', $data); + if ($type === 'DEFAULT') { + $data += array( + 'uuid' => $uuid, + 'config' => json_encode($config), + 'language' => $config['language'], + ); + + die(Render::parse('frontend-default', $data)); + } + + if ($type === 'SUMMARY') { + $locations = LocationInfo::getLocationsOr404($uuid, false); + $config['tree'] = Location::getRecursive($locations); + $data += array( + 'uuid' => $uuid, + 'config' => json_encode($config), + 'language' => $config['language'], + ); + + die(Render::parse('frontend-summary', $data)); + } + + http_response_code(500); + die('Unknown panel type ' . $type); } } -- cgit v1.2.3-55-g7522