if (isset($_GET['do'])) { switch ($_GET['do']) { case "edit": break; case "add": break; case "delete": break; } } else { if (isset($_POST['new_cat_order']) && is_json($_POST['new_cat_order'])) { $data = object2array(json_decode($_POST['new_cat_order'])); function recurse_update($array, $parent = 0) { global $db; foreach ($array as $pos => $val) { $upd = $db->query(" UPDATE dl_categories \n SET category_parent = '" . $db->real_escape($parent) . "', \n category_sort = '" . $db->real_escape($pos) . "' \n WHERE category_id = '" . $db->real_escape($val['id']) . "'"); if (isset($val['children'])) { recurse_update($val['children'], $val['id']); } } } recurse_update($data); die("ok"); } $categories = CONTENT::get_categories(); // assign data TPL::assign('categories', $categories); // set rander TPL::render('v_categories/categories_list'); }
if (isset($_POST['btn_submit'])) { // filter $page['content_title'] = strip_tags($_POST['page_title']); $page['content_text'] = $_POST['page_content']; $page['content_category'] = $_POST['page_category']; $page['content_slug'] = $_POST['page_slug'] == '' ? slugify($_POST['page_title']) : $_POST['page_slug']; $page['content_visible'] = $_POST['page_visible']; // update content if (CONTENT::set_content($page, $_GET['id']) !== false) { // show success message TPL::message('Continutul a fost actualizat cu succes!', 'success'); } } // assign data TPL::assign("content", CONTENT::get()); TPL::assign('categories', CONTENT::get_categories()); // set render TPL::render('v_pages/page_types/page_text'); }); EVENTS::add_action("before_render", function () { EVENTS::do_action("edit_page_" . CONTENT::get('content_type')); }); break; /* * delete page */ /* * delete page */ case "delete": $page_id = $db->real_escape($_GET['id']);