Adicionada a lingua pt aos menus

This commit is contained in:
Nuno Miguel Reis
2012-10-11 00:01:42 +00:00
parent 8c32fd31bb
commit c8deeea07a
6 changed files with 131 additions and 86 deletions

View File

@@ -126,6 +126,13 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "where default_setting_uuid = '$default_setting_uuid'"; $sql .= "where default_setting_uuid = '$default_setting_uuid'";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
$sql = "update v_domain_settings set ";
$sql .= "domain_setting_value = '$default_setting_value' ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and domain_setting_subcategory = 'menu' ";
$db->exec(check_sql($sql));
unset($sql);
require_once "includes/header.php"; require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=default_settings.php\">\n"; echo "<meta http-equiv=\"refresh\" content=\"2;url=default_settings.php\">\n";

View File

@@ -179,7 +179,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
} }
echo "<td width='70%' align='right'>\n"; echo "<td width='70%' align='right'>\n";
if (permission_exists('menu_restore')) { if (permission_exists('menu_restore')) {
echo " <input type='button' class='btn' value='Restore Default' onclick=\"document.location.href='menu_restore_default.php?menu_uuid=$menu_uuid&menu_uuid=$menu_uuid';\" />"; echo " <input type='button' class='btn' value='Restore Default' onclick=\"document.location.href='menu_restore_default.php?menu_uuid=$menu_uuid&menu_language=$menu_language';\" />";
} }
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='menu.php'\" value='Back'></td>\n"; echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='menu.php'\" value='Back'></td>\n";
echo "</tr>\n"; echo "</tr>\n";

View File

