diff options
| author | Simon Rettberg | 2025-07-18 16:35:46 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2025-07-18 16:35:46 +0200 |
| commit | a8d23f91f6cfd803be1ecaae4c8d1b5e1268a699 (patch) | |
| tree | 58e3abdb7b915a5be041071c8a3324828ea596cf | |
| parent | [locationinfo] Add UPCOMING panel type (diff) | |
| download | slx-admin-a8d23f91f6cfd803be1ecaae4c8d1b5e1268a699.tar.gz slx-admin-a8d23f91f6cfd803be1ecaae4c8d1b5e1268a699.tar.xz slx-admin-a8d23f91f6cfd803be1ecaae4c8d1b5e1268a699.zip | |
[locationinfo] Parametrize panel type configuration
Avoids a lot of copy and paste and duplicate work in php and html
part, for example explicitly handling every config variable for
a specific panel when displaying the config dialog, when saving the
config, and when loading the config for displaying the panel.
This also parametrizes enums, limits and ranges, so dropdowns
can be rendered automatically, validity of selected option can
be checked, and putting numeric settings into bounds all happens
generically.
Edit dialog for DEFAULT panel is still completely custom, as it has
too much special sauce going on with the room config overrides.
URL-panel is half-half, but SUMMARY and UPCOMING are entirely generic
now.
14 files changed, 540 insertions, 943 deletions
diff --git a/inc/request.inc.php b/inc/request.inc.php index 0b0600da..7edb8140 100644 --- a/inc/request.inc.php +++ b/inc/request.inc.php @@ -123,7 +123,14 @@ class Request } foreach ($params as $type => $list) { foreach ($list as $field => $limits) { - $default = $limits['default'] ?? false; + if ($type === 'bool') { + // An unchecked checkbox will not have its key in the post data, so self::handle would fall back + // to the default value. If the default is true, this would mean the parameter would be set to + // true, which is incorrect. + $default = false; + } else { + $default = $limits['default'] ?? false; + } $value = self::handle($input, $field, $default, $type); if (isset($limits['min']) && $value < $limits['min']) { $value = $limits['min']; @@ -132,7 +139,7 @@ class Request $value = $limits['max']; } if (isset($limits['enum']) && !in_array($value, $limits['enum'])) { - $value = array_shift($limits['enum']); + $value = $limits['default'] ?? array_shift($limits['enum']); } $out[$field] = $value; } diff --git a/modules-available/locationinfo/hooks/translation.inc.php b/modules-available/locationinfo/hooks/translation.inc.php index 0b58c0e9..228e26b9 100644 --- a/modules-available/locationinfo/hooks/translation.inc.php +++ b/modules-available/locationinfo/hooks/translation.inc.php @@ -24,16 +24,25 @@ if (Module::isAvailable('locationinfo')) { $HANDLER['subsections'][] = 'panel-params'; $HANDLER['grep_panel-params'] = function($module) { $return = []; - foreach (['UPCOMING'] as $panelType) { + // DEFAULT is not using this mechanism as it's too specialized + foreach (['UPCOMING', 'URL', 'SUMMARY'] as $panelType) { + $return['intro-' . $panelType] = true; $params = LocationInfo::getPanelParameters($panelType); $params['string']['panelname'] = []; foreach ($params as $types) { foreach ($types as $key => $data) { - $return[$key] = true; - $return[$key . '_helptext'] = true; if (isset($data['section'])) { + if ($data['section'] === false) + continue; // Hidden entry; doesn't need translation $return['section_' . $data['section']] = true; } + $return[$key] = true; + $return[$key . '_helptext'] = true; + if (!empty($data['enum'])) { + foreach ($data['enum'] as $enum) { + $return[$key . '_enum_' . $enum] = true; + } + } } } } diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 831f5ad0..2da79fcd 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -85,39 +85,125 @@ class LocationInfo public static function getPanelParameters(string $type): array { - $mods = []; - $lowType = strtolower($type); - foreach (glob('modules/locationinfo/templates/frontend-' . $lowType . '-*.html') as $file) { - if (!preg_match('/frontend-' . $lowType . '-([a-z0-9]+)\.html$/', $file, $matches)) - continue; - $mods[] = $matches[1]; - } - if (!empty($mods)) { - array_unshift($mods, ''); - } - if ($type === 'UPCOMING') { - return [ + switch ($type) { + case 'DEFAULT': + $return = [ + 'string' => [], + 'int' => [ + 'mode' => ['section' => 'general', 'default' => 1, 'min' => 1, 'max' => 4], + 'startday' => ['section' => 'calendar', 'default' => 0, 'min' => 0, 'max' => 7], + 'daystoshow' => ['section' => 'calendar', 'default' => 7, 'min' => 1, 'max' => 7], + 'rotation' => ['section' => 'roomplan', 'default' => 0, 'min' => 0, 'max' => 3], + 'scale' => ['section' => 'styling', 'default' => 50, 'min' => 10, 'max' => 90], + 'switchtime' => ['section' => 'general', 'default' => 20, 'min' => 1, 'max' => 120], + 'calupdate' => ['section' => 'calendar', 'default' => 120, 'min' => 5, 'max' => 300], + 'roomupdate' => ['section' => 'roomplan', 'default' => 30, 'min' => 5, 'max' => 60], + ], + 'bool' => [ + 'qrcode' => ['section' => 'general'], + 'vertical' => ['section' => 'styling'], + 'eco' => ['section' => 'styling'], + 'prettytime' => ['section' => 'styling'], + 'roomplanner' => ['section' => 'roomplan', 'default' => true], + 'scaledaysauto' => ['section' => 'calendar', 'default' => true], + 'hostname' => ['section' => 'roomplan', 'default' => false], + ], + ]; + break; + case 'URL': + $return = [ 'string' => [ - 'language' => [ - 'section' => 'general', - 'default' => defined('LANG') ? LANG : 'en', - 'enum' => Dictionary::getLanguages(), + 'url' => ['section' => 'general', 'default' => 'https://www.bwlehrpool.de/'], + 'blacklist' => ['section' => false], + 'whitelist' => ['section' => false, 'default' => ''], + 'browser' => ['section' => 'general', 'default' => 'firefox', 'enum' => [ + 'firefox', 'slx-browser', 'chromium', + ]], + 'accept-language' => ['section' => 'general', 'default' => 'de-DE,en-US'], + 'screen-rotation' => ['section' => 'general', 'default' => '', 'enum' => [ + '', 'left', 'right', 'inverted', + ]], + 'allow-tty' => ['section' => 'general', 'enum' => [ + '', 'yes', 'no', + ]], + ], + 'int' => [ + 'reload-minutes' => ['section' => 'general', 'default' => 0, 'min' => 0], + 'zoom-factor' => [ + 'section' => 'browser-tweaks', + 'default' => 100, + 'min' => 10, + 'max' => 1000, + 'slider' => '%', ], + ], + 'bool' => [ + 'insecure-ssl' => [ + 'section' => 'browser-tweaks', + 'class' => 'browser-specific show-slx-browser show-chromium', + ], + 'split-login' => ['section' => 'general'], + 'interactive' => [ + 'section' => 'browser-tweaks', + 'class' => 'browser-specific show-firefox show-chromium', + ], + 'hw-video' => [ + 'section' => 'browser-tweaks', + 'class' => 'browser-specific show-firefox show-chromium', + ], + ], + ]; + break; + case 'UPCOMING': + $return = [ + 'string' => [ 'heading' => ['section' => 'general'], 'subheading' => ['section' => 'general'], 'color_bg' => ['section' => 'styling', 'default' => 'rgb(52, 73, 154)'], 'color_fg' => ['section' => 'styling', 'default' => '#fff'], 'color_section' => ['section' => 'styling', 'default' => 'rgba(255,255,255, .2)'], 'color_time' => ['section' => 'styling', 'default' => 'rgba(255,255,255, .5)'], - 'mod' => ['section' => 'general', 'enum' => $mods], ], 'bool' => [ 'qrcode' => ['section' => 'general'], - 'language-system' => ['section' => 'general'], - ] + ], ]; + break; + case 'SUMMARY': + $return = [ + 'string' => [], + 'int' => [ + 'panelupdate' => ['section' => 'roomplan', 'default' => 30, 'min' => 5, 'max' => 60], + 'roomplanner' => ['section' => 'roomplan', 'default' => 0, 'enum' => [0, 1]], + ], + 'bool' => [ + 'eco' => ['section' => 'styling'], + ], + ]; + break; + default: + ErrorHandler::traceError("Invalid panel type: '$type'"); + } + if ($type !== 'URL') { + $mods = []; + $lowType = strtolower($type); + foreach (glob('modules/locationinfo/templates/frontend-' . $lowType . '-*.html') as $file) { + if (!preg_match('/frontend-' . $lowType . '-([a-z0-9]+)\.html$/', $file, $matches)) + continue; + $mods[] = $matches[1]; + } + if (!empty($mods)) { + array_unshift($mods, ''); + $return['string']['mod'] = ['section' => 'general', 'enum' => $mods]; + } + $return['string']['language'] = [ + 'section' => 'general', + 'default' => defined('LANG') ? LANG : 'en', + 'enum' => Dictionary::getLanguages(), + ]; + $return['bool']['language-system'] = ['section' => 'general']; } - ErrorHandler::traceError("Invalid panel type: '$type'"); + return $return; } /** @@ -157,68 +243,28 @@ class LocationInfo */ public static function defaultPanelConfig(string $type): array { - if ($type === 'DEFAULT') { - return array( - 'language' => defined('LANG') ? LANG : 'en', - 'mode' => 1, - 'vertical' => false, - 'eco' => false, - 'prettytime' => true, - 'roomplanner' => true, - 'scaledaysauto' => true, - 'startday' => 0, - 'daystoshow' => 7, - 'rotation' => 0, - 'scale' => 50, - 'switchtime' => 20, - 'calupdate' => 30, - 'roomupdate' => 15, - 'configupdate' => 180, - 'overrides' => [], - 'hostname' => false, - ); - } - if ($type === 'SUMMARY') { - return array( - 'language' => defined('LANG') ? LANG : 'en', - 'roomplanner' => true, - 'eco' => false, - 'panelupdate' => 60, - ); - } - if ($type === 'URL') { - return array( - 'whitelist' => '*', - 'blacklist' => '', - 'insecure-ssl' => 0, - 'reload-minutes' => 0, - 'split-login' => 0, - 'browser' => 'firefox', - 'interactive' => 0, - 'hw-video' => 0, - 'bookmarks' => '', - 'allow-tty' => '', - 'url' => '', - 'zoom-factor' => 100, - ); - } - if ($type === 'UPCOMING') { - $p = self::getPanelParameters($type); - $out = []; - foreach ($p as $sub) { - foreach ($sub as $field => $options) { - $out[$field] = $options['default'] ?? $options['min'] - ?? (isset($options['enum']) ? array_shift($options['enum']) : ''); - } + $p = self::getPanelParameters($type); + $out = []; + foreach ($p as $sub) { + foreach ($sub as $field => $options) { + $out[$field] = $options['default'] ?? $options['min'] + ?? (isset($options['enum']) ? array_shift($options['enum']) : ''); } - return $out; } - ErrorHandler::traceError("Invalid panel type: '$type'"); + return $out; } + /** + * Get data for editing a panel based on the type and current configuration. + * The returned data is suitable for rendering it in a mustache template. + * @param string $type The type of template to edit. + * @param array $current The current configuration data. + * @return array The edit template data formatted for display in a mustache template. + */ public static function getEditTemplateData(string $type, array $current): array { $params = self::getPanelParameters($type); + // Make sure panelname is the first element $params['string'] = array_reverse($params['string'], true); $params['string']['panelname'] = []; $params['string'] = array_reverse($params['string'], true); @@ -228,6 +274,8 @@ class LocationInfo if (isset($properties['enum']) && empty($properties['enum'])) continue; // Enum with no values - ignore $section = ($properties['section'] ?? 'general'); + if ($section === false) // To be hidden + continue; if (!isset($sections[$section])) { $sections[$section] = []; } @@ -235,6 +283,7 @@ class LocationInfo 'title' => Dictionary::translateFile('panel-params', $key, true), 'helptext' => Dictionary::translateFile('panel-params', $key . '_helptext', true), 'html' => self::makeEditField($varType, $key, $properties, $current[$key] ?? ''), + 'class' => $properties['class'] ?? null, ]; } } @@ -248,31 +297,61 @@ class LocationInfo return $output; } - private static function makeEditField(string $varType, string $key, array $var, $current): string + /** + * Transform the given variable into an edit field based on its type and configuration. + * + * @param string $varType The type of the variable ('int', 'bool', 'string'). + * @param string $key The key used in the form field name attribute. + * @param array $opts The variable configuration array. + * @param mixed $current The current value of the variable. + * @return string The HTML representation of the edit field for the given variable. + */ + private static function makeEditField(string $varType, string $key, array $opts, $current): string { - if (isset($var['enum'])) { - $return = '<select class="form-control" name="' . $key . '">'; - foreach ($var['enum'] as $enumValue) { + $hCurrent = htmlspecialchars($current); + $hDefault = htmlspecialchars($opts['default'] ?? ''); + if (isset($opts['enum'])) { + // Enum is a select/dropdown/combobox + $return = '<select id="input-' . $key . '" class="form-control" name="' . $key . '">'; + foreach ($opts['enum'] as $enumValue) { $return .= '<option value="' . htmlspecialchars($enumValue) . '"' . ($current == $enumValue ? ' selected' : '') . '>' - . htmlspecialchars($enumValue) . '</option>'; + . htmlspecialchars(Dictionary::translateFile('panel-params', $key . '_enum_' . $enumValue, false) ?: $enumValue) + . '</option>'; } $return .= '</select>'; } elseif ($varType === 'int') { - $return = '<input class="form-control" type="number" name="' . $key . '" value="' . htmlspecialchars($current) . '"' - . ' placeholder="' . htmlspecialchars($var['default'] ?? '') . '"'; - if (isset($var['min'])) { - $return .= ' min="' . $var['min'] . '"'; - } - if (isset($var['max'])) { - $return .= ' max="' . $var['max'] . '"'; + if (($opts['slider'] ?? false) && isset($opts['min']) && isset($opts['max'])) { + // Slider requested + $return = '<div class="row input-slider"><div class="col-sm-10 col-xs-9">' + . '<input class="form-control" id="input-' . $key . '" type="range" min="' . $opts['min'] + . '" max="' . $opts['max'] . '" name="' . $key . '" value="' . $hCurrent . '"'; + if (isset($opts['step'])) { + $return .= ' step="' . $opts['step'] . '"'; + } + $return .= '></div><div class="col-sm-2 col-xs-3">' + . '<span class="slider-value">' . $hCurrent . '</span>' . htmlspecialchars($opts['slider']) + . '</div></div>'; + } else { + // Normal text field for numbers + $return = '<input id="input-' . $key . '" class="form-control" type="number" name="' . $key . '" value="' + . $hCurrent . '"' + . ' placeholder="' . $hDefault . '"'; + if (isset($opts['min'])) { + $return .= ' min="' . $opts['min'] . '"'; + } + if (isset($opts['max'])) { + $return .= ' max="' . $opts['max'] . '"'; + } + $return .= '>'; } } elseif ($varType === 'bool') { - $return = '<div class="checkbox"><input type="checkbox" name="' . $key . '" value="1"' + $return = '<div class="checkbox"><input id="input-' . $key . '" type="checkbox" name="' . $key . '" value="1"' . ($current ? ' checked' : '') . '><label></label></div>'; } elseif ($varType === 'string') { - $return = '<input class="form-control" type="text" name="' . $key . '" value="' . htmlspecialchars($current) . '"' - . ' placeholder="' . htmlspecialchars($var['default'] ?? '') . '">'; + $return = '<input id="input-' . $key . '" class="form-control" type="text" name="' . $key . '" value="' + . $hCurrent . '"' + . ' placeholder="' . $hDefault . '">'; } else { ErrorHandler::traceError("Invalid variable type: '$varType'"); } @@ -412,6 +491,8 @@ class LocationInfo $config['blacklist'] = ''; $config['whitelist'] = ''; } + $config['blacklist'] = preg_replace('/\r?\n/', "\r\n", $config['blacklist']); + $config['whitelist'] = preg_replace('/\r?\n/', "\r\n", $config['whitelist']); } /** diff --git a/modules-available/locationinfo/lang/de/panel-params.json b/modules-available/locationinfo/lang/de/panel-params.json index a05a3e12..1830a93c 100644 --- a/modules-available/locationinfo/lang/de/panel-params.json +++ b/modules-available/locationinfo/lang/de/panel-params.json @@ -1,4 +1,16 @@ { + "accept-language": "Pr\u00e4ferierte Sprache", + "accept-language_helptext": "Betrifft nur bwLehrpool-Clients, die diesem Panel zugewiesen sind: Welche Sprache(n) soll der auf dem Client laufende Browser beim Aufruf von Webseiten anfordern, z.B. de-DE,fr-CH,en-US", + "allow-tty": "Wechsel auf Textkonsole erlauben", + "allow-tty_enum_": "Vorgabe f\u00fcr Raum\/Rechner verwenden", + "allow-tty_enum_no": "Nein", + "allow-tty_enum_yes": "Ja", + "allow-tty_helptext": "Legt fest, ob ein wechsel auf die Textkonsole mittels Strg-Alt-F1 erlaubt ist", + "browser": "Browser", + "browser_enum_chromium": "Chromium", + "browser_enum_firefox": "Firefox", + "browser_enum_slx-browser": "SLX-Browser (Webkit-basiert)", + "browser_helptext": "Welcher Browser soll genutzt werden", "color_bg": "Hintergrund", "color_bg_helptext": "Hintergrundfarbe des Panels", "color_fg": "Vordergrundfarbe", @@ -7,20 +19,56 @@ "color_section_helptext": "Textfarbe f\u00fcr \"Aktuell\"- und \"Anstehend\"-\u00dcberschrift", "color_time": "Datum\/Zeit", "color_time_helptext": "Textfarbe f\u00fcr die Datum-\/Zeitanzeige im Vollbild", + "eco": "E-Ink Modus", + "eco_helptext": "Niedrigere Aktualisierungsrate, Countdown ohne Sekunden", "heading": "\u00dcberschrift", "heading_helptext": "Prim\u00e4re \u00dcberschrift", + "hw-video": "Video Hardware-Decode erzwingen", + "hw-video_helptext": "Versuche hardwarebeschleunigte Videodekodierung zu erzwingen, auch wenn der Browser dies auf der vorgefundenen Hardware standardm\u00e4\u00dfig nicht tut. Kann die Leistung verbessern, oder aber zu Anzeige-\/Stabilit\u00e4tsproblemen f\u00fchren.", + "insecure-ssl": "Unsicheres SSL", + "insecure-ssl_helptext": "Akzeptiere ung\u00fcltige, abgelaufene oder selbstsignierte SSL-Zertifikate", + "interactive": "Interaktiver Browser", + "interactive_helptext": "Volles UI anzeigen (tabs, bookmarks, ...)", + "intro-SUMMARY": "Hier k\u00f6nnen Sie ein \u00dcbersichts-Panel definieren. Das Panel zeigt eine \u00dcbersicht der in den R\u00e4umen enthalten PCs.", + "intro-UPCOMING": "Eine Anzeigetafel, die die n\u00e4chsten Veranstaltungen in einem oder mehreren R\u00e4umen anzeigt. Die Veranstaltungen werden chronologisch aufsteigend untereinander angezeigt, mit Start- und Endzeit.", + "intro-URL": "unused", "language": "Sprache", "language-system": "Systemsprache bevorzugen", "language-system_helptext": "Sofern unterst\u00fctzt, wird das Panel in der Sprache ausgeliefert, die der Browser des Users anfordert", + "language_enum_de": "Deutsch", + "language_enum_en": "Englisch", "language_helptext": "Anzeigesprache des Panels", "mod": "Panelvariante", + "mod_enum_": "-", "mod_helptext": "Alternatives Template f\u00fcr das Panel verwenden", "panelname": "Interner Name", "panelname_helptext": "Name des Panels, wie er in der Administrationsoberfl\u00e4che angezeigt wird", + "panelupdate": "Aktualisierungsinterval", + "panelupdate_helptext": "Interval (in Sekunden), das bestimmt, wie oft die Belegungsdaten aktualisiert werden", "qrcode": "QRCode zeigen", "qrcode_helptext": "QRCode in der unteren rechten Ecke anzeigen", + "reload-minutes": "Neulade\/start-Interval", + "reload-minutes_helptext": "Betrifft nur bwLehrpool-Clients: Setzen Sie dieses Feld auf einen Wert > 0 (in Minuten), um die Seite auf den Clients regelm\u00e4\u00dfig neu zu laden. Der Z\u00e4hler wird bei Nutzeraktivit\u00e4t (Maus\/Tastatur) zur\u00fcckgesetzt, sodass nicht mitten in einer Sitzung zur\u00fcck auf die Startseite navigiert wird. Feld auf 0 setzen oder leer lassen deaktiviert diese Funktion.", + "roomplanner": "Z\u00e4hlweise", + "roomplanner_enum_0": "Alle durch IP-Adresse oder Raumplan in den Raum fallenden Rechner z\u00e4hlen", + "roomplanner_enum_1": "Nur die Rechner z\u00e4hlen, die per Raumplaner dem Raum zugewiesen sind", + "roomplanner_helptext": "Wie die Anzahl der Rechner gez\u00e4hlt werden soll", + "screen-rotation": "Bildschirm-Rotation", + "screen-rotation_enum_": "Normal", + "screen-rotation_enum_inverted": "Kopf\u00fcber", + "screen-rotation_enum_left": "Nach links", + "screen-rotation_enum_right": "Nach rechts", + "screen-rotation_helptext": "Falls der Bildschirm gedreht ist (Portrait oder \u00fcberkopf), geben Sie hier die entsprechend n\u00f6tige Rotation des Bildschirminhaltes an. Falls Sie bereits in den Konfigurationsvariablen eines Clients, oder in dessen zugeh\u00f6rigem Raum eine feste Aufl\u00f6sung mit Rotation angegeben haben (SLX_FORCE_RESOLUTION), so wird die hier angegebene Einstellung ignoriert.", + "section_browser-tweaks": "Browserspezifische Konfiguration", "section_general": "Allgemein", + "section_roomplan": "Raumplan", "section_styling": "Design", + "split-login": "Geteiltes Login", + "split-login_helptext": "Erlaube nur Gast-Login oder Gast+Nutzer-Login wenn aktiviert", "subheading": "Zweite \u00dcberschrift", - "subheading_helptext": "Sekund\u00e4re \u00dcberschrift, die unter der prim\u00e4ren angezeigt wird" + "subheading_helptext": "Sekund\u00e4re \u00dcberschrift, die unter der prim\u00e4ren angezeigt wird", + "url": "URL", + "url_helptext": "URL die aufgerufen wird", + "zoom-factor": "Zoom-Faktor", + "zoom-factor_helptext": "Betrifft nur bwLehrpool-Clients: Initialer Zoom-Faktor beim Start des Panels. Je nach gew\u00e4hltem Browser kann der Faktor vom Benutzer angepasst werden." }
\ No newline at end of file diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index f10a4ae2..e4c8d4e3 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -1,7 +1,5 @@ { "lang_addServer": "Server", - "lang_allowTtySwitch": "Wechsel auf Textkonsole erlauben", - "lang_allowTtySwitchTooltip": "Legt fest, ob ein wechsel auf die Textkonsole mittels Strg-Alt-F1 erlaubt ist", "lang_autoScale": "Auto Tage", "lang_autoscaleTooltip": "Berechnet anhand der Bildschirmbreite die optimale Anzahl an Tagen, die der Kalender anzeigt", "lang_backend": "Backend", @@ -9,14 +7,11 @@ "lang_backends": "Backends", "lang_blacklist": "Blacklist", "lang_bookmarks": "Lesezeichen", + "lang_bookmarksHeading": "Lesezeichen", "lang_bookmarksTooltip": "F\u00fcge Lesezeichen hinzu, die der Browser erhalten soll", - "lang_browser": "Browser", - "lang_browserLanguageTooltip": "Die Sprache oder Sprachen, die der Browser mit seinen Request-Headern vom Server anfordert. Es k\u00f6nnen mehrere Sprachen mit absteigender Priorit\u00e4t mit Komma getrennt angegeben werden, z.B. de-DE,fr-CH,en-US", - "lang_browserTooltip": "Welcher Browser soll genutzt werden", "lang_calendarUpdate": "Kalender Update", "lang_calupdateTooltip": "Zeit nachdem der Kalender aktualisiert wird (in Minuten)", "lang_checkConnection": "Verbindung pr\u00fcfen", - "lang_chromium": "Chromium", "lang_closed": "Geschlossen", "lang_configOverride": "Konfiguration \u00fcberschreiben", "lang_countIp": "\u00fcber IP-Adressbereich", @@ -29,19 +24,15 @@ "lang_daysToShowTooltip": "Legt die Anzahl an Tagen im Kalender fest, die angezeigt werden", "lang_defaultPanel": "Raum\/Kalender", "lang_deleteConfirmation": "Sind Sie sicher?", - "lang_display": "Anzeige", "lang_displayName": "Name", "lang_displayNameTooltip": "Name f\u00fcr dieses Panel (in Auflistung)", "lang_ecoMode": "E-Ink Modus", "lang_ecoTooltip": "Niedrigere Aktualisierungsrate, Countdown ohne Sekunden", "lang_editDefaultPanelHints": "Hier k\u00f6nnen Sie ein Panel (z.B. digitales T\u00fcrschild) in Aussehen und Funktionsweise definieren. Um im Kalender \u00d6ffnungszeiten anzeigen zu k\u00f6nnen, m\u00fcssen Sie im Tab \"Raum-\/Ortsbezogene Einstellungen\" f\u00fcr den ausgew\u00e4hlten Raum entsprechend \u00d6ffnungszeiten eintragen. Damit im Kalender Veranstaltungen und andere Termine angezeigt werden k\u00f6nnen, muss ein funktionierendes Backend konfiguriert und den ausgew\u00e4hlten R\u00e4umen zugewiesen worden sein.", "lang_editPanel": "Panel bearbeiten", - "lang_editSummaryPanelHints": "Hier k\u00f6nnen Sie ein \u00dcbersichts-Panel definieren. Das Panel zeigt eine \u00dcbersicht der in den R\u00e4umen enthalten PCs.", - "lang_editUpcomingPanelHints": "Eine Anzeigetafel, die die n\u00e4chsten Veranstaltungen in einem oder mehreren R\u00e4umen anzeigt. Die Veranstaltungen werden chronologisch aufsteigend untereinander angezeigt, mit Start- und Endzeit.", "lang_editUrlPanelHints": "Hier k\u00f6nnen Sie konfigurieren, welche URL das Panel aufrufen soll. Dies erm\u00f6glicht Ihnen z.B. in Eingangsbereichen aktuelle Meldungen der Hochschule oder sonstige Webseiten anzuzeigen.", "lang_entryName": "Name", "lang_error": "Fehler", - "lang_firefox": "Firefox", "lang_for": "f\u00fcr", "lang_fourLocsHint": "Hier k\u00f6nnen Sie bis zu vier Orte ausw\u00e4hlen, die in diesem Panel angezeigt werden.", "lang_free": "Ge\u00f6ffnet", @@ -51,12 +42,6 @@ "lang_goToLocation": "Gehe zu Raum", "lang_goToLocationWarning": "Weiterleitung zum Raum-Modul", "lang_hostnameTooltip": "Zeige kurzen Hostnamen in Rechner-Piktogramm", - "lang_hwAccelVideo": "Video Hardware-Decode erzwingen", - "lang_hwAccelVideoTooltip": "Versuche hardwarebeschleunigte Videodekodierung zu erzwingen, auch wenn der Browser dies auf der vorgefundenen Hardware standardm\u00e4\u00dfig nicht tut. Kann die Leistung verbessern, oder aber zu Anzeige-\/Stabilit\u00e4tsproblemen f\u00fchren.", - "lang_ignoreSslTooltip": "Akzeptiere ung\u00fcltige, abgelaufene oder selbstsignierte SSL-Zertifikate", - "lang_insecureSsl": "Unsicheres SSL", - "lang_interactive": "Interaktiver Browser", - "lang_interactiveTooltip": "Volles UI anzeigen (tabs, bookmarks, ...)", "lang_language": "Sprache", "lang_languageTooltip": "Legt die Sprache der angezeigten Oberfl\u00e4che fest", "lang_lastCalendarUpdate": "Kalender Update", @@ -97,8 +82,6 @@ "lang_prettytimeTooltip": "Verwende ein anderes Anzeigeformat f\u00fcr die Uhrzeit", "lang_recursiveServerSet": "Auch f\u00fcr alle untergeordneten R\u00e4ume setzen", "lang_recursiveSetTooltip": "Wenn aktiviert, wird der Backend-Server auch f\u00fcr alle untergeordneten R\u00e4ume auf den hier gew\u00e4hlten Wert gesetzt", - "lang_reloadIntervalMins": "Neuladen der Startseite alle X Minuten (bei Inaktivit\u00e4t)", - "lang_reloadIntervalTooltip": "Setzen Sie dieses Feld auf einen Wert > 0 (in Minuten), um die Seite auf den Clients regelm\u00e4\u00dfig neu zu laden. Der Z\u00e4hler wird bei Nutzeraktivit\u00e4t (Maus\/Tastatur) zur\u00fcckgesetzt, sodass nicht mitten in einer Sitzung zur\u00fcck auf die Startseite navigiert wird. Feld auf 0 setzen oder leer lassen deaktiviert diese Funktion.", "lang_remoteSchedule": "Abruf Belegungsplan", "lang_room": "Raum", "lang_roomId": "Raum ID", @@ -116,7 +99,6 @@ "lang_saturday": "Samstag", "lang_scale": "Kalenderbreite", "lang_scaleTooltip": "[10-90] Legt die Kalenderbreite fest (in Prozent)", - "lang_screenRotationTooltip": "Falls der Bildschirm gedreht ist (Portrait oder \u00fcberkopf), geben Sie hier die entsprechend n\u00f6tige Rotation des Bildschirminhaltes an. Falls Sie bereits in den Konfigurationsvariablen eines Clients, oder in dessen zugeh\u00f6rigem Raum eine feste Aufl\u00f6sung mit Rotation angegeben haben (SLX_FORCE_RESOLUTION), so wird die hier angegebene Einstellung ignoriert.", "lang_sec": "sek", "lang_serverLogHead": "Fehlerprotokoll", "lang_serverTable": "Backend-Server verwalten", @@ -132,13 +114,9 @@ "lang_shortWed": "Mi", "lang_showHostname": "Hostname anzeigen", "lang_showLog": "Log", - "lang_slxbrowser": "SLX Browser", - "lang_splitlogin": "Geteiltes Login", - "lang_splitloginTooltip": "Erlaube nur Gast-Login oder Gast+Nutzer-Login wenn aktiviert", "lang_startDay": "Start Tag", "lang_startDayTooltip": "Der Wochentag an dem der Kalender anf\u00e4ngt", "lang_summaryPanel": "Gesamt\u00fcbersicht", - "lang_summaryUpdateIntervalTooltip": "Aktualisierungsintervall (Sekunden)", "lang_sunday": "Sonntag", "lang_switchTime": "Wechselintervall", "lang_switchTimeTooltip": "[1-120] Legt die Zeit fest, die vergeht bis ein Wechsel erfolgt (in Sekunden)", @@ -149,19 +127,14 @@ "lang_typeTooltip": "Legt fest um welchen Server-Typ es sich handelt", "lang_upcomingEvents": "Anstehend", "lang_upcomingPanel": "Anstehende Veranstaltungen", - "lang_updateRates": "Aktualisierungsintervall", - "lang_url": "URL", "lang_urlListHelp": "Sie k\u00f6nnen hier Listen von URLs oder Hostnamen angeben, die dann als Whitelist bzw. Blacklist interpretiert werden. Je nach gew\u00e4hltem Browser hat entweder die Whitelist Vorrang, oder die \"genauere\" Regel. Wenn keine Regel zutrifft, wird der Zugriff erlaubt, es sei denn, es gibt den Eintrag \"*\" in der Blacklist. Je nach verwendetem Browser wird \"*\" als Wildcard an verschiedenen Stellen unterst\u00fctzt. Sie k\u00f6nnen Kommentare hinter oder zwischen den Zeilen mittels \"#\" einleiten.", "lang_urlListHelpUrl": "Weitere Informationen finden Sie im bwLehrpool-Wiki.", "lang_urlPanel": "URL-Panel", - "lang_urlTooltip": "URL die aufgerufen wird", - "lang_useDefault": "Vorgabe f\u00fcr Raum\/Rechner verwenden", + "lang_urlfilterHeading": "Zugriffsfilter", "lang_useRoomplanner": "Rechner z\u00e4hlen", "lang_vertical": "Vertikaler Modus", "lang_verticalTooltip": "Legt fest, ob Kalender und Raum \u00fcbereinander angezeigt werden sollen", "lang_wednesday": "Mittwoch", "lang_when": "Wann", - "lang_whitelist": "Whitelist", - "lang_zoomFactor": "Zoom-Faktor", - "lang_zoomFactorTooltip": "Initialer Zoom-Faktor beim Start des Panels. Je nach gew\u00e4hltem Browser kann der Faktor vom Benutzer angepasst werden." + "lang_whitelist": "Whitelist" }
\ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/panel-params.json b/modules-available/locationinfo/lang/en/panel-params.json index 0eff714d..257e44a1 100644 --- a/modules-available/locationinfo/lang/en/panel-params.json +++ b/modules-available/locationinfo/lang/en/panel-params.json @@ -1,4 +1,16 @@ { + "accept-language": "Prefered language", + "accept-language_helptext": "Which language should the browser request from the visited website(s), e.g. de-DE,fr-CH,en-US", + "allow-tty": "Allow switching to text console", + "allow-tty_enum_": "Use setting from location\/machine", + "allow-tty_enum_no": "Yes", + "allow-tty_enum_yes": "No", + "allow-tty_helptext": "Set whether the user can switch to the text console via Ctrl-Alt-F1", + "browser": "Browser", + "browser_enum_chromium": "Chromium", + "browser_enum_firefox": "Firefox", + "browser_enum_slx-browser": "SLX browser (webkit based)", + "browser_helptext": "Which browser should be used", "color_bg": "Background", "color_bg_helptext": "Background color of panel", "color_fg": "Foreground", @@ -7,20 +19,56 @@ "color_section_helptext": "Color for \"current\" and \"upcoming\" headline", "color_time": "Date\/time", "color_time_helptext": "Color for date\/time display in fullscreen display", + "eco": "E-ink mode", + "eco_helptext": "Lower update rate, countdown doesn't show seconds", "heading": "Heading", "heading_helptext": "Primary heading", + "hw-video": "Force hardware accelerated video decode", + "hw-video_helptext": "Try to force the browser to use hardware accelerated video decode. Might improve performance, but might also lead to instability or glitches.", + "insecure-ssl": "Insecure SSL", + "insecure-ssl_helptext": "Accept invalid, expired or self-signed ssl certificates", + "interactive": "Interactive Browser", + "interactive_helptext": "Show full browser UI (tabs, bookmarks, ...)", + "intro-SUMMARY": "Here you can define a summary panel which shows a overview of clients in your locations.", + "intro-UPCOMING": "Panel that shows active and upcoming events in one or more locations. Events will be shown in ascending order.", + "intro-URL": "unused", "language": "Language", "language-system": "Prefer system language", "language-system_helptext": "If supported, the panel will be displayed in the language the user's browser requested", + "language_enum_de": "German", + "language_enum_en": "English", "language_helptext": "Language to display the panel in", "mod": "Panel variant", + "mod_enum_": "-", "mod_helptext": "Use alternate template for panel", "panelname": "Internal name", "panelname_helptext": "Name of panel as displayed in admin interface", + "panelupdate": "Refresh interval", + "panelupdate_helptext": "Interval (seconds) determining how often the usage data is fetched from the server", "qrcode": "QR code", "qrcode_helptext": "Display QR code in lower right corner", + "reload-minutes": "Reload\/start interval", + "reload-minutes_helptext": "Navigate to start URL every X minutes (when idle). Set to 0 to disable.", + "roomplanner": "Machine counting", + "roomplanner_enum_0": "Any client matching via IP address or assigned via room planner", + "roomplanner_enum_1": "Only count clients assigned via room planner", + "roomplanner_helptext": "How to count machines belonging to a room", + "screen-rotation": "Screen rotation", + "screen-rotation_enum_": "Normal", + "screen-rotation_enum_inverted": "Upside down", + "screen-rotation_enum_left": "Left", + "screen-rotation_enum_right": "Right", + "screen-rotation_helptext": "If the screen is mounted in portrait mode or upside down, you can specify the required rotation of screen contents here. In case you already specified a rotation for a client or location via its configuration variables (SLX_FORCE_RESOLUTION), then the setting you specify here will be ignored.", + "section_browser-tweaks": "Browser specific configuration", "section_general": "General", + "section_roomplan": "Room planner", "section_styling": "Styling", + "split-login": "Split Login", + "split-login_helptext": "Allow only guest-login or guest+user-login if activated", "subheading": "Subheading", - "subheading_helptext": "Secondary heading, displayed below primary heading" + "subheading_helptext": "Secondary heading, displayed below primary heading", + "url": "URL", + "url_helptext": "URL which is shown by the panel", + "zoom-factor": "Zoom level", + "zoom-factor_helptext": "Initial zoom level at startup. Depending on selected browser, this can later be changed by the user." }
\ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index 7a25a512..46d4d144 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -1,7 +1,5 @@ { "lang_addServer": "Server", - "lang_allowTtySwitch": "Allow switching to text console", - "lang_allowTtySwitchTooltip": "Set whether the user can switch to the text console via Ctrl-Alt-F1", "lang_autoScale": "Auto Days", "lang_autoscaleTooltip": "Calculates the optimum amount of days to show from the display width", "lang_backend": "Backend", @@ -9,14 +7,11 @@ "lang_backends": "Backends", "lang_blacklist": "Blacklist", "lang_bookmarks": "Bookmarks", + "lang_bookmarksHeading": "Bookmarks", "lang_bookmarksTooltip": "Add bookmarks to the browser", - "lang_browser": "Browser", - "lang_browserLanguageTooltip": "Language or languages the browser will request from servers. You can specify a comma-separated list in order of Priority, like de-DE,fr-CH,en-US", - "lang_browserTooltip": "Which browser shall be used", "lang_calendarUpdate": "Calendar Update", "lang_calupdateTooltip": "Time the calendar queries for updates (in minutes)", "lang_checkConnection": "Check connection", - "lang_chromium": "Chromium", "lang_closed": "Closed", "lang_configOverride": "Configuration override", "lang_countIp": "by IP-Range", @@ -29,19 +24,15 @@ "lang_daysToShowTooltip": "Defines the amount of days to show in the calendar", "lang_defaultPanel": "Room\/Calendar", "lang_deleteConfirmation": "Are you sure?", - "lang_display": "Display", "lang_displayName": "Name", "lang_displayNameTooltip": "Name for this panel (as shown in listing)", "lang_ecoMode": "E-Ink mode", "lang_ecoTooltip": "Lower update rate, countdown doesn't show seconds", "lang_editDefaultPanelHints": "Here you can define panel properties for e.g. a digital door sign. To show opening times for a room you need to define corresponding times in the settings.\r\nIf you want to show calendar events you have to define a functioning backend first and link it to corresponding rooms.", "lang_editPanel": "Edit panel", - "lang_editSummaryPanelHints": "Here you can define a summary panel which shows a overview of clients in your locations.", - "lang_editUpcomingPanelHints": "Panel that shows active and upcoming events in one or more locations. Events will be shown in ascending order.", "lang_editUrlPanelHints": "Here you can define which URL is opened by the panel. This enables you to show news about your university or any other website.", "lang_entryName": "Name", "lang_error": "Error", - "lang_firefox": "Firefox", "lang_for": "for", "lang_fourLocsHint": "You can pick up to four locations that will be shown in this panel.", "lang_free": "Open", @@ -51,12 +42,6 @@ "lang_goToLocation": "GoTo Location", "lang_goToLocationWarning": "Forward to Location-Module", "lang_hostnameTooltip": "Show simple hostname inside computer icon", - "lang_hwAccelVideo": "Force hardware accelerated video decode", - "lang_hwAccelVideoTooltip": "Try to force the browser to use hardware accelerated video decode. Might improve performance, but might also lead to instability or glitches.", - "lang_ignoreSslTooltip": "Accept invalid, expired or self-signed ssl certificates", - "lang_insecureSsl": "Insecure SSL", - "lang_interactive": "Interactive Browser", - "lang_interactiveTooltip": "Show full browser UI (tabs, bookmarks, ...)", "lang_language": "Language", "lang_languageTooltip": "The language the frontend uses", "lang_lastCalendarUpdate": "Calendar update", @@ -97,8 +82,6 @@ "lang_prettytimeTooltip": "Use a different display format for the time", "lang_recursiveServerSet": "Also set for all child locations", "lang_recursiveSetTooltip": "If checked, all direct and indirect child locations will be configured to use the backend server selected above", - "lang_reloadIntervalMins": "Reload start URL every X minutes (when idle)", - "lang_reloadIntervalTooltip": "Set this field to a value > 0 (in minutes) to reload the page periodically. The idle timeout will reset on user input (mouse\/keyboard), so the page will not reset while a user is using the browser. Set to 0 or leave blank to disable any resets.", "lang_remoteSchedule": "Time table retrieval", "lang_room": "Room", "lang_roomId": "Room ID", @@ -116,7 +99,6 @@ "lang_saturday": "Saturday", "lang_scale": "Calendar width", "lang_scaleTooltip": "[10-90] Defines the calendar width (in percent)", - "lang_screenRotationTooltip": "If the screen is mounted in portrait mode or upside down, you can specify the required rotation of screen contents here. In case you already specified a rotation for a client or location via its configuration variables (SLX_FORCE_RESOLUTION), then the setting you specify here will be ignored.", "lang_sec": "sec", "lang_serverLogHead": "Error log", "lang_serverTable": "Manage backend servers", @@ -132,13 +114,9 @@ "lang_shortWed": "Wed", "lang_showHostname": "Show hostname", "lang_showLog": "Log", - "lang_slxbrowser": "SLX Browser", - "lang_splitlogin": "Split Login", - "lang_splitloginTooltip": "Allow only guest-login or guest+user-login if activated", "lang_startDay": "Start Day", "lang_startDayTooltip": "The day of the week at which the calendar starts", "lang_summaryPanel": "Summary panel", - "lang_summaryUpdateIntervalTooltip": "Update interval (seconds)", "lang_sunday": "Sunday", "lang_switchTime": "Switchtime", "lang_switchTimeTooltip": "[1-120] Sets the time between switching (in seconds)", @@ -149,19 +127,14 @@ "lang_typeTooltip": "Defines on which type of server you want to connect to", "lang_upcomingEvents": "Upcoming", "lang_upcomingPanel": "Upcoming events", - "lang_updateRates": "Update rates", - "lang_url": "URL", "lang_urlListHelp": "You can specify lists of URLs or hostnames here, which are then interpreted as a whitelist or blacklist. Depending on the selected browser, either the whitelist or the \"more precise\" rule takes precedence. If no rule applies, access will be allowed unless there is an entry \"*\" in the blacklist. Depending on the browser used, \"*\" is supported as a wildcard in different places. You can introduce comments at the end of or between lines using \"#\".", "lang_urlListHelpUrl": "Further information can be found in the bwLehrpool-Wiki.", "lang_urlPanel": "URL panel", - "lang_urlTooltip": "URL which is shown by the panel", - "lang_useDefault": "Use setting from location\/machine", + "lang_urlfilterHeading": "Access filter", "lang_useRoomplanner": "Count PCs", "lang_vertical": "Vertical mode", "lang_verticalTooltip": "Defines whether the room and calendar are shown above each other", "lang_wednesday": "Wednesday", "lang_when": "When", - "lang_whitelist": "Whitelist", - "lang_zoomFactor": "Zoom level", - "lang_zoomFactorTooltip": "Initial zoom level at startup. Depending on selected browser, this can later be changed by the user." + "lang_whitelist": "Whitelist" }
\ No newline at end of file diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 538f2514..a6d56e5a 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -248,8 +248,6 @@ class Page_LocationInfo extends Page $params = $this->preparePanelConfigUrl(); break; case 'SUMMARY': - $params = $this->preparePanelConfigSummary(); - break; case 'UPCOMING': $params = [ 'config' => LocationInfo::panelConfigFromPost($paneltype), @@ -295,52 +293,29 @@ class Page_LocationInfo extends Page if (count($locationids) > 4) { $locationids = array_slice($locationids, 0, 4); } - // Build struct from POST - $conf = array( - 'language' => Request::post('language', 'en', 'string'), - 'mode' => Request::post('mode', 1, 'int'), - 'vertical' => Request::post('vertical', false, 'bool'), - 'eco' => Request::post('eco', false, 'bool'), - 'prettytime' => Request::post('prettytime', false, 'bool'), - 'roomplanner' => Request::post('roomplanner', true, 'bool'), - 'startday' => Request::post('startday', 0, 'int'), - 'scaledaysauto' => Request::post('scaledaysauto', false, 'bool'), - 'daystoshow' => Request::post('daystoshow', 7, 'int'), - 'rotation' => Request::post('rotation', 0, 'int'), - 'scale' => Request::post('scale', 50, 'int'), - 'switchtime' => Request::post('switchtime', 20, 'int'), - 'calupdate' => Request::post('calupdate', 120, 'int'), - 'roomupdate' => Request::post('roomupdate', 30, 'int'), - 'hostname' => Request::post('hostname', false, 'bool'), - ); - if ($conf['roomupdate'] < 15) { - $conf['roomupdate'] = 15; - } - if ($conf['calupdate'] < 30) { - $conf['calupdate'] = 30; - } + $conf = LocationInfo::panelConfigFromPost('DEFAULT'); - $overrides = array(); - for ($i = 0; $i < sizeof($locationids); $i++) { - $overrideLoc = Request::post('override'.$locationids[$i], false, 'bool'); + $overrides = []; + foreach ($locationids as $lid) { + $overrideLoc = Request::post('override'.$lid, false, 'bool'); if ($overrideLoc) { $overrideArray = array( - 'mode' => Request::post('override'.$locationids[$i].'mode', 1, 'int'), - 'roomplanner' => Request::post('override'.$locationids[$i].'roomplanner', false, 'bool'), - 'vertical' => Request::post('override'.$locationids[$i].'vertical', false, 'bool'), - 'startday' => Request::post('override'.$locationids[$i].'startday', 0, 'int'), - 'scaledaysauto' => Request::post('override'.$locationids[$i].'scaledaysauto', false, 'bool'), - 'daystoshow' => Request::post('override'.$locationids[$i].'daystoshow', 7, 'int'), - 'rotation' => Request::post('override'.$locationids[$i].'rotation', 0, 'int'), - 'scale' => Request::post('override'.$locationids[$i].'scale', 50, 'int'), - 'switchtime' => Request::post('override'.$locationids[$i].'switchtime', 60, 'int'), + 'mode' => Request::post('override'.$lid.'mode', 1, 'int'), + 'roomplanner' => Request::post('override'.$lid.'roomplanner', false, 'bool'), + 'vertical' => Request::post('override'.$lid.'vertical', false, 'bool'), + 'startday' => Request::post('override'.$lid.'startday', 0, 'int'), + 'scaledaysauto' => Request::post('override'.$lid.'scaledaysauto', false, 'bool'), + 'daystoshow' => Request::post('override'.$lid.'daystoshow', 7, 'int'), + 'rotation' => Request::post('override'.$lid.'rotation', 0, 'int'), + 'scale' => Request::post('override'.$lid.'scale', 50, 'int'), + 'switchtime' => Request::post('override'.$lid.'switchtime', 60, 'int'), ); - $overrides[$locationids[$i]] = $overrideArray; + $overrides[$lid] = $overrideArray; } } $conf['overrides'] = $overrides; - return array('config' => $conf, 'locationids' => $locationids); + return ['config' => $conf, 'locationids' => $locationids]; } /** @@ -352,56 +327,17 @@ class Page_LocationInfo extends Page $bookmarkUrls = Request::post('bookmarkUrls', [], 'array'); $bookmarkString = ''; for ($i = 0; $i < count($bookmarkNames); $i++) { - if ($bookmarkNames[$i] == '' || $bookmarkUrls[$i] == '') continue; - $bookmarkString .= rawurlencode($bookmarkNames[$i]); - $bookmarkString .= ","; - $bookmarkString .= rawurlencode($bookmarkUrls[$i]); - $bookmarkString .= " "; - } - $bookmarkString = substr($bookmarkString, 0, -1); - - $rotation = strtolower(Request::post('screen-rotation', '', 'string')); - if (!in_array($rotation, ['', 'left', 'right', 'inverted'])) { - $rotation = ''; - } - - $conf = array( - 'url' => Request::post('url', 'https://www.bwlehrpool.de/', 'string'), - 'insecure-ssl' => Request::post('insecure-ssl', 0, 'int'), - 'reload-minutes' => max(0, Request::post('reloadminutes', 0, 'int')), - 'whitelist' => preg_replace("/[\r\n]+/m", "\n", Request::post('whitelist', '', 'string')), - 'blacklist' => preg_replace("/[\r\n]+/m", "\n", Request::post('blacklist', '', 'string')), - 'split-login' => Request::post('split-login', 0, 'bool'), - 'browser' => Request::post('browser', 'firefox', 'string'), - 'interactive' => Request::post('interactive', '0', 'bool'), - 'hw-video' => Request::post('hw-video', '0', 'bool'), - 'bookmarks' => $bookmarkString ?: '', - 'allow-tty' => Request::post('allow-tty', '', 'string'), - 'zoom-factor' => max(0, Request::post('zoom-factor', 100, 'int')), - 'language' => str_replace(['_', ' '], ['-', ''], Request::post('language', '', 'string')), - 'screen-rotation' => $rotation, - ); - return array('config' => $conf, 'locationids' => []); - } - - /** - * @return array{config: array, locationids: array} - */ - private function preparePanelConfigSummary(): array - { - // Build json structure - $conf = array( - 'language' => Request::post('language', 'en', 'string'), - 'eco' => Request::post('eco', false, 'bool'), - 'roomplanner' => Request::post('roomplanner', false, 'bool'), - 'panelupdate' => Request::post('panelupdate', 30, 'int') - ); - if ($conf['panelupdate'] < 15) { - $conf['panelupdate'] = 15; + if (empty($bookmarkNames[$i]) || empty($bookmarkUrls[$i])) + continue; + $bookmarkString .= rawurlencode($bookmarkNames[$i]) . ',' + . rawurlencode($bookmarkUrls[$i]) . ' '; } - // Check locations - $locationids = self::getLocationIdsFromRequest(); - return array('config' => $conf, 'locationids' => $locationids); + $bookmarkString = trim($bookmarkString); + + $conf = LocationInfo::panelConfigFromPost('URL'); + $conf['bookmarks'] = $bookmarkString; + $conf['accept-language'] = str_replace(['_', ' '], ['-', ''], $conf['accept-language']); + return ['config' => $conf, 'locationids' => []]; } /** @@ -910,9 +846,6 @@ class Page_LocationInfo extends Page $array[$day][] = array($s, $e); } - /** - * Ajax the config of a panel. - */ private function showPanelConfig(): void { $id = Request::get('uuid', false, 'string'); @@ -953,43 +886,24 @@ class Page_LocationInfo extends Page } $config['panelname'] = $panel['panelname']; - $langs = Dictionary::getLanguages(true); - if (isset($config['language'])) { - foreach ($langs as &$lang) { - if ($lang['cc'] === $config['language']) { - $lang['selected'] = 'selected'; - } - } - } + $configData = LocationInfo::getEditTemplateData($panel['paneltype'], $config); + LocationInfo::makeCheckedProperties($panel['paneltype'], $config); if ($panel['paneltype'] === 'DEFAULT') { - Render::addTemplate('page-config-panel-default', array( + // The override part is unfortunately too specialized to use the LocationInfo::getEditTemplateData() + // helper, so we keep using our specialized template + Render::addTemplate('page-config-panel-default', [ 'new' => $id === 'new', 'uuid' => $id, 'panelname' => $panel['panelname'] ?? '', - 'languages' => $langs, - 'mode' => $config['mode'], - 'vertical_checked' => $config['vertical'] ? 'checked' : '', - 'eco_checked' => $config['eco'] ? 'checked' : '', - 'prettytime_checked' => $config['prettytime'] ? 'checked' : '', - 'roomplanner' => $config['roomplanner'], - 'startday' => $config['startday'], - 'scaledaysauto_checked' => $config['scaledaysauto'] ? 'checked' : '', - 'daystoshow' => $config['daystoshow'], - 'rotation' => $config['rotation'], - 'scale' => $config['scale'], - 'switchtime' => $config['switchtime'], - 'calupdate' => $config['calupdate'], - 'roomupdate' => $config['roomupdate'], 'locations' => Location::getLocations(), 'locationids' => $panel['locationids'] ?? '', 'overrides' => json_encode($config['overrides']), - 'hostname_checked' => $config['hostname'] ? 'checked' : '', - )); + ] + $config); } elseif ($panel['paneltype'] === 'URL') { - + // Bookmarks are handled differently $bookmarksArray = []; - if ($config['bookmarks'] !== '') { + if (!empty($config['bookmarks'])) { $bookmarksConfig = explode(' ', $config['bookmarks']); foreach ($bookmarksConfig AS $bookmark) { $bookmark = explode(',', $bookmark); @@ -1001,50 +915,26 @@ class Page_LocationInfo extends Page ]; } } - + unset($config['bookmarks']); + // URL filtering also has a custom style that can't be handled generically LocationInfo::cleanupUrlFilter($config); - Render::addTemplate('page-config-panel-url', array( 'new' => $id === 'new', 'uuid' => $id, - 'panelname' => $panel['panelname'] ?? '', - 'url' => $config['url'], - 'zoom-factor' => $config['zoom-factor'], - 'language' => $config['language'], - 'screen-rotation' => $config['screen-rotation'], - 'ssl_checked' => $config['insecure-ssl'] ? 'checked' : '', - 'reloadminutes' => (int)$config['reload-minutes'], - 'whitelist' => str_replace("\n", "\r\n", $config['whitelist']), - 'blacklist' => str_replace("\n", "\r\n", $config['blacklist']), - 'split-login_checked' => $config['split-login'] ? 'checked' : '', - 'browser' => $config['browser'], - 'interactive_checked' => $config['interactive'] ? 'checked' : '', - 'hwvideo_checked' => $config['hw-video'] ? 'checked' : '', + 'sections' => $configData, 'bookmarks' => $bookmarksArray, - 'allow-tty_' . $config['allow-tty'] . '_checked' => 'checked', + 'whitelist' => $config['whitelist'], + 'blacklist' => $config['blacklist'], )); - } elseif ($panel['paneltype'] === 'UPCOMING') { - $configData = LocationInfo::getEditTemplateData($panel['paneltype'], $config); - LocationInfo::makeCheckedProperties($panel['paneltype'], $config); - Render::addTemplate('page-config-panel-upcoming', array( + } else { + // Use generic edit template + Render::addTemplate('page-config-panel-generic', array( 'new' => $id === 'new', 'uuid' => $id, 'sections' => $configData, - 'locationtree' => Render::parse('fragment-locationtree', [ - 'locations' => Location::getLocations(explode(',', $panel['locationids'] ?? '')), - ]), - )); - } elseif ($panel['paneltype'] === 'SUMMARY') { - Render::addTemplate('page-config-panel-summary', array( - 'new' => $id === 'new', - 'uuid' => $id, - 'panelname' => $panel['panelname'] ?? '', - 'languages' => $langs, - 'panelupdate' => $config['panelupdate'], - 'roomplanner' => $config['roomplanner'], - 'locations' => Location::getLocations(), - 'locationids' => $panel['locationids'] ?? '', - 'eco_checked' => $config['eco'] ? 'checked' : '', + 'paneltype' => $panel['paneltype'], + 'heading-hint' => Dictionary::translateFile('panel-params', 'intro-' . $panel['paneltype']), + 'locations' => Location::getLocations(explode(',', $panel['locationids'] ?? '')), )); } } @@ -1062,27 +952,35 @@ class Page_LocationInfo extends Page http_response_code(404); die('Panel with given uuid not found'); } - - if ($type === 'URL') { + if ($type === 'URL') { // Shortcut - URL panel is just a redirect Util::redirect($config['url']); } - $data = []; + // Figure out if the panel is being accessed directly, or via the pretty rewrite preg_match('#^/(.*)/#', $_SERVER['PHP_SELF'], $script); preg_match('#^/([^?]+)/#', $_SERVER['REQUEST_URI'], $request); if ($script[1] !== $request[1]) { - // Working with server-side redirects - $data['api'] = 'api/'; + // Working with server-side rewrites + $config['api'] = 'api/'; } else { // 1:1 - $data['api'] = 'api.php?do=locationinfo&'; + $config['api'] = 'api.php?do=locationinfo&'; + } + + // Check if we have a customized template, build filename + $templateFile = 'frontend-' . strtolower($type); + if (!empty($config['mod']) && preg_match('#^[a-z0-9]+$#', $config['mod']) + && file_exists('modules/locationinfo/templates/' . $templateFile . '-' . $config['mod'] . '.html')) { + $templateFile .= '-' . $config['mod']; } $lang = $config['language'] ?? 'en'; $reqLang = Request::get('forcelang', false, 'string'); if ($reqLang !== false && Dictionary::hasLanguage($reqLang)) { + // Language overridden by parameter? $lang = $reqLang; } elseif ($config['language-system'] ?? false) { + // Language overridden by client's browser headers? $langs = preg_split('/[,\s]+/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); foreach ($langs as $check) { $check = substr($check, 0, 2); @@ -1092,46 +990,28 @@ class Page_LocationInfo extends Page } } } - unset($config['language']); - unset($config['language-system']); + unset($config['language'], $config['language-system']); + $config['uuid'] = $uuid; + $config['language'] = $lang; + if ($type === 'SUMMARY') { $locations = LocationInfo::getLocationsOr404($uuid, false); $config['tree'] = Location::getTree(...$locations); - } - $data += array( - 'uuid' => $uuid, - 'config' => json_encode($config), - 'language' => $lang, - ) + $config; - - if ($type === 'DEFAULT') { - die(Render::parse('frontend-default', $data, null, $lang)); - } - - if ($type === 'UPCOMING') { - $mod = ''; - if (!empty($config['mod']) && preg_match('#^[a-z0-9]+$#', $config['mod']) && file_exists('modules/locationinfo/templates/frontend-upcoming-' . $config['mod'] . '.html')) { - $mod = '-' . $config['mod']; - } + } elseif ($type === 'UPCOMING') { $bg = $this->parseCssColor($config['color_bg'] ?? '#000'); if ($bg !== null) { - $data['color_grad1'] = 'rgba(' . $bg[0] . ',' . $bg[1] . ',' . $bg[2] . ', 0)'; - $data['color_grad2'] = 'rgba(' . $bg[0] . ',' . $bg[1] . ',' . $bg[2] . ', .1)'; - $data['color_grad3'] = 'rgba(' . $bg[0] . ',' . $bg[1] . ',' . $bg[2] . ', .9)'; + $config['color_grad1'] = 'rgba(' . $bg[0] . ',' . $bg[1] . ',' . $bg[2] . ', 0)'; + $config['color_grad2'] = 'rgba(' . $bg[0] . ',' . $bg[1] . ',' . $bg[2] . ', .1)'; + $config['color_grad3'] = 'rgba(' . $bg[0] . ',' . $bg[1] . ',' . $bg[2] . ', .9)'; } $fg = $this->parseCssColor($config['color_fg'] ?? '#fff'); if ($fg !== null) { - $data['color_half'] = 'rgba(' . $fg[0] . ',' . $fg[1] . ',' . $fg[2] . ', .5)'; + $config['color_half'] = 'rgba(' . $fg[0] . ',' . $fg[1] . ',' . $fg[2] . ', .5)'; } - die(Render::parse('frontend-upcoming' . $mod, $data, null, $lang)); - } - - if ($type === 'SUMMARY') { - die(Render::parse('frontend-summary', $data, null, $lang)); } - http_response_code(500); - die('Unknown panel type ' . $type); + $config['config'] = json_encode($config); // Must be last, obviously + die(Render::parse($templateFile, $config, null, $lang)); } /** diff --git a/modules-available/locationinfo/templates/fragment-locationtree.html b/modules-available/locationinfo/templates/fragment-locationtree.html deleted file mode 100644 index 96cd8e24..00000000 --- a/modules-available/locationinfo/templates/fragment-locationtree.html +++ /dev/null @@ -1,48 +0,0 @@ -<div class="col-md-6"> - <div class="panel panel-default"> - <div class="panel-heading">{{lang_locations}}</div> - <div class="panel-body"> - <p>{{lang_locsHint}}</p> - <ul id="selected-locations" class="list-unstyled"> - {{#locations}} - <li> - {{locationpad}} - <div class="checkbox checkbox-inline"> - <input type="checkbox" name="locationids[]" value="{{locationid}}" {{checked}} id="locid-{{locationid}}"> - <label for="locid-{{locationid}}">{{locationname}}</label> - </div> - </li> - {{/locations}} - </ul> - </div> - </div> -</div> - -<div class="modal fade" id="no-locations-message" tabindex="-1" role="dialog"> - <div class="modal-dialog"> <!--style="min-width:600px;width:70%"--> - - <div class="modal-content"> - <div class="modal-header">{{lang_error}}</div> - <div class="modal-body"> - {{lang_noLocationsWarning}} - </div> - <div class="modal-footer"> - <a class="btn btn-primary pull-right" data-dismiss="modal">{{lang_close}}</a> - <div class="clearfix"></div> - </div> - </div> - - </div> -</div> - -<script> - document.addEventListener('DOMContentLoaded', function() { - $('#config-form').submit(function(ev) { - if ($('#selected-locations input[type=checkbox]:checked').length > 0) { - return; - } - ev.preventDefault(); - $('#no-locations-message').modal('show'); - }); - }); -</script>
\ No newline at end of file diff --git a/modules-available/locationinfo/templates/frontend-summary.html b/modules-available/locationinfo/templates/frontend-summary.html index ababe08d..81545d22 100644 --- a/modules-available/locationinfo/templates/frontend-summary.html +++ b/modules-available/locationinfo/templates/frontend-summary.html @@ -127,6 +127,11 @@ }); function init() { + if (!config || !config.tree || !config.tree.length) { + fatalError("No config found, or corrupted."); + return; + } + console.log("Config: " + JSON.stringify(config)) var time = false; if (config.time) { var p = config.time.split('-'); diff --git a/modules-available/locationinfo/templates/page-config-panel-generic.html b/modules-available/locationinfo/templates/page-config-panel-generic.html new file mode 100644 index 00000000..36f7da81 --- /dev/null +++ b/modules-available/locationinfo/templates/page-config-panel-generic.html @@ -0,0 +1,98 @@ +<h2> + {{#new}}{{lang_createPanel}}{{/new}} + {{^new}}{{lang_editPanel}}{{/new}} +</h2> + +<p>{{heading-hint}}</p> + +<form method="post" action="?do=locationinfo" id="config-form"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="writePanelConfig"> + <input type="hidden" name="ptype" value="{{paneltype}}"> + <input type="hidden" name="uuid" value="{{uuid}}"> + + <div class="row"> + + <div class="col-md-6"> + {{#sections}} + <div class="panel panel-default"> + <div class="panel-heading">{{title}}</div> + <div class="list-group"> + {{#elements}} + <div class="list-group-item"> + <div class="row"> + <div class="col-sm-5"> + <label for="panel-title">{{title}}</label> + </div> + <div class="col-sm-7"> + {{{html}}} + </div> + <div class="col-sm-12 small text-muted spacebottop"> + {{helptext}} + </div> + </div> + </div> + {{/elements}} + </div> + </div> + {{/sections}} + </div> + + <div class="col-md-6"> + <div class="panel panel-default"> + <div class="panel-heading">{{lang_locations}}</div> + <div class="panel-body"> + <p>{{lang_locsHint}}</p> + <ul id="selected-locations" class="list-unstyled"> + {{#locations}} + <li> + {{locationpad}} + <div class="checkbox checkbox-inline"> + <input type="checkbox" name="locationids[]" value="{{locationid}}" {{checked}} id="locid-{{locationid}}"> + <label for="locid-{{locationid}}">{{locationname}}</label> + </div> + </li> + {{/locations}} + </ul> + </div> + </div> + </div> + + </div> + <div class="text-right"> + <a href="?do=locationinfo&show=panels" class="btn btn-default">{{lang_cancel}}</a> + <button type="submit" class="btn btn-primary"> + <span class="glyphicon glyphicon-floppy-disk"></span> + {{lang_save}} + </button> + </div> +</form> + +<div class="modal fade" id="no-locations-message" tabindex="-1" role="dialog"> + <div class="modal-dialog"> + + <div class="modal-content"> + <div class="modal-header">{{lang_error}}</div> + <div class="modal-body"> + {{lang_noLocationsWarning}} + </div> + <div class="modal-footer"> + <a class="btn btn-primary pull-right" data-dismiss="modal">{{lang_close}}</a> + <div class="clearfix"></div> + </div> + </div> + + </div> +</div> + +<script> + document.addEventListener('DOMContentLoaded', function() { + $('#config-form').submit(function(ev) { + if ($('#selected-locations input[type=checkbox]:checked').length > 0) { + return; + } + ev.preventDefault(); + $('#no-locations-message').modal('show'); + }); + }); +</script>
\ No newline at end of file diff --git a/modules-available/locationinfo/templates/page-config-panel-summary.html b/modules-available/locationinfo/templates/page-config-panel-summary.html deleted file mode 100644 index a7a34217..00000000 --- a/modules-available/locationinfo/templates/page-config-panel-summary.html +++ /dev/null @@ -1,243 +0,0 @@ -<h2> - {{#new}}{{lang_createPanel}}{{/new}} - {{^new}}{{lang_editPanel}}{{/new}} -</h2> - -<p>{{lang_editSummaryPanelHints}}</p> - -<form method="post" action="?do=locationinfo" id="config-form"> - <input type="hidden" name="token" value="{{token}}"> - <input type="hidden" name="action" value="writePanelConfig"> - <input type="hidden" name="ptype" value="SUMMARY"> - <input type="hidden" name="uuid" value="{{uuid}}"> - - <div class="row"> - - <div class="col-md-6"> - <div class="modify-inputs panel panel-default"> - <div class="panel-heading">{{lang_display}}</div> - <div class="list-group"> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="panel-title">{{lang_displayName}}</label> - </div> - <div class="col-sm-8"> - <input class="form-control" name="name" id="panel-title" type="text" value="{{panelname}}"> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_displayNameTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="language">{{lang_language}}</label> - </div> - <div class="col-sm-8"> - <select class="form-control" name="language" id="language"> - {{#languages}} - <option value="{{cc}}" id="lang-{{cc}}" {{selected}}>{{name}}</option> - {{/languages}} - </select> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_languageTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="input-eco">{{lang_ecoMode}}</label> - </div> - <div class="col-sm-8"> - <div class="checkbox"> - <input id="input-eco" type="checkbox" name="eco" {{eco_checked}}> - <label></label> - </div> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_ecoTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="input-roomplanner">{{lang_useRoomplanner}}</label> - </div> - <div class="col-sm-8"> - <select class="form-control" name="roomplanner" id="input-roomplanner"> - <option value="0" id="roomplanner0">{{lang_countIp}}</option> - <option value="1" id="roomplanner1">{{lang_countRoomplan}}</option> - </select> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_roomplannerTooltip}} - </div> - </div> - </div> -<!-- - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="input-prettytime">{{lang_prettytime}}</label> - </div> - <div class="col-sm-8"> - <input id="input-prettytime" type="checkbox" name="prettytime" {{prettytime_checked}}> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_prettytimeTooltip}} - </div> - </div> - </div> ---> - </div> - </div> - </div> - - <div class="col-md-6"> - <div class="panel panel-default"> - <div class="panel-heading">{{lang_updateRates}}</div> - <div class="list-group"> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="form-panelupdate">{{lang_panel}}</label> - </div> - <div class="col-sm-8"> - <input class="form-control" name="panelupdate" type="number" min="15" id="form-panelupdate" - max="86400" value="{{panelupdate}}" required> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_summaryUpdateIntervalTooltip}} - </div> - </div> - </div> - - </div> - </div> - </div> - </div> - - <div class="modify-inputs"> - <div class="row"> - - <div class="col-md-6"> - <div class="panel panel-default"> - <div class="panel-heading">{{lang_locations}}</div> - <div class="panel-body"> - <input type="hidden" name="locationids" value="{{locationids}}" id="locationids"> - <p>{{lang_locsHint}}</p> - <ul id="selected-locations" class="list-unstyled"> - - </ul> - <div class="dropdown pull-right"> - <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown"> - <span class="glyphicon glyphicon-plus"></span> - </button> - <ul class="dropdown-menu" id="location-list"> - {{#locations}} - <li><a href="#" data-lid="{{locationid}}">{{locationpad}} <span class="name">{{locationname}}</span></a></li> - {{/locations}} - </ul> - </div> - <div class="clearfix"></div> - </div> - </div> - </div> - - </div> - </div> - <div class="text-right"> - <a href="?do=locationinfo&show=panels" class="btn btn-default">{{lang_cancel}}</a> - <button type="submit" class="btn btn-primary"> - <span class="glyphicon glyphicon-floppy-disk"></span> - {{lang_save}} - </button> - </div> -</form> - -<div class="modal fade" id="no-locations-message" tabindex="-1" role="dialog"> - <div class="modal-dialog"> <!--style="min-width:600px;width:70%"--> - - <div class="modal-content"> - <div class="modal-header">{{lang_error}}</div> - <div class="modal-body"> - {{lang_noLocationsWarning}} - </div> - <div class="modal-footer"> - <a class="btn btn-primary pull-right" data-dismiss="modal">{{lang_close}}</a> - <div class="clearfix"></div> - </div> - </div> - - </div> -</div> - -<script type="text/javascript"><!-- - -document.addEventListener("DOMContentLoaded", function () { - var $selLocs = $('#selected-locations'); - var $locList = $('#location-list'); - var $locInput = $('#locationids'); - - // Add listener to range sliders so their label can be updated - $('input[type="range"]').change(function () { - $(this).siblings().find('.range-display').text($(this).val()); - }); - // Set state of input controls that aren't statically initialized server side - var lids = $locInput.val().split(','); - $selLocs.empty(); - for (var i = 0; i < lids.length; ++i) { - var $name = $locList.find('a[data-lid="' + lids[i] + '"] .name'); - if ($name.length === 0) continue; - addLocation(lids[i], $name.text()); - } - - // Adding/removing locations - $locList.find('a').click(function(ev) { - ev.preventDefault(); - ev.stopPropagation(); - var $this = $(this); - var name = $this.find('.name').text(); - var id = $this.data('lid'); - addLocation(id, name); - serializeLocs(); - }); - - $('#config-form').submit(function(ev) { - if ($locInput.val().length > 0) - return; - ev.preventDefault(); - $('#no-locations-message').modal('show'); - }); - - function addLocation(id, name) { - $selLocs.find('li[data-lid="' + id + '"]').remove(); - var delButton = $('<button style="margin-right: 5px;" class="btn btn-danger btn-xs" type="button">').append($('<span class="glyphicon glyphicon-remove">')).click(delParent); - $selLocs.append($('<li style="margin-top: 5px;">').attr('data-lid', id).text(name).prepend(delButton)); - } - - function delParent() { - $(this).parent().remove(); - serializeLocs(); - } - - function serializeLocs() { - var res = $selLocs.find('li[data-lid]').map( function() { - return $(this).data('lid'); - }).get().join(','); - $locInput.val(res); - } - -}); - -//--></script> diff --git a/modules-available/locationinfo/templates/page-config-panel-upcoming.html b/modules-available/locationinfo/templates/page-config-panel-upcoming.html deleted file mode 100644 index d99b1157..00000000 --- a/modules-available/locationinfo/templates/page-config-panel-upcoming.html +++ /dev/null @@ -1,51 +0,0 @@ -<h2> - {{#new}}{{lang_createPanel}}{{/new}} - {{^new}}{{lang_editPanel}}{{/new}} -</h2> - -<p>{{lang_editUpcomingPanelHints}}</p> - -<form method="post" action="?do=locationinfo" id="config-form"> - <input type="hidden" name="token" value="{{token}}"> - <input type="hidden" name="action" value="writePanelConfig"> - <input type="hidden" name="ptype" value="UPCOMING"> - <input type="hidden" name="uuid" value="{{uuid}}"> - - <div class="row"> - - <div class="col-md-6"> - {{#sections}} - <div class="panel panel-default"> - <div class="panel-heading">{{title}}</div> - <div class="list-group"> - {{#elements}} - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-5"> - <label for="panel-title">{{title}}</label> - </div> - <div class="col-sm-7"> - {{{html}}} - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{helptext}} - </div> - </div> - </div> - {{/elements}} - </div> - </div> - {{/sections}} - </div> - - {{{locationtree}}} - - </div> - <div class="text-right"> - <a href="?do=locationinfo&show=panels" class="btn btn-default">{{lang_cancel}}</a> - <button type="submit" class="btn btn-primary"> - <span class="glyphicon glyphicon-floppy-disk"></span> - {{lang_save}} - </button> - </div> -</form>
\ No newline at end of file diff --git a/modules-available/locationinfo/templates/page-config-panel-url.html b/modules-available/locationinfo/templates/page-config-panel-url.html index a0485709..192c5ab5 100644 --- a/modules-available/locationinfo/templates/page-config-panel-url.html +++ b/modules-available/locationinfo/templates/page-config-panel-url.html @@ -11,85 +11,39 @@ <input type="hidden" name="ptype" value="URL"> <input type="hidden" name="uuid" value="{{uuid}}"> - <div class="panel panel-default"> - <div class="panel-heading">{{lang_display}}</div> - <div class="list-group"> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="panel-title">{{lang_displayName}}</label> - </div> - <div class="col-sm-8"> - <input class="form-control" name="name" id="panel-title" type="text" value="{{panelname}}"> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_displayNameTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="panel-url">{{lang_url}}</label> - </div> - <div class="col-sm-8"> - <input class="form-control" name="url" id="panel-url" type="text" value="{{url}}" - placeholder="http://www.bwlehrpool.de/" pattern=".*://.*" required> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_urlTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label>{{lang_allowTtySwitch}}</label> - </div> - <div class="col-sm-8"> - <div class="radio"> - <input id="tty1" type="radio" name="allow-tty" {{allow-tty__checked}} value=""> - <label for="tty1">{{lang_useDefault}}</label> - </div> - <div class="radio"> - <input id="tty2" type="radio" name="allow-tty" {{allow-tty_yes_checked}} value="yes"> - <label for="tty2">{{lang_yes}}</label> - </div> - <div class="radio"> - <input id="tty3" type="radio" name="allow-tty" {{allow-tty_no_checked}} value="no"> - <label for="tty3">{{lang_no}}</label> + {{#sections}} + <div class="panel panel-default"> + <div class="panel-heading">{{title}}</div> + <div class="list-group"> + {{#elements}} + <div class="list-group-item {{class}}"> + <div class="row"> + <div class="col-sm-5"> + <label for="panel-title">{{title}}</label> + </div> + <div class="col-sm-7"> + {{{html}}} + </div> + <div class="col-sm-12 small text-muted spacebottop"> + {{helptext}} + </div> </div> </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_allowTtySwitchTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="input-reload">{{lang_reloadIntervalMins}}</label> - </div> - <div class="col-sm-8"> - <input class="form-control" id="input-reload" type="number" min="0" max="999" name="reloadminutes" pattern="\d*" value="{{reloadminutes}}"> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_reloadIntervalTooltip}} - </div> - </div> + {{/elements}} </div> + </div> + {{/sections}} + <div class="panel panel-default"> + <div class="panel-heading">{{lang_urlfilterHeading}}</div> + <div class="list-group"> <div class="list-group-item"> <div class="row"> - <div class="col-sm-6"> + <div class="col-md-6"> <label for="whitelist">{{lang_whitelist}}</label> <textarea id="whitelist" name="whitelist" rows="10" class="form-control">{{whitelist}}</textarea> </div> - <div class="col-sm-6"> + <div class="col-md-6"> <label for="blacklist">{{lang_blacklist}}</label> <textarea id="blacklist" name="blacklist" rows="10" class="form-control">{{blacklist}}</textarea> </div> @@ -101,152 +55,51 @@ </div> </div> </div> + </div> + </div> - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="split-login">{{lang_splitlogin}}</label> - </div> - <div class="col-sm-8"> - <div class="checkbox"> - <input id="split-login" type="checkbox" name="split-login" {{split-login_checked}} value="1"> - <label></label> - </div> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_splitloginTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="zoom-factor">{{lang_zoomFactor}}</label> - </div> - <div class="col-sm-7 col-xs-10"> - <input class="form-control" id="zoom-factor" type="range" min="50" max="300" step="5" - name="zoom-factor" value="{{zoom-factor}}"> - </div> - <div class="col-sm-1 col-xs-2"> - <span id="zoom-value">{{zoom-factor}}</span>% - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_zoomFactorTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="screen-rotation">{{lang_rotation}}</label> - </div> - <div class="col-sm-8"> - <select class="form-control" id="screen-rotation" name="screen-rotation"> - <option value="">{{lang_rotation0}}</option> - <option value="left">{{lang_rotation1}}</option> - <option value="right">{{lang_rotation3}}</option> - <option value="inverted">{{lang_rotation2}}</option> - </select> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_screenRotationTooltip}} - </div> - </div> - </div> - - <div class="list-group-item"> + <div class="panel panel-default browser-specific show-chromium show-firefox"> + <div class="panel-heading">{{lang_bookmarksHeading}}</div> + <div class="list-group"> + <div class="list-group-item" id="bookmarks"> <div class="row"> <div class="col-sm-4"> - <label for="language">{{lang_language}}</label> + <label for="bookmarks">{{lang_bookmarks}}</label> </div> <div class="col-sm-8"> - <input class="form-control" id="language" type="text" placeholder="de-DE,en-US" - name="language" value="{{language}}" pattern="[a-zA-Z0-9,_ -]*"> + <button type="button" class="btn btn-success" onclick="addBookmark()"> + <span class="glyphicon glyphicon-plus"></span> + </button> </div> <div class="col-sm-12 small text-muted spacebottop"> - {{lang_browserLanguageTooltip}} + {{lang_bookmarksTooltip}} </div> </div> - </div> - - <div class="list-group-item"> - <div class="row"> - <div class="col-sm-4"> - <label for="browser">{{lang_browser}}</label> - </div> - <div class="col-sm-8"> - <select class="form-control" name="browser" id="browser" onchange="browserChange()"> - <option value="slx-browser" id="slx">{{lang_slxbrowser}}</option> - <option value="chromium" id="chrome">{{lang_chromium}}</option> - <option value="firefox" id="firefox">{{lang_firefox}}</option> - </select> + <div class="row" style="margin-top: 1em;" id="bookmarkRow" hidden> + <div class="col-sm-3 col-sm-offset-3"> + <input class="form-control" name="bookmarkNames[]" type="text" value="" + placeholder="bwLehrpool"> </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_browserTooltip}} - </div> - </div> - </div> - - <div id="browser-specific"> - - <div class="list-group-item show-chromium show-firefox"> - <div class="row"> - <div class="col-sm-4"> - <label for="interactive">{{lang_interactive}}</label> - </div> - <div class="col-sm-8"> - <div class="checkbox"> - <input id="interactive" type="checkbox" name="interactive" {{interactive_checked}} value="1"> - <label></label> - </div> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_interactiveTooltip}} - </div> + <div class="col-sm-5"> + <input class="form-control" name="bookmarkUrls[]" type="text" value="" + placeholder="https://www.bwlehrpool.de/" pattern=".*://.*"> </div> - </div> - - <div class="list-group-item show-slx-browser show-chromium"> - <div class="row"> - <div class="col-sm-4"> - <label for="input-ssl">{{lang_insecureSsl}}</label> - </div> - <div class="col-sm-8"> - <div class="checkbox"> - <input id="input-ssl" type="checkbox" name="insecure-ssl" {{ssl_checked}} value="1"> - <label></label> - </div> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_ignoreSslTooltip}} - </div> + <div class="col-sm-1"> + <button type="button" class="btn btn-danger" onclick="$(this).closest('.row').remove()"> + <span class="glyphicon glyphicon-minus"></span> + </button> </div> </div> - <div class="list-group-item show-chromium show-firefox" id="bookmarks"> - <div class="row"> - <div class="col-sm-4"> - <label for="bookmarks">{{lang_bookmarks}}</label> - </div> - <div class="col-sm-8"> - <button type="button" class="btn btn-success" onclick="addBookmark()"> - <span class="glyphicon glyphicon-plus"></span> - </button> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_bookmarksTooltip}} - </div> - </div> - <div class="row" style="margin-top: 1em;" id="bookmarkRow" hidden> + {{#bookmarks}} + <div class="row" style="margin-top: 1em;"> <div class="col-sm-3 col-sm-offset-3"> - <input class="form-control" name="bookmarkNames[]" type="text" value="" - placeholder="bwLehrpool"> + <input class="form-control" name="bookmarkNames[]" type="text" value="{{name}}" + placeholder="bwLehrpool" required> </div> <div class="col-sm-5"> - <input class="form-control" name="bookmarkUrls[]" type="text" value="" - placeholder="https://www.bwlehrpool.de/" pattern=".*://.*"> + <input class="form-control" name="bookmarkUrls[]" type="text" value="{{url}}" + placeholder="http://www.bwlehrpool.de/" pattern=".*://.*" required> </div> <div class="col-sm-1"> <button type="button" class="btn btn-danger" onclick="$(this).closest('.row').remove()"> @@ -254,47 +107,11 @@ </button> </div> </div> - - {{#bookmarks}} - <div class="row" style="margin-top: 1em;"> - <div class="col-sm-3 col-sm-offset-3"> - <input class="form-control" name="bookmarkNames[]" type="text" value="{{name}}" - placeholder="bwLehrpool" required> - </div> - <div class="col-sm-5"> - <input class="form-control" name="bookmarkUrls[]" type="text" value="{{url}}" - placeholder="http://www.bwlehrpool.de/" pattern=".*://.*" required> - </div> - <div class="col-sm-1"> - <button type="button" class="btn btn-danger" onclick="$(this).closest('.row').remove()"> - <span class="glyphicon glyphicon-minus"></span> - </button> - </div> - </div> - {{/bookmarks}} - </div> - - <div class="list-group-item show-chromium show-firefox"> - <div class="row"> - <div class="col-sm-4"> - <label for="hw-video">{{lang_hwAccelVideo}}</label> - </div> - <div class="col-sm-8"> - <div class="checkbox"> - <input id="hw-video" type="checkbox" name="hw-video" {{hwvideo_checked}} value="1"> - <label></label> - </div> - </div> - <div class="col-sm-12 small text-muted spacebottop"> - {{lang_hwAccelVideoTooltip}} - </div> - </div> - </div> - + {{/bookmarks}} </div> - </div> </div> + <div class="text-right"> <a href="?do=locationinfo&show=panels" class="btn btn-default">{{lang_cancel}}</a> <button type="submit" class="btn btn-primary"> @@ -310,27 +127,27 @@ <script> document.addEventListener("DOMContentLoaded", function () { - // load value to dropdown menus - $('#browser option[value="{{browser}}"]').prop("selected", true); - $('#screen-rotation option[value="{{screen-rotation}}"]').prop("selected", true); - browserChange(); - var $zv = $('#zoom-value'); - var $zf = $('#zoom-factor'); - var sliderUpdate = function() { - $zv.text($zf.val()); + // Initialize show/hide logic for browser-specific settings + var browserChange = function() { + var value = $('#input-browser').val(); + var $lgis = $('.browser-specific'); + $lgis.filter(':not(.show-' + value + ')').hide(); + $lgis.filter('.show-' + value).show(); }; - $zf.on('input', sliderUpdate); - sliderUpdate(); + browserChange(); + $('#input-browser').change(browserChange); + // Slider with caption field + $('.input-slider').each(function() { + var $zf = $(this).find('input[type=range]'); + var $zv = $(this).find('.slider-value'); + var sliderUpdate = function() { + $zv.text($zf.val()); + }; + $zf.on('input', sliderUpdate); + sliderUpdate(); + }); }); -// Hide interactive-input if slx-browser is selected -function browserChange() { - var value = $('#browser').val(); - var $lgis = $('#browser-specific > .list-group-item'); - $lgis.filter(':not(.show-' + value + ')').hide(); - $lgis.filter('.show-' + value).show(); -} - // Add another bookmark input field to the form function addBookmark() { var rowCopy = $('#bookmarkRow').clone(); |
