Share Pastebin
Guest
Public paste!

yingyes

By: a guest | Apr 4th, 2008 | Syntax: None | Size: 1.15 KB | Hits: 147 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Home extends Module
  4. {
  5.        
  6.     function Home()
  7.     {
  8.         parent::Module();
  9.                 $this->init();
  10.     }
  11.  
  12.     function index($_data)
  13.     {
  14.                 if($_data['current_action']=='contact' && method_exists($this,'contact'))
  15.                 {
  16.                         $this->contact($_data);
  17.                 }
  18.  
  19.                 $data = array(
  20.                         'current_page'=>$_data['current_page'],
  21.                         'current_action'=>$_data['current_action'],
  22.                         'page_title'=>site_url()
  23.                 );
  24.  
  25.                 $data=array_merge($data,$_data);
  26.                 return $this->render($data);
  27.     }
  28.    
  29.         function init()
  30.         {
  31.                 if($this->uri->segment(2)!='init')
  32.                 {
  33.                         $this->method = ($this->uri->segment(2)!=''&&function_exists($this->uri->segment(2))) ? $this->uri->segment(2) : 'index';      
  34.                 }
  35.                 else
  36.                 {
  37.                         $this->_error();       
  38.                 }
  39.                                
  40.         }
  41.  
  42.         function render($data,$template='tpl_index')
  43.     {      
  44.                 return ($this->uri->segment(2)!='render')?$this->smarty_parser->parse('ci:'.$this->environ->template.$template,$data,true):$this->_error();
  45.         }
  46.  
  47.         function _error($to='',$message='')
  48.         {
  49.                 $this->session->set_flashdata('error',$message);
  50.                 redirect($to);//echo 'ERROR 404';
  51.         }
  52. }
  53. ?>