Additional work to improve the install, template and the menu.
This commit is contained in:
parent
0e649f9020
commit
ba095f3852
|
|
@ -124,12 +124,6 @@
|
|||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//set a default template
|
||||
$default_template = 'default';
|
||||
if (isset($_SESSION['domain']['template']['name']) and strlen($_SESSION['domain']['template']['name']) != 0) {
|
||||
$default_template = $_SESSION['domain']['template']['name'];
|
||||
}
|
||||
|
||||
//set a default enviroment if first_time
|
||||
//initialize some varibles to cut down on warnings
|
||||
$_SESSION['message'] = '';
|
||||
|
|
@ -138,9 +132,6 @@
|
|||
$default_login = 0;
|
||||
$onload = '';
|
||||
|
||||
//get the contents of the template and save it to the template variable
|
||||
$template = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes/'.$default_template.'/template.php');
|
||||
|
||||
//buffer the content
|
||||
ob_end_clean(); //clean the buffer
|
||||
ob_start();
|
||||
|
|
@ -215,7 +206,7 @@
|
|||
echo " <input type='hidden' name='return_install_step' value='select_language'/>\n";
|
||||
echo " <input type='hidden' name='install_step' value='detect_config'/>\n";
|
||||
echo " <div style='text-align:right'>\n";
|
||||
echo " <button type='submit' id='next'>".$text['button-next']."</button>\n";
|
||||
echo " <button type='submit' class='btn' id='next'>".$text['button-next']."</button>\n";
|
||||
echo " </div>\n";
|
||||
echo "</form>\n";
|
||||
} elseif($install_step == 'detect_config'){
|
||||
|
|
@ -232,14 +223,14 @@
|
|||
echo " <input type='hidden' name='event_port' value='$event_port'/>\n";
|
||||
echo " <input type='hidden' name='event_password' value='$event_password'/>\n";
|
||||
echo " <div style='text-align:right'>\n";
|
||||
echo " <button type='button' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
|
||||
echo " <button type='submit' id='next'>".$text['button-next']."</button>\n";
|
||||
echo " <button type='button' class='btn' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
|
||||
echo " <button type='submit' class='btn' id='next'>".$text['button-next']."</button>\n";
|
||||
echo " </div>\n";
|
||||
echo "</form>\n";
|
||||
} else {
|
||||
echo "<form method='post' name='frm' action=''>\n";
|
||||
echo " <div style='text-align:right'>\n";
|
||||
echo " <button type='button' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
|
||||
echo " <button type='button' class='btn' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
|
||||
echo " </div>\n";
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
|
@ -329,8 +320,8 @@
|
|||
}else {
|
||||
echo "<form method='post' name='frm' action=''>\n";
|
||||
echo " <div style='text-align:right'>\n";
|
||||
echo " <button type='button' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
|
||||
echo " <button type='button' onclick=\"location.reload(true);\">".$text['button-execute']."</button>\n";
|
||||
echo " <button type='button' class='btn' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
|
||||
echo " <button type='button' class='btn' onclick=\"location.reload(true);\">".$text['button-execute']."</button>\n";
|
||||
echo " </div>\n";
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
|
@ -340,44 +331,47 @@
|
|||
echo "<p>Unkown install_step '$install_step'</p>\n";
|
||||
}
|
||||
|
||||
//get the default theme
|
||||
$set_session_theme = 1;
|
||||
$domains_processed = 1;
|
||||
include "themes/".$default_template."/template.php";
|
||||
unset($set_session_theme, $domains_processed);
|
||||
//initialize some defaults so we can be 'logged in'
|
||||
//$_SESSION['username'] = 'install_enabled';
|
||||
//$_SESSION['permissions'][]['permission_name'] = 'superadmin';
|
||||
//$_SESSION['menu'] = '';
|
||||
|
||||
//show errors
|
||||
ini_set('display_errors', '1');
|
||||
//error_reporting (E_ALL); // Report everything
|
||||
//error_reporting (E_ALL ^ E_NOTICE); // Report everything
|
||||
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings
|
||||
|
||||
//add the content to the template and then send output
|
||||
$body = ob_get_contents(); //get the output from the buffer
|
||||
ob_end_clean(); //clean the buffer
|
||||
|
||||
//replace known used constants
|
||||
$body = str_replace ("<!--{project_path}-->", PROJECT_PATH, $body); //defined in /resources/menu.php
|
||||
//set a default template
|
||||
$default_template = 'default';
|
||||
$_SESSION['domain']['template']['name'] = $default_template;
|
||||
|
||||
//set the default template path
|
||||
$template_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes/'.$default_template.'/template.php';
|
||||
|
||||
//get the content of the template
|
||||
$template_content = file_get_contents($template_path);
|
||||
|
||||
//replace the variables in the template
|
||||
$template_content = str_replace ("<!--{title}-->", $document['title'], $template_content); //<!--{title}--> defined in each individual page
|
||||
$template_content = str_replace ("<!--{head}-->", '', $template_content); //<!--{head}--> defined in each individual page
|
||||
//$template_content = str_replace ("<!--{menu}-->", $_SESSION["menu"], $template_content); //included in the theme
|
||||
$template_content = str_replace ("<!--{body}-->", $body, $template_content); //defined in /themes/default/template.php
|
||||
$template_content = str_replace ("<!--{project_path}-->", PROJECT_PATH, $template_content); //defined in /themes/default/template.php
|
||||
|
||||
//get the contents of the template and save it to the template variable
|
||||
ob_start();
|
||||
eval('?>' . $template . '<?php ');
|
||||
$template = ob_get_contents(); //get the output from the buffer
|
||||
require_once "resources/classes/menu.php";
|
||||
eval('?>' . $template_content . '<?php ');
|
||||
$content = ob_get_contents(); //get the output from the buffer
|
||||
ob_end_clean(); //clean the buffer
|
||||
//echo $content;
|
||||
|
||||
$custom_head = '';
|
||||
$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
|
||||
$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);
|
||||
}
|
||||
|
||||
echo $output;
|
||||
unset($output);
|
||||
//send the content to the browser and then clear the variable
|
||||
echo $content;
|
||||
|
||||
?>
|
||||
|
|
@ -386,24 +386,102 @@
|
|||
//create the menu array
|
||||
function menu_array($sql, $menu_item_level) {
|
||||
|
||||
$db = $this->db;
|
||||
//get the database connnection return immediately if it doesn't exist
|
||||
if ($this->db) {
|
||||
$db = $this->db;
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['groups'])) {
|
||||
$_SESSION['groups'][0]['group_name'] = 'public';
|
||||
}
|
||||
//if there are no groups then set the public group
|
||||
if (!isset($_SESSION['groups'])) {
|
||||
$_SESSION['groups'][0]['group_name'] = 'public';
|
||||
}
|
||||
|
||||
if (strlen($sql) == 0) { //default sql for base of the menu
|
||||
//get the menu from the database
|
||||
if (strlen($sql) == 0) { //default sql for base of the menu
|
||||
$sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_uuid, i.menu_item_parent_uuid ";
|
||||
$sql .= "from v_menu_items as i, v_menu_languages as l ";
|
||||
$sql .= "where i.menu_item_uuid = l.menu_item_uuid ";
|
||||
$sql .= "and l.menu_language = '".$_SESSION['domain']['language']['code']."' ";
|
||||
$sql .= "and l.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_item_parent_uuid is null ";
|
||||
$sql .= "and i.menu_item_uuid in ";
|
||||
$sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and ( ";
|
||||
if (!isset($_SESSION['groups'])) {
|
||||
$sql .= "group_name = 'public' ";
|
||||
}
|
||||
else {
|
||||
$x = 0;
|
||||
foreach($_SESSION['groups'] as $row) {
|
||||
if ($x == 0) {
|
||||
$sql .= "group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "or group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= "and menu_item_uuid is not null ";
|
||||
$sql .= ") ";
|
||||
$sql .= "order by i.menu_item_order asc ";
|
||||
}
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
|
||||
//save the menu into an array
|
||||
$x = 0;
|
||||
foreach($result as $row) {
|
||||
//add the row to the array
|
||||
$a[$x] = $row;
|
||||
|
||||
//add the sub menus to the array
|
||||
$menu_item_level = 0;
|
||||
if (strlen($row['menu_item_uuid']) > 0) {
|
||||
$a[$x]['menu_items'] = $this->menu_child_array($menu_item_level, $row['menu_item_uuid']);
|
||||
}
|
||||
|
||||
//increment the row number
|
||||
$x++;
|
||||
} //end for each
|
||||
|
||||
//unset the variables
|
||||
unset($prep_statement, $sql, $result);
|
||||
|
||||
//return the array
|
||||
return $a;
|
||||
}
|
||||
|
||||
//create the sub menus
|
||||
function menu_child_array($menu_item_level, $menu_item_uuid) {
|
||||
|
||||
//get the database connnection return immediately if it doesn't exist
|
||||
if ($this->db) {
|
||||
$db = $this->db;
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
|
||||
//set the level
|
||||
$menu_item_level = $menu_item_level+1;
|
||||
|
||||
//get the child menu from the database
|
||||
$sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_uuid, i.menu_item_parent_uuid ";
|
||||
$sql .= "from v_menu_items as i, v_menu_languages as l ";
|
||||
$sql .= "where i.menu_item_uuid = l.menu_item_uuid ";
|
||||
$sql .= "and l.menu_language = '".$_SESSION['domain']['language']['code']."' ";
|
||||
$sql .= "and l.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_item_parent_uuid is null ";
|
||||
$sql .= "and i.menu_item_parent_uuid = '$menu_item_uuid' ";
|
||||
$sql .= "and i.menu_item_uuid in ";
|
||||
$sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and ( ";
|
||||
if (!isset($_SESSION['groups'])) {
|
||||
if (count($_SESSION['groups']) == 0) {
|
||||
$sql .= "group_name = 'public' ";
|
||||
}
|
||||
else {
|
||||
|
|
@ -419,111 +497,45 @@
|
|||
}
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= "and menu_item_uuid is not null ";
|
||||
$sql .= ") ";
|
||||
$sql .= "order by i.menu_item_order asc ";
|
||||
}
|
||||
try {
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
//menu is not available
|
||||
}
|
||||
$sql .= "order by l.menu_item_title, i.menu_item_order asc ";
|
||||
$sub_prep_statement = $db->prepare($sql);
|
||||
$sub_prep_statement->execute();
|
||||
$sub_result = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
|
||||
|
||||
$x = 0;
|
||||
foreach($result as $row) {
|
||||
//add the row to the array
|
||||
$a[$x] = $row;
|
||||
//save the child menu into an array
|
||||
if (count($sub_result) > 0) {
|
||||
foreach($sub_result as $row) {
|
||||
//set the variables
|
||||
$menu_item_link = $row['menu_item_link'];
|
||||
$menu_item_category = $row['menu_item_category'];
|
||||
$menu_item_uuid = $row['menu_item_uuid'];
|
||||
$menu_item_parent_uuid = $row['menu_item_parent_uuid'];
|
||||
|
||||
//add the sub menus to the array
|
||||
$menu_item_level = 0;
|
||||
if (strlen($row['menu_item_uuid']) > 0) {
|
||||
$a[$x]['menu_items'] = $this->menu_child_array($menu_item_level, $row['menu_item_uuid']);
|
||||
//add the row to the array
|
||||
$a[$x] = $row;
|
||||
|
||||
//prepare the protected menus
|
||||
if ($row['menu_item_protected'] == "true") {
|
||||
$a[$x]['menu_item_title'] = $row['menu_item_title'];
|
||||
}
|
||||
else {
|
||||
$a[$x]['menu_item_title'] = $row['menu_language_title'];
|
||||
}
|
||||
|
||||
//get sub menu for children
|
||||
if (strlen($menu_item_uuid) > 0) {
|
||||
$a[$x]['menu_items'] = $this->menu_child_array($menu_item_level, $menu_item_uuid);
|
||||
//$str_child_menu =
|
||||
}
|
||||
|
||||
//increment the row
|
||||
$x++;
|
||||
}
|
||||
|
||||
//increment the row number
|
||||
$x++;
|
||||
} //end for each
|
||||
|
||||
unset($prep_statement, $sql, $result);
|
||||
return $a;
|
||||
}
|
||||
|
||||
//create the sub menus
|
||||
function menu_child_array($menu_item_level, $menu_item_uuid) {
|
||||
|
||||
$db = $this->db;
|
||||
$menu_item_level = $menu_item_level+1;
|
||||
|
||||
if (count($_SESSION['groups']) == 0) {
|
||||
$_SESSION['groups'][0]['group_name'] = 'public';
|
||||
}
|
||||
|
||||
$sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_uuid, i.menu_item_parent_uuid ";
|
||||
$sql .= "from v_menu_items as i, v_menu_languages as l ";
|
||||
$sql .= "where i.menu_item_uuid = l.menu_item_uuid ";
|
||||
$sql .= "and l.menu_language = '".$_SESSION['domain']['language']['code']."' ";
|
||||
$sql .= "and l.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and i.menu_item_parent_uuid = '$menu_item_uuid' ";
|
||||
$sql .= "and i.menu_item_uuid in ";
|
||||
$sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' ";
|
||||
$sql .= "and ( ";
|
||||
if (count($_SESSION['groups']) == 0) {
|
||||
$sql .= "group_name = 'public' ";
|
||||
}
|
||||
else {
|
||||
$x = 0;
|
||||
foreach($_SESSION['groups'] as $row) {
|
||||
if ($x == 0) {
|
||||
$sql .= "group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "or group_name = '".$row['group_name']."' ";
|
||||
}
|
||||
$x++;
|
||||
unset($sql, $sub_result);
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
$sql .= ") ";
|
||||
$sql .= ") ";
|
||||
$sql .= "order by l.menu_item_title, i.menu_item_order asc ";
|
||||
$prep_statement_2 = $db->prepare($sql);
|
||||
$prep_statement_2->execute();
|
||||
$result_2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result_2) > 0) {
|
||||
foreach($result_2 as $row) {
|
||||
//set the variables
|
||||
$menu_item_link = $row['menu_item_link'];
|
||||
$menu_item_category = $row['menu_item_category'];
|
||||
$menu_item_uuid = $row['menu_item_uuid'];
|
||||
$menu_item_parent_uuid = $row['menu_item_parent_uuid'];
|
||||
|
||||
//add the row to the array
|
||||
$a[$x] = $row;
|
||||
|
||||
//prepare the protected menus
|
||||
if ($row['menu_item_protected'] == "true") {
|
||||
$a[$x]['menu_item_title'] = $row['menu_item_title'];
|
||||
}
|
||||
else {
|
||||
$a[$x]['menu_item_title'] = $row['menu_language_title'];
|
||||
}
|
||||
|
||||
//get sub menu for children
|
||||
if (strlen($menu_item_uuid) > 0) {
|
||||
$a[$x]['menu_items'] = $this->menu_child_array($menu_item_level, $menu_item_uuid);
|
||||
//$str_child_menu =
|
||||
}
|
||||
|
||||
//increment the row
|
||||
$x++;
|
||||
}
|
||||
unset($sql, $result_2);
|
||||
return $a;
|
||||
}
|
||||
unset($prep_statement_2, $sql);
|
||||
unset($sub_prep_statement, $sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ require_once "resources/require.php";
|
|||
}
|
||||
}
|
||||
|
||||
//start the output buffer
|
||||
//get the template
|
||||
ob_start();
|
||||
$template = $_SESSION["template_content"];
|
||||
eval('?>' . $template . '<?php ');
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2016
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
|
|
|||
|
|
@ -1717,7 +1717,7 @@
|
|||
<td width='100%' style='padding-right: 15px;' align='right' valign='middle'>
|
||||
<?php
|
||||
// login form
|
||||
if ($_SERVER['PHP_SELF'] != PROJECT_PATH."/resources/install.php" && !$default_login) {
|
||||
if ($_SERVER['PHP_SELF'] != PROJECT_PATH."/core/install/install.php" && !$default_login) {
|
||||
if (strlen($_SESSION["username"]) == 0) {
|
||||
//add multi-lingual support
|
||||
require_once "core/user_settings/app_languages.php";
|
||||
|
|
|
|||
Loading…
Reference in New Issue