/** * Returns JSON object of one entity * */ public function get_entity() { // Contains ether a page dot article string, ether one page or article ID $rel = $this->input->post('rel'); $type = $this->input->post('type'); $rel = explode('.', $rel); $id_article = !empty($rel[1]) ? $rel[1] : NULL; $id_page = $rel[0]; // returned entity array $entity = array(); $page = array(); switch ($type) { case 'article': if ($id_article) { // Get article $article = $this->article_model->get(array('id_page' => $id_page, 'id_article' => $id_article), Settings::get_lang('default')); // Get the corresponding page if (!empty($article)) { $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default')); } if (!empty($article) && !empty($page)) { $entity = array('page' => $page, 'article' => $article); } } break; case 'page': $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default')); $entity = array('page' => $page); break; } $this->response($entity); }
/** * Checks views of both pages and articles * */ public function check_views() { $nb = 0; $result = array('title' => lang('ionize_title_check_views'), 'status' => 'success'); $views_folder = FCPATH . 'themes/' . Settings::get('theme') . '/views/'; // Check and correct page's views $pages = $this->page_model->get_list(); foreach ($pages as $page) { if (!empty($page['view']) && !is_file($views_folder . $page['view'] . EXT)) { $this->db->set('view', ''); $this->db->where('id_page', $page['id_page']); $nb += $this->db->update('page'); } } // Check and correct article's views $article_contexts = $this->article_model->get_all_context(); foreach ($article_contexts as $context) { if (!empty($context['view']) && !is_file($views_folder . $page['view'] . EXT)) { $this->db->set('view', ''); $this->db->where(array('id_page' => $context['id_page'], 'id_article' => $context['id_article'])); $nb += $this->db->update('page_article'); } } // Correct if ($nb > 0) { $result['message'] = lang('ionize_message_check_corrected'); } else { $result['message'] = lang('ionize_message_check_ok'); } // Result view $view = $this->load->view('system/check_result', $result, TRUE); $this->callback = array(array('fn' => 'ION.appendDomElement', 'args' => array('system_check_report', $view)), array('fn' => 'ION.notification', 'args' => array('success', 'Check complete !'))); $this->response(); }
/** * 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); $page['menu'] = $this->menu_model->get($page['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' => $page['menu']['name'] . 'Tree.updateElement', 'args' => array($article_lang, 'article')); }
public function __construct() { parent::__construct(); $this->page_break_separator = "/<div(\\s)*style(\\s)*=(\\s)*\"page-break-after(\\s)*:(\\s)*always(;)*\"(\\s)*>(\\s)*<span(\\s)*style(\\s)*=(\\s)*\"display(\\s)*:(\\s)*none(;)*\">(\\s)* (\\s)*<\\/span>(\\s)*<\\/div>/i"; if (self::$__article_properties == NULL) { self::$__article_properties = array(); } $default_properties = array('is_article_cached' => FALSE, 'is_category_cached' => FALSE, 'is_category_article_cached' => FALSE, 'articles' => array(), 'categories' => array(), 'article_categories' => array(), 'photos' => array()); foreach ($default_properties as $key => $val) { if (!array_key_exists($key, self::$__article_properties)) { self::$__article_properties[$key] = $default_properties[$key]; } } }
/** * Returns the element definition list * Used to admin elements (elements_definition_list and element_definition views) * * XHR call * */ function get_element_definition_list() { $elements = $this->element_definition_model->get_lang_list(array('order_by' => 'ordering ASC'), Settings::get_lang('default')); $elements_lang = $this->element_definition_model->get_all('element_definition_lang'); // Elements foreach ($elements as &$element) { $element['languages'] = array(); // Translated elements. foreach (Settings::get_languages() as $lang) { $element['languages'][$lang['lang']] = array('title' => ''); foreach ($elements_lang as $ld) { if ($ld['id_element_definition'] == $element['id_element_definition'] && $ld['lang'] == $lang['lang']) { $element['languages'][$lang['lang']] = $ld; } } } // Element's fields $element['fields'] = $this->extend_field_model->get_list(array('parent' => 'element', 'id_parent' => $element['id_element_definition']), Settings::get_lang('default')); // Element usages on pages, articles $query = $this->db->where('id_element_definition = ' . $element['id_element_definition'])->from('element')->get(); $usages = $query->result_array(); foreach ($usages as $index => $usageElement) { if ($usageElement['parent'] === 'page') { // get page: parent page of element $usages[$index]['page'] = $this->page_model->get_by_id($usageElement['id_parent']); $usages[$index]['article'] = null; } else { // get page: parent page of article which is parent of element $usages[$index]['article'] = $this->article_model->get_by_id($usageElement['id_parent']); $usages[$index]['page'] = $this->page_model->get_by_id($usages[$index]['article']['id_page']); } } $element['usages'] = $usages; } $this->template['elements'] = $elements; $this->output('element/definition/list'); }
/** * Adds a link to a page * * Receives : * $_POST['link_type'] : type of the link * $_POST['link_rel'] : REL to the link (can be a page or an article) * $_POST['receiver_rel'] : REL of the receiver's article * $_POST['url'] : URL of the external link * */ public function add_link() { // Clear the cache Cache()->clear_cache(); // Sent by ION.dropElementAsLink() or ION.addExternalLink() $id_page = $this->input->post('receiver_rel'); $link_type = $this->input->post('link_type'); $link_id = $this->input->post('link_rel'); // Link name (default lang title, for display) $title = NULL; switch ($link_type) { case 'page': $link = $this->page_model->get_by_id($link_id, Settings::get_lang('default')); $title = !empty($link['title']) ? $link['title'] : $link['name']; break; case 'article': $link_rel = explode('.', $link_id); $link = $this->article_model->get_by_id($link_rel[1], Settings::get_lang('default')); $title = !empty($link['title']) ? $link['title'] : $link['name']; break; case 'external': if ($this->input->post('url') != lang('ionize_label_drop_link_here')) { $title = prep_url($this->input->post('url')); } else { $title = $link_type = ''; } break; case 'anchor': $title = $this->input->post('url'); } $data = array('link_id' => $link_id, 'link_type' => $link_type, 'link' => $title); // Save the link $this->page_model->update(array('id_page' => $id_page), $data); // Test the external link /* if ($link_type == 'external') { $check = check_url($title); if($check === FALSE) { $this->callback[] = array ( 'fn' => 'ION.notification', 'args' => array ( 'error', lang('ionize_message_url_not_found') ) ); $this->response(); } elseif($check == 404) { $this->callback[] = array ( 'fn' => 'ION.notification', 'args' => array ( 'error', lang('ionize_message_url_got_404') ) ); $this->response(); } } */ if ($title != '') { $this->callback = array(array('fn' => 'ION.HTML', 'args' => array('page/get_link', array('id_page' => $id_page), array('update' => 'linkContainer'))), array('fn' => 'ION.notification', 'args' => array('success', lang('ionize_message_link_added')))); } $this->response(); }
/** * Save article * * @param string $bid * @return void */ public function update($bid) { // load dictionaries $this->dict->get_words(); // get article id $mod = new Article_model(); $item = $mod->get_by_bid($bid); // check permission AdmUtils_helper::chklevel($_SESSION['xuid'], 'articles', $item->id, 2); // only if there are differences if ($item->content != $_POST['content']) { // tinymce $post = array('bid' => $bid, 'id_area' => $item->id_area, 'lang' => $item->lang, 'code_context' => $item->code_context, 'id_page' => $item->id_page, 'date_in' => time(), 'xkeys' => $item->xkeys, 'name' => $item->name, 'content' => $_POST['content'], 'excerpt' => 0, 'author' => $_SESSION['mail'], 'module' => $item->module, 'param' => $item->param, 'id_editor' => $_SESSION['xuid'], 'xon' => AUTOREFRESH); // insert new article's version $result = $mod->insert($post); if ($result[1]) { // add permission $perm = new Permission_model(); // privs permissions $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('articles', $array, $item->id_area); } // set message X4Utils_helper::set_msg($result); echo $_SESSION['msg']; unset($_SESSION['msg']); } else { echo ''; } }
/** * Delete article's version * * @access private * @param integer $id article ID * @param string $bid BID code * @return void */ private function deleting_version($id) { $msg = null; // check permissions $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'articles', $id, 4); if (is_null($msg)) { // do action $mod = new Article_model(); $obj = $mod->get_by_id($id, 'articles', 'id_area, lang, bid'); $result = $mod->delete($id); // clear useless permissions if ($result[1]) { $perm = new Permission_model(); $perm->deleting_by_what('articles', $id); } // set message $msg = AdmUtils_helper::set_msg($result); // set what update if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'articles/history/' . $obj->id_area . '/' . $obj->lang . '/' . $obj->bid, 'title' => null); } } $this->response($msg); }
/** * Constructor * * @access public * @return void */ public function __construct() { parent::__construct(); }
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'); }