@@ -36,12 +36,14 @@ else {
//get the http value and set as a php variable //get the http value and set as a php variable
$menu_uuid = check_str($_REQUEST["menu_uuid"]); $menu_uuid = check_str($_REQUEST["menu_uuid"]);
$menu_language = check_str($_REQUEST["menu_language"]);
//menu restore default //menu restore default
require_once "includes/classes/menu.php"; require_once "includes/classes/menu.php";
$menu = new menu; $menu = new menu;
$menu->db = $db; $menu->db = $db;
$menu->menu_uuid = $menu_uuid; $menu->menu_uuid = $menu_uuid;
$menu->menu_language = $menu_language;
$menu->delete(); $menu->delete();
$menu->restore(); $menu->restore();

View File

@@ -27,6 +27,7 @@
//define the follow me class //define the follow me class
class menu { class menu {
public $menu_uuid; public $menu_uuid;
public $menu_language;
//delete items in the menu that are not protected //delete items in the menu that are not protected
function delete() { function delete() {
@@ -58,66 +59,67 @@
foreach ($apps as $row) { foreach ($apps as $row) {
foreach ($row['menu'] as $menu) { foreach ($row['menu'] as $menu) {
//set the variables //set the variables
$menu_item_title = $menu['title']['en']; //$menu_item_title = $menu['title']['en'];
$menu_item_language = 'en'; $menu_item_title = $menu['title'][$this->menu_language];
//$menu_item_language = 'en';
$menu_item_uuid = $menu['uuid']; $menu_item_uuid = $menu['uuid'];
$menu_item_parent_uuid = $menu['parent_uuid']; $menu_item_parent_uuid = $menu['parent_uuid'];
$menu_item_category = $menu['category']; $menu_item_category = $menu['category'];
$menu_item_path = $menu['path']; $menu_item_path = $menu['path'];
$menu_item_order = $menu['order']; $menu_item_order = $menu['order'];
$menu_item_description = $menu['desc']; $menu_item_description = $menu['desc'];
//if the item uuid is not currently in the db then add it //if the item uuid is not currently in the db then add it
$sql = "select * from v_menu_items "; $sql = "select * from v_menu_items ";
$sql .= "where menu_uuid = '".$this->menu_uuid."' "; $sql .= "where menu_uuid = '".$this->menu_uuid."' ";
$sql .= "and menu_item_uuid = '$menu_item_uuid' "; $sql .= "and menu_item_uuid = '$menu_item_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
if (count($result) == 0) { if (count($result) == 0) {
//insert the default menu into the database //insert the default menu into the database
$sql = "insert into v_menu_items "; $sql = "insert into v_menu_items ";
$sql .= "("; $sql .= "(";
$sql .= "menu_item_uuid, "; $sql .= "menu_item_uuid, ";
$sql .= "menu_uuid, "; $sql .= "menu_uuid, ";
//$sql .= "menu_item_language, "; //$sql .= "menu_item_language, ";
$sql .= "menu_item_title, "; $sql .= "menu_item_title, ";
$sql .= "menu_item_link, "; $sql .= "menu_item_link, ";
$sql .= "menu_item_category, "; $sql .= "menu_item_category, ";
if (strlen($menu_item_order) > 0) { if (strlen($menu_item_order) > 0) {
$sql .= "menu_item_order, "; $sql .= "menu_item_order, ";
} }
if (strlen($menu_item_parent_uuid) > 0) { if (strlen($menu_item_parent_uuid) > 0) {
$sql .= "menu_item_parent_uuid, "; $sql .= "menu_item_parent_uuid, ";
} }
$sql .= "menu_item_description "; $sql .= "menu_item_description ";
$sql .= ") "; $sql .= ") ";
$sql .= "values "; $sql .= "values ";
$sql .= "("; $sql .= "(";
$sql .= "'".$menu_item_uuid."', "; $sql .= "'".$menu_item_uuid."', ";
$sql .= "'".$this->menu_uuid."', "; $sql .= "'".$this->menu_uuid."', ";
//$sql .= "'$menu_item_language', "; //$sql .= "'$menu_item_language', ";
$sql .= "'$menu_item_title', "; $sql .= "'$menu_item_title', ";
$sql .= "'$menu_item_path', "; $sql .= "'$menu_item_path', ";
$sql .= "'$menu_item_category', "; $sql .= "'$menu_item_category', ";
if (strlen($menu_item_order) > 0) { if (strlen($menu_item_order) > 0) {
$sql .= "'$menu_item_order', "; $sql .= "'$menu_item_order', ";
} }
if (strlen($menu_item_parent_uuid) > 0) { if (strlen($menu_item_parent_uuid) > 0) {
$sql .= "'$menu_item_parent_uuid', "; $sql .= "'$menu_item_parent_uuid', ";
} }
$sql .= "'$menu_item_description' "; $sql .= "'$menu_item_description' ";
$sql .= ")"; $sql .= ")";
if ($menu_item_uuid == $menu_item_parent_uuid) { if ($menu_item_uuid == $menu_item_parent_uuid) {
//echo $sql."<br />\n"; //echo $sql."<br />\n";
} }
else { else {
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
} }
unset($sql); unset($sql);
} }
} }
} }
} }

View File

@@ -26,6 +26,13 @@
include "root.php"; include "root.php";
require_once "includes/require.php"; require_once "includes/require.php";
require_once "includes/Logging.php";
// Logging class initialization
$log = new Logging();
// set path and name of log file (optional)
$log->lfile('/tmp/mylog.txt');
//if reloadxml then run the command //if reloadxml then run the command
if (isset($_SESSION["reload_xml"])) { if (isset($_SESSION["reload_xml"])) {
if (strlen($_SESSION["reload_xml"]) > 0) { if (strlen($_SESSION["reload_xml"]) > 0) {
@@ -72,7 +79,7 @@ require_once "includes/require.php";
else { else {
$content = ''; $content = '';
} }
$log->lwrite($_SESSION['domain']['menu']['uuid']);
//get the parent id //get the parent id
$sql = "select * from v_menu_items "; $sql = "select * from v_menu_items ";
$sql .= "where menu_uuid = '".$_SESSION['domain']['menu']['uuid']."' "; $sql .= "where menu_uuid = '".$_SESSION['domain']['menu']['uuid']."' ";

View File

@@ -34,7 +34,7 @@ require_once "includes/lib_functions.php";
//add the menu uuid //add the menu uuid
$menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286'; $menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286';
$menu_uuid_pt = '1a2b789b-64a0-4a45-84eb-7ebf4f9c576b';
//error reporting //error reporting
ini_set('display_errors', '1'); ini_set('display_errors', '1');
//error_reporting (E_ALL); // Report everything //error_reporting (E_ALL); // Report everything
@@ -671,6 +671,12 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
$tmp[$x]['subcategory'] = 'menu'; $tmp[$x]['subcategory'] = 'menu';
$tmp[$x]['enabled'] = 'true'; $tmp[$x]['enabled'] = 'true';
$x++; $x++;
/* $tmp[$x]['name'] = 'uuid';
$tmp[$x]['value'] = $menu_uuid_pt;
$tmp[$x]['category'] = 'domain';
$tmp[$x]['subcategory'] = 'menu';
$tmp[$x]['enabled'] = 'true';
$x++;*/
$tmp[$x]['name'] = 'name'; $tmp[$x]['name'] = 'name';
$tmp[$x]['category'] = 'domain'; $tmp[$x]['category'] = 'domain';
$tmp[$x]['subcategory'] = 'time_zone'; $tmp[$x]['subcategory'] = 'time_zone';
@@ -833,6 +839,12 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
$tmp[$x]['subcategory'] = 'menu'; $tmp[$x]['subcategory'] = 'menu';
$tmp[$x]['enabled'] = 'true'; $tmp[$x]['enabled'] = 'true';
$x++; $x++;
/*$tmp[$x]['name'] = 'uuid';
$tmp[$x]['value'] = $menu_uuid_pt;
$tmp[$x]['category'] = 'domain';
$tmp[$x]['subcategory'] = 'menu';
$tmp[$x]['enabled'] = 'true';
$x++;*/
$tmp[$x]['name'] = 'name'; $tmp[$x]['name'] = 'name';
$tmp[$x]['value'] = $install_template_name; $tmp[$x]['value'] = $install_template_name;
$tmp[$x]['category'] = 'domain'; $tmp[$x]['category'] = 'domain';
@@ -1133,37 +1145,52 @@ if ($_POST["install_step"] == "3" && count($_POST)>0 && strlen($_POST["persistfo
require "includes/require.php"; require "includes/require.php";
//set the defaults //set the defaults
$menu_name = 'default'; $x = 0;
$menu_language = 'en'; $tmp[$x]['menu_name'] = 'default';
$menu_description = ''; $tmp[$x]['menu_language'] = 'en';
$tmp[$x]['menu_description'] = '';
$tmp[$x]['menu_uuid'] = $menu_uuid;
$x++;
$tmp[$x]['menu_name'] = 'portuguese';
$tmp[$x]['menu_language'] = 'pt-pt';
$tmp[$x]['menu_description'] = '';
$tmp[$x]['menu_uuid'] = $menu_uuid_pt;
//add the parent menu //add the parent menu
$sql = "insert into v_menus "; foreach($tmp as $row) {
$sql .= "("; $sql = "insert into v_menus ";
$sql .= "menu_uuid, "; $sql .= "(";
$sql .= "menu_name, "; $sql .= "menu_uuid, ";
$sql .= "menu_language, "; $sql .= "menu_name, ";
$sql .= "menu_description "; $sql .= "menu_language, ";
$sql .= ") "; $sql .= "menu_description ";
$sql .= "values "; $sql .= ") ";
$sql .= "("; $sql .= "values ";
$sql .= "'".$menu_uuid."', "; $sql .= "(";
$sql .= "'$menu_name', "; $sql .= "'".$row['menu_uuid']."', ";
$sql .= "'$menu_language', "; $sql .= "'".$row['menu_name']."', ";
$sql .= "'$menu_description' "; $sql .= "'".$row['menu_language']."', ";
$sql .= ");"; $sql .= "'".$row['menu_description']."' ";
if ($v_debug) { $sql .= ");";
fwrite($fp, $sql."\n"); if ($v_debug) {
} fwrite($fp, $sql."\n");
$db->exec(check_sql($sql)); }
unset($sql); $db->exec(check_sql($sql));
unset($sql);
//add the menu items
require_once "includes/classes/menu.php";
$menu = new menu;
$menu->db = $db;
$menu->menu_uuid = $row['menu_uuid'];
$menu->menu_language = $row['menu_language'];
$menu->restore();
unset($menu);
}
unset($tmp);
//add the menu items
require_once "includes/classes/menu.php";
$menu = new menu;
$menu->db = $db;
$menu->menu_uuid = $menu_uuid;
$menu->restore();
unset($menu);
//setup the switch config directory if it exists //setup the switch config directory if it exists
if ($switch_conf_dir != "/conf") { if ($switch_conf_dir != "/conf") {