Example #1
0
 function do_edit()
 {
     global $ttH;
     $err = "";
     $menu_id = $ttH->input["id"];
     if (isset($ttH->post['do_submit'])) {
         /*print_arr($ttH->post);
         		die();*/
         $name_action = $ttH->func->get_friendly_link($ttH->post["name_action"]);
         if (empty($err) && empty($ttH->post["title"])) {
             $err = $ttH->html->html_alert($ttH->lang["global"]["err_invalid_title"], "error");
         }
         if (empty($err)) {
             $col = array();
             $col["menu_nav"] = get_menu_nav($ttH->post["parent_id"], $menu_id);
             $col["menu_level"] = substr_count($col['menu_nav'], ',') + 1;
             $col["parent_id"] = $ttH->post["parent_id"];
             $col["name_action"] = $name_action;
             $col["target"] = $ttH->post["target"];
             $col["show_mod"] = isset($ttH->post["show_mod"]) ? get_input_show($ttH->post["show_mod"]) : "";
             $col["show_act"] = isset($ttH->post["show_act"]) ? get_input_show($ttH->post["show_act"]) : "";
             $col["date_update"] = time();
             $ok = $ttH->db->do_update("menu", $col, " menu_id='" . $menu_id . "'");
             if ($ok) {
                 $col_l = array();
                 $col_l["menu_id"] = $menu_id;
                 $col_l["title"] = $ttH->post["title"];
                 $col_l["link_type"] = $ttH->post["link_type"];
                 $col_l["link"] = $ttH->post["link"];
                 $ttH->db->do_update("menu_lang", $col_l, " menu_id='" . $menu_id . "' and lang='" . $ttH->conf["lang_cur"] . "'");
                 built_menu_nav_sub($menu_id, $col["menu_nav"]);
                 $err = $ttH->html->html_alert($ttH->lang["global"]["edit_success"], "success");
             } else {
                 $err = $ttH->html->html_alert($ttH->lang["global"]["edit_false"], "error");
             }
         }
     }
     $sql = "select * from menu a, menu_lang al \n\t\t\t\t\t\twhere a.menu_id=al.menu_id \n\t\t\t\t\t\tand lang='" . $ttH->conf['lang_cur'] . "' \n\t\t\t\t\t\tand a.menu_id=" . $menu_id;
     $result = $ttH->db->query($sql);
     if ($data = $ttH->db->fetch_row($result)) {
     }
     $data["err"] = $err;
     $data["link_action"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("id" => $menu_id));
     $data["list_group"] = list_group("group_id", $data["group_id"], " class=\"form-control\" onchange=\"window.location.href='" . $data["link_action"] . "&group_id='+this.value;\"");
     //$data['group_name'] = $ttH->data["menu_group"][$this->cur_group];
     $data["list_menu"] = list_menu($this->cur_group, "parent_id", $data["parent_id"], " class=\"form-control\"", array("title" => $ttH->lang['global']['select_title'], 'disabled' => $data["menu_id"]));
     $data["list_link_type"] = $ttH->admin->list_link_type("link_type", $data["link_type"], " class=\"form-control\"");
     $data["list_target"] = $ttH->admin->list_target("target", $data["target"], " class=\"form-control\"");
     $data["list_module"] = list_module("show_mod[]", $data["show_mod"], " class=\"form-control\"", array('title' => $ttH->lang["global"]["select_all"]));
     $ttH->temp_act->assign('data', $data);
     $ttH->temp_act->parse("edit");
     return $ttH->temp_act->text("edit");
 }
