/** * Serves the tree browser * */ public function browser() { // Menus : All menus $menus = $this->menu_model->get_list(array('order_by' => 'ordering ASC')); $this->template['menus'] = $menus; $this->output('tree/browser'); }
/** * When called, reloads the Page Edition panel * * @param int $id_page */ protected function _reload_panel($id_page) { $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default')); $page['menu'] = $this->menu_model->get($page['id_menu']); $title = empty($page['title']) ? $page['name'] : $page['title']; $this->callback[] = array('fn' => 'ION.splitPanel', 'args' => array('urlMain' => admin_url(TRUE) . 'page/edit/' . $id_page, 'urlOptions' => admin_url(TRUE) . 'page/get_options/' . $id_page, 'title' => lang('ionize_title_edit_page') . ' : ' . $title)); $this->callback[] = array('fn' => $page['menu']['name'] . 'Tree.updateElement', 'args' => array($page, 'page')); }
function get_menu($filter) { $permisos = new Permiso_model(); $menu = $permisos->listar($filter); $filamenu = ""; if (count($menu) > 0) { foreach ($menu as $indice => $value) { if ($value->MENU_Codigo_Padre == 1) { $filamenu .= "<li>"; $filamenu .= "<a href='#'>" . $value->MENU_Descripcion . "</a>"; $filamenu .= "<ul>"; foreach ($menu as $indice2 => $value2) { if ($value2->MENU_Codigo_Padre == $value->MENU_Codigo) { $filamenu .= "<li>"; $filamenu .= "<a href='" . ($value2->MENU_Url != "#" ? base_url() . $value2->MENU_Url : "#") . "'>" . $value2->MENU_Descripcion . "</a>"; $submenu = ""; foreach ($menu as $item3 => $value3) { if ($value3->MENU_Codigo_Padre == $value2->MENU_Codigo) { $submenu .= "<li><a href='" . ($value3->MENU_Url != "#" ? base_url() . $value3->MENU_Url : "#") . "'>" . $value3->MENU_Descripcion . "</a></li>"; } } if ($submenu != "") { $filamenu .= "<ul>" . $submenu . "</ul>"; } $filamenu .= "</li>"; } } $filamenu .= "</ul>"; $filamenu .= "</li>"; } } } else { $permisos = new Menu_model(); $filter = new stdClass(); $filter->codigo = 1; $menu = $permisos->listar($filter); foreach ($menu as $indice => $value) { $filamenu .= "<li>"; $filamenu .= "<a href='#'>" . $value->MENU_Descripcion . "</a>"; $filamenu .= "</li>"; } } return $filamenu; }
/** * Delete a menu * * @param string menu ID * */ public function delete($id) { $affected_rows = $this->menu_model->delete($id); if ($affected_rows > 0) { $this->_update_panels(); // Answer send $this->success(lang('ionize_message_menu_deleted')); } else { // Answer send $this->error(lang('ionize_message_menu_not_deleted')); } }
/** * Show pages * As default display public area pages * Display all child pages of a given page * If the page is the home of the area, then you also view the home * * @param integer $id_area Area ID * @param string $lang language code * @param string $xfrom page URL of origin * @return void */ public function index($id_area, $lang = '', $xfrom = 'home') { $area = new Area_model(); list($id_area, $areas) = $area->get_my_areas($id_area); // initialize parameters $lang = empty($lang) ? X4Route_core::$lang : $lang; $xfrom = str_replace('§', '/', urldecode($xfrom)); // load dictionary $this->dict->get_wordarray(array('pages')); $view = new X4View_core('container'); // content $view->content = new X4View_core('pages/pages'); //$view->page = $this->get_page('pages'); // content $mod = new Page_model($id_area, $lang); $view->content->id_area = $id_area; $view->content->lang = $lang; $view->content->xfrom = $xfrom; $view->content->area = $mod->get_var($id_area, 'areas', 'name'); $obj = $mod->get_page($xfrom); $view->content->page = $obj ? $obj : new Page_obj($id_area, $lang); $page = $this->get_page('pages'); $navbar = array($this->site->get_bredcrumb($page), array('areas' => 'index')); $view->content->navbar = $navbar; // referer $view->content->referer = urlencode('pages/index/' . $id_area . '/' . $lang . '/' . $xfrom); // pages to show $view->content->pages = $mod->get_pages($xfrom, $view->content->page->deep); // available menus $mod = new Menu_model(); $view->content->menus = $mod->get_menus($id_area, '', 'id'); // language switcher $lang = new Language_model(); $view->content->langs = $lang->get_languages(); // area switcher $view->content->areas = $areas; $view->render(TRUE); }
/** * Reloads the Edition panel * * @param int $id_page * @param int $id_article */ protected function _reload_panel($id_page, $id_article) { $page = $this->page_model->get_by_id($id_page); $id_menu = array_key_exists('id_menu', $page) ? (int) $page['id_menu'] : 0; $page['menu'] = $this->menu_model->get($id_menu); // Main data $article = $this->article_model->get_by_id($id_article); $article_lang = $this->article_model->get_by_id($id_article, Settings::get_lang('default')); $title = empty($article_lang['title']) ? $article_lang['name'] : $article_lang['title']; // Correcting some lang data $article_lang['online'] = $article['online']; $this->callback[] = array('fn' => 'ION.splitPanel', 'args' => array('urlMain' => admin_url(TRUE) . 'article/edit/' . $id_page . '.' . $id_article, 'urlOptions' => admin_url(TRUE) . 'article/get_options/' . $id_page . '.' . $id_article, 'title' => lang('ionize_title_edit_article') . ' : ' . $title)); $this->callback[] = array('fn' => array_key_exists('name', $page['menu']) ? $page['menu']['name'] . 'Tree.updateElement' : '', 'args' => array($article_lang, 'article')); }
public function salvar_ordem() { $iditem = $this->input->post('iditem'); $i = 1; foreach ($iditem as $id) { $menu_model = new Menu_model(); $menu_model->setId($id); $menu_model->ordem = $i++; $menu_model->set_fields_update_only(array('ordem')); if (!$menu_model->salvar(FALSE)) { $this->session->set_flashdata('alerta', 'error_save'); redirect($this->control_url . '/busca'); } } $this->session->set_flashdata('alerta', 'success_save'); redirect($this->control_url . '/busca'); }
/** * Install a plugin * * @param integer $id_area Area ID * @param string $plugin_name Plugin name * @return void */ public function install($id_area, $plugin_name) { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_module_install', 0, 4); if (is_null($msg)) { $qs = X4Route_core::get_query_string(); // load global dictionary $this->dict->get_words(); // install the plugin $mod = new X4Plugin_model(); $result = $mod->install($id_area, $plugin_name); // the result is an array only if an error occurred if (is_array($result) && !empty($result)) { // build msg $str = array(); foreach ($result as $i) { $str[] = $i['label'] . _TRAIT_ . $this->dict->get_word(strtoupper($i['error'][0]), 'msg'); } $msg = AdmUtils_helper::set_msg(false, '', implode('<br />', $str)); } else { // set message $msg = AdmUtils_helper::set_msg(true); // installed if ($result) { $area = $mod->get_by_id($id_area, 'areas', 'name'); // add permission $mod = new Permission_model(); $array[] = array('action' => 'insert', 'id_what' => $result, 'id_user' => $_SESSION['xuid'], 'level' => 4); $result = $mod->pexec('modules', $array, $id_area); // refresh deep, xpos and ordinal $mod = new Menu_model(); $mod->ordinal(1, X4Route_core::$lang, 'modules', 'A0021005'); $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'modules/index/' . $id_area . '/' . $area->name, 'title' => null); } } } $this->response($msg); }
public function drpdwn_menu($object, $selected_id = 0, $drpdwn_name, $are_disabled = '') { $drpdwn = "<select class='input_pr' name='{$drpdwn_name}' id='{$drpdwn_name}' {$are_disabled}>"; $drpdwn = $drpdwn . "<option value='0'></option>"; $menu_model = new Menu_model(); $arr = $menu_model->get_all($object->table, $selected_id); foreach ($arr as $record) { $are_selected = ""; if ($selected_id == $record->id) { $are_selected = "selected='selected'"; } if ($object->lang->lang() == 'ar') { $title = $record->title_ar; } else { $title = $record->title; } $drpdwn = $drpdwn . "<option value='" . $record->id . "' {$are_selected}>{$title}</option>"; } $drpdwn = $drpdwn . "</select>"; echo $drpdwn; }
/** * Refresh menu order * Called via Ajax * * @param integer $id Page ID * @param integer $holder Menu ID * @param string $orders Encoded string, for each menu you have a section, each section contains the list of Page ID in menu * @return void */ public function menu($id, $holder, $orders) { $msg = null; if (!is_null($id) && is_numeric($id)) { // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'pages', $id, 3); if (is_null($msg)) { // refresh order $menu = new Menu_model(); $result = $menu->menu($id, substr($holder, 1), $orders); // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg($result); } } $this->response($msg); }
/** * Register Edit / New Area form data * * @access private * @param integer $id item ID (if 0 then is a new item) * @param array $_post _POST array * @return void */ private function editing($id, $_post) { $msg = null; // check permissions $msg = $id ? AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'areas', $id, 2) : AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_area_creation', 0, 4); if (is_null($msg)) { // handle _post $post = array('lang' => $_post['lang'], 'name' => X4Utils_helper::unspace($_post['name']), 'title' => $_post['title'], 'description' => $_post['description'], 'id_theme' => $_post['id_theme'], 'private' => intval(isset($_post['private'])) && $_post['private'], 'folder' => $_post['folder']); $mod = new Area_model(); // check if area name already exists $check = (bool) $mod->exists($post['name'], $id); if ($check) { $msg = AdmUtils_helper::set_msg(false, '', $this->dict->get_word('_AREA_ALREADY_EXISTS', 'msg')); } else { // Redirect checker $redirect = false; // enable logs if (LOGS && DEVEL) { $mod->set_log(true); } // update or insert if ($id) { $result = $mod->update($id, $post); if ($id == 1 && X4Route_core::$lang != $post['lang']) { $redirect = true; } } else { $result = $mod->insert($post); // create permissions if ($result[1]) { $id = $result[0]; $perm = new Permission_model(); // aprivs permissions $domain = X4Utils_helper::obj2array($perm->get_aprivs($_SESSION['xuid']), null, 'id_area'); $domain[] = $result[0]; $res = $perm->set_aprivs($_SESSION['xuid'], $domain); // privs permissions $array[] = array('action' => 'insert', 'id_what' => $id, 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('areas', $array, $id); } } if ($result[1]) { // refresh languages related to area $lang = new Language_model(); $lang->set_alang($id, $_post['languages'], $_post['lang']); // update theme settings if ($_post['id'] && $_post['id_theme'] != $_post['old_id_theme']) { $menu = new Menu_model(); // reset tpl, css, id_menu, ordinal $result = $menu->reset($_post['id']); $langs = $lang->get_languages(); // restore ordinal foreach ($langs as $i) { $menu->ordinal($_post['id'], $i->code, 'home', 'A'); } } if (APC) { apc_clear_cache(); apc_clear_cache('user'); apc_clear_cache('opcode'); } } // set message $msg = AdmUtils_helper::set_msg($result); // set what update if ($result[1]) { if ($redirect) { X4Route_core::redirect($this->site->site->domain . '/admin'); } else { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'areas', 'title' => null); } } } } $this->response($msg); }