/** * Checks if all articles which have one page context have the page as "Main Parent" * End of check. * */ public function check_article_context() { $result = array('title' => lang('ionize_title_check_article_context'), 'status' => 'success'); $nb_orphan_articles = $this->system_check_model->check_article_context(); // Correct if ($nb_orphan_articles > 0) { $result['message'] = lang('ionize_message_check_corrected'); } else { $result['message'] = lang('ionize_message_check_ok'); } $this->xhr_output($result); }
/** * Saves a page * */ public function save() { /* Check if the default lang URL or the default lang title are set * One of these need to be set to save the page * */ if ($this->_check_before_save() === TRUE) { $id_page = $this->input->post('id_page'); // Clear the cache Cache()->clear_cache(); // Prepare data before save $this->_prepare_data(); // Event : On before save $event_data = array('base' => $this->data, 'lang' => $this->lang_data, 'post' => $this->input->post()); $event_received = Event::fire('Page.save.before', $event_data); $event_received = array_pop($event_received); if (!empty($event_received['base']) && !empty($event_received['lang'])) { $this->data = $event_received['base']; $this->lang_data = $event_received['lang']; } // Save Page $saved_id = $this->page_model->save($this->data, $this->lang_data); // Correct Pages levels // TODO : Move this into the model. if (!empty($id_page)) { // Correct pages levels regarding parents. $this->system_check_model->check_page_level(TRUE); } // Save extends fields data $this->extend_field_model->save_data('page', $saved_id, $_POST); // Save linked access groups authorizations // $this->base_model->join_items_keys_to('user_groups', $this->input->post('groups'), 'page', $this->id); // Save the Sitemap $this->structure->build_sitemap(); // Prepare the Json answer $page = array_merge($this->lang_data[Settings::get_lang('default')], $this->page_model->get_by_id($saved_id)); $page['menu'] = $this->menu_model->get(array('id_menu' => $page['id_menu'])); // Remove HTML tags from returned array strip_html($page); $this->callback = array(); // Event : On after save $event_data = array('base' => $this->data, 'lang' => $this->lang_data, 'post' => $this->input->post()); Event::fire('Page.save.success', $event_data); // New page : Simply reloads the panel if (empty($id_page)) { // Save the Urls $this->page_model->save_urls($saved_id); // Used by JS Tree to detect if page in inserted in tree or not $page['inserted'] = TRUE; $this->callback[] = array('fn' => $page['menu']['name'] . 'Tree.insertElement', 'args' => array($page, 'page')); // Reload the panel $this->_reload_panel($saved_id); $this->success(lang('ionize_message_page_saved')); } else { // Save options : as callback $this->callback[] = array('fn' => 'ION.sendForm', 'args' => array('page/save_options', 'pageOptionsForm')); $this->response(); } } else { Event::fire('Page.save.error'); $this->error(lang('ionize_message_page_needs_url_or_title')); } }