Example #2
0
 function do_add_menu()
 {
     global $ttH;
     $cur_group = isset($ttH->input['group_id']) ? $ttH->input['group_id'] : 'menu_header';
     $temp = 'menu_add';
     $name_action = isset($ttH->get['name_action']) ? $ttH->get['name_action'] : '';
     $link_action = $ttH->admin->get_link_admin_popup('layout', 'menu', 'add_menu', array("name_action" => $name_action));
     $tmp = explode('-', $name_action);
     $table = $tmp[1] != 'item' ? $tmp[0] . '_' . $tmp[1] : $tmp[0];
     $table_key = $tmp[1] . '_id';
     $table_id = $tmp[2];
     $sql = "select * from " . $table . " a, " . $table . "_lang al \r\r\n\t\t\t\t\t\twhere a." . $table_key . "=al." . $table_key . " \r\r\n\t\t\t\t\t\tand lang='" . $ttH->conf['lang_cur'] . "' \r\r\n\t\t\t\t\t\tand a." . $table_key . "='" . $table_id . "'";
     $result = $ttH->db->query($sql);
     if ($table_info = $ttH->db->fetch_row($result)) {
     }
     $data = array();
     $err = "";
     if (isset($ttH->post['do_submit'])) {
         /*print_arr($ttH->post);
         		die();*/
         $name_action = $ttH->func->get_friendly_link($ttH->post["name_action"]);
         if (empty($ttH->post["title"])) {
             $err = $ttH->html->html_alert($ttH->lang["global"]["err_invalid_title"], "error");
         }
         if (empty($err)) {
             $col = array();
             $col["group_id"] = $cur_group;
             $col["parent_id"] = $ttH->post["parent_id"];
             $col["name_action"] = $name_action;
             $col["target"] = $ttH->post["target"];
             $col["show_mod"] = isset($ttH->post["show_mod"]) ? get_input_show($ttH->post["show_mod"]) : "";
             $col["show_act"] = isset($ttH->post["show_act"]) ? get_input_show($ttH->post["show_act"]) : "";
             $col["show_order"] = 0;
             $col["is_show"] = 1;
             $col["date_create"] = time();
             $col["date_update"] = time();
             $ok = $ttH->db->do_insert("menu", $col);
             if ($ok) {
                 $menu_id = $ttH->db->insertid();
                 $col_l = array();
                 $col_l["menu_id"] = $menu_id;
                 $col_l["title"] = $ttH->post["title"];
                 $col_l["link_type"] = $ttH->post["link_type"];
                 $col_l["link"] = $ttH->post["link"];
                 foreach ($ttH->data["lang"] as $lang_id => $lang_row) {
                     $col_l["lang"] = $lang_row["name"];
                     $ttH->db->do_insert("menu_lang", $col_l);
                 }
                 //update group_nav
                 $col = array();
                 $col["menu_nav"] = get_menu_nav($ttH->post["parent_id"], $menu_id);
                 $col["menu_level"] = substr_count($col['menu_nav'], ',') + 1;
                 $ok = $ttH->db->do_update("menu", $col, " menu_id='" . $menu_id . "'");
                 if ($ok) {
                     built_menu_nav_sub($menu_id, $col["menu_nav"]);
                 }
                 $data = array();
                 $err = $ttH->html->html_alert($ttH->lang["global"]["add_success"], "success");
             } else {
                 $data = $ttH->post;
                 $err = $ttH->html->html_alert($ttH->lang["global"]["add_false"], "error");
             }
         } else {
             $data = $ttH->post;
         }
     }
     $data["err"] = $err;
     $arr_isset = array('group_id', 'parent_id', 'link_type', 'target');
     foreach ($arr_isset as $tmp) {
         $data[$tmp] = isset($data[$tmp]) ? $data[$tmp] : '';
     }
     $data['show_mod'] = isset($data['show_mod']) ? @implode(',', $data['show_mod']) : '';
     $data['name_action'] = $name_action;
     $data['title'] = isset($data['title']) ? $data['title'] : $table_info['title'];
     $data['link'] = isset($data['link']) ? $data['link'] : $table_info['friendly_link'];
     $data["link_action"] = $link_action;
     $data["list_group"] = list_group("group_id", $cur_group, " class=\"form-control\" onchange=\"window.location.href='" . $data["link_action"] . "&group_id='+this.value;\"");
     //$data['group_name'] = $ttH->data["menu_group"][$cur_group];
     $data["list_menu"] = list_menu($cur_group, "parent_id", $data['parent_id'], " class=\"form-control\"", array("title" => $ttH->lang['global']['select_title']));
     $data["list_link_type"] = $ttH->admin->list_link_type("link_type", $data['link_type'], " class=\"form-control\"");
     $data["list_target"] = $ttH->admin->list_target("target", $data['target'], " class=\"form-control\"");
     $data["list_module"] = list_module("show_mod[]", $data['show_mod'], " class=\"form-control\"", array('title' => $ttH->lang["global"]["select_all"]));
     $ttH->temp_act->assign('data', $data);
     $ttH->temp_act->parse($temp);
     return $ttH->temp_act->text($temp);
 }
