diff --git a/resources/classes/menu.php b/resources/classes/menu.php
index 12e5588646..c46c575980 100644
--- a/resources/classes/menu.php
+++ b/resources/classes/menu.php
@@ -47,6 +47,7 @@ if (!class_exists('menu')) {
private $location;
public $menu_uuid;
public $menu_language;
+ public $text;
/**
* called when the object is created
@@ -909,6 +910,257 @@ if (!class_exists('menu')) {
}
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 = "\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 = "
\n";
+ $html .= "
";
+ $html .= "
";
+ $html .= "
\n";
+ }
+ else {
+ $html = " \n";
+ //menu toggle buttons
+ if ($_SESSION['theme']['menu_brand_type']['text'] != 'none') {
+ $html .= "
\n";
+ $html .= "
\n";
+ $html .= "
\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 .= "
";
+ $html .= "
";
+ $html .= "
";
+ $html .= "\n";
+ }
+ else if ($_SESSION['theme']['menu_brand_type']['text'] == 'image_text') {
+ $html .= "
";
+ $html .= "
";
+ $html .= "".$menu_brand_text."";
+ $html .= "\n";
+ }
+ else if ($_SESSION['theme']['menu_brand_type']['text'] == 'text') {
+ $html .= "
".$menu_brand_text."\n";
+ }
+ $html .= "
\n";
+ }
+ //main menu items
+ if (is_array($menu_array) && sizeof($menu_array) != 0) {
+ foreach ($menu_array as $menu_index_main => $menu_item_main) {
+ $html .= " ";
+ if ($menu_item_main['menu_item_icon'] != '') {
+ $html .= "";
+ }
+ $html .= "";
+ $html .= "\n";
+ //sub menu items
+ if (is_array($menu_item_main['menu_items']) && sizeof($menu_item_main['menu_items']) != 0) {
+ $html .= " \n";
+ foreach ($menu_item_main['menu_items'] as $menu_index_sub => $menu_item_sub) {
+ $html .= " \n";
+ }
+ $html .= "
\n";
+ }
+ }
+ $html .= " \n";
+ }
+ $html .= "\n";
+ $html .= "\n";
+ $html .= " \n";
+
+ return $html;
+ unset($html);
+
+ }
+
}
}
diff --git a/resources/footer.php b/resources/footer.php
index 877fac85a8..75dc860e1d 100644
--- a/resources/footer.php
+++ b/resources/footer.php
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane
- 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.
Contributor(s):
@@ -25,7 +25,7 @@
*/
//includes
- include "root.php";
+ require_once "root.php";
require_once "resources/require.php";
//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
+ */
- if (isset($_SESSION["theme"]["title"]["text"])) {
- if (strlen($_SESSION["theme"]["title"]["text"]) > 0) {
- $document_title = (($document["title"] != '') ? $document["title"]." - " : null).$_SESSION["theme"]["title"]["text"];
- }
- else {
- $document_title = (($document["title"] != '') ? $document["title"]." " : null);
- }
- }
- else {
- if (isset($_SESSION["software_name"])) {
- $document_title = (($document["title"] != '') ? $document["title"]." - " : null).$_SESSION["software_name"];
- }
- else {
- $document_title = (($document["title"] != '') ? $document["title"]." " : null);
- }
- }
- $output = str_replace ("", $document_title, $template); // defined in each individual page
- $output = str_replace ("", $custom_head, $output); // defined in each individual page
- if (strlen($v_menu) > 0) {
- $output = str_replace ("", $v_menu, $output); //defined in /resources/menu.php
- }
- else {
- $output = str_replace ("", $_SESSION["menu"], $output); //defined in /resources/menu.php
- }
- $output = str_replace ("", PROJECT_PATH, $output); //defined in /resources/menu.php
+//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();
- $pos = strrpos($output, "");
- if ($pos === false) {
- $output = $body; //if tag not found just show the body
- }
- else {
- //replace the body
- $output = str_replace ("", $body, $output);
- }
+//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
+
+ //add translations
+ foreach($text as $key => $value) {
+ $array[str_replace('-', '_', $key)] = $value;
+ }
+ $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'] : '© '.$text['theme-label-copyright'].' 2008 - '.date('Y')." ".$text['theme-label-all_rights_reserved'];
+ $view->assign('settings', $settings);
+ }
+ //document title
+ if (isset($_SESSION['theme']['title']['text']) && $_SESSION['theme']['title']['text'] != '') {
+ $document_title = $_SESSION['theme']['title']['text'];
+ }
+ else if (isset($_SESSION['software_name'])) {
+ $document_title = $_SESSION['software_name'];
+ }
+ $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 = "