Ejemplo n.º 1
0
 /** 
  * 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');
 }