partia duużych zmian
[watermeloncms.git] / wtrmln / modules / controllers / pages.php
blob40af64e48e19820eef81e3ce5c7674efe2ce2190
1 <?php
2 /********************************************************************
4 Watermelon CMS
6 Copyright 2008-2009 Radosław Pietruszewski
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ********************************************************************/
23 class Pages extends Controller
25 function Index()
27 // wyciągamy segmenty URL-a (nazwa page'a) i mierzymy ich ilość
29 $page = URL::$segments;
31 $segments = count($page);
33 // jeśli brak segmentów
35 if($segments == 0)
37 $this->e404('');
38 return;
41 // jeśli $page jest stringiem zamieniamy go na tablicę z jedną wartością
43 if(is_string($page))
45 $page = array($page);
48 // łączymy w łańcuch
50 $page = implode('/', $page);
52 // sprawdzamy czy istnieje
54 $Pages = $this->load->model('Pages');
56 $data = $Pages->getData($page);
58 if($data->exists())
60 $data = $data->to_obj();
62 // ustawiamy tytuł
64 setH1($data->title);
66 $content = $data->content;
68 // przetwarzamy pseudotagi
70 $content = ViewTags::Process($content);
72 // wykonujemy :)
74 eval('?>' . $content . '<?php ');
77 else
79 $this->e404($page);
83 private function e404($pageName = '')
85 setH1('Błąd 404 : Nie odnaleziono');
87 echo $this->load->view('e404', array('pageName' => $pageName));