diff options
-rw-r--r-- | inc/render.inc.php | 19 | ||||
-rw-r--r-- | modules-available/main/templates/main-menu.html | 1 | ||||
-rw-r--r-- | modules-available/webinterface/page.inc.php | 30 | ||||
-rw-r--r-- | modules-available/webinterface/templates/customization.html | 30 |
4 files changed, 79 insertions, 1 deletions
diff --git a/inc/render.inc.php b/inc/render.inc.php index 5515c659..c34c285a 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -40,6 +40,11 @@ class Render self::$mustache = new Mustache_Engine($options); } + private static function cssEsc($str) + { + return str_replace(array('"', '&', '<', '>'), array('\\000022', '\\000026', '\\00003c', '\\00003e'), $str); + } + /** * Output the buffered, generated page */ @@ -47,12 +52,24 @@ class Render { Header('Content-Type: text/html; charset=utf-8'); $modules = array_reverse(Module::getActivated()); + $title = Property::get('page-title-prefix', ''); + $bgcolor = Property::get('logo-background', ''); + if (!empty($bgcolor) || !empty($title)) { + self::$header .= '<style type="text/css">' . "\n"; + if (!empty($bgcolor)) { + self::$header .= ".navbar-header { background-color: $bgcolor; }"; + } + if (!empty($title)) { + self::$header .= '#navbar-sub:after { content: "' . self::cssEsc($title) . '";margin:0 }'; + } + self::$header .= "\n</style>"; + } ob_start('ob_gzhandler'); echo '<!DOCTYPE html> <html> <head> - <title>', self::$title, RENDER_DEFAULT_TITLE, '</title> + <title>', $title, self::$title, RENDER_DEFAULT_TITLE, '</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> diff --git a/modules-available/main/templates/main-menu.html b/modules-available/main/templates/main-menu.html index 2ede4f87..55b19833 100644 --- a/modules-available/main/templates/main-menu.html +++ b/modules-available/main/templates/main-menu.html @@ -20,6 +20,7 @@ <span class="icon-bar"></span> </button> <a class="navbar-brand" href="?do=Main">OpenSLX</a> + <div id="navbar-sub" class="gray small"></div> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-sidebar-navbar-collapse-1"> diff --git a/modules-available/webinterface/page.inc.php b/modules-available/webinterface/page.inc.php index ae9a94fd..e5a25834 100644 --- a/modules-available/webinterface/page.inc.php +++ b/modules-available/webinterface/page.inc.php @@ -21,6 +21,9 @@ class Page_WebInterface extends Page case 'password': $this->actionShowHidePassword(); break; + case 'customization': + $this->actionCustomization(); + break; } } @@ -57,6 +60,17 @@ class Page_WebInterface extends Page Util::redirect('?do=WebInterface'); } + private function actionCustomization() + { + $prefix = Request::post('prefix', '', 'string'); + if (!empty($prefix) && !preg_match('/[\]\)\}\-_\s\&\$\!\/\+\*\^\>]$/', $prefix)) { + $prefix .= ' '; + } + Property::set('page-title-prefix', $prefix); + Property::set('logo-background', Request::post('bgcolor', '', 'string')); + Util::redirect('?do=WebInterface'); + } + protected function doRender() { // @@ -118,6 +132,22 @@ class Page_WebInterface extends Page else $data['selected_hide'] = 'checked'; Render::addTemplate('passwords', $data); + $data = array('prefix' => Property::get('page-title-prefix')); + $data['colors'] = array_map(function ($i) { return array('color' => $i); }, + array('', 'red', 'green', 'blue', 'black', 'white', 'orange', 'gray', 'lime', 'magenta', 'yellow')); + $color = Property::get('logo-background'); + foreach ($data['colors'] as &$c) { + if ($c['color'] === $color) { + $c['selected'] = 'selected'; + $color = false; + break; + } + } + unset($c); + if ($color) { + $data['colors'][] = array('color' => $color, 'selected' => 'selected'); + } + Render::addTemplate('customization', $data); } private function setHttpsOff() diff --git a/modules-available/webinterface/templates/customization.html b/modules-available/webinterface/templates/customization.html new file mode 100644 index 00000000..447404a6 --- /dev/null +++ b/modules-available/webinterface/templates/customization.html @@ -0,0 +1,30 @@ +<form action="?do=WebInterface" method="post"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="customization"> + <div class="panel panel-default"> + <div class="panel-heading">{{lang_customization}}</div> + <div class="panel-body"> + <p>{{lang_customizationDesc}}</p> + <div> + <label> + {{lang_pageTitlePrefix}} + <input type="text" class="form-control" name="prefix" value="{{prefix}}"> + </label> + + </div> + <div> + <label> + {{lang_logoBackground}} + <select class="form-control" name="bgcolor"> + {{#colors}} + <option style="color:{{color}}" {{selected}}>{{color}}</option> + {{/colors}} + </select> + </label> + </div> + <div class="pull-right"> + <button type="submit" class="btn btn-primary">{{lang_save}}</button> + </div> + </div> + </div> +</form> |