Browse Source

Template: Convert to Smarty syntax.

Nate 5 years ago
parent
commit
749eb06838
6 changed files with 977 additions and 863 deletions
  1. 252 0
      resources/classes/menu.php
  2. 164 40
      resources/footer.php
  3. 0 1
      resources/login.php
  4. 0 3
      resources/require.php
  5. 4 6
      themes/default/css.php
  6. 557 813
      themes/default/template.php

+ 252 - 0
resources/classes/menu.php

@@ -47,6 +47,7 @@ if (!class_exists('menu')) {
 		private $location;
 		private $location;
 		public $menu_uuid;
 		public $menu_uuid;
 		public $menu_language;
 		public $menu_language;
+		public $text;
 
 
 		/**
 		/**
 		 * called when the object is created
 		 * called when the object is created
@@ -909,6 +910,257 @@ if (!class_exists('menu')) {
 				}
 				}
 				unset($sql, $parameters, $result, $row);
 				unset($sql, $parameters, $result, $row);
 		}
 		}
+
+		/**
+		 * build the fixed, static or inline horizontal menu html
+		 */
+		public function menu_horizontal($menu_array) {
+
+			//determine menu behavior
+				$menu_style = $_SESSION['theme']['menu_style']['text'] != '' ? $_SESSION['theme']['menu_style']['text'] : 'fixed';
+				switch ($menu_style) {
+					case 'inline':
+						$menu_type = 'default';
+						$menu_width = 'calc(100% - 20px)';
+						$menu_brand = false;
+						$menu_corners = null;
+						break;
+					case 'static':
+						$menu_type = 'static-top';
+						$menu_width = 'calc(100% - 40px)';
+						$menu_brand = true;
+						$menu_corners = "style='-webkit-border-radius: 0 0 4px 4px; -moz-border-radius: 0 0 4px 4px; border-radius: 0 0 4px 4px;'";
+						break;
+					case 'fixed':
+					default:
+						$menu_type = 'fixed-'.($_SESSION['theme']['menu_position']['text'] != '' ? $_SESSION['theme']['menu_position']['text'] : 'top');
+						if (!http_user_agent('mobile')) {
+							$menu_width = $_SESSION['theme']['menu_width_fixed']['text'] != '' ? $_SESSION['theme']['menu_width_fixed']['text'] : 'calc(90% - 20px)';
+						}
+						$menu_brand = true;
+						$menu_corners = null;
+				}
+
+			//begin navbar code
+				$html = "<nav class='navbar navbar-expand-sm ".$menu_type."' ".$menu_corners.">\n";
+				$html .= "	<div class='container-fluid' style='width: ".$menu_width."; padding: 0;'>\n";
+				$html .= "		<div class='navbar-brand'>\n";
+
+				if ($menu_brand) {
+					//define menu brand mark
+						$menu_brand_text = ($_SESSION['theme']['menu_brand_text']['text'] != '') ? escape($_SESSION['theme']['menu_brand_text']['text']) : "FusionPBX";
+						switch ($_SESSION['theme']['menu_brand_type']['text']) {
+							case 'text':
+								$html .= "			<a class='navbar-brand-text'  href='".PROJECT_PATH."/'>".$menu_brand_text."</a>\n";
+								break;
+							case 'image_text':
+								$menu_brand_image = ($_SESSION['theme']['menu_brand_image']['text'] != '') ? escape($_SESSION['theme']['menu_brand_image']['text']) : PROJECT_PATH."/themes/default/images/logo.png";
+								$html .= "			<a href='".PROJECT_PATH."/'>";
+								$html .= "				<img id='menu_brand_image' class='navbar-logo' src='".$menu_brand_image."' title=\"".escape($menu_brand_text)."\">";
+								if ($_SESSION['theme']['menu_brand_image_hover']['text'] != '') {
+									$html .= 			"<img id='menu_brand_image_hover' class='navbar-logo' style='display: none;' src='".$_SESSION['theme']['menu_brand_image_hover']['text']."' title=\"".escape($menu_brand_text)."\">";
+								}
+								$html .= 			"</a>\n";
+								$html .= "			<a class='navbar-brand-text' href='".PROJECT_PATH."/'>".$menu_brand_text."</a>\n";
+								break;
+							case 'none':
+								break;
+							case 'image':
+							default:
+								$menu_brand_image = ($_SESSION['theme']['menu_brand_image']['text'] != '') ? escape($_SESSION['theme']['menu_brand_image']['text']) : PROJECT_PATH."/themes/default/images/logo.png";
+								$html .= "			<a href='".PROJECT_PATH."/'>";
+								$html .= "				<img id='menu_brand_image' class='navbar-logo' src='".$menu_brand_image."' title=\"".escape($menu_brand_text)."\">";
+								if (isset($_SESSION['theme']['menu_brand_image_hover']['text']) && $_SESSION['theme']['menu_brand_image_hover']['text'] != '') {
+									$html .= 			"<img id='menu_brand_image_hover' class='navbar-logo' style='display: none;' src='".$_SESSION['theme']['menu_brand_image_hover']['text']."' title=\"".escape($menu_brand_text)."\">";
+								}
+								$html .= 			"</a>\n";
+								$html .= "			<a style='margin: 0;'></a>\n";
+						}
+				}
+
+				$html .= "		</div>\n";
+
+				$html .= "		<button type='button' class='navbar-toggler' data-toggle='collapse' data-target='#main_navbar' aria-expanded='false' aria-controls='main_navbar' aria-label='Toggle Menu'>\n";
+				$html .= "			<span class='fas fa-bars'></span>\n";
+				$html .= "		</button>\n";
+
+				$html .= "		<div class='collapse navbar-collapse' id='main_navbar'>\n";
+				$html .= "			<ul class='navbar-nav'>\n";
+
+				if (is_array($menu_array) && sizeof($menu_array) != 0) {
+					foreach ($menu_array as $index_main => $menu_parent) {
+						$mod_li = "nav-item";
+						$mod_a_1 = "";
+						$submenu = false;
+						if (is_array($menu_parent['menu_items']) && sizeof($menu_parent['menu_items']) > 0) {
+							$mod_li = "nav-item dropdown ";
+							$mod_a_1 = "data-toggle='dropdown' ";
+							$submenu = true;
+						}
+						$mod_a_2 = ($menu_parent['menu_item_link'] != '' && !$submenu) ? $menu_parent['menu_item_link'] : '#';
+						$mod_a_3 = ($menu_parent['menu_item_category'] == 'external') ? "target='_blank' " : null;
+						if (isset($_SESSION['theme']['menu_main_icons']['boolean']) && $_SESSION['theme']['menu_main_icons']['boolean'] == 'true') {
+							if ($menu_parent['menu_item_icon'] != '' && substr_count($menu_parent['menu_item_icon'], 'fa-') > 0) {
+								$menu_main_icon = "<span class='fas ".$menu_parent['menu_item_icon']."' title=\"".escape($menu_parent['menu_language_title'])."\"></span>\n";
+							}
+							else {
+								$menu_main_icon = null;
+							}
+							$menu_main_item = "<span class='d-sm-none d-md-none d-lg-inline' style='margin-left: 5px;'>".$menu_parent['menu_language_title']."</span>\n";
+						}
+						else {
+							$menu_main_item = $menu_parent['menu_language_title'];
+						}
+						$html .= "				<li class='".$mod_li."'>\n";
+						$html .= "					<a class='nav-link' ".$mod_a_1." href='".$mod_a_2."' ".$mod_a_3.">\n";
+						$html .= "						".$menu_main_icon.$menu_main_item;
+						$html .= "					</a>\n";
+						if ($submenu) {
+							$html .= "					<ul class='dropdown-menu'>\n";
+							foreach ($menu_parent['menu_items'] as $index_sub => $menu_sub) {
+								$mod_a_2 = $menu_sub['menu_item_link'];
+								if ($mod_a_2 == '') {
+									$mod_a_2 = '#';
+								}
+								$mod_a_3 = ($menu_sub['menu_item_category'] == 'external') ? "target='_blank' " : null;
+								if ($_SESSION['theme']['menu_sub_icons']['boolean'] != 'false') {
+									if ($menu_sub['menu_item_icon'] != '' && substr_count($menu_sub['menu_item_icon'], 'fa-') > 0) {
+										$menu_sub_icon = "<span class='fas ".escape($menu_sub['menu_item_icon'])."'></span>";
+									}
+									else {
+										$menu_sub_icon = null;
+									}
+								}
+								$html .= "						<li class='nav-item'><a class='nav-link' href='".$mod_a_2."' ".$mod_a_3.">".($_SESSION['theme']['menu_sub_icons'] ? "<span class='fas fa-bar d-inline-block d-sm-none float-left' style='margin: 4px 10px 0 25px;'></span>" : null).escape($menu_sub['menu_language_title']).$menu_sub_icon."</a></li>\n";
+							}
+							$html .= "					</ul>\n";
+						}
+						$html .= "				</li>\n";
+					}
+				}
+				$html .= "			</ul>\n";
+
+				$html .= "			<ul class='navbar-nav ml-auto'>\n";
+				//domain name/selector
+					if (isset($_SESSION['username']) && $_SESSION['username'] != '' && permission_exists('domain_select') && count($_SESSION['domains']) > 1 && $_SESSION['theme']['domain_visible']['text'] == 'true') {
+						$html .= "		<li class='nav-item'>\n";
+						$html .= "			<a class='nav-link domain_selector_domain' href='#' title='".$this->text['theme-label-open_selector']."'>".escape($_SESSION['domain_name'])."</a>";
+						$html .= "		</li>\n";
+					}
+				//logout icon
+					if (isset($_SESSION['username']) && $_SESSION['username'] != '' && $_SESSION['theme']['logout_icon_visible']['text'] == "true") {
+						$username_full = $_SESSION['username'].((count($_SESSION['domains']) > 1) ? "@".$_SESSION["user_context"] : null);
+						$html .= "		<li class='nav-item'>\n";
+						$html .= "			<a class='nav-link logout_icon' href='".PROJECT_PATH."/logout.php' title=\"".$text['theme-label-logout']."\" onclick=\"return confirm('".$this->text['theme-confirm-logout']."')\"><span class='fas fa-sign-out-alt'></span></a>";
+						$html .= "		</li>\n";
+						unset($username_full);
+					}
+				$html .= "			</ul>\n";
+
+				$html .= "		</div>\n";
+				$html .= "	</div>\n";
+				$html .= "</nav>\n";
+
+				return $html;
+				unset($html);
+
+		}
+
+		/**
+		 * build the vertical side menu html
+		 */
+		public function menu_vertical($menu_array) {
+
+			//menu brand image and/or text
+				if ($_SESSION['theme']['menu_brand_type']['text'] == 'none') {
+					$html = "	<div style='height: 75px;'>\n";
+					$html .= 		"<a class='menu_side_item_main menu_side_contract' onclick='menu_side_contract();' style='display: none;'><i class='fas fa-chevron-left' style='z-index: 99800; padding-left: 3px;'></i></a>";
+					$html .= 		"<a class='menu_side_item_main menu_side_expand' onclick='menu_side_expand();'><i class='fas fa-bars' style='z-index: 99800; padding-left: 3px;'></i></a>";
+					$html .= 	"</div>\n";
+				}
+				else {
+					$html = "	<div id='menu_side_brand_container'>\n";
+					//menu toggle buttons
+						if ($_SESSION['theme']['menu_brand_type']['text'] != 'none') {
+							$html .= "		<div style='float: right; margin-right: -20px; margin-top: -20px;'>\n";
+							$html .= "			<a class='menu_side_item_main menu_side_contract' onclick='menu_side_contract();' style='display: none;'><i class='fas fa-chevron-left'></i></a>\n";
+							$html .= "		</div>\n";
+						}
+					//show the menu brand image and/or text
+						$menu_brand_image_contracted =  $_SESSION['theme']['menu_side_brand_image_contracted']['text'] != '' ? $_SESSION['theme']['menu_side_brand_image_contracted']['text'] : PROJECT_PATH."/themes/default/images/logo_side_contracted.png";
+						$menu_brand_image_expanded =  $_SESSION['theme']['menu_side_brand_image_expanded']['text'] != '' ? $_SESSION['theme']['menu_side_brand_image_expanded']['text'] : PROJECT_PATH."/themes/default/images/logo_side_expanded.png";
+						$menu_brand_text = ($_SESSION['theme']['menu_brand_text']['text'] != '') ? escape($_SESSION['theme']['menu_brand_text']['text']) : "FusionPBX";
+						if ($_SESSION['theme']['menu_brand_type']['text'] == 'image' || $_SESSION['theme']['menu_brand_type']['text'] == '') {
+							$html .= "		<a href='".PROJECT_PATH."/' style='text-decoration: none;'>";
+							$html .= 			"<img id='menu_brand_image_contracted' style='width: 20px; margin-left: -2px; margin-top: -5px;' src='".escape($menu_brand_image_contracted)."' title=\"".escape($menu_brand_text)."\">";
+							$html .= 			"<img id='menu_brand_image_expanded' style='display: none;' src='".escape($menu_brand_image_expanded)."' title=\"".escape($menu_brand_text)."\">";
+							$html .= 		"</a>\n";
+						}
+						else if ($_SESSION['theme']['menu_brand_type']['text'] == 'image_text') {
+							$html .= "		<a href='".PROJECT_PATH."/' style='text-decoration: none;'>";
+							$html .= 			"<img id='menu_brand_image_contracted' style='width: 20px; margin-left: -2px; margin-top: -5px;' src='".escape($menu_brand_image_contracted)."' title=\"".escape($menu_brand_text)."\">";
+							$html .= 			"<span class='menu_brand_text' style='display: none;'>".$menu_brand_text."</span>";
+							$html .= 		"</a>\n";
+						}
+						else if ($_SESSION['theme']['menu_brand_type']['text'] == 'text') {
+							$html .= "		<a class='menu_brand_text' style='display: none;' href='".PROJECT_PATH."/'>".$menu_brand_text."</a>\n";
+						}
+					$html .= "	</div>\n";
+				}
+			//main menu items
+				if (is_array($menu_array) && sizeof($menu_array) != 0) {
+					foreach ($menu_array as $menu_index_main => $menu_item_main) {
+						$html .= "	<a class='menu_side_item_main' ".($menu_item_main['menu_item_link'] != '' ? "href='".$menu_item_main['menu_item_link']."'" : "onclick=\"menu_side_expand(); $('#sub_".$menu_item_main['menu_item_uuid']."').slideToggle(180, function() { if (!$(this).is(':hidden')) { $('.menu_side_sub').not($(this)).slideUp(180); } });\"")." title=\"".$menu_item_main['menu_language_title']."\">";
+						if ($menu_item_main['menu_item_icon'] != '') {
+							$html .= "<i class='fas ".$menu_item_main['menu_item_icon']." fa-fw' style='z-index: 99800; margin-right: 8px;'></i>";
+						}
+						$html .= "<span class='menu_side_item_title' style='display: none;'>".$menu_item_main['menu_language_title']."</span>";
+						$html .= "</a>\n";
+						//sub menu items
+							if (is_array($menu_item_main['menu_items']) && sizeof($menu_item_main['menu_items']) != 0) {
+								$html .= "	<div id='sub_".$menu_item_main['menu_item_uuid']."' class='menu_side_sub' style='display: none;'>\n";
+								foreach ($menu_item_main['menu_items'] as $menu_index_sub => $menu_item_sub) {
+									$html .= "		<a class='menu_side_item_sub' ".($menu_item_sub['menu_item_category'] == 'external' ? "target='_blank'" : null)." href='".$menu_item_sub['menu_item_link']."'>";
+									$html .= 			"<span class='menu_side_item_title' style='display: none;'>".$menu_item_sub['menu_language_title']."</span>";
+									$html .= 		"</a>\n";
+								}
+								$html .= "	</div>\n";
+							}
+					}
+					$html .= "	<div style='height: 100px;'></div>\n";
+				}
+			$html .= "</div>\n";
+			$html .= "<div id='content_container' style='padding: 0; width: calc(100% - ".(is_numeric($_SESSION['theme']['menu_side_width_contracted']['text']) ? $_SESSION['theme']['menu_side_width_contracted']['text'] : '55')."px); float: right; padding-top: 0px; text-align: center;'>\n";
+			$html .= "	<div id='content_header'>\n";
+			//header: left
+				$html .= "<div class='float-left'>\n";
+				$html .= "</div>\n";
+			//header: right
+				$html .= "<span class='float-right' style='white-space: nowrap;'>";
+				//current user
+					$html .= "<span style='display: inline-block; padding-right: 20px; font-size: 85%;'>\n";
+					$html .= "<strong>".$this->text['theme-label-user']."</strong>: ";
+					$html .= "<a href='".PROJECT_PATH."/core/users/user_edit.php?id=user'>".$_SESSION['username']."</a>";
+					$html .= "</span>\n";
+				//domain name/selector (sm+)
+					if (isset($_SESSION['username']) && $_SESSION['username'] != '' && permission_exists('domain_select') && count($_SESSION['domains']) > 1 && $_SESSION['theme']['domain_visible']['text'] == 'true') {
+						$html .= "<span style='display: inline-block; padding-right: 10px; font-size: 85%;'>\n";
+						$html .= "<strong>".$this->text['theme-label-domain']."</strong>: ";
+						$html .= "<a href='#' id='header_domain_selector_domain' title='".$this->text['theme-label-open_selector']."'>".escape($_SESSION['domain_name'])."</a>";
+						$html .= "</span>\n";
+					}
+				//logout icon
+					if (isset($_SESSION['username']) && $_SESSION['username'] != '' && $_SESSION['theme']['logout_icon_visible']['text'] == "true") {
+						$html .= "<a id='header_logout_icon' href='".PROJECT_PATH."/logout.php' title=\"".$this->text['theme-label-logout']."\" onclick=\"return confirm('".$this->text['theme-confirm-logout']."')\"><span class='fas fa-log-out'></span></a>";
+					}
+				$html .= "</span>";
+			$html .= "	</div>\n";
+
+			return $html;
+			unset($html);
+
+		}
+
 	}
 	}
 }
 }
 
 

