summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/page.inc.php
diff options
context:
space:
mode:
authorJannik Schönartz2017-11-30 12:59:49 +0100
committerJannik Schönartz2017-11-30 12:59:49 +0100
commite88a313149cb39e187baf74a2fc18cc7c5d86d81 (patch)
treef2019cc85e1ff50d0708cb4828357b2d7e6f1d7a /modules-available/locationinfo/page.inc.php
parent[inc/Database] Do EXPLAIN SELECT at shutdown so we don't interfere with SQL_C... (diff)
downloadslx-admin-e88a313149cb39e187baf74a2fc18cc7c5d86d81.tar.gz
slx-admin-e88a313149cb39e187baf74a2fc18cc7c5d86d81.tar.xz
slx-admin-e88a313149cb39e187baf74a2fc18cc7c5d86d81.zip
[locationinfo] Reworked summary-panel to the new panel uuid stuff.
Diffstat (limited to 'modules-available/locationinfo/page.inc.php')
-rw-r--r--modules-available/locationinfo/page.inc.php47
1 files changed, 39 insertions, 8 deletions
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);
}
}