/** * Gets the parent list list for the parent select dropdown * * Receives by $_POST : * - id_menu : Menu ID * - id_current : Current page ID * - id_parent : Parent page ID * * @returns string HTML string of options items */ public function get_parents_select() { $id_menu = $this->input->post('id_menu'); $id_current = $this->input->post('id_current'); $id_parent = $this->input->post('id_parent'); $element_id = $this->input->post('element_id'); $check_add_page = $this->input->post('check_add_page'); $data = $this->page_model->get_lang_list(array('id_menu' => $id_menu), Settings::get_lang('default')); $parents = array('0' => '/'); ($parents_array = $this->structure->get_parent_select($data, $id_current)) ? $parents += $parents_array : ''; if ($check_add_page) { foreach ($parents as $id_page => $str) { if (Authority::cannot('add_page', 'backend/page/' . $id_page, NULL, TRUE)) { unset($parents[$id_page]); } } } $this->template['pages'] = $parents; $this->template['id_selected'] = $id_parent; $this->template['element_id'] = $element_id; $this->output('page/parent_select'); }
/** * Create one article * @TODO Developp the "existing tags" functionality * * @param string page ID. Article parent. * */ public function create($id_page = NULL) { // Page if (!is_null($id_page)) { $page = $this->page_model->get_by_id($id_page); } else { $id_page = '0'; $page = array('id_menu' => '1'); } // Create blank data for this article $this->article_model->feed_blank_template($this->template); $this->article_model->feed_blank_lang_template($this->template); // Put the page ID to the template $this->template['id_page'] = $id_page; // Tags : Default no one $this->template['tags'] = ''; // All other pages articles $this->template['articles'] = $this->article_model->get_lang_list(array('id_page' => $id_page), Settings::get_lang('default')); // Dropdown menus $data = $this->menu_model->get_select(); $this->template['menus'] = form_dropdown('id_menu', $data, $page['id_menu'], 'id="id_menu" class="select"'); // Menu Info $menu = ''; foreach ($data as $id_page_in_menu => $value) { if ($page['id_menu'] == $id_page_in_menu) { $menu = $value; } } $this->template['menu'] = $menu; // Dropdown parents $data = $this->page_model->get_lang_list(array('id_menu' => $page['id_menu']), Settings::get_lang('default')); $parents = array('0' => lang('ionize_select_no_parent')); ($parents_array = $this->structure->get_parent_select($data)) ? $parents += $parents_array : ''; $this->template['parent_select'] = form_dropdown('id_page', $parents, $id_page, 'id="id_page" class="select"'); // Parent info $breadcrumbs = array(); $b_id_page = $id_page; $level = 1; while ($level > -1) { foreach ($data as $page) { if ($b_id_page == $page['id_page']) { $level = $page['level']; $breadcrumbs[] = $page; $b_id_page = $page['id_parent']; break; } } $level--; } $breadcrumbs = array_reverse($breadcrumbs); $this->template['breadcrumbs'] = $breadcrumbs; // Dropdown articles views $views = array(); if (is_file(APPPATH . '../themes/' . Settings::get('theme') . '/config/views.php')) { require_once APPPATH . '../themes/' . Settings::get('theme') . '/config/views.php'; } $data = isset($views['article']) ? $views['article'] : array(); if (count($data) > 0) { $data = array('0' => lang('ionize_select_default_view')) + $data; $this->template['article_views'] = form_dropdown('view', $data, FALSE, 'class="select w160"'); } // Categories $categories = $this->category_model->get_categories_select(); $this->template['categories'] = form_dropdown('categories[]', $categories, FALSE, 'class="select" multiple="multiple"'); // Article types $types = $this->article_type_model->get_types_select(); $this->template['article_types'] = form_dropdown('id_type', $types, FALSE, 'class="select"'); // Extends fields $extend_fields = $this->extend_field_model->get_element_extend_fields('article'); $this->template['has_translated_extend_fields'] = $this->_has_translated_extend_fields($extend_fields); $this->template['extend_fields'] = $extend_fields; // Context data initialized when article creation $this->template['online'] = '0'; $this->template['main_parent'] = '1'; $this->template['has_url'] = '1'; $this->output('article/article'); }
function index() { // Articles $articles = $this->article_model->get_lang_list(array('order_by' => 'updated DESC'), Settings::get_lang('default')); // Last 10 articles $last_articles = array(); $max = count($articles) > 9 ? 10 : count($articles); $count = 0; if (!empty($articles)) { foreach ($articles as $article) { if (Authority::can('access', 'backend/menu/' . $article['id_menu'], NULL, TRUE) && Authority::can('access', 'backend/page/' . $article['id_page'], NULL, TRUE) && Authority::can('access', 'backend/article/' . $article['id_article'], NULL, TRUE)) { $last_articles[] = $article; $count++; if ($count == $max) { break; } } } } // Orphan articles $orphan_articles = array(); foreach ($articles as $article) { if (!$article['id_page']) { $orphan_articles[] = $article; } } // Orphan pages $orphan_pages = $this->page_model->get_lang_list(array('id_menu' => '0', 'order_by' => 'name ASC'), Settings::get_lang('default')); // Last connected /registered users $logged_user_role = User()->get_role(); $users = $this->user_model->get_list_with_role(array('limit' => '10', 'order_by' => 'last_visit DESC', 'last_visit <>' => '')); $last_registered_users = $this->user_model->get_list_with_role(array('limit' => '10', 'order_by' => 'join_date DESC')); // Updates on last articles foreach ($last_articles as &$article) { // User name update foreach ($users as $user) { if ($user['username'] == $article['updater']) { $article['updater'] = $user['screen_name']; } if ($user['username'] == $article['author']) { $article['author'] = $user['screen_name']; } } $pages = $this->page_model->get_parent_array($article['id_page'], array(), Settings::get_lang('default')); $breadcrumb = array(); foreach ($pages as $page) { $breadcrumb[] = !empty($page['title']) ? $page['title'] : $page['name']; } $article['breadcrumb'] = implode(' > ', $breadcrumb); } // Updates on orphan pages foreach ($orphan_pages as &$page) { // User name update foreach ($users as $user) { if ($user['username'] == $page['updater']) { $page['updater'] = $user['screen_name']; } if ($user['username'] == $page['author']) { $page['author'] = $user['screen_name']; } } } // Updates on orphan articles foreach ($orphan_articles as &$article) { // User name update foreach ($users as $user) { if ($user['username'] == $article['updater']) { $article['updater'] = $user['screen_name']; } if ($user['username'] == $article['author']) { $article['author'] = $user['screen_name']; } } } // Flags $settings = Settings::get_settings(); $flags = array(); foreach ($settings as $key => $setting) { if (strpos($key, 'flag') !== FALSE && $setting != '') { $flags[substr($key, -1)] = $setting; } } // Put installed module list to template $installed_modules = Modules()->get_installed_modules(); $modules = array(); foreach ($installed_modules as $module) { if ($module['has_admin'] && Authority::can('access', 'module/' . $module['key'])) { $modules[] = $module; } } $this->template['modules'] = $modules; $this->template['flags'] = $flags; $this->template['last_articles'] = $last_articles; $this->template['orphan_pages'] = $orphan_pages; $this->template['orphan_articles'] = $orphan_articles; $this->template['users'] = $users; $this->template['last_registered_users'] = $last_registered_users; $this->output('desktop/dashboard'); }