+ 164 - 40
resources/footer.php

@@ -17,7 +17,7 @@
 
 
 	The Initial Developer of the Original Code is
 	The Initial Developer of the Original Code is
 	Mark J Crane <[email protected]>
 	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2019
+	Portions created by the Initial Developer are Copyright (C) 2008-2020
 	the Initial Developer. All Rights Reserved.
 	the Initial Developer. All Rights Reserved.
 
 
 	Contributor(s):
 	Contributor(s):
@@ -25,7 +25,7 @@
 */
 */
 
 
 //includes
 //includes
-	include "root.php";
+	require_once "root.php";
 	require_once "resources/require.php";
 	require_once "resources/require.php";
 
 
 //set variables if not set
 //set variables if not set
@@ -68,49 +68,173 @@
 		}
 		}
 	}
 	}
 
 
-//get the template
-	ob_start();
-	include($_SESSION["template_full_path"]);
-	$template = ob_get_contents(); //get the output from the buffer
-	ob_end_clean(); //clean the buffer
 
 
-//prepare the template to display the output
-	$custom_head = '';
+/************************************************************************************************************************************************
+ * new template
+ */
+
+//initialize a template object
+	$view = new template();
+	$view->engine = 'smarty';
+	$view->template_dir = $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH.'/themes/'.$_SESSION['domain']['template']['name'].'/';
+	$view->cache_dir = $_SESSION['server']['temp']['dir'];
+	$view->init();
+
+//add multi-lingual support
+	$language = new text;
+	$text_default = $language->get();
+	$text_application = $language->get(null,'themes/default');
+	$text = array_merge($text_default, $text_application);
+
+//set template variables
 
 
-	if (isset($_SESSION["theme"]["title"]["text"])) {
-		if (strlen($_SESSION["theme"]["title"]["text"]) > 0) {
-			$document_title = (($document["title"] != '') ? $document["title"]." - " : null).$_SESSION["theme"]["title"]["text"];
+	//add translations
+		foreach($text as $key => $value) {
+			$array[str_replace('-', '_', $key)] = $value;
 		}
 		}
-		else {
-			$document_title = (($document["title"] != '') ? $document["title"]." " : null);
+		$view->assign('text', $array);
+	//project path
+		$view->assign('project_path', PROJECT_PATH);
+	//domain menu
+		$view->assign('domain_menu', escape($_SESSION['domain']['menu']['uuid']));
+	//theme settings
+		if (is_array($_SESSION['theme']) && @sizeof($_SESSION['theme']) != 0) {
+			//load into array
+				foreach ($_SESSION['theme'] as $subcategory => $setting) {
+					if (isset($setting['text']) && $setting['text'] != '') {
+						$settings['theme'][$subcategory] = escape($setting['text']);
+					}
+					else if (isset($setting['boolean'])) {
+						$settings['theme'][$subcategory] = $setting['boolean'] == 'true' ? true : false;
+					}
+					else {
+						$settings['theme'][$subcategory] = escape($setting);
+					}
+				}
+			//pre-process some settings
+				$settings['theme']['favicon'] = $settings['theme']['favicon'] != '' ? urlencode($settings['theme']['favicon']) : PROJECT_PATH.'/themes/default/favicon.ico';
+				$settings['theme']['font_loader_version'] = $settings['theme']['font_loader_version'] != '' ? urlencode($settings['theme']['font_loader_version']) : '1';
+				$settings['theme']['message_delay'] = is_numeric($settings['theme']['message_delay']) ? 1000 * (float) $settings['theme']['message_delay'] : 3000;
+				$settings['theme']['menu_side_width_contracted'] = is_numeric($settings['theme']['menu_side_width_contracted']) ? $settings['theme']['menu_side_width_contracted'] : '60';
+				$settings['theme']['menu_side_width_expanded'] = is_numeric($settings['theme']['menu_side_width_expanded']) ? $settings['theme']['menu_side_width_expanded'] : '225';
+				$settings['theme']['menu_style'] = $settings['theme']['menu_style'] != '' ? $settings['theme']['menu_style'] : 'fixed';
+				$settings['theme']['menu_position'] = $settings['theme']['menu_position'] != '' ? $settings['theme']['menu_position'] : 'top';
+				$settings['theme']['footer'] = $settings['theme']['footer'] != '' ? $settings['theme']['footer'] : '&copy; '.$text['theme-label-copyright'].' 2008 - '.date('Y')." <a href='http://www.fusionpbx.com' class='footer' target='_blank'>fusionpbx.com</a> ".$text['theme-label-all_rights_reserved'];
+			$view->assign('settings', $settings);
 		}
 		}
-	}
-	else {
-		if (isset($_SESSION["software_name"])) {
-			$document_title = (($document["title"] != '') ? $document["title"]." - " : null).$_SESSION["software_name"];
+	//document title
+		if (isset($_SESSION['theme']['title']['text']) && $_SESSION['theme']['title']['text'] != '') {
+			$document_title = $_SESSION['theme']['title']['text'];
 		}
 		}
-		else {
-			$document_title = (($document["title"] != '') ? $document["title"]." " : null);
+		else if (isset($_SESSION['software_name'])) {
+			$document_title = $_SESSION['software_name'];
 		}
 		}
-	}
-	$output = str_replace ("<!--{title}-->", $document_title, $template); //<!--{title}--> defined in each individual page
-	$output = str_replace ("<!--{head}-->", $custom_head, $output); //<!--{head}--> defined in each individual page
-	if (strlen($v_menu) > 0) {
-		$output = str_replace ("<!--{menu}-->", $v_menu, $output); //defined in /resources/menu.php
-	}
-	else {
-		$output = str_replace ("<!--{menu}-->", $_SESSION["menu"], $output); //defined in /resources/menu.php
-	}
-	$output = str_replace ("<!--{project_path}-->", PROJECT_PATH, $output); //defined in /resources/menu.php
-
-	$pos = strrpos($output, "<!--{body}-->");
-	if ($pos === false) {
-		$output = $body; //if tag not found just show the body
-	}
-	else {
-		//replace the body
-		$output = str_replace ("<!--{body}-->", $body, $output);
-	}
+		$document_title = ($document['title'] != '' ? $document['title'].' - ' : null).$document_title;
+		$view->assign('document_title', $document_title);
+	//domain selector control
+		$domain_selector_enabled = permission_exists('domain_select') && count($_SESSION['domains']) > 1 ? true : false;
+		$view->assign('domain_selector_enabled', $domain_selector_enabled);
+	//browser name
+		$user_agent = http_user_agent();
+		$browser_version = $user_agent['version'];
+		$view->assign('browser_name', $user_agent['name']);
+		$view->assign('browser_name_short', $user_agent['name_short']);
+	//login state
+		$authenticated = isset($_SESSION['username']) && $_SESSION['username'] != '' ? true : false;
+		$view->assign('authenticated', $authenticated);
+	//domains application path
+		$view->assign('domains_app_path', PROJECT_PATH.(file_exists($_SERVER['DOCUMENT_ROOT'].'/app/domains/domains.php') ? '/app/domains/domains.php' : '/core/domains/domains.php'));
+	//domain count
+		$view->assign('domain_count', is_array($_SESSION['domains']) ? sizeof($_SESSION['domains']) : 0);
+	//domain selector row background colors
+		$view->assign('domain_selector_background_color_1', $_SESSION['theme']['domain_inactive_background_color'][0] != '' ? $_SESSION['theme']['domain_inactive_background_color'][0] : '#eaedf2');
+		$view->assign('domain_selector_background_color_2', $_SESSION['theme']['domain_inactive_background_color'][1] != '' ? $_SESSION['theme']['domain_inactive_background_color'][1] : '#ffffff');
+	//domain list
+		$view->assign('domains', $_SESSION['domains']);
+	//domain uuid
+		$view->assign('domain_uuid', $_SESSION['domain_uuid']);
+	//menu container
+		//load menu array into the session
+			if (!isset($_SESSION['menu']['array'])) {
+				$menu = new menu;
+				$menu->menu_uuid = $_SESSION['domain']['menu']['uuid'];
+				$_SESSION['menu']['array'] = $menu->menu_array();
+				unset($menu);
+			}
+		//build menu by style
+			switch ($_SESSION['theme']['menu_style']['text']) {
+				case 'side':
+					$container_open = "<div id='menu_side_container'>\n";
+					$menu = new menu;
+					$menu->text = $text;
+					$menu_html = $menu->menu_vertical($_SESSION['menu']['array']);
+					unset($menu);
+					break;
+				case 'inline':
+					$container_open = "<div class='container-fluid' style='padding: 0;' align='".($_SESSION['theme']['logo_align']['text'] != '' ? $_SESSION['theme']['logo_align']['text'] : 'left')."'>\n";
+					if ($_SERVER['PHP_SELF'] != PROJECT_PATH.'/core/install/install.php') {
+						$logo = "<a href='".PROJECT_PATH."/'><img src='".($_SESSION['theme']['logo']['text'] ?: PROJECT_PATH.'/themes/default/images/logo.png')."' style='padding: 15px 20px; ".($_SESSION['theme']['logo_style']['text'] ?: null)."'></a>";
+					}
+					$menu = new menu;
+					$menu->text = $text;
+					$menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
+					unset($menu);
+					break;
+				case 'static':
+					$container_open = "<div class='container-fluid' style='padding: 0;' align='center'>\n";
+					$menu = new menu;
+					$menu->text = $text;
+					$menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
+					unset($menu);
+					break;
+				case 'fixed':
+				default:
+					$menu = new menu;
+					$menu->text = $text;
+					$menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
+					unset($menu);
+					$container_open = "<div class='container-fluid' style='padding: 0;' align='center'>\n";
+					break;
+			}
+		$view->assign('logo', $logo);
+		$view->assign('menu', $menu_html);
+		$view->assign('container_open', $container_open);
+		$view->assign('container_close', '</div>');
+		$view->assign('document_body', $body);
+		$view->assign('current_year', date('Y'));
+	//login logo
+		//determine logo source
+			if (isset($_SESSION['theme']['logo_login']['text']) && $_SESSION['theme']['logo_login']['text'] != '') {
+				$login_logo_source = $_SESSION['theme']['logo_login']['text'];
+			}
+			else if (isset($_SESSION['theme']['logo']['text']) && $_SESSION['theme']['logo']['text'] != '') {
+				$login_logo_source = $_SESSION['theme']['logo']['text'];
+			}
+			else {
+				$login_logo_source = PROJECT_PATH.'/themes/default/images/logo_login.png';
+			}
+		//determine logo dimensions
+			if (isset($_SESSION['theme']['login_logo_width']['text']) && $_SESSION['theme']['login_logo_width']['text'] != '') {
+				$login_logo_width = $_SESSION['theme']['login_logo_width']['text'];
+			}
+			else {
+				$login_logo_width = 'auto; max-width: 300px';
+			}
+			if (isset($_SESSION['theme']['login_logo_height']['text']) && $_SESSION['theme']['login_logo_height']['text'] != '') {
+				$login_logo_height = $_SESSION['theme']['login_logo_height']['text'];
+			}
+			else {
+				$login_logo_height = 'auto; max-height: 300px';
+			}
+		$view->assign('login_logo_source', $login_logo_source);
+		$view->assign('login_logo_width', $login_logo_width);
+		$view->assign('login_logo_height', $login_logo_height);
+
+	//render the view
+		$output = $view->render('template.php');
+
+	//unset background image
+		unset($_SESSION['background_image']);
 
 
 //send the output to the browser
 //send the output to the browser
 	echo $output;
 	echo $output;
