blob: 35eeb2dcf240aece7277ec6f56f4508a7c7aa890 [file] [log] [blame]
Luigi Santivetti7bab4942019-06-16 07:40:53 +00001<?php
2
3class 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}