Example #1
0
function built_group_nav_sub($group_id, $group_nav = '')
{
    global $ttH;
    //update project
    $col_up = array();
    $col_up["group_nav"] = $group_nav;
    $ttH->db->do_update("project", $col_up, " group_id='" . $group_id . "'");
    //End
    $query = "select group_id \r\r\n\t\t\t\t\t\tfrom project_group   \r\r\n\t\t\t\t\t\twhere parent_id='" . $group_id . "' ";
    //echo $query;
    $result = $ttH->db->query($query);
    while ($row = $ttH->db->fetch_row($result)) {
        $col = array();
        $col["group_nav"] = $group_nav;
        $col["group_nav"] .= !empty($col["group_nav"]) ? ',' : '';
        $col["group_nav"] .= $row['group_id'];
        $col["group_level"] = substr_count($col['group_nav'], ',') + 1;
        $ok = $ttH->db->do_update("project_group", $col, " group_id='" . $row['group_id'] . "'");
        if ($ok) {
            //update project
            $col_up = array();
            $col_up["group_nav"] = $col["group_nav"];
            $ttH->db->do_update("project", $col_up, " group_id='" . $row['group_id'] . "'");
            //End
            built_group_nav_sub($row['group_id'], $col["group_nav"]);
        }
    }
    return '';
}
Example #2
0
 function do_edit()
 {
     global $ttH;
     $err = "";
     $group_id = $ttH->input["id"];
     if (isset($ttH->post['do_submit'])) {
         /*print_arr($ttH->post);
         		die();*/
         $parent_id = isset($ttH->post["parent_id"]) ? (double) $ttH->post["parent_id"] : 0;
         if (empty($ttH->post["title"])) {
             $err = $ttH->html->html_alert($ttH->lang["global"]["err_invalid_title"], "error");
         }
         if (empty($err)) {
             $col = array();
             $col["group_nav"] = get_group_nav($parent_id, $group_id);
             $col["group_level"] = substr_count($col['group_nav'], ',') + 1;
             $col["parent_id"] = $parent_id;
             foreach ($this->arr_picture as $k => $v) {
                 $col[$k] = isset($ttH->post[$k]) ? $ttH->func->get_input_pic($ttH->post[$k]) : '';
             }
             foreach ($this->arr_select as $k => $v) {
                 if (isset($v['muti']) && $v['muti'] == true) {
                     $col[$k] = isset($ttH->post[$k]) ? implode(',', $ttH->post[$k]) : '';
                 } else {
                     $col[$k] = isset($ttH->post[$k]) ? $ttH->post[$k] : '';
                 }
             }
             foreach ($this->arr_checkbox as $k => $v) {
                 if (isset($v['muti']) && $v['muti'] == true) {
                     $col[$k] = isset($ttH->post[$k]) ? implode(',', $ttH->post[$k]) : '';
                 } else {
                     $col[$k] = isset($ttH->post[$k]) ? $ttH->post[$k] : '';
                 }
             }
             $col["date_update"] = time();
             $ok = $ttH->db->do_update($this->modules . "_group", $col, " group_id='" . $group_id . "'");
             if ($ok) {
                 $col_l = array();
                 $col_l["title"] = $ttH->post["title"];
                 foreach ($this->arr_editor as $k => $v) {
                     $col_l[$k] = $ttH->func->input_editor($ttH->post[$k]);
                 }
                 $friendly_link = $ttH->post["friendly_link"] ? $ttH->post["friendly_link"] : $ttH->post["title"];
                 $col_l["friendly_link"] = $ttH->func->get_friendly_link_db($friendly_link, $this->modules . '_group_lang', 'group_id', $group_id, $ttH->conf['lang_cur']);
                 $col_l["meta_title"] = $ttH->post["meta_title"] ? $ttH->post["meta_title"] : $ttH->func->meta_title($ttH->post["title"]);
                 $col_l["meta_key"] = $ttH->post["meta_key"] ? $ttH->post["meta_key"] : $ttH->func->meta_key($ttH->post["title"]);
                 $col_l["meta_desc"] = $ttH->post["meta_desc"] ? $ttH->func->meta_desc($ttH->post["meta_desc"]) : $ttH->func->meta_desc(isset($ttH->post["content"]) ? $ttH->post["content"] : '');
                 $ttH->db->do_update($this->modules . "_group_lang", $col_l, " group_id='" . $group_id . "' and lang='" . $ttH->conf["lang_cur"] . "'");
                 //Update menu link
                 $this->func->update_menu_link($this->modules . "-group-" . $group_id, $col_l);
                 //End
                 built_group_nav_sub($group_id, $col["group_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 " . $this->modules . "_group a, " . $this->modules . "_group_lang al \n\t\t\t\t\t\twhere a.group_id=al.group_id \n\t\t\t\t\t\tand lang='" . $ttH->conf['lang_cur'] . "' \n\t\t\t\t\t\tand a.group_id=" . $group_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" => $group_id));
     return $this->_form_input($data);
 }
Example #3
0
 function do_edit()
 {
     global $ttH;
     $err = "";
     $item_id = $ttH->input["id"];
     if (isset($ttH->post['do_submit'])) {
         /*print_arr($ttH->post);
         		die();*/
         foreach ($this->arr_element as $k => $v) {
             if ($err) {
                 break;
             }
             $required = isset($v['required']) ? $v['required'] : false;
             if ($required === false) {
                 continue;
             }
             $err = $this->func->_required($k, $v);
         }
         if (empty($err)) {
             $col = array();
             $col["parent_id"] = isset($ttH->post['parent_id']) ? $ttH->post['parent_id'] : 0;
             $col["group_nav"] = $this->func->get_group_nav($col["parent_id"], $item_id, 'group');
             $col["group_level"] = substr_count($col['group_nav'], ',') + 1;
             foreach ($this->arr_element as $k => $v) {
                 $of_lang = isset($v['of_lang']) ? true : false;
                 if ($of_lang == true) {
                     continue;
                 }
                 if ($k == 'lang') {
                     continue;
                 }
                 if (isset($v['only']) && $v['only'] != $this->sub) {
                     continue;
                 }
                 $col[$k] = $this->func->_inputdb($k, $v);
             }
             /*print_arr($ttH->post);
             		print_arr($col);
             		die();*/
             $ok = $ttH->db->do_update($this->dbtable, $col, " " . $this->dbtable_id . "='" . $item_id . "'");
             if ($ok) {
                 $col_l = array();
                 foreach ($this->arr_element as $k => $v) {
                     $of_lang = isset($v['of_lang']) ? true : false;
                     if ($of_lang == false) {
                         continue;
                     }
                     if ($k == 'lang') {
                         continue;
                     }
                     $col_l[$k] = $this->func->_inputdb($k, $v);
                 }
                 $friendly_link = $ttH->post["friendly_link"] ? $ttH->post["friendly_link"] : $ttH->post["title"];
                 $col_l["friendly_link"] = $ttH->func->get_friendly_link_db($friendly_link, $this->dbtable, $this->dbtable_id, $item_id, $ttH->conf['lang_cur']);
                 $col_l["meta_title"] = $ttH->post["meta_title"] ? $ttH->post["meta_title"] : $ttH->func->meta_title($ttH->post["title"]);
                 $col_l["meta_key"] = $ttH->post["meta_key"] ? $ttH->post["meta_key"] : $ttH->func->meta_key($ttH->post["title"]);
                 $col_l["meta_desc"] = $ttH->post["meta_desc"] ? $ttH->func->meta_desc($ttH->post["meta_desc"]) : $ttH->func->meta_desc(isset($ttH->post["content"]) ? $ttH->post["content"] : '');
                 $ttH->db->do_update($this->dbtable, $col_l, " " . $this->dbtable_id . "='" . $item_id . "' and lang='" . $ttH->conf["lang_cur"] . "'");
                 //Update menu link
                 $this->func->update_menu_link($this->modules . "-group-" . $item_id, $col_l);
                 //End
                 built_group_nav_sub($item_id, $col["group_nav"]);
                 $err = $ttH->html->html_alert($ttH->lang["global"]["edit_success"], "success");
             } else {
                 $err = $ttH->html->html_alert($ttH->lang["global"]["edit_false"], "error");
             }
         }
     }
     $where = '';
     if (array_key_exists('lang', $this->arr_element)) {
         $where .= " and lang='" . $ttH->conf['lang_cur'] . "' ";
     }
     $sql = "select * from " . $this->dbtable . " \r\r\n\t\t\t\t\t\twhere " . $this->dbtable_id . "='" . $item_id . "' \r\r\n\t\t\t\t\t\t" . $where;
     $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" => $item_id));
     return $this->func->_form_input($data);
 }
Example #4
0
 function do_edit()
 {
     global $ttH;
     $err = "";
     $group_id = $ttH->input["id"];
     if (isset($ttH->post['do_submit'])) {
         /*print_arr($ttH->post);
         		die();*/
         $parent_id = isset($ttH->post["parent_id"]) ? (double) $ttH->post["parent_id"] : 0;
         if (empty($ttH->post["title"])) {
             $err = $ttH->html->html_alert($ttH->lang["global"]["err_invalid_title"], "error");
         }
         if (empty($err)) {
             $col = array();
             $col["group_nav"] = get_group_nav($parent_id, $group_id);
             $col["group_level"] = substr_count($col['group_nav'], ',') + 1;
             $col["parent_id"] = $parent_id;
             $col["picture"] = $ttH->func->get_input_pic($ttH->post["picture"]);
             $col["group_related"] = isset($ttH->post["group_related"]) ? implode(',', $ttH->post["group_related"]) : '';
             $col["pic_show"] = isset($ttH->post["pic_show"]) ? $ttH->post["pic_show"] : 'slide';
             $col["type_show"] = isset($ttH->post["type_show"]) ? $ttH->post["type_show"] : 'list_item';
             $col["num_show"] = isset($ttH->post["num_show"]) ? $ttH->post["num_show"] : 0;
             $col["date_update"] = time();
             $ok = $ttH->db->do_update("page_group", $col, " group_id='" . $group_id . "'");
             if ($ok) {
                 $col_l = array();
                 $col_l["title"] = $ttH->post["title"];
                 $col_l["short"] = $ttH->func->input_editor($ttH->post["short"]);
                 $col_l["content"] = $ttH->func->input_editor($ttH->post["content"]);
                 $friendly_link = $ttH->post["friendly_link"] ? $ttH->post["friendly_link"] : $ttH->post["title"];
                 $col_l["friendly_link"] = $ttH->func->get_friendly_link_db($friendly_link, 'page_group_lang', 'group_id', $group_id, $ttH->conf['lang_cur']);
                 $col_l["meta_title"] = $ttH->post["meta_title"] ? $ttH->post["meta_title"] : $ttH->func->meta_title($ttH->post["title"]);
                 $col_l["meta_key"] = $ttH->post["meta_key"] ? $ttH->post["meta_key"] : $ttH->func->meta_key($ttH->post["title"]);
                 $col_l["meta_desc"] = $ttH->post["meta_desc"] ? $ttH->func->meta_desc($ttH->post["meta_desc"]) : $ttH->func->meta_desc($ttH->post["content"]);
                 $ttH->db->do_update("page_group_lang", $col_l, " group_id='" . $group_id . "' and lang='" . $ttH->conf["lang_cur"] . "'");
                 built_group_nav_sub($group_id, $col["group_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 page_group a, page_group_lang al \r\r\n\t\t\t\t\t\twhere a.group_id=al.group_id \r\r\n\t\t\t\t\t\tand lang='" . $ttH->conf['lang_cur'] . "' \r\r\n\t\t\t\t\t\tand a.group_id=" . $group_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" => $group_id));
     $data["list_group"] = list_group("parent_id", $data['parent_id'], " class=\"form-control\"", array("title" => $ttH->lang['global']['select_title'], 'disabled' => $data["group_id"]));
     $data['picture'] = $ttH->admin->get_form_pic('picture', $data['picture'], $this->folder_upload, $this->dir);
     $data["html_short"] = $ttH->editor->load_editor("short", "short", $data['short'], "", "mini", array("folder_up" => $this->folder_upload, "fldr" => $this->dir));
     $data["html_content"] = $ttH->editor->load_editor("content", "content", $data['content'], "", "full", array("folder_up" => $this->folder_upload, "fldr" => $this->dir));
     $data["group_related"] = is_array($data["group_related"]) ? $data["group_related"] : explode(',', $data["group_related"]);
     //$data["list_group_related"] = list_group ("group_related[]", $data["group_related"], " class=\"form-control\"", array('select_muti' => 1));
     $data["list_pic_show"] = list_pic_show("pic_show", $data["pic_show"], " class=\"form-control\"");
     $data["list_type_show"] = list_type_show("type_show", $data["type_show"], " class=\"form-control\"");
     $data["list_num_show"] = $ttH->admin->list_number("num_show", 1, 50, $data['num_show'], " class=\"form-control\"", array('title' => 'Tự động ---'));
     $ttH->temp_act->assign('data', $data);
     $ttH->temp_act->parse("edit");
     return $ttH->temp_act->text("edit");
 }