@@ -119,4 +243,4 @@
 //$statsauth = "a3az349x2bf3fdfa8dbt7x34fas5X";
 //$statsauth = "a3az349x2bf3fdfa8dbt7x34fas5X";
 //require_once "stats/stat_sadd.php";
 //require_once "stats/stat_sadd.php";
 
 
-?>
+?>

+ 0 - 1
resources/login.php

@@ -376,7 +376,6 @@
 	}
 	}
 
 
 //add the footer
 //add the footer
-	$default_login = true;
 	include "resources/footer.php";
 	include "resources/footer.php";
 
 
 ?>
 ?>

+ 0 - 3
resources/require.php

@@ -67,9 +67,6 @@
 	}
 	}
 	$autoload = new auto_loader();
 	$autoload = new auto_loader();
 
 
-//define variable(s)
-	$default_login = false;	//used in the themes
-
 //additional includes
 //additional includes
 	require_once "resources/php.php";
 	require_once "resources/php.php";
 	require_once "resources/functions.php";
 	require_once "resources/functions.php";

+ 4 - 6
themes/default/css.php

@@ -1,11 +1,10 @@
 <?php
 <?php
-include "root.php";
+
+require_once "root.php";
 require_once "resources/require.php";
 require_once "resources/require.php";
 
 
 header("Content-type: text/css; charset: UTF-8");
 header("Content-type: text/css; charset: UTF-8");
 
 
