public function reorder_articles() { $id_page = $this->input->post('id_page'); $direction = $this->input->post('direction'); if ($direction && $id_page) { // Clear the cache Cache()->clear_cache(); $articles = $this->article_model->get_lang_list(array('id_page' => $id_page), Settings::get_lang('default')); $keyDate = array(); foreach ($articles as $key => $article) { $keyDate[$key] = strtotime($article['date']); } $sort_direction = 'SORT_' . $direction; // Sort the results by realm occurrences DESC first, by date DESC second. array_multisort($keyDate, constant($sort_direction), $articles); $ids = array(); foreach ($articles as $idx => $article) { $this->page_model->update(array('id_page' => $id_page, 'id_article' => $article['id_article']), array('ordering' => $idx + 1), 'page_article'); $ids[] = $article['id_article']; } $this->callback = array(array('fn' => 'ION.HTML', 'args' => array('article/get_list', array('id_page' => $id_page), array('update' => 'articleListContainer'))), array('fn' => 'ION.notification', 'args' => array('success', lang('ionize_message_articles_ordered'))), array('fn' => 'ION.updateArticleOrder', 'args' => array('id_page' => $id_page, 'order' => implode(',', $ids)))); $this->response(); } }
/** * Gets the article list for the ordering select dropdown * * @param int $id_page * @returns string HTML string of options items */ public function get_ordering_article_select($id_page) { // Articles array $this->template['articles'] = $this->article_model->get_lang_list(array('id_page' => $id_page), Settings::get_lang('default')); $this->output('article/ordering_select'); }
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'); }