Beispiel #1
0
 /**
  * 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);
 }
Beispiel #2
0
 /**
  * Duplicates one article
  * Called by /views/toolboxes/article_toolbox
  *
  * @param	int		$id_article		Source article ID
  * 
  * TODO :	Check if the article exists and display an error window if not.
  *			JS Callbacks of MUI.formWindow() needs to be implemented
  *
  */
 public function duplicate($id_article)
 {
     // Source article
     $cond = array('id_page' => $this->input->post('id_page'), 'id_article' => $id_article);
     if ($this->input->post('id_page')) {
         $source_article = array_shift($this->article_model->get_linked_lang_items('page', 'article', $cond, Settings::get_lang('default')));
     } else {
         unset($cond['id_page']);
         $source_article = $this->article_model->get($cond, Settings::get_lang('default'));
     }
     // Context page, if any
     $this->template['page'] = $this->page_model->get_by_id($this->input->post('id_page'), Settings::get_lang('default'));
     // Dropdowns Views
     if (is_file(APPPATH . '../themes/' . Settings::get('theme') . '/config/views.php')) {
         require_once APPPATH . '../themes/' . Settings::get('theme') . '/config/views.php';
     }
     $views = isset($views['article']) ? $views['article'] : array();
     if (count($views) > 0) {
         if (!isset($source_article['view'])) {
             $source_article['view'] = FALSE;
         }
         $views = array('' => lang('ionize_select_default_view')) + $views;
         $this->template['views'] = form_dropdown('article_view', $views, $source_article['view'], 'class="select w160"');
     }
     $this->template['all_views'] = $views;
     // All articles type to template
     $types = $this->article_type_model->get_types_select();
     $types = array('' => lang('ionize_select_no_type')) + $types;
     $this->template['all_types'] = $types;
     if (!isset($source_article['id_type'])) {
         $source_article['id_type'] = FALSE;
     }
     $this->template = array_merge($this->template, $source_article);
     $this->template['name'] = $source_article['name'];
     // $this->template['has_url'] = $source_article['has_url'];
     $this->template['title'] = $source_article['title'] != '' ? $source_article['title'] : $source_article['name'];
     // Dropdown menus
     $data = $this->menu_model->get_select();
     $this->template['menus'] = form_dropdown('dup_id_menu', $data, '1', 'id="dup_id_menu" class="select"');
     $this->output('article/duplicate');
 }