-$default_login = ($_REQUEST['login'] == 'default') ? true : false;
-
 //parse fonts (add surrounding single quotes to each font name)
 //parse fonts (add surrounding single quotes to each font name)
 	if (is_array($_SESSION['theme']) && sizeof($_SESSION['theme']) > 0) {
 	if (is_array($_SESSION['theme']) && sizeof($_SESSION['theme']) > 0) {
 		foreach ($_SESSION['theme'] as $subcategory => $type) {
 		foreach ($_SESSION['theme'] as $subcategory => $type) {
@@ -34,7 +33,7 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false;
 
 
 //determine which background image/color settings to use (login or standard)
 //determine which background image/color settings to use (login or standard)
 	$background_images_enabled = false;
 	$background_images_enabled = false;
-	if ($default_login) {
+	if (isset($_SESSION['username']) && $_SESSION['username'] != '') {
 		//try using login background images/colors
 		//try using login background images/colors
 		if (isset($_SESSION['theme']) && $_SESSION['theme']['login_background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['login_background_image'])) {
 		if (isset($_SESSION['theme']) && $_SESSION['theme']['login_background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['login_background_image'])) {
 			$background_images_enabled = true;
 			$background_images_enabled = true;
@@ -1092,8 +1091,7 @@ $default_login = ($_REQUEST['login'] == 'default') ? true : false;
 		width: 100%;
 		width: 100%;
 		<?php
 		<?php
 		if (
 		if (
-			(strlen($_SESSION["username"]) > 0 || !$default_login)
-			&&
+			isset($_SESSION['username']) && $_SESSION['username'] != '' &&
 			(isset($background_images) || $background_colors[0] != '' || $background_colors[1] != '')
 			(isset($background_images) || $background_colors[0] != '' || $background_colors[1] != '')
 			) { ?>
 			) { ?>
 			background: <?php echo ($_SESSION['theme']['body_color']['text'] != '') ? $_SESSION['theme']['body_color']['text'] : "#ffffff"; ?>;
 			background: <?php echo ($_SESSION['theme']['body_color']['text'] != '') ? $_SESSION['theme']['body_color']['text'] : "#ffffff"; ?>;

+ 557 - 813
themes/default/template.php

@@ -1,374 +1,419 @@
-<?php
-
-//get the browser version
-	$user_agent = http_user_agent();
-	$browser_version =  $user_agent['version'];
-	$browser_name =  $user_agent['name'];
-	$browser_version_array = explode('.', $browser_version);
-
-//set the doctype
-	echo ($browser_name != "Internet Explorer") ? "<!DOCTYPE html>\n" : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
-
-//get the php self path and set a variable with only the directory path
-	$php_self_array = explode ("/", $_SERVER['PHP_SELF']);
-	$php_self_dir = '';
-	foreach ($php_self_array as &$value) {
-		if (substr($value, -4) != ".php") {
-			$php_self_dir .= $value."/";
-		}
-	}
-	unset($php_self_array);
-	if (strlen(PROJECT_PATH) > 0) {
-		$php_self_dir = substr($php_self_dir, strlen(PROJECT_PATH), strlen($php_self_dir));
-	}
-
-echo "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n";
-echo "<head>\n";
-echo "<meta charset='utf-8'>\n";
-echo "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n";
-echo "<meta http-equiv='X-UA-Compatible' content='IE=edge'>\n";
-echo "<meta name='viewport' content='width=device-width, initial-scale=1'>\n";
-
-echo "<link rel='stylesheet' type='text/css' href='<!--{project_path}-->/resources/bootstrap/css/bootstrap.min.css'>\n";
-echo "<link rel='stylesheet' type='text/css' href='<!--{project_path}-->/resources/bootstrap/css/bootstrap-tempusdominus.css'>\n";
-echo "<link rel='stylesheet' type='text/css' href='<!--{project_path}-->/resources/bootstrap/css/bootstrap-colorpicker.min.css'>\n";
-echo "<link rel='stylesheet' type='text/css' href='<!--{project_path}-->/themes/".escape($_SESSION['domain']['template']['name'])."/css.php".($default_login ? '?login=default' : null)."'>\n";
-echo "<link rel='stylesheet' type='text/css' href='<!--{project_path}-->/resources/fontawesome/css/all.css'>\n";
-
-//link to custom css file
-	if ($_SESSION['theme']['custom_css']['text'] != '') {
-		echo "<link rel='stylesheet' type='text/css' href='".$_SESSION['theme']['custom_css']['text']."'>\n\n";
-	}
-//output custom css
-	if ($_SESSION['theme']['custom_css_code']['text'] != '') {
-		echo "<style>\n";
-		echo $_SESSION['theme']['custom_css_code']['text'];
-		echo "</style>\n\n";
-	}
-
-//set fav icon
-	$favicon = (isset($_SESSION['theme']['favicon']['text'])) ? $_SESSION['theme']['favicon']['text'] : '<!--{project_path}-->/themes/default/favicon.ico';
-	echo "<link rel='icon' href='".$favicon."'>\n";
-
-echo "<title><!--{title}--></title>\n";
-
-echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/jquery/jquery-3.4.1.min.js'></script>\n";
-echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/jquery/jquery.autosize.input.js'></script>\n";
-echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/momentjs/moment-with-locales.min.js'></script>\n";
-echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/bootstrap/js/bootstrap.min.js'></script>\n";
-echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/bootstrap/js/bootstrap-tempusdominus.min.js'></script>\n";
-echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/bootstrap/js/bootstrap-colorpicker.js'></script>\n";
-echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/bootstrap/js/bootstrap-pwstrength.min.js'></script>\n";
-
-echo "<script language='JavaScript' type='text/javascript'>window.FontAwesomeConfig = { autoReplaceSvg: false }</script>\n";
-echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/fontawesome/js/all.js' defer></script>\n";
-
-//web font loader
-	if ($_SESSION['theme']['font_loader']['text'] == 'true') {
-		if ($_SESSION['theme']['font_retrieval']['text'] != 'asynchronous') {
-			$font_loader_version = ($_SESSION['theme']['font_loader_version']['text'] != '') ? escape($_SESSION['theme']['font_loader_version']['text']) : 1;
-			echo "<script language='JavaScript' type='text/javascript' src='//ajax.googleapis.com/ajax/libs/webfont/".escape($font_loader_version)."/webfont.js'></script>\n";
-		}
-		echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/fonts/web_font_loader.php?v=".escape($font_loader_version)."'></script>\n";
-	}
-?>
-
-<script language="JavaScript" type="text/javascript">
-
-	//display message bar via js
-		function display_message(msg, mood, delay) {
-			mood = (typeof mood !== 'undefined') ? mood : 'default';
-			delay = (typeof delay !== 'undefined') ? delay : <?php echo (1000 * (float) $_SESSION['theme']['message_delay']['text']); ?>;
-			if (msg !== '') {
-				var message_text = $(document.createElement('div'));
-				message_text.addClass('message_text message_mood_'+mood);
-				message_text.html(msg);
-				message_text.on('click', function() {
-					var object = $(this);
-					object.clearQueue().finish();
-					$("#message_container div").remove();
-					$("#message_container").css({opacity: 0, 'height': 0}).css({'height': 'auto'});
-				} );
-				$("#message_container").append(message_text);
-				message_text.css({'height': 'auto'}).animate({opacity: 1}, 250, function(){
-					$("#message_container").delay(delay).animate({opacity: 0, 'height': 0}, 500, function() {
-						$("#message_container div").remove();
-						$("#message_container").animate({opacity: 1}, 300).css({'height': 'auto'});
+{* <?php *}
+
+{*//set the doctype *}
+	{if $browser_name == 'Internet Explorer'}
+		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+	{else}
+		<!DOCTYPE html>
+	{/if}
+
+<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
+<head>
+<meta charset='utf-8'>
+<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
+<meta http-equiv='X-UA-Compatible' content='IE=edge'>
+<meta name='viewport' content='width=device-width, initial-scale=1'>
+
+{*//external css files *}
+	<link rel='stylesheet' type='text/css' href='{$project_path}/resources/bootstrap/css/bootstrap.min.css'>
+	<link rel='stylesheet' type='text/css' href='{$project_path}/resources/bootstrap/css/bootstrap-tempusdominus.css'>
+	<link rel='stylesheet' type='text/css' href='{$project_path}/resources/bootstrap/css/bootstrap-colorpicker.min.css'>
+	<link rel='stylesheet' type='text/css' href='{$project_path}/resources/fontawesome/css/all.css'>
+	<link rel='stylesheet' type='text/css' href='{$project_path}/themes/default/css.php'>
+
+{*//link to custom css file *}
+	{if $settings.theme.custom_css}
+		<link rel='stylesheet' type='text/css' href='$settings.theme.custom_css'>
+	{/if}
+
+{*//output custom css *}
+	{if $settings.theme.custom_css_code}
+		<style>
+		$settings.theme.custom_css_code
+		</style>
+	{/if}
+
+{*//set favorite icon *}
+	<link rel='icon' href='{$settings.theme.favicon}'>
+
+{*//document title *}
+	<title>{$document_title}</title>
+
+{*//remote javascript *}
+	<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/jquery/jquery-3.4.1.min.js'></script>
+	<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/jquery/jquery.autosize.input.js'></script>
+	<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/momentjs/moment-with-locales.min.js'></script>
+	<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/bootstrap/js/bootstrap.min.js'></script>
+	<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/bootstrap/js/bootstrap-tempusdominus.min.js'></script>
+	<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/bootstrap/js/bootstrap-colorpicker.js'></script>
+	<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/bootstrap/js/bootstrap-pwstrength.min.js'></script>
+	<script language='JavaScript' type='text/javascript'>{literal}window.FontAwesomeConfig = { autoReplaceSvg: false }{/literal}</script>
+	<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/fontawesome/js/all.js' defer></script>
+
+{*//web font loader *}
+	{if $settings.theme.font_loader == 'true'}
+		{if $settings.theme.font_retrieval != 'asynchronous'}
+			<script language='JavaScript' type='text/javascript' src='//ajax.googleapis.com/ajax/libs/webfont/{$settings.theme.font_loader_version}/webfont.js'></script>
+		{/if}
+		<script language='JavaScript' type='text/javascript' src='{$project_path}/resources/fonts/web_font_loader.php?v={$settings.theme.font_loader_version}'></script>
+	{/if}
+
+{*//local javascript *}
+	<script language='JavaScript' type='text/javascript'>
+
+		//message bar display
+			{literal}
+			function display_message(msg, mood, delay) {
+				mood = typeof mood !== 'undefined' ? mood : 'default';
+				delay = typeof delay !== 'undefined' ? delay : {/literal}{$settings.theme.message_delay}{literal};
+				if (msg !== '') {
+					var message_text = $(document.createElement('div'));
+					message_text.addClass('message_text message_mood_'+mood);
+					message_text.html(msg);
+					message_text.on('click', function() {
+						var object = $(this);
+						object.clearQueue().finish();
+						$('#message_container div').remove();
+						$('#message_container').css({opacity: 0, 'height': 0}).css({'height': 'auto'});
+					} );
+					$('#message_container').append(message_text);
+					message_text.css({'height': 'auto'}).animate({opacity: 1}, 250, function(){
+						$('#message_container').delay(delay).animate({opacity: 0, 'height': 0}, 500, function() {
+							$('#message_container div').remove();
+							$('#message_container').animate({opacity: 1}, 300).css({'height': 'auto'});
+						});
 					});
 					});
-				});
+				}
 			}
 			}
-		}
-
-	<?php if ($_SESSION['theme']['menu_style']['text'] == 'side') { ?>
-		//toggle side menu visibility (if enabled)
-			var menu_side_state = 'contracted';
-			function menu_side_contract() {
-				$('.menu_side_sub').slideUp(180);
-				$('.menu_side_item_title').hide();
-				<?php if ($_SESSION['theme']['menu_brand_type']['text'] == 'image' || $_SESSION['theme']['menu_brand_type']['text'] == '') { ?>
-					$('#menu_brand_image_expanded').fadeOut(180, function() {
-						$('#menu_brand_image_contracted').fadeIn(180);
+			{/literal}
+
+		{if $settings.theme.menu_style == 'side'}
+			//side menu visibility toggle
+				{literal}
+				var menu_side_state = 'contracted';
+				function menu_side_contract() {
+					$('.menu_side_sub').slideUp(180);
+					$('.menu_side_item_title').hide();
+					{/literal}
+					{if $settings.theme.menu_brand_type == 'image' || $settings.theme.menu_brand_type == ''}
+						{literal}
+						$('#menu_brand_image_expanded').fadeOut(180, function() {
+							$('#menu_brand_image_contracted').fadeIn(180);
+						});
+						{/literal}
+					{elseif $settings.theme.menu_brand_type == 'image_text'}
+						{literal}
+						$('.menu_brand_text').hide();
+						$('#menu_brand_image_contracted').animate({ width: '20px', 'margin-left': '-2px' }, 250);
+						{/literal}
+					{else if $settings.theme.menu_brand_type == 'text'}
+						{literal}
+						$('.menu_brand_text').fadeOut(180);
+						{/literal}
+					{/if}
+					{literal}
+					$('#menu_side_container').animate({ width: '{/literal}{$settings.theme.menu_side_width_contracted}{literal}px' }, 250);
+					$('#content_container').animate({ width: $(window).width() - {/literal}{$settings.theme.menu_side_width_contracted}{literal} }, 250, function() {
+						menu_side_state = 'contracted';
 					});
 					});
-				<?php } else if ($_SESSION['theme']['menu_brand_type']['text'] == 'image_text') { ?>
-					$('.menu_brand_text').hide();
-					$('#menu_brand_image_contracted').animate({ width: '20px', 'margin-left': '-2px' }, 250);
-				<?php } else if ($_SESSION['theme']['menu_brand_type']['text'] == 'text') { ?>
-					$('.menu_brand_text').fadeOut(180);
-				<?php } ?>
-				$('#menu_side_container').animate({ width: '<?php echo is_numeric($_SESSION['theme']['menu_side_width_contracted']['text']) ? $_SESSION['theme']['menu_side_width_contracted']['text'] : '60'; ?>px' }, 250);
-				$('#content_container').animate({ width: $(window).width() - <?php echo is_numeric($_SESSION['theme']['menu_side_width_contracted']['text']) ? $_SESSION['theme']['menu_side_width_contracted']['text'] : '60'; ?> }, 250, function() {
-					menu_side_state = 'contracted';
-				});
 
 
-				$('.menu_side_contract').hide();
-				$('.menu_side_expand').show();
-			}
-
-			function menu_side_expand() {
-				<?php if ($_SESSION['theme']['menu_brand_type']['text'] == 'image_text') { ?>
-					$('#menu_brand_image_contracted').animate({ width: '30px', 'margin-left': '0' }, 250);
-				<?php } else if ($_SESSION['theme']['menu_brand_type']['text'] == 'image' || $_SESSION['theme']['menu_brand_type']['text'] == '') { ?>
-					$('#menu_brand_image_contracted').fadeOut(180);
-				<?php } ?>
-				$('#menu_side_container').animate({ width: '<?php echo  is_numeric($_SESSION['theme']['menu_side_width_expanded']['text']) ? $_SESSION['theme']['menu_side_width_expanded']['text'] : '225'; ?>px' }, 250);
-				$('#content_container').animate({ width: $(window).width() - <?php echo is_numeric($_SESSION['theme']['menu_side_width_expanded']['text']) ? $_SESSION['theme']['menu_side_width_expanded']['text'] : '225'; ?> }, 250, function() {
-					$('.menu_brand_text').fadeIn(180);
-					$('.menu_side_item_title').fadeIn(180);
-					<?php if ($_SESSION['theme']['menu_brand_type']['text'] != 'none') { ?>
-						$('.menu_side_contract').fadeIn(180);
-					<?php } ?>
-					<?php if ($_SESSION['theme']['menu_brand_type']['text'] == 'image' || $_SESSION['theme']['menu_brand_type']['text'] == '') { ?>
-						$('#menu_brand_image_expanded').fadeIn(180);
-					<?php } ?>
-					menu_side_state = 'expanded';
-				});
-				<?php if ($_SESSION['theme']['menu_brand_type']['text'] == 'none') { ?>
-					$('.menu_side_contract').show();
-				<?php } ?>
-				$('.menu_side_expand').hide();
-			}
-	<?php } ?>
+					$('.menu_side_contract').hide();
+					$('.menu_side_expand').show();
+				}
 
 
+				function menu_side_expand() {
+					{/literal}
+					{if $settings.theme.menu_brand_type == 'image_text'}
+						{literal}
+						$('#menu_brand_image_contracted').animate({ width: '30px', 'margin-left': '0' }, 250);
+						{/literal}
+					{elseif $settings.theme.menu_brand_type == 'image' || $settings.theme.menu_brand_type == ''}
+						{literal}
+						$('#menu_brand_image_contracted').fadeOut(180);
+						{/literal}
+					{/if}
+					{literal}
+					$('#menu_side_container').animate({ width: '{/literal}{$settings.theme.menu_side_width_expanded}{literal}px' }, 250);
+					$('#content_container').animate({ width: $(window).width() - {/literal}{$settings.theme.menu_side_width_expanded}{literal} }, 250, function() {
+						$('.menu_brand_text').fadeIn(180);
+						$('.menu_side_item_title').fadeIn(180);
+						{/literal}
+						{if $settings.theme.menu_brand_type != 'none'}
+							{literal}
+							$('.menu_side_contract').fadeIn(180);
+							{/literal}
+						{/if}
+						{if $settings.theme.menu_brand_type == 'image' || $settings.theme.menu_brand_type == ''}
+							{literal}
+							$('#menu_brand_image_expanded').fadeIn(180);
+							{/literal}
+						{/if}
+						{literal}
+						menu_side_state = 'expanded';
+					});
+					{/literal}
+					{if $settings.theme.menu_brand_type == 'none'}
+						{literal}
+						$('.menu_side_contract').show();
+						{/literal}
+					{/if}
+					{literal}
+					$('.menu_side_expand').hide();
+				}
+				{/literal}
+		{/if}
 
 
+	{literal}
 	$(document).ready(function() {
 	$(document).ready(function() {
+		{/literal}
 
 
-		<?php echo message::html(true, "		"); ?>
+		// echo message::html(true, '		');
 
 
-		//hide message bar on hover
-			$("#message_container").on('mouseenter',function() {
-				$("#message_container div").remove();
-				$("#message_container").css({opacity: 0, 'height': 0}).css({'height': 'auto'});
+		//message bar hide on hover
+			{literal}
+			$('#message_container').on('mouseenter',function() {
+				$('#message_container div').remove();
+				$('#message_container').css({opacity: 0, 'height': 0}).css({'height': 'auto'});
 			});
 			});
+			{/literal}
 
 
-		<?php
-		if (permission_exists("domain_select") && count($_SESSION['domains']) > 1) {
-			?>
-
-			//domain selector controls
-				$(".domain_selector_domain").on('click', function() { show_domains(); });
-				$("#header_domain_selector_domain").on('click', function() { show_domains(); });
-				$("#domains_hide").on('click', function() { hide_domains(); });
+		//domain selector controls
+			{if $domain_selector_enabled}
+				{literal}
+				$('.domain_selector_domain').on('click', function() { show_domains(); });
+				$('#header_domain_selector_domain').on('click', function() { show_domains(); });
+				$('#domains_hide').on('click', function() { hide_domains(); });
 
 
 				function show_domains() {
 				function show_domains() {
 					$('#domains_visible').val(1);
 					$('#domains_visible').val(1);
 					var scrollbar_width = (window.innerWidth - $(window).width()); //gold: only solution that worked with body { overflow:auto } (add -ms-overflow-style: scrollbar; to <body> style for ie 10+)
 					var scrollbar_width = (window.innerWidth - $(window).width()); //gold: only solution that worked with body { overflow:auto } (add -ms-overflow-style: scrollbar; to <body> style for ie 10+)
 					if (scrollbar_width > 0) {
 					if (scrollbar_width > 0) {
-						$("body").css({'margin-right':scrollbar_width, 'overflow':'hidden'}); //disable body scroll bars
-						$(".navbar").css('margin-right',scrollbar_width); //adjust navbar margin to compensate
-						$("#domains_container").css('right',-scrollbar_width); //domain container right position to compensate
+						$('body').css({'margin-right':scrollbar_width, 'overflow':'hidden'}); //disable body scroll bars
+						$('.navbar').css('margin-right',scrollbar_width); //adjust navbar margin to compensate
+						$('#domains_container').css('right',-scrollbar_width); //domain container right position to compensate
 					}
 					}
 					$(document).scrollTop(0);
 					$(document).scrollTop(0);
-					$("#domains_container").show();
-					$("#domains_block").animate({marginRight: '+=300'}, 400, function() {
-						$("#domain_filter").trigger('focus');
+					$('#domains_container').show();
+					$('#domains_block').animate({marginRight: '+=300'}, 400, function() {
+						$('#domain_filter').trigger('focus');
 					});
 					});
 				}
 				}
 
 
 				function hide_domains() {
 				function hide_domains() {
 					$('#domains_visible').val(0);
 					$('#domains_visible').val(0);
 					$(document).ready(function() {
 					$(document).ready(function() {
-						$("#domains_block").animate({marginRight: '-=300'}, 400, function() {
-							$("#domain_filter").val('');
-							domain_search($("#domain_filter").val());
-							$(".navbar").css('margin-right','0'); //restore navbar margin
-							$("#domains_container").css('right','0'); //domain container right position
-							$("#domains_container").hide();
-							$("body").css({'margin-right':'0','overflow':'auto'}); //enable body scroll bars
+						$('#domains_block').animate({marginRight: '-=300'}, 400, function() {
+							$('#domain_filter').val('');
+							domain_search($('#domain_filter').val());
+							$('.navbar').css('margin-right','0'); //restore navbar margin
+							$('#domains_container').css('right','0'); //domain container right position
+							$('#domains_container').hide();
+							$('body').css({'margin-right':'0','overflow':'auto'}); //enable body scroll bars
 							document.activeElement.blur();
 							document.activeElement.blur();
 						});
 						});
 					});
 					});
 				}
 				}
-
-			<?php
-		}
+				{/literal}
+			{/if}
 
 
 		//keyboard shortcut scripts
 		//keyboard shortcut scripts
 
 
-		//key: [enter] - retain default behavior to submit form, when present
-			echo "	var action_bar_actions, first_form, first_submit;\n";
-			echo "	action_bar_actions = document.querySelector('div#action_bar.action_bar > div.actions');\n";
-			echo "	first_form = document.querySelector('form#frm');\n";
-
-			echo "	if (action_bar_actions !== null) {\n";
-			echo "		if (first_form !== null) {\n";
-			echo "			first_submit = document.createElement('input');\n";
-			echo "			first_submit.type = 'submit';\n";
-			echo "			first_submit.id = 'default_submit';\n";
-			echo "			first_submit.setAttribute('style',\"position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden;\");\n"; //note: safari doesn't honor first submit element using "display: none;"
-			echo "			first_form.prepend(first_submit);\n";
-			echo "			window.addEventListener('keydown',function(e){\n";
-			echo "				if (e.which == 13 && (e.target.tagName == 'INPUT' || e.target.tagName == 'SELECT')) {\n";
-			echo "					if (typeof window.submit_form === 'function') { submit_form(); }\n";
-			echo "					else { document.getElementById('frm').submit(); }\n";
-			echo "				}\n";
-			echo "			});\n";
-			echo "		}\n";
-			echo "	}\n";
+		//key: [enter] - retain default behavior to submit form, when present - note: safari does not honor the first submit element when hiding it using 'display: none;' in the setAttribute method
+			{literal}
+			var action_bar_actions, first_form, first_submit;
+			action_bar_actions = document.querySelector('div#action_bar.action_bar > div.actions');
+			first_form = document.querySelector('form#frm');
+
+			if (action_bar_actions !== null) {
+				if (first_form !== null) {
+					first_submit = document.createElement('input');
+					first_submit.type = 'submit';
+					first_submit.id = 'default_submit';
+					first_submit.setAttribute('style','position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden;');
+					first_form.prepend(first_submit);
+					window.addEventListener('keydown',function(e){
+						if (e.which == 13 && (e.target.tagName == 'INPUT' || e.target.tagName == 'SELECT')) {
+							if (typeof window.submit_form === 'function') { submit_form(); }
+							else { document.getElementById('frm').submit(); }
+						}
+					});
+				}
+			}
+			{/literal}
 
 
 		//common (used by delete and toggle)
 		//common (used by delete and toggle)
-			echo "	var list_checkboxes;\n";
-			echo "	list_checkboxes = document.querySelectorAll('table.list tr.list-row td.checkbox input[type=checkbox]');\n";
+			var list_checkboxes;
+			list_checkboxes = document.querySelectorAll('table.list tr.list-row td.checkbox input[type=checkbox]');
 
 
 		//keyup event listener
 		//keyup event listener
-			echo "	window.addEventListener('keyup', function(e) {\n";
-
-		//key: [escape] - close modal window, if open, or toggle domain selector
-			echo "		if (e.which == 27) {\n";
-			echo "			e.preventDefault();\n";
-			echo "			var modals, modal_visible, modal;\n";
-			echo "			modal_visible = false;\n";
-			echo "			modals = document.querySelectorAll('div.modal-window');\n";
-			echo "			if (modals.length !== 0) {\n";
-			echo "				for (var x = 0, max = modals.length; x < max; x++) {\n";
-			echo "					modal = document.getElementById(modals[x].id);\n";
-			echo "					if (window.getComputedStyle(modal).getPropertyValue('opacity') == 1) {\n";
-			echo "						modal_visible = true;\n";
-			echo "					}\n";
-			echo "				}\n";
-			echo "			}\n";
-			echo "			if (modal_visible) {\n";
-			echo "				modal_close();\n";
-			echo "			}\n";
-			if (permission_exists("domain_select") && count($_SESSION['domains']) > 1) {
-				echo "			else {\n";
-				echo "				if (document.getElementById('domains_visible').value == 0) {\n";
-				echo "					show_domains();\n";
-				echo "				}\n";
-				echo "				else { \n";
-				echo "					hide_domains();\n";
-				echo "				}\n";
-				echo "			}\n";
-			}
-			echo "		}\n";
-
-		//key: [insert], list: to add
-			echo "		if (e.which == 45 && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {\n";
-			echo "			e.preventDefault();\n";
-			echo "			var list_add_button;\n";
-			echo "			list_add_button = document.getElementById('btn_add');\n";
-			echo "			if (list_add_button === null || list_add_button === 'undefined') {\n";
-			echo "				list_add_button = document.querySelector('button[name=btn_add]');\n";
-			echo "			}\n";
-			echo "			if (list_add_button !== null) { list_add_button.click(); }\n";
-			echo "		}\n";
-
-		//key: [delete], list: to delete checked, edit: to delete
-			echo "		if (e.which == 46 && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {\n";
-			echo "			e.preventDefault();\n";
-			echo "			if (list_checkboxes.length !== 0) {\n";
-			echo "				var list_delete_button;\n";
-			echo "				list_delete_button = document.querySelector('button[name=btn_delete]');\n";
-			echo "				if (list_delete_button === null || list_delete_button === 'undefined') {\n";
-			echo "					list_delete_button = document.getElementById('btn_delete');\n";
-			echo "				}\n";
-			echo "				if (list_delete_button !== null) { list_delete_button.click(); }\n";
-			echo "			}\n";
-			echo "			else {\n";
-			echo "				var edit_delete_button;\n";
-			echo "				edit_delete_button = document.querySelector('button[name=btn_delete]');\n";
-			echo "				if (edit_delete_button === null || edit_delete_button === 'undefined') {\n";
-			echo "					edit_delete_button = document.getElementById('btn_delete');\n";
-			echo "				}\n";
-			echo "				if (edit_delete_button !== null) { edit_delete_button.click(); }\n";
-			echo "			}\n";
-			echo "		}\n";
-
-		//end keyup
-			echo "	});\n";
+			{literal}
+			window.addEventListener('keyup', function(e) {
+				{/literal}
+
+				//key: [escape] - close modal window, if open, or toggle domain selector
+					{literal}
+					if (e.which == 27) {
+						e.preventDefault();
+						var modals, modal_visible, modal;
+						modal_visible = false;
+						modals = document.querySelectorAll('div.modal-window');
+						if (modals.length !== 0) {
+							for (var x = 0, max = modals.length; x < max; x++) {
+								modal = document.getElementById(modals[x].id);
+								if (window.getComputedStyle(modal).getPropertyValue('opacity') == 1) {
+									modal_visible = true;
+								}
+							}
+						}
+						if (modal_visible) {
+							modal_close();
+						}
+						{/literal}
+						{if $domain_selector_enabled}
+							{literal}
+							else {
+								if (document.getElementById('domains_visible').value == 0) {
+									show_domains();
+								}
+								else {
+									hide_domains();
+								}
+							}
+							{/literal}
+						{/if}
+						{literal}
+					}
+					{/literal}
+
+				//key: [insert], list: to add
+					{literal}
+					if (e.which == 45 && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {
+						e.preventDefault();
+						var list_add_button;
+						list_add_button = document.getElementById('btn_add');
+						if (list_add_button === null || list_add_button === 'undefined') {
+							list_add_button = document.querySelector('button[name=btn_add]');
+						}
+						if (list_add_button !== null) { list_add_button.click(); }
+					}
+					{/literal}
+
+				//key: [delete], list: to delete checked, edit: to delete
+					{literal}
+					if (e.which == 46 && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {
+						e.preventDefault();
+						if (list_checkboxes.length !== 0) {
+							var list_delete_button;
+							list_delete_button = document.querySelector('button[name=btn_delete]');
+							if (list_delete_button === null || list_delete_button === 'undefined') {
+								list_delete_button = document.getElementById('btn_delete');
+							}
+							if (list_delete_button !== null) { list_delete_button.click(); }
+						}
+						else {
+							var edit_delete_button;
+							edit_delete_button = document.querySelector('button[name=btn_delete]');
+							if (edit_delete_button === null || edit_delete_button === 'undefined') {
+								edit_delete_button = document.getElementById('btn_delete');
+							}
+							if (edit_delete_button !== null) { edit_delete_button.click(); }
+						}
+					}
+					{/literal}
+
+		//keyup end
+			{literal}
+			});
+			{/literal}
 
 
 		//keydown event listener
 		//keydown event listener
-			echo "	window.addEventListener('keydown', function(e) {\n";
-
-		//key: [space], list: to toggle checked
-			echo "		if (e.which == 32 && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA' && list_checkboxes.length !== 0) {\n"; //note: for default [space] checkbox behavior (ie. toggle focused checkbox) include: " && !(e.target.tagName == 'INPUT' && e.target.type == 'checkbox')"
-			echo "			e.preventDefault();\n";
-			echo "			var list_toggle_button;\n";
-			echo "			list_toggle_button = document.querySelector('button[name=btn_toggle]');\n";
-			echo "			if (list_toggle_button === null || list_toggle_button === 'undefined') {\n";
-			echo "				list_toggle_button = document.getElementById('btn_toggle');\n";
-			echo "			}\n";
-			echo "			if (list_toggle_button !== null) { list_toggle_button.click(); }\n";
-			echo "		}\n";
-
-		//key: [ctrl]+[a], list,edit: to check all
-			echo "		if ((((e.which == 97 || e.which == 65) && (e.ctrlKey || e.metaKey) && !e.shiftKey) || e.which == 19) && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {\n";
-			echo "			var list_checkbox_all;\n";
-			echo "			list_checkbox_all = document.querySelectorAll('table.list tr.list-header th.checkbox input[name=checkbox_all]');\n";
-			echo "			if (list_checkbox_all !== null && list_checkbox_all.length > 0) {\n";
-			echo "				e.preventDefault();\n";
-			echo "				for (var x = 0, max = list_checkbox_all.length; x < max; x++) {\n";
-			echo "					list_checkbox_all[x].click();\n";
-			echo "				}\n";
-			echo "			}\n";
-			echo "			var edit_checkbox_all;\n";
-			echo "			edit_checkbox_all = document.querySelectorAll('td.edit_delete_checkbox_all > span > input[name=checkbox_all]');\n";
-			echo "			if (edit_checkbox_all !== null && edit_checkbox_all.length > 0) {\n";
-			echo "				e.preventDefault();\n";
-			echo "				for (var x = 0, max = edit_checkbox_all.length; x < max; x++) {\n";
-			echo "					edit_checkbox_all[x].click();\n";
-			echo "				}\n";
-			echo "			}\n";
-			echo "		}\n";
-
-		//key: [ctrl]+[s], edit: to save
-			echo "		if (((e.which == 115 || e.which == 83) && (e.ctrlKey || e.metaKey) && !e.shiftKey) || (e.which == 19)) {\n";
-			echo "			e.preventDefault();\n";
-			echo "			var edit_save_button;\n";
-			echo "			edit_save_button = document.getElementById('btn_save');\n";
-			echo "			if (edit_save_button === null || edit_save_button === 'undefined') {\n";
-			echo "				edit_save_button = document.querySelector('button[name=btn_save]');\n";
-			echo "			}\n";
-			echo "			if (edit_save_button !== null) { edit_save_button.click(); }\n";
-			echo "		}\n";
-
-		//key: [ctrl]+[c], list,edit: to copy
-			if (http_user_agent('name_short') == 'Safari') { //emulate with detecting [c] only, as [command] and [control] keys are ignored when captured
-				echo "	if ((e.which == 99 || e.which == 67) && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {\n";
-			}
-			else {
-				echo "	if ((((e.which == 99 || e.which == 67) && (e.ctrlKey || e.metaKey) && !e.shiftKey) || (e.which == 19)) && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {\n";
-			}
-			echo "			var current_selection, copy_button;\n";
-			echo "			current_selection = window.getSelection();\n";
-			echo "			if (current_selection === null || current_selection == 'undefined' || current_selection.toString() == '') {\n";
-			echo "				e.preventDefault();\n";
-			echo "				copy_button = document.getElementById('btn_copy');\n";
-			echo "				if (copy_button === null || copy_button === 'undefined') {\n";
-			echo "					copy_button = document.querySelector('button[name=btn_copy]');\n";
-			echo "				}\n";
-			echo "				if (copy_button !== null) { copy_button.click(); }\n";
-			echo "			}\n";
-			echo "		}\n";
-
-		//end keydown
-			echo "	});\n";
-
-		?>
-
-		//link table rows (except the last - the list_control_icons cell) on a table with a class of 'tr_hover', according to the href attribute of the <tr> tag
+			{literal}
+			window.addEventListener('keydown', function(e) {
+				{/literal}
+
+				//key: [space], list: to toggle checked - note: for default [space] checkbox behavior (ie. toggle focused checkbox) include in the if statement: && !(e.target.tagName == 'INPUT' && e.target.type == 'checkbox')
+					{literal}
+					if (e.which == 32 && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA' && list_checkboxes.length !== 0) {
+						e.preventDefault();
+						var list_toggle_button;
+						list_toggle_button = document.querySelector('button[name=btn_toggle]');
+						if (list_toggle_button === null || list_toggle_button === 'undefined') {
+							list_toggle_button = document.getElementById('btn_toggle');
+						}
+						if (list_toggle_button !== null) { list_toggle_button.click(); }
+					}
+					{/literal}
+
+				//key: [ctrl]+[a], list,edit: to check all
+					{literal}
+					if ((((e.which == 97 || e.which == 65) && (e.ctrlKey || e.metaKey) && !e.shiftKey) || e.which == 19) && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {
+						var list_checkbox_all;
+						list_checkbox_all = document.querySelectorAll('table.list tr.list-header th.checkbox input[name=checkbox_all]');
+						if (list_checkbox_all !== null && list_checkbox_all.length > 0) {
+							e.preventDefault();
+							for (var x = 0, max = list_checkbox_all.length; x < max; x++) {
+								list_checkbox_all[x].click();
+							}
+						}
+						var edit_checkbox_all;
+						edit_checkbox_all = document.querySelectorAll('td.edit_delete_checkbox_all > span > input[name=checkbox_all]');
+						if (edit_checkbox_all !== null && edit_checkbox_all.length > 0) {
+							e.preventDefault();
+							for (var x = 0, max = edit_checkbox_all.length; x < max; x++) {
+								edit_checkbox_all[x].click();
+							}
+						}
+					}
+					{/literal}
+
+				//key: [ctrl]+[s], edit: to save
+					{literal}
+					if (((e.which == 115 || e.which == 83) && (e.ctrlKey || e.metaKey) && !e.shiftKey) || (e.which == 19)) {
+						e.preventDefault();
+						var edit_save_button;
+						edit_save_button = document.getElementById('btn_save');
+						if (edit_save_button === null || edit_save_button === 'undefined') {
+							edit_save_button = document.querySelector('button[name=btn_save]');
+						}
+						if (edit_save_button !== null) { edit_save_button.click(); }
+					}
+					{/literal}
+
+				//key: [ctrl]+[c], list,edit: to copy
+					{if $browser_name_short == 'Safari'} //emulate with detecting [c] only, as [command] and [control] keys are ignored when captured
+						{literal}
+						if ((e.which == 99 || e.which == 67) && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {
+						{/literal}
+					{else}
+						{literal}
+						if ((((e.which == 99 || e.which == 67) && (e.ctrlKey || e.metaKey) && !e.shiftKey) || (e.which == 19)) && !(e.target.tagName == 'INPUT' && e.target.type == 'text') && e.target.tagName != 'TEXTAREA') {
+						{/literal}
+					{/if}
+					{literal}
+						var current_selection, copy_button;
+						current_selection = window.getSelection();
+						if (current_selection === null || current_selection == 'undefined' || current_selection.toString() == '') {
+							e.preventDefault();
+							copy_button = document.getElementById('btn_copy');
+							if (copy_button === null || copy_button === 'undefined') {
+								copy_button = document.querySelector('button[name=btn_copy]');
+							}
+							if (copy_button !== null) { copy_button.click(); }
+						}
+					}
+					{/literal}
+
+		//keydown end
+			{literal}
+			});
+			{/literal}
+
+
+		//link list rows
+			{literal}
 			$('.tr_hover tr,.list tr').each(function(i,e) {
 			$('.tr_hover tr,.list tr').each(function(i,e) {
 				$(e).children('td:not(.list_control_icon,.list_control_icons,.tr_link_void,.list-row > .no-link,.list-row > .checkbox,.list-row > .button,.list-row > .action-button)').on('click', function() {
 				$(e).children('td:not(.list_control_icon,.list_control_icons,.tr_link_void,.list-row > .no-link,.list-row > .checkbox,.list-row > .button,.list-row > .action-button)').on('click', function() {
-					var href = $(this).closest("tr").attr("href");
+					var href = $(this).closest('tr').attr('href');
 					var target = $(this).closest('tr').attr('target');
 					var target = $(this).closest('tr').attr('target');
 					if (href) {
 					if (href) {
 						if (target) { window.open(href, target); }
 						if (target) { window.open(href, target); }
@@ -376,11 +421,15 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 					}
 					}
 				});
 				});
 			});
 			});
+			{/literal}
 
 
 		//autosize jquery autosize plugin on applicable input fields
 		//autosize jquery autosize plugin on applicable input fields
-			$("input[type=text].txt.auto-size,input[type=number].txt.auto-size,input[type=password].txt.auto-size,input[type=text].formfld.auto-size,input[type=number].formfld.auto-size,input[type=password].formfld.auto-size").autosizeInput();
+			{literal}
+			$('input[type=text].txt.auto-size,input[type=number].txt.auto-size,input[type=password].txt.auto-size,input[type=text].formfld.auto-size,input[type=number].formfld.auto-size,input[type=password].formfld.auto-size').autosizeInput();
+			{/literal}
 
 
 		//initialize bootstrap tempusdominus (calendar/datetime picker) plugin
 		//initialize bootstrap tempusdominus (calendar/datetime picker) plugin
+			{literal}
 			$(function() {
 			$(function() {
 				//set defaults
 				//set defaults
 					$.fn.datetimepicker.Constructor.Default = $.extend({}, $.fn.datetimepicker.Constructor.Default, {
 					$.fn.datetimepicker.Constructor.Default = $.extend({}, $.fn.datetimepicker.Constructor.Default, {
@@ -401,14 +450,15 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 							close: 'fas fa-times',
 							close: 'fas fa-times',
 						}
 						}
 					});
 					});
-
 				//define formatting of individual classes
 				//define formatting of individual classes
-					$('.datepicker').datetimepicker({ 			format: 'YYYY-MM-DD', });
-					$('.datetimepicker').datetimepicker({ 		format: 'YYYY-MM-DD HH:mm', });
-					$('.datetimesecpicker').datetimepicker({ 	format: 'YYYY-MM-DD HH:mm:ss', });
+					$('.datepicker').datetimepicker({ format: 'YYYY-MM-DD', });
+					$('.datetimepicker').datetimepicker({ format: 'YYYY-MM-DD HH:mm', });
+					$('.datetimesecpicker').datetimepicker({ format: 'YYYY-MM-DD HH:mm:ss', });
 			});
 			});
+			{/literal}
 
 
 		//apply bootstrap colorpicker plugin
 		//apply bootstrap colorpicker plugin
+			{literal}
 			$(function(){
 			$(function(){
 				$('.colorpicker').colorpicker({
 				$('.colorpicker').colorpicker({
 					align: 'left',
 					align: 'left',
@@ -427,27 +477,30 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 					}
 					}
 				});
 				});
 			});
 			});
+			{/literal}
 
 
 		//apply bootstrap password strength plugin
 		//apply bootstrap password strength plugin
+			{literal}
 			$('#password').pwstrength({
 			$('#password').pwstrength({
 				common: {
 				common: {
 					minChar: 8,
 					minChar: 8,
 					usernameField: '#username',
 					usernameField: '#username',
 				},
 				},
-				/* rules: { },  */
+				//rules: { },
 				ui: {
 				ui: {
-					//				very weak weak		normal	   medium	  strong	 very strong
-					colorClasses: ["danger", "warning", "warning", "warning", "success", "success"],
+					colorClasses: ['danger', 'warning', 'warning', 'warning', 'success', 'success'], //weak,poor,normal,medium,good,strong
 					progressBarMinPercentage: 15,
 					progressBarMinPercentage: 15,
 					showVerdicts: false,
 					showVerdicts: false,
 					viewports: {
 					viewports: {
-						progress: "#pwstrength_progress"
+						progress: '#pwstrength_progress'
 					}
 					}
 				}
 				}
 			});
 			});
+			{/literal}
 
 
-		<?php if ($_SESSION['theme']['menu_brand_image']['text'] != '' && $_SESSION['theme']['menu_brand_image_hover']['text'] != '' && $_SESSION['theme']['menu_style']['text'] != 'side') { ?>
-			//crossfade menu brand images (if hover version set)
+		//crossfade menu brand images (if hover version set)
+			{if $settings.theme.menu_brand_image != '' && $settings.theme.menu_brand_image_hover != '' && $settings.theme.menu_style != 'side'}
+				{literal}
 				$(function(){
 				$(function(){
 					$('#menu_brand_image').on('mouseover',function(){
 					$('#menu_brand_image').on('mouseover',function(){
 						$(this).fadeOut('fast', function(){
 						$(this).fadeOut('fast', function(){
@@ -460,26 +513,34 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 						});
 						});
 					});
 					});
 				});
 				});
-		<?php } ?>
+				{/literal}
+			{/if}
 
 
 		//generate resizeEnd event after window resize event finishes (used when side menu and on messages app)
 		//generate resizeEnd event after window resize event finishes (used when side menu and on messages app)
+			{literal}
 			$(window).on('resize', function() {
 			$(window).on('resize', function() {
 				if (this.resizeTO) { clearTimeout(this.resizeTO); }
 				if (this.resizeTO) { clearTimeout(this.resizeTO); }
 				this.resizeTO = setTimeout(function() { $(this).trigger('resizeEnd'); }, 180);
 				this.resizeTO = setTimeout(function() { $(this).trigger('resizeEnd'); }, 180);
 			});
 			});
+			{/literal}
 
 
-		<?php if ($_SESSION['theme']['menu_style']['text'] == 'side') { ?>
-			//side menu: adjust content container width after window resize
+		//side menu: adjust content container width after window resize
+			{if $settings.theme.menu_style == 'side'}
+				{literal}
 				$(window).on('resizeEnd', function() {
 				$(window).on('resizeEnd', function() {
 					$('#content_container').animate({ width: $(window).width() - $('#menu_side_container').width() }, 200);
 					$('#content_container').animate({ width: $(window).width() - $('#menu_side_container').width() }, 200);
 				});
 				});
-		<?php } ?>
+				{/literal}
+			{/if}
+
+	{literal}
+	}); //document ready end
+	{/literal}
 
 
-	});
 
 
 	//audio playback functions
 	//audio playback functions
-		var recording_audio;
-		var audio_clock;
+		{literal}
+		var recording_audio, audio_clock;
 
 
 		function recording_play(recording_id) {
 		function recording_play(recording_id) {
 			if (document.getElementById('recording_progress_bar_'+recording_id)) {
 			if (document.getElementById('recording_progress_bar_'+recording_id)) {
@@ -490,22 +551,22 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 			if (recording_audio.paused) {
 			if (recording_audio.paused) {
 				recording_audio.volume = 1;
 				recording_audio.volume = 1;
 				recording_audio.play();
 				recording_audio.play();
-				document.getElementById('recording_button_'+recording_id).innerHTML = "<span class='<?php echo $_SESSION['theme']['button_icon_pause']['text']; ?> fa-fw'></span>";
+				document.getElementById('recording_button_'+recording_id).innerHTML = "<span class='{/literal}{$settings.theme.button_icon_pause}{literal} fa-fw'></span>";
 				audio_clock = setInterval(function () { update_progress(recording_id); }, 20);
 				audio_clock = setInterval(function () { update_progress(recording_id); }, 20);
 
 
-				$("[id*=recording_button]").not("[id*=recording_button_"+recording_id+"]").html("<span class='<?php echo $_SESSION['theme']['button_icon_play']['text']; ?> fa-fw'></span>");
-				$("[id*=recording_progress_bar]").not("[id*=recording_progress_bar_"+recording_id+"]").css('display', 'none');
+				$('[id*=recording_button]').not('[id*=recording_button_'+recording_id+']').html("<span class='{/literal}{$settings.theme.button_icon_play}{literal} fa-fw'></span>");
+				$('[id*=recording_progress_bar]').not('[id*=recording_progress_bar_'+recording_id+']').css('display', 'none');
 
 
 				$('audio').each(function(){$('#menu_side_container').width()
 				$('audio').each(function(){$('#menu_side_container').width()
 					if ($(this).get(0) != recording_audio) {
 					if ($(this).get(0) != recording_audio) {
-						$(this).get(0).pause(); // Stop playing
-						$(this).get(0).currentTime = 0; // Reset time
+						$(this).get(0).pause(); //stop playing
+						$(this).get(0).currentTime = 0; //reset time
 					}
 					}
 				});
 				});
 			}
 			}
 			else {
 			else {
 				recording_audio.pause();
 				recording_audio.pause();
-				document.getElementById('recording_button_'+recording_id).innerHTML = "<span class='<?php echo $_SESSION['theme']['button_icon_play']['text']; ?> fa-fw'></span>";
+				document.getElementById('recording_button_'+recording_id).innerHTML = "<span class='{/literal}{$settings.theme.button_icon_play}{literal} fa-fw'></span>";
 				clearInterval(audio_clock);
 				clearInterval(audio_clock);
 			}
 			}
 		}
 		}
@@ -522,7 +583,7 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 			if (document.getElementById('recording_progress_bar_'+recording_id)) {
 			if (document.getElementById('recording_progress_bar_'+recording_id)) {
 				document.getElementById('recording_progress_bar_'+recording_id).style.display='none';
 				document.getElementById('recording_progress_bar_'+recording_id).style.display='none';
 			}
 			}
-			document.getElementById('recording_button_'+recording_id).innerHTML = "<span class='<?php echo $_SESSION['theme']['button_icon_play']['text']; ?> fa-fw'></span>";
+			document.getElementById('recording_button_'+recording_id).innerHTML = "<span class='{/literal}{$settings.theme.button_icon_play}{literal} fa-fw'></span>";
 			clearInterval(audio_clock);
 			clearInterval(audio_clock);
 		}
 		}
 
 
@@ -533,13 +594,15 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 			if (recording_audio.currentTime > 0) {
 			if (recording_audio.currentTime > 0) {
 				value = (100 / recording_audio.duration) * recording_audio.currentTime;
 				value = (100 / recording_audio.duration) * recording_audio.currentTime;
 			}
 			}
-			recording_progress.style.marginLeft = value + "%";
+			recording_progress.style.marginLeft = value + '%';
 			if (parseInt(recording_audio.duration) > 30) { //seconds
 			if (parseInt(recording_audio.duration) > 30) { //seconds
 				clearInterval(audio_clock);
 				clearInterval(audio_clock);
 			}
 			}
 		}
 		}
+		{/literal}
 
 
 	//handle action bar style on scroll
 	//handle action bar style on scroll
+		{literal}
 		window.addEventListener('scroll', function(){
 		window.addEventListener('scroll', function(){
 			action_bar_scroll('action_bar', 20);
 			action_bar_scroll('action_bar', 20);
 		}, false);
 		}, false);
@@ -557,8 +620,10 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 					}
 					}
 			}
 			}
 		}
 		}
+		{/literal}
 
 
 	//enable button class button
 	//enable button class button
+		{literal}
 		function button_enable(button_id) {
 		function button_enable(button_id) {
 			button = document.getElementById(button_id);
 			button = document.getElementById(button_id);
 			button.disabled = false;
 			button.disabled = false;
@@ -569,8 +634,10 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 				anchor.setAttribute('onclick','');
 				anchor.setAttribute('onclick','');
 			}
 			}
 		}
 		}
+		{/literal}
 
 
 	//disable button class button
 	//disable button class button
+		{literal}
 		function button_disable(button_id) {
 		function button_disable(button_id) {
 			button = document.getElementById(button_id);
 			button = document.getElementById(button_id);
 			button.disabled = true;
 			button.disabled = true;
@@ -581,8 +648,10 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 				anchor.setAttribute('onclick','return false;');
 				anchor.setAttribute('onclick','return false;');
 			}
 			}
 		}
 		}
+		{/literal}
 
 
-	//list functions
+	//list page functions
+		{literal}
 		function list_all_toggle(modifier) {
 		function list_all_toggle(modifier) {
 			var checkboxes = (modifier !== undefined) ? document.getElementsByClassName('checkbox_'+modifier) : document.querySelectorAll("input[type='checkbox']");
 			var checkboxes = (modifier !== undefined) ? document.getElementsByClassName('checkbox_'+modifier) : document.querySelectorAll("input[type='checkbox']");
 			var checkbox_checked = document.getElementById('checkbox_all' + (modifier !== undefined ? '_'+modifier : '')).checked;
 			var checkbox_checked = document.getElementById('checkbox_all' + (modifier !== undefined ? '_'+modifier : '')).checked;
@@ -633,7 +702,10 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 			document.getElementById('btn_reset').style.display = 'none';
 			document.getElementById('btn_reset').style.display = 'none';
 			document.getElementById('btn_search').style.display = '';
 			document.getElementById('btn_search').style.display = '';
 		}
 		}
+		{/literal}
 
 
+	//edit page functions
+		{literal}
 		function edit_all_toggle(modifier) {
 		function edit_all_toggle(modifier) {
 			var checkboxes = document.getElementsByClassName('checkbox_'+modifier);
 			var checkboxes = document.getElementsByClassName('checkbox_'+modifier);
 			var checkbox_checked = document.getElementById('checkbox_all_'+modifier).checked;
 			var checkbox_checked = document.getElementById('checkbox_all_'+modifier).checked;
@@ -664,7 +736,10 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 				document.getElementById('btn_delete').value = checkbox_checked ? '' : 'delete';
 				document.getElementById('btn_delete').value = checkbox_checked ? '' : 'delete';
 			}
 			}
 		}
 		}
+		{/literal}
 
 
+	//misc functions
+		{literal}
 		function swap_display(a_id, b_id, display_value) {
 		function swap_display(a_id, b_id, display_value) {
 			display_value = display_value !== undefined ? display_value : 'inline-block';
 			display_value = display_value !== undefined ? display_value : 'inline-block';
 			a = document.getElementById(a_id);
 			a = document.getElementById(a_id);
@@ -695,460 +770,129 @@ echo "<script language='JavaScript' type='text/javascript' src='<!--{project_pat
 		window.addEventListener('beforeunload', function(e){
 		window.addEventListener('beforeunload', function(e){
 			hide_password_fields();
 			hide_password_fields();
 		});
 		});
-
-</script>
-
-<?php
-
-echo "<!--{head}-->\n";
-echo "</head>\n";
-
-//add multilingual support
-	$language = new text;
-	$text = $language->get(null,'themes/default');
-
-echo "<body onload=\"".$onload."\">\n";
-
-echo "	<div id='message_container'></div>\n";
-
-//logged in, show the domains block
-	if (strlen($_SESSION["username"]) > 0 && permission_exists("domain_select") && count($_SESSION['domains']) > 1) {
-
-		echo "<div id='domains_container'>\n";
-		echo "	<input type='hidden' id='domains_visible' value='0'>\n";
-		echo "	<div id='domains_block'>\n";
-		echo "		<div id='domains_header'>\n";
-		echo "			<input id='domains_hide' type='button' class='btn' style='float: right' value=\"".$text['theme-button-close']."\">\n";
-
-		if (file_exists($_SERVER["DOCUMENT_ROOT"]."/app/domains/domains.php")) {
-			$domain_path = PROJECT_PATH.'/app/domains/domains.php';
-		}
-		else {
-			$domain_path = PROJECT_PATH.'/core/domains/domains.php';
-		}
-		echo "			<a href=\"".$domain_path."\"><b style=\"color: #000;\">".$text['theme-title-domains']."</b></a> (".sizeof($_SESSION['domains']).")";
-		echo "			<br><br>\n";
-		echo "			<input type='text' id='domain_filter' class='formfld' style='margin-left: 0; min-width: 100%; width: 100%;' placeholder=\"".$text['theme-label-search']."\" onkeyup='domain_search(this.value)'>\n";
-		echo "		</div>\n";
-		echo "		<div id='domains_list'>\n";
-
-		//alternating background colors of inactive domains
-		if ($_SESSION['theme']['domain_inactive_background_color'][0] != '') {
-			$bgcolor1 = $_SESSION['theme']['domain_inactive_background_color'][0];
-		}
-		else {
-			$bgcolor1 = "#eaedf2";
-		}	
-		if ($_SESSION['theme']['domain_inactive_background_color'][1] != '') {
-			$bgcolor2 = $_SESSION['theme']['domain_inactive_background_color'][1];
-		}	
-		else {
-			$bgcolor2 = "#fff";
-		}
-		
-		foreach($_SESSION['domains'] as $domain) {
-			//active domain color
-			$bgcolor = ($bgcolor == $bgcolor1) ? $bgcolor2 : $bgcolor1;
-			if ($_SESSION['theme']['domain_active_background_color']['text'] != '') {
-				$bgcolor = ($domain['domain_uuid'] == $_SESSION['domain_uuid']) ? escape($_SESSION['theme']['domain_active_background_color']['text']) : $bgcolor;
-			}
-			else {
-				$bgcolor = ($domain['domain_uuid'] == $_SESSION['domain_uuid']) ? "#eeffee" : $bgcolor;
-			}
-			//active domain's text hover color
-			if ($_SESSION['theme']['domain_active_text_color_hover']['text'] != '' && $domain['domain_uuid'] == $_SESSION['domain_uuid']) {
-				echo "<div id=\"".$domain['domain_name']."\" class='domains_list_item_active' style='background-color: ".$bgcolor."' onclick=\"document.location.href='".escape($domain_path)."?domain_uuid=".escape($domain['domain_uuid'])."&domain_change=true';\">";
-			}
-			else if ($_SESSION['theme']['domain_inactive_text_color_hover']['text'] != '' && $domain['domain_uuid'] != $_SESSION['domain_uuid']) {
-				echo "<div id=\"".$domain['domain_name']."\" class='domains_list_item_inactive' style='background-color: ".$bgcolor."' onclick=\"document.location.href='".escape($domain_path)."?domain_uuid=".escape($domain['domain_uuid'])."&domain_change=true';\">";
-			}
-			else {
-				echo "<div id=\"".$domain['domain_name']."\" class='domains_list_item' style='background-color: ".$bgcolor."' onclick=\"document.location.href='".escape($domain_path)."?domain_uuid=".escape($domain['domain_uuid'])."&domain_change=true';\">";
-			}
-			echo "<a href='".escape($domain_path)."?domain_uuid=".escape($domain['domain_uuid'])."&domain_change=true' ".(($domain['domain_uuid'] == $_SESSION['domain_uuid']) ? "style='font-weight: bold;'" : null).">".escape($domain['domain_name'])."</a>\n";
-			if ($domain['domain_description'] != '') {
-				//active domain description text color
-				if ($_SESSION['theme']['domain_active_desc_text_color']['text'] != '' && $domain['domain_uuid'] == $_SESSION['domain_uuid']) {
-					echo "<span class='domain_active_list_item_description' title=\"".escape($domain['domain_description'])."\"> - ".escape($domain['domain_description'])."</span>\n";
-				}
-				//inactive domains description text color
-				else if ($_SESSION['theme']['domain_inactive_desc_text_color']['text'] != '' && $domain['domain_uuid'] != $_SESSION['domain_uuid']) {
-					echo "<span class='domain_inactive_list_item_description' title=\"".escape($domain['domain_description'])."\"> - ".escape($domain['domain_description'])."</span>\n";
-				}
-				//default domain description text color
-				else {
-					echo "<span class='domain_list_item_description' title=\"".escape($domain['domain_description'])."\"> - ".escape($domain['domain_description'])."</span>\n";
-				}
-			}
-			echo "</div>\n";
-			$ary_domain_names[] = $domain['domain_name'];
-			$ary_domain_descs[] = str_replace('"','\"',$domain['domain_description']);
-		}
-
-		echo "		</div>\n";
-
-		echo "		<script>\n";
-		echo "			var domain_names = new Array(\"".implode('","', $ary_domain_names)."\");\n";
-		echo "			var domain_descs = new Array(\"".implode('","', $ary_domain_descs)."\");\n";
-		echo "			function domain_search(criteria) {\n";
-		echo "				for (var x = 0; x < domain_names.length; x++) {\n";
-		echo "					if (domain_names[x].toLowerCase().match(criteria.toLowerCase()) || domain_descs[x].toLowerCase().match(criteria.toLowerCase())) {\n";
-		echo "						document.getElementById(domain_names[x]).style.display = '';\n";
-		echo "					}\n";
-		echo "					else {\n";
-		echo "						document.getElementById(domain_names[x]).style.display = 'none';\n";
-		echo "					}\n";
-		echo "				}\n";
-		echo "			}\n";
-		echo "		</script>\n";
-
-		echo "	</div>\n";
-		echo "</div>\n";
-
-	}
-
-// qr code container for contacts
-	echo "<div id='qr_code_container' style='display: none;' onclick='$(this).fadeOut(400);'>\n";
-	echo "	<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td align='center' valign='middle'>\n";
-	echo "		<span id='qr_code' onclick=\"$('#qr_code_container').fadeOut(400);\"></span>\n";
-	echo "	</td></tr></table>\n";
-	echo "</div>\n";
-
-
-if (!$default_login) {
-
-	//top fixed, static or inline boostrap menu
-	function show_menu($menu_array, $menu_style, $menu_position) {
-		global $text;
-
-		//determine menu behavior
-			switch ($menu_style) {
-				case 'inline':
-					$menu_type = 'default';
-					$menu_width = 'calc(100% - 20px)';
-					$menu_brand = false;
-					$menu_corners = null;
-					break;
-				case 'static':
-					$menu_type = 'static-top';
-					$menu_width = 'calc(100% - 40px)';
-					$menu_brand = true;
-					$menu_corners = "style='-webkit-border-radius: 0 0 4px 4px; -moz-border-radius: 0 0 4px 4px; border-radius: 0 0 4px 4px;'";
-					break;
-				case 'fixed':
-				default:
-					$menu_position = ($menu_position != '') ? $menu_position : 'top';
-					$menu_type = 'fixed-'.$menu_position;
-					if (!http_user_agent('mobile')) {
-						$menu_width = $_SESSION['theme']['menu_width_fixed']['text'] != '' ? $_SESSION['theme']['menu_width_fixed']['text'] : 'calc(90% - 20px)';
-					}
-					$menu_brand = true;
-					$menu_corners = null;
-			}
-
-		//begin navbar code
-			echo "<nav class='navbar navbar-expand-sm ".$menu_type."' ".$menu_corners.">\n";
- 			echo "	<div class='container-fluid' style='width: ".$menu_width."; padding: 0;'>\n";
-			echo "		<div class='navbar-brand'>\n";
-
-			if ($menu_brand) {
-				//define menu brand link
-					if (strlen(PROJECT_PATH) > 0) {
-						$menu_brand_link = PROJECT_PATH;
-					}
-					else if (!$default_login) {
-						$menu_brand_link = '/';
-					}
-				//define menu brand mark
-					$menu_brand_text = ($_SESSION['theme']['menu_brand_text']['text'] != '') ? escape($_SESSION['theme']['menu_brand_text']['text']) : "FusionPBX";
-					switch ($_SESSION['theme']['menu_brand_type']['text']) {
-						case 'text':
-							echo "			<a class='navbar-brand-text'  href=\"".$menu_brand_link."\">".$menu_brand_text."</a>\n";
-							break;
-						case 'image_text':
-							$menu_brand_image = ($_SESSION['theme']['menu_brand_image']['text'] != '') ? escape($_SESSION['theme']['menu_brand_image']['text']) : PROJECT_PATH."/themes/default/images/logo.png";
-							echo "			<a href='".$menu_brand_link."'>";
-							echo "				<img id='menu_brand_image' class='navbar-logo' src='".$menu_brand_image."' title=\"".escape($menu_brand_text)."\">";
-							if ($_SESSION['theme']['menu_brand_image_hover']['text'] != '') {
-								echo 			"<img id='menu_brand_image_hover' class='navbar-logo' style='display: none;' src='".$_SESSION['theme']['menu_brand_image_hover']['text']."' title=\"".escape($menu_brand_text)."\">";
-							}
-							echo 			"</a>\n";
-							echo "			<a class='navbar-brand-text' href=\"".$menu_brand_link."\">".$menu_brand_text."</a>\n";
-							break;
-						case 'none':
-							break;
-						case 'image':
-						default:
-							$menu_brand_image = ($_SESSION['theme']['menu_brand_image']['text'] != '') ? escape($_SESSION['theme']['menu_brand_image']['text']) : PROJECT_PATH."/themes/default/images/logo.png";
-							echo "			<a href='".$menu_brand_link."'>";
-							echo "				<img id='menu_brand_image' class='navbar-logo' src='".$menu_brand_image."' title=\"".escape($menu_brand_text)."\">";
-							if (isset($_SESSION['theme']['menu_brand_image_hover']['text']) && $_SESSION['theme']['menu_brand_image_hover']['text'] != '') {
-								echo 			"<img id='menu_brand_image_hover' class='navbar-logo' style='display: none;' src='".$_SESSION['theme']['menu_brand_image_hover']['text']."' title=\"".escape($menu_brand_text)."\">";
-							}
-							echo 			"</a>\n";
-							echo "			<a style='margin: 0;'></a>\n";
-					}
-			}
-
-			echo "		</div>\n";
-
-			echo "		<button type='button' class='navbar-toggler' data-toggle='collapse' data-target='#main_navbar' aria-expanded='false' aria-controls='main_navbar' aria-label='Toggle Menu'>\n";
-			echo "			<span class='fas fa-bars'></span>\n";
-			echo "		</button>\n";
-
-			echo "		<div class='collapse navbar-collapse' id='main_navbar'>\n";
-			echo "			<ul class='navbar-nav'>\n";
-
-			foreach ($menu_array as $index_main => $menu_parent) {
-				$mod_li = "nav-item";
-				$mod_a_1 = "";
-				$submenu = false;
-				if (is_array($menu_parent['menu_items']) && sizeof($menu_parent['menu_items']) > 0) {
-					$mod_li = "nav-item dropdown ";
-					$mod_a_1 = "data-toggle='dropdown' ";
-					$submenu = true;
-				}
-				$mod_a_2 = ($menu_parent['menu_item_link'] != '' && !$submenu) ? $menu_parent['menu_item_link'] : '#';
-				$mod_a_3 = ($menu_parent['menu_item_category'] == 'external') ? "target='_blank' " : null;
-				if (isset($_SESSION['theme']['menu_main_icons']['boolean']) && $_SESSION['theme']['menu_main_icons']['boolean'] == 'true') {
-					if ($menu_parent['menu_item_icon'] != '' && substr_count($menu_parent['menu_item_icon'], 'fa-') > 0) {
-						$menu_main_icon = "<span class='fas ".$menu_parent['menu_item_icon']."' title=\"".escape($menu_parent['menu_language_title'])."\"></span>\n";
-					}
-					else {
-						$menu_main_icon = null;
-					}
-					$menu_main_item = "<span class='d-sm-none d-md-none d-lg-inline' style='margin-left: 5px;'>".$menu_parent['menu_language_title']."</span>\n";
-				}
-				else {
-					$menu_main_item = $menu_parent['menu_language_title'];
-				}
-				echo "				<li class='".$mod_li."'>\n";
-				echo "					<a class='nav-link' ".$mod_a_1." href='".$mod_a_2."' ".$mod_a_3.">\n";
-				echo "						".$menu_main_icon.$menu_main_item;
-				echo "					</a>\n";
-				if ($submenu) {
-					echo "					<ul class='dropdown-menu'>\n";
-					foreach ($menu_parent['menu_items'] as $index_sub => $menu_sub) {
-						$mod_a_2 = $menu_sub['menu_item_link'];
-						if ($mod_a_2 == '') {
-							$mod_a_2 = '#';
-						}
-						$mod_a_3 = ($menu_sub['menu_item_category'] == 'external') ? "target='_blank' " : null;
-						if ($_SESSION['theme']['menu_sub_icons']['boolean'] != 'false') {
-							if ($menu_sub['menu_item_icon'] != '' && substr_count($menu_sub['menu_item_icon'], 'fa-') > 0) {
-								$menu_sub_icon = "<span class='fas ".escape($menu_sub['menu_item_icon'])."'></span>";
-							}
-							else {
-								$menu_sub_icon = null;
-							}
-						}
-						echo "						<li class='nav-item'><a class='nav-link' href='".$mod_a_2."' ".$mod_a_3.">".($_SESSION['theme']['menu_sub_icons'] ? "<span class='fas fa-bar d-inline-block d-sm-none float-left' style='margin: 4px 10px 0 25px;'></span>" : null).escape($menu_sub['menu_language_title']).$menu_sub_icon."</a></li>\n";
-					}
-					echo "					</ul>\n";
-				}
-				echo "				</li>\n";
-			}
-
-			echo "			</ul>\n";
-
-			echo "			<ul class='navbar-nav ml-auto'>\n";
-			//domain name/selector
-				if ($_SESSION["username"] != '' && permission_exists("domain_select") && count($_SESSION['domains']) > 1 && $_SESSION['theme']['domain_visible']['text'] == 'true') {
-					echo "		<li class='nav-item'>\n";
-					echo "			<a class='nav-link domain_selector_domain' href='#' title='".$text['theme-label-open_selector']."'>".escape($_SESSION['domain_name'])."</a>";
-					echo "		</li>\n";
-				}
-			//logout icon
-				if ($_SESSION['username'] != '' && $_SESSION['theme']['logout_icon_visible']['text'] == "true") {
-					$username_full = $_SESSION['username'].((count($_SESSION['domains']) > 1) ? "@".$_SESSION["user_context"] : null);
-					echo "		<li class='nav-item'>\n";
-					echo "			<a class='nav-link logout_icon' href='".PROJECT_PATH."/logout.php' title=\"".$text['theme-label-logout']."\" onclick=\"return confirm('".$text['theme-confirm-logout']."')\"><span class='fas fa-sign-out-alt'></span></a>";
-					echo "		</li>\n";
-					unset($username_full);
-				}
-			echo "			</ul>\n";
-
-			echo "		</div>\n";
-			echo "	</div>\n";
-			echo "</nav>\n";
-	}
-
-	//get the menu array and save it to the session
-		if (!isset($_SESSION['menu']['array'])) {
-			$menu = new menu;
-			$menu->menu_uuid = $_SESSION['domain']['menu']['uuid'];
-			$_SESSION['menu']['array'] = $menu->menu_array();
-			unset($menu);
-		}
-	//get the menu style and position
-		$menu_style = ($_SESSION['theme']['menu_style']['text'] != '') ? $_SESSION['theme']['menu_style']['text'] : 'fixed';
-		$menu_position = ($_SESSION['theme']['menu_position']['text'] != '') ? $_SESSION['theme']['menu_position']['text'] : 'top';
-
-	//show the menu style
-		switch ($menu_style) {
-			case 'inline':
-				$logo_align = ($_SESSION['theme']['logo_align']['text'] != '') ? $_SESSION['theme']['logo_align']['text'] : 'left';
-				$logo_style = ($_SESSION['theme']['logo_style']['text'] != '') ? $_SESSION['theme']['logo_style']['text'] : null;
-				echo "<div class='container-fluid' style='padding: 0;' align='".$logo_align."'>\n";
-				if ($_SERVER['PHP_SELF'] != PROJECT_PATH."/core/install/install.php") {
-					$logo = ($_SESSION['theme']['logo']['text'] != '') ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH."/themes/default/images/logo.png";
-					echo "<a href='".((PROJECT_PATH != '') ? PROJECT_PATH : '/')."'><img src='".$logo."' style='padding: 15px 20px; ".$logo_style."'></a>";
-				}
-
-				show_menu($_SESSION['menu']['array'], $menu_style, $menu_position);
-				break;
-			case 'static':
-				echo "<div class='container-fluid' style='padding: 0;' align='center'>\n";
-				show_menu($_SESSION['menu']['array'], $menu_style, $menu_position);
-				break;
-			case 'fixed':
-				show_menu($_SESSION['menu']['array'], $menu_style, $menu_position);
-				echo "<div class='container-fluid' style='padding: 0;' align='center'>\n";
-				break;
-			case 'side':
-				echo "<div id='menu_side_container'>\n";
-				//menu brand image and/or text
-					if ($_SESSION['theme']['menu_brand_type']['text'] == 'none') {
-						echo "	<div style='height: 75px;'>\n";
-						echo 		"<a class='menu_side_item_main menu_side_contract' onclick='menu_side_contract();' style='display: none;'><i class='fas fa-chevron-left' style='z-index: 99800; padding-left: 3px;'></i></a>";
-						echo 		"<a class='menu_side_item_main menu_side_expand' onclick='menu_side_expand();'><i class='fas fa-bars' style='z-index: 99800; padding-left: 3px;'></i></a>";
-						echo 	"</div>\n";
-					}
-					else {
-						echo "	<div id='menu_side_brand_container'>\n";
-						//menu toggle buttons
-							if ($_SESSION['theme']['menu_brand_type']['text'] != 'none') {
-								echo "		<div style='float: right; margin-right: -20px; margin-top: -20px;'>\n";
-								echo "			<a class='menu_side_item_main menu_side_contract' onclick='menu_side_contract();' style='display: none;'><i class='fas fa-chevron-left'></i></a>\n";
-								echo "		</div>\n";
-							}
-						//define the menu brand link
-							if (strlen(PROJECT_PATH) > 0) {
-								$menu_brand_link = PROJECT_PATH;
-							}
-							else if (!$default_login) {
-								$menu_brand_link = '/';
-							}
-						//show the menu brand image and/or text
-							$menu_brand_image_contracted =  $_SESSION['theme']['menu_side_brand_image_contracted']['text'] != '' ? $_SESSION['theme']['menu_side_brand_image_contracted']['text'] : PROJECT_PATH."/themes/default/images/logo_side_contracted.png";
-							$menu_brand_image_expanded =  $_SESSION['theme']['menu_side_brand_image_expanded']['text'] != '' ? $_SESSION['theme']['menu_side_brand_image_expanded']['text'] : PROJECT_PATH."/themes/default/images/logo_side_expanded.png";
-							$menu_brand_text = ($_SESSION['theme']['menu_brand_text']['text'] != '') ? escape($_SESSION['theme']['menu_brand_text']['text']) : "FusionPBX";
-							if ($_SESSION['theme']['menu_brand_type']['text'] == 'image' || $_SESSION['theme']['menu_brand_type']['text'] == '') {
-								echo "		<a href='".$menu_brand_link."' style='text-decoration: none;'>";
-								echo 			"<img id='menu_brand_image_contracted' style='width: 20px; margin-left: -2px; margin-top: -5px;' src='".escape($menu_brand_image_contracted)."' title=\"".escape($menu_brand_text)."\">";
-								echo 			"<img id='menu_brand_image_expanded' style='display: none;' src='".escape($menu_brand_image_expanded)."' title=\"".escape($menu_brand_text)."\">";
-								echo 		"</a>\n";
-							}
-							else if ($_SESSION['theme']['menu_brand_type']['text'] == 'image_text') {
-								echo "		<a href='".$menu_brand_link."' style='text-decoration: none;'>";
-								echo 			"<img id='menu_brand_image_contracted' style='width: 20px; margin-left: -2px; margin-top: -5px;' src='".escape($menu_brand_image_contracted)."' title=\"".escape($menu_brand_text)."\">";
-								echo 			"<span class='menu_brand_text' style='display: none;'>".$menu_brand_text."</span>";
-								echo 		"</a>\n";
-							}
-							else if ($_SESSION['theme']['menu_brand_type']['text'] == 'text') {
-								echo "		<a class='menu_brand_text' style='display: none;' href=\"".$menu_brand_link."\">".$menu_brand_text."</a>\n";
-							}
-						echo "	</div>\n";
-					}
-
-					//main menu items
-						if (is_array($_SESSION['menu']['array']) && sizeof($_SESSION['menu']['array']) != 0) {
-							foreach ($_SESSION['menu']['array'] as $menu_index_main => $menu_item_main) {
-								echo "	<a class='menu_side_item_main' ".($menu_item_main['menu_item_link'] != '' ? "href='".$menu_item_main['menu_item_link']."'" : "onclick=\"menu_side_expand(); $('#sub_".$menu_item_main['menu_item_uuid']."').slideToggle(180, function() { if (!$(this).is(':hidden')) { $('.menu_side_sub').not($(this)).slideUp(180); } });\"")." title=\"".$menu_item_main['menu_language_title']."\">";
-								if ($menu_item_main['menu_item_icon'] != '') {
-									echo "<i class='fas ".$menu_item_main['menu_item_icon']." fa-fw' style='z-index: 99800; margin-right: 8px;'></i>";
+		{/literal}
+
+	</script>
+
+</head>
+<body>
+
+	{*//message container *}
+		<div id='message_container'></div>
+
+	{*//domain selector *}
+		{if $authenticated && $domain_selector_enabled}
+
+			<div id='domains_container'>
+				<input type='hidden' id='domains_visible' value='0'>
+				<div id='domains_block'>
+					<div id='domains_header'>
+						<input id='domains_hide' type='button' class='btn' style='float: right' value="{$text.theme_button_close}">
+						<a href='{$domains_app_path}'><b style='color: #000;'>{$text.theme_title_domains}</b></a> ({$domain_count})
+						<br><br>
+						<input type='text' id='domain_filter' class='formfld' style='margin-left: 0; min-width: 100%; width: 100%;' placeholder="{$text.theme_label_search}" onkeyup='domain_search(this.value)'>
+					</div>
+					<div id='domains_list'>
+						{foreach $domains as $row}
+							{*//alternate background colors of inactive domains *}
+								{if $background_color == $domain_selector_background_color_1}
+									{$background_color=$domain_selector_background_color_2}
+								{else}
+									{$background_color=$domain_selector_background_color_1}
+								{/if}
+							{*//set active domain color *}
+								{if $domain_active_background_color != ''}
+									{if $row.domain_uuid == $domain_uuid}{$background_color=$domain_active_background_color}{/if}
+								{else}
+									{if $row.domain_uuid == $domain_uuid}{$background_color='#eeffee'}{/if}
+								{/if}
+							{*//active domain text hover color *}
+								{if $settings.theme.domain_active_text_color_hover != '' && $row.domain_uuid == $domain_uuid}
+									<div id='{$row.domain_name}' class='domains_list_item_active' style='background-color: {$background_color}' onclick="document.location.href='{$domains_app_path}?domain_uuid={$row.domain_uuid}&domain_change=true';">
+								{elseif $settings.theme.domain_inactive_text_color_hover != '' && $row.domain_uuid != $domain_uuid}
+									<div id='{$row.domain_name}' class='domains_list_item_inactive' style='background-color: {$background_color}' onclick="document.location.href='{$domains_app_path}?domain_uuid={$row.domain_uuid}&domain_change=true';">
+								{else}
+									<div id='{$row.domain_name}' class='domains_list_item' style='background-color: {$background_color}' onclick="document.location.href='{$domains_app_path}?domain_uuid={$row.domain_uuid}&domain_change=true';">
+								{/if}
+							{*//domain link *}
+								<a href='{$domains_app_path}?domain_uuid={$row.domain_uuid}&domain_change=true' {if $row.domain_uuid == $domain_uuid}style='font-weight: bold;'{/if}>{$row.domain_name}</a>
+							{*//domain description *}
+								{if $row.domain_description != ''}
+									{*//active domain description text color *}
+										{if $settings.theme.domain_active_desc_text_color != '' && $row.domain_uuid == $domain_uuid}
+											<span class='domain_active_list_item_description' title="{$row.domain_description}"> - {$row.domain_description}</span>
+									{*//inactive domains description text color *}
+										{elseif $settings.theme.domain_inactive_desc_text_color != '' && $row.domain_uuid != $domain_uuid}
+											<span class='domain_inactive_list_item_description' title="{$row.domain_description}"> - {$row.domain_description}</span>
+									{*//default domain description text color *}
+										{else}
+											<span class='domain_list_item_description' title="{$row.domain_description}"> - {$row.domain_description}</span>
+										{/if}
+								{/if}
+							</div>
+							{$ary_domain_names[]=$row.domain_name}
+							{$ary_domain_descs[]=$row.domain_description|replace:'"':'\"'}
+						{/foreach}
+					</div>
+
+					<script>
+						{literal}
+						var domain_names = new Array("{/literal}{'","'|implode:$ary_domain_names}{literal}");
+						var domain_descs = new Array("{/literal}{'","'|implode:$ary_domain_descs}{literal}");
+						function domain_search(criteria) {
+							for (var x = 0; x < domain_names.length; x++) {
+								if (domain_names[x].toLowerCase().match(criteria.toLowerCase()) || domain_descs[x].toLowerCase().match(criteria.toLowerCase())) {
+									document.getElementById(domain_names[x]).style.display = '';
+								}
+								else {
+									document.getElementById(domain_names[x]).style.display = 'none';
 								}
 								}
-								echo "<span class='menu_side_item_title' style='display: none;'>".$menu_item_main['menu_language_title']."</span>";
-								echo "</a>\n";
-								//sub menu items
-									if (is_array($menu_item_main['menu_items']) && sizeof($menu_item_main['menu_items']) != 0) {
-										echo "	<div id='sub_".$menu_item_main['menu_item_uuid']."' class='menu_side_sub' style='display: none;'>\n";
-										foreach ($menu_item_main['menu_items'] as $menu_index_sub => $menu_item_sub) {
-											echo "		<a class='menu_side_item_sub' ".($menu_item_sub['menu_item_category'] == 'external' ? "target='_blank'" : null)." href='".$menu_item_sub['menu_item_link']."'>";
-											echo 			"<span class='menu_side_item_title' style='display: none;'>".$menu_item_sub['menu_language_title']."</span>";
-											echo 		"</a>\n";
-										}
-										echo "	</div>\n";
-									}
 							}
 							}
-							echo "	<div style='height: 100px;'></div>\n";
 						}
 						}
-				echo "</div>\n";
-				echo "<div id='content_container' style='padding: 0; width: calc(100% - ".(is_numeric($_SESSION['theme']['menu_side_width_contracted']['text']) ? $_SESSION['theme']['menu_side_width_contracted']['text'] : '55')."px); float: right; padding-top: 0px; text-align: center;'>\n";
-				echo "	<div id='content_header'>\n";
-				//header: left
-					echo "<div class='float-left'>\n";
-					echo "</div>\n";
-				//header: right
-					echo "<span class='float-right' style='white-space: nowrap;'>";
-					//current user
-						echo "<span style='display: inline-block; padding-right: 20px; font-size: 85%;'>\n";
-						echo "<strong>".$text['theme-label-user']."</strong>: ";
-						echo "<a href='".PROJECT_PATH."/core/users/user_edit.php?id=user'>".$_SESSION['username']."</a>";
-						echo "</span>\n";
-					//domain name/selector (sm+)
-						if ($_SESSION["username"] != '' && permission_exists("domain_select") && count($_SESSION['domains']) > 1 && $_SESSION['theme']['domain_visible']['text'] == 'true') {
-							echo "<span style='display: inline-block; padding-right: 10px; font-size: 85%;'>\n";
-							echo "<strong>".$text['theme-label-domain']."</strong>: ";
-							echo "<a href='#' id='header_domain_selector_domain' title='".$text['theme-label-open_selector']."'>".escape($_SESSION['domain_name'])."</a>";
-							echo "</span>\n";
-						}
-					//logout icon
-						if ($_SESSION['username'] != '' && $_SESSION['theme']['logout_icon_visible']['text'] == "true") {
-							echo "<a id='header_logout_icon' href='".PROJECT_PATH."/logout.php' title=\"".$text['theme-label-logout']."\" onclick=\"return confirm('".$text['theme-confirm-logout']."')\"><span class='fas fa-log-out'></span></a>";
-						}
-					echo "</span>";
-				echo "	</div>\n";
-				break;
-		}
-
-		echo "<div id='main_content'>\n";
-		echo "	<!--{body}-->\n";
-		echo "</div>\n";
-		echo "<div id='footer'>\n";
-		echo "	<span class='footer'>".(isset($_SESSION['theme']['footer']['text']) && $_SESSION['theme']['footer']['text'] != '' ? $_SESSION['theme']['footer']['text'] : "&copy; ".$text['theme-label-copyright']." 2008 - ".date("Y")." <a href='http://www.fusionpbx.com' class='footer' target='_blank'>fusionpbx.com</a> ".$text['theme-label-all_rights_reserved'])."</span>\n";
-		echo "</div>\n";
-
-		echo "</div>\n"; //initial div from switch statement above
-}
-else {
-	//default login being used
-	if ($_SESSION['theme']['logo_login']['text'] != '') {
-		$logo = $_SESSION['theme']['logo_login']['text'];
-	}
-	else if ($_SESSION['theme']['logo']['text'] != '') {
-		$logo = $_SESSION['theme']['logo']['text'];
-	}
-	else {
-		$logo = PROJECT_PATH."/themes/default/images/logo_login.png";
-	}
-
-	//set the login logo width and height
-	if (isset($_SESSION['theme']['login_logo_width']['text'])) {
-		$login_logo_width = $_SESSION['theme']['login_logo_width']['text'];
-	}
-	else {
-		$login_logo_width = 'auto; max-width: 300px';
-	}
-	if (isset($_SESSION['theme']['login_logo_height']['text'])) {
-		$login_logo_height = $_SESSION['theme']['login_logo_height']['text'];
-	}
-	else {
-		$login_logo_height = 'auto; max-height: 300px';
-	}
-
-	echo "<div id='default_login'>\n";
-	echo "	<a href='".PROJECT_PATH."/'><img id='login_logo' style='width: ".$login_logo_width."; height: ".$login_logo_height.";' src='".escape($logo)."'></a><br />\n";
-	echo "	<!--{body}-->\n";
-	echo "</div>\n";
-	echo "<div id='footer_login'>\n";
-	echo "	<span class='footer'>".($_SESSION['theme']['footer']['text'] != '' ? $_SESSION['theme']['footer']['text'] : "&copy; ".$text['theme-label-copyright']." 2008 - ".date("Y")." <a href='http://www.fusionpbx.com' class='footer' target='_blank'>fusionpbx.com</a> ".$text['theme-label-all_rights_reserved'])."</span>\n";
-	echo "</div>\n";
-
-	unset($_SESSION['background_image']);
-}
-
-echo "</body>\n";
-echo "</html>\n";
-
-?>
+						{/literal}
+					</script>
+
+				</div>
+			</div>
+
+		{/if}
+
+	{*//qr code container for contacts *}
+		<div id='qr_code_container' style='display: none;' onclick='$(this).fadeOut(400);'>
+			<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td align='center' valign='middle'>
+				<span id='qr_code' onclick="$('#qr_code_container').fadeOut(400);"></span>
+			</td></tr></table>
+		</div>
+
+	{*//logged in *}
+		{if $authenticated}
+			{if $settings.theme.menu_style == 'side' || $settings.theme.menu_style == 'inline' || $settings.theme.menu_style == 'static'}
+				{if $settings.theme.menu_style == 'inline'}{$logo}{/if}
+				{$container_open}
+				{$menu}
+				{if $settings.theme.menu_style == 'inline' || $settings.theme.menu_style == 'static'}<br />{/if}
+			{else} {*//default: fixed *}
+				{$menu}
+				{$container_open}
+			{/if}
+			<div id='main_content'>
+				{$document_body}
+			</div>
+			<div id='footer'>
+				<span class='footer'>{$settings.theme.footer}</span>
+			</div>
+			{$container_close}
+
+	{*//not logged in *}
+		{else}
+			<div id='default_login'>
+				<a href='{$project_path}/'><img id='login_logo' style='width: {$login_logo_width}; height: {$login_logo_height};' src='{$login_logo_source}'></a><br />
+				{$document_body}
+			</div>
+			<div id='footer_login'>
+				<span class='footer'>{$settings.theme.footer}</span>
+			</div>
+		{/if}
+
+</body>
+</html>