Example #3
0
 function _add_menu($name_action)
 {
     global $ttH;
     $name_action = $ttH->func->get_friendly_link($name_action);
     $tmp = explode('-', $name_action);
     $add_act = $tmp[1];
     $table = $add_act != 'item' ? $tmp[0] . '_' . $add_act : $tmp[0];
     $table_key = $add_act . '_id';
     $table_id = $tmp[2];
     $input_tmp = $ttH->post['data'];
     foreach ($input_tmp as $key) {
         $input[$key['name']] = $key['value'];
     }
     /*print_arr($input);
     		die('adasd');*/
     $cur_group = isset($input['group_id']) ? $input['group_id'] : 'menu_header';
     $err = '';
     $arr_check = array('group_id');
     foreach ($arr_check as $key) {
         if (empty($err) && (!isset($input[$key]) || empty($input[$key]))) {
             $tmp = isset($ttH->lang[$this->modules][$key]) ? $ttH->lang[$this->modules][$key] : $ttH->lang['global'][$key];
             $err = $ttH->html->html_alert(str_replace('[name]', $tmp, $ttH->lang['global']['err_invalid']), "error");
             break;
         }
     }
     if (empty($err)) {
         $col = array();
         $col["menu_id"] = 0;
         $col["group_id"] = $cur_group;
         $col["parent_id"] = $input["parent_id"];
         $col["name_action"] = $name_action;
         $col["show_order"] = 0;
         $col["is_show"] = 1;
         $col["date_create"] = time();
         $col["date_update"] = time();
         $i = 0;
         $sql = "select * from " . $table . " \n\t\t\t\t\t\t\twhere " . $table_key . "='" . $table_id . "'";
         $result = $ttH->db->query($sql);
         while ($table_row = $ttH->db->fetch_row($result)) {
             $i++;
             $col["title"] = $table_row["title"];
             $col["link"] = $add_act == 'item' ? $table_row["friendly_link"] . '.html' : $table_row["friendly_link"];
             $col["lang"] = $table_row["lang"];
             $ok = $ttH->db->do_insert("menu", $col);
             if ($ok && $col["menu_id"] == 0) {
                 $menu_id = $ttH->db->insertid();
                 $col["menu_id"] = $menu_id;
                 $col_l = array();
                 $col_l["menu_id"] = $menu_id;
                 $ttH->db->do_update("menu", $col_l, " id='" . $menu_id . "'");
                 // update current
             }
         }
         if ($ok) {
             //update group_nav
             $col = array();
             $col["menu_nav"] = get_menu_nav($input["parent_id"], $menu_id);
             $col["menu_level"] = substr_count($col['menu_nav'], ',') + 1;
             $ok = $ttH->db->do_update("menu", $col, " menu_id='" . $menu_id . "'");
             if ($ok) {
                 built_menu_nav_sub($menu_id, $col["menu_nav"]);
             }
         } else {
             $err = $ttH->html->html_alert($ttH->lang["global"]["add_false"], "error");
         }
     }
     return $err;
 }
Example #4
0
 function do_edit()
 {
     global $ttH;
     $err = "";
     $menu_id = $ttH->input["id"];
     if (isset($ttH->post['do_submit'])) {
         /*print_arr($ttH->post);
         		die();*/
         $name_action = $ttH->func->fix_name_action($ttH->post["name_action"]);
         if (empty($err) && empty($ttH->post["title"])) {
             $err = $ttH->html->html_alert($ttH->lang["global"]["err_invalid_title"], "error");
         }
         if (empty($err)) {
             $col = array();
             $col["menu_nav"] = get_menu_nav($ttH->post["parent_id"], $menu_id);
             $col["menu_level"] = substr_count($col['menu_nav'], ',') + 1;
             $col["parent_id"] = $ttH->post["parent_id"];
             $col["name_action"] = $name_action;
             $col["target"] = $ttH->post["target"];
             //$col["picture"] = (isset($ttH->post['picture'])) ? $ttH->func->get_input_pic ($ttH->post['picture']) : '';
             $col["group_id"] = isset($ttH->post['group_id']) ? $ttH->post['group_id'] : '';
             $col["show_mod"] = isset($ttH->post["show_mod"]) ? get_input_show($ttH->post["show_mod"]) : "";
             $col["show_act"] = isset($ttH->post["show_act"]) ? get_input_show($ttH->post["show_act"]) : "";
             $col["date_update"] = time();
             //print_arr($col);die;
             $ok = $ttH->db->do_update("menu", $col, " menu_id='" . $menu_id . "'");
             if ($ok) {
                 $col_l = array();
                 $col_l["title"] = $ttH->post["title"];
                 //$col_l["short"] = $ttH->func->input_editor($ttH->post["short"]);
                 $col_l["link_type"] = $ttH->post["link_type"];
                 $col_l["link"] = $ttH->post["link"];
                 $ttH->db->do_update("menu", $col_l, " menu_id='" . $menu_id . "' and lang='" . $ttH->conf["lang_cur"] . "'");
                 built_menu_nav_sub($menu_id, $col["menu_nav"]);
                 $err = $ttH->html->html_alert($ttH->lang["global"]["edit_success"], "success");
             } else {
                 $err = $ttH->html->html_alert($ttH->lang["global"]["edit_false"], "error");
             }
         }
     }
     $sql = "select * from menu \r\r\n\t\t\t\t\t\twhere lang='" . $ttH->conf['lang_cur'] . "' \r\r\n\t\t\t\t\t\tand menu_id=" . $menu_id;
     $result = $ttH->db->query($sql);
     if ($data = $ttH->db->fetch_row($result)) {
     } else {
         $ttH->html->alert($ttH->lang["global"]["not_found_page"], $ttH->admin->get_link_admin($this->modules, $this->action));
     }
     $data["err"] = $err;
     $data["link_action"] = $ttH->admin->get_link_admin($this->modules, $this->action, $this->sub, array("id" => $menu_id));
     return $this->_form_input($data);
 }