Luigi Santivetti | 7bab494 | 2019-06-16 07:40:53 +0000 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | class Pelican extends CI_Controller { |
| 4 | private function is_valid_file($rel_path = '/', $file_html = 'home.html') |
| 5 | { |
| 6 | $abs_path = APPPATH.$rel_path.$file_html; |
| 7 | if (file_exists($abs_path)) |
| 8 | return true; |
| 9 | |
| 10 | return false; |
| 11 | } |
| 12 | |
| 13 | public function index() |
| 14 | { |
| 15 | $this->load->view('index.html'); |
| 16 | } |
| 17 | |
| 18 | public function view($file_name = 'home') |
| 19 | { |
| 20 | $file_html = $file_name.'.html'; |
| 21 | if ($this->is_valid_file('views/blog/', $file_html)) |
| 22 | { |
| 23 | $this->load->view('blog/'.$file_html); |
| 24 | } |
| 25 | else if ($this->is_valid_file('views/category/', $file_html)) |
| 26 | { |
| 27 | $this->load->view('category/'.$file_html); |
| 28 | } |
| 29 | else if ($this->is_valid_file('views/page/', $file_html)) |
| 30 | { |
| 31 | $this->load->view('page/'.$file_html); |
| 32 | } |
| 33 | else if ($this->is_valid_file('views/', $file_html)) |
| 34 | { |
| 35 | $this->load->view($file_html); |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | $this->index(); |
| 40 | } |
| 41 | } |
| 42 | } |