- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- class Default_controller extends Controller
- {
- function Default_controller()
- {
- parent::Controller();
- }
- var $module;
- var $method;
- var $data=array();
- function _remap()
- {
- // modules::load('search');
- $this->module = $this->uri->segment(1) OR $this->module = 'home';
- $this->method = $this->uri->segment(2) OR $this->method = 'index';
- $this->init();
- if(modules::exists($this->module,$this->module,'controllers/')!=NULL)
- {
- if(modules::exists($this->method,$this->module,'methods/')!=NULL)
- {
- $content = modules::run($this->module, $this->data, $this->method);
- }
- else
- {
- $content = modules::run($this->module, $this->data, 'index');
- }
- }
- else
- {
- redirect('');
- }
- $this->render($content);
- }
- function init()
- {
- $this->data=$this->lang->language;
- $this->data['username'] = $this->session->userdata('username');
- $this->data['user_group'] = $this->session->userdata('user_group');
- $this->data['logged_in']= $this->session->userdata('logged_in');
- $this->data['logged_in_value']=$this->config->item('logged_in_value');
- $this->data['response']=$this->session->flashdata('response');
- $this->data['error']=$this->session->flashdata('error');
- $this->data['message']=$this->session->flashdata('message');
- $this->data['current_page']=$this->module;
- $this->data['current_action']=$this->method.'_tpl';
- $this->data['query_count']=$this->template_model->query_count;
- $this->data['page_title']=$this->method." - ".$this->module." - ".site_url();
- $this->data['uri_string']=$this->uri->uri_string();
- $this->data['segment_array']=$this->uri->segment_array();
- $this->data['total_segments']=$this->uri->total_segments();
- $this->data=array_merge($this->data,$this->environ->data['template_layout']);
- $this->data=array_merge($this->data,$this->environ->data);
- }
- function render($content,$template="ci:default_layout")
- {
- //This calls the active template index page
- $layout = array(
- 'template'=> $content//$this->smarty_parser->parse('ci:'.$this->template.'/index',$content,true)
- );
- /*contains only <?=$template?>*/
- $this->smarty_parser->parse($template,$layout);
- }
- function error($method, $data = '')
- {
- //trap unknown method calls, suppress error message
- if ($content = parent::error($method, $data, FALSE))
- {
- return $content;
- }
- redirect('');
- }
- }
- ?>
