コード例 #1
0
 /**
  * Generate and return the HTML for this element
  *
  * @param String $element_position Name of the position in the layout
  * @param Integer $element_order The order of appearance
  * @param Integer $element_type_order The order of appearance per element type
  *
  * @return string The HTML for this element
  */
 public function generate($element_position, $element_order, $element_type_order)
 {
     // store the generated HTML
     $output = NULL;
     // load this elements model
     $this->ci->load->model($this->element_path->models . 'element_text_model');
     // get text from database
     $data['text'] = array();
     $data['element_position'] = $element_position;
     $data['element_order'] = $element_order;
     $data['element_type_order'] = $element_type_order;
     // only when logged in
     if ($this->ci->input->get('preview', TRUE) === 'true') {
         if (app_preview_mode()) {
             $data['text'] = $this->ci->element_text_model->get_text_concept($this->id);
         } else {
             if (intval($this->ci->input->get('revision', TRUE))) {
                 $data['text'] = $this->ci->element_text_model->get_text_revision($this->id, intval($this->ci->input->get('revision', TRUE)));
             }
         }
     }
     // geen pagina gevonden voor preview of revision -> pak huidige pagina
     if (empty($data['text'])) {
         $data['text'] = $this->ci->element_text_model->get_text($this->id);
     }
     // generate the HTML, only if visible
     if (is_array($data['text']) and !empty($data['text'])) {
         $output = $this->ci->load->view($this->element_path->views . 'element_text', $data, true);
     }
     return $output;
 }
コード例 #2
0
ファイル: Element.php プロジェクト: BitmanNL/traffictower-cms
 /**
  * Generate Elements
  *
  * Generate the elements HTML, CSS and javascript for the given page.
  *
  * @param integer $page_id Id for the page to generate the elements for
  *
  * @return mixed[] content, css and javascript inserted in each element position
  */
 public function genenerate_elements($page_id)
 {
     // store the output for content
     $output = array();
     // get elements from db per page id
     $this->ci->load->model('element_model');
     $elements = $this->ci->element_model->get_elements_by_page_id($page_id, app_preview_mode());
     // generate the HTML for each of the elements and put
     // them in the correct position
     if (is_array($elements)) {
         $i = array();
         $i_type = array();
         foreach ($elements as $element) {
             // load element
             $element_library = $this->_load_element_library($element['type'], $element['content_id']);
             // store element order
             if (!isset($i[$element['position']])) {
                 $i[$element['position']] = 0;
             }
             if (!isset($i_type[$element['position']][$element['type']])) {
                 $i_type[$element['position']][$element['type']] = 0;
             }
             // generate element HTML output and put it in the correct position
             // send it's own position and order
             $output_element = $this->ci->{$element_library}->generate($element['position'], $i[$element['position']], $i_type[$element['position']][$element['type']]);
             if (!isset($output[$element['position']])) {
                 $output[$element['position']] = $output_element;
             } else {
                 $output[$element['position']] .= $output_element;
             }
             // Set global element custom css and javascript
             $this->css[$element['type']] = $this->ci->{$element_library}->get_css();
             $this->javascript[$element['type']] = $this->ci->{$element_library}->get_javascript();
             $i[$element['position']]++;
             $i_type[$element['position']][$element['type']]++;
         }
     }
     // Retrieve custom css an js and add to CMS controller
     $this->_generate_element_assets();
     return $output;
 }
コード例 #3
0
 /**
  * Redirect() page if set field replace_by in database.
  *
  * @param array $page Page to check for redirect
  */
 protected function _redirect_replace_by($page)
 {
     if (!empty($page)) {
         if ($page['replace_by'] == 'external') {
             if (substr($page['replace_value'], 0, 4) == 'http' || substr($page['replace_value'], 0, 2) == '//') {
                 redirect($page['replace_value']);
             } else {
                 redirect(site_url($page['replace_value']));
             }
         } else {
             $replace_by_page = array();
             if (!empty($page['replace_by'])) {
                 $this->load->model('page_model');
                 if ($page['replace_by'] == 'internal' && is_numeric($page['replace_value'])) {
                     $replace_by_page = $this->page_model->get_page_by_id($page['replace_value']);
                 }
                 if ($page['replace_by'] == 'first_sub') {
                     // get first sub
                     $secondary_navigation = !empty($page['secondary_navigation']) ? $page['secondary_navigation'] : NULL;
                     $sub_navigation = $this->page_model->get_navigation_by_parent_id($page['id'], $this->config->item('language'), $secondary_navigation, app_preview_mode());
                     if (!empty($sub_navigation)) {
                         $replace_by_page = current($sub_navigation);
                     }
                 }
             }
             if (!empty($replace_by_page)) {
                 redirect(site_url($replace_by_page['slug']));
             }
         }
     }
 }
コード例 #4
0
 public function get_breadcrumb($trace = array())
 {
     $breadcrumb = array();
     // get home if not present
     $home_page = $this->ci->page_model->get_home($this->ci->config->item('language'), app_preview_mode());
     if ($home_page['id'] != current($trace)) {
         $breadcrumb[] = $this->_retrieve_replace_by_page($home_page);
     }
     if (!empty($trace)) {
         foreach ($trace as $page_id) {
             $page = $this->ci->page_model->get_page_by_id($page_id, app_preview_mode());
             if (!empty($page)) {
                 $breadcrumb[] = $this->_retrieve_replace_by_page($page);
             }
         }
     }
     // set last key active
     $breadcrumb[end(array_keys($breadcrumb))]['active'] = TRUE;
     return $breadcrumb;
 }