kolejna partia drobniejszych zmian (wciąż możliwe, że zacommitowany watermelon nie...
[watermeloncms.git] / wtrmln / modules / controllers / pages.php
blobefdcddd02ccc88a34bbb4f235a99ff56f9afa35e
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 __construct()
27 parent::Controller();
30 function Index()
32 // wyciągamy segmenty URL-a (nazwa page'a) i mierzymi ich ilość
34 $page = URL::$segments;
36 $segments = count($page);
38 // jeśli brak segmentów
40 if($segments == 0)
42 $this->e404('');
43 return;
46 // jeśli $page jest stringiem zamieniamy go na tablicę z jedną wartością
48 if(is_string($page))
50 $page = array($page);
53 // łączymy w łańcuch
55 $page = implode('/', $page);
57 // sprawdzamy czy istnieje
59 $Pages = $this->load->model('Pages');
61 $data = $Pages->getData($page);
63 if($data->num_rows() > 0)
65 $data = $data->to_obj();
67 // ustawiamy tytuł
69 setH1($data->title);
71 $content = $data->content;
73 // przetwarzamy pseudotagi
75 $content = ViewTags::Process($content);
77 // wykonujemy :)
79 eval('?>' . $content . '<?php ');
82 else
84 $this->e404($page);
88 private function e404($pageName = '')
90 setH1('Błąd 404 : Nie odnaleziono');
92 echo '<div class="box_e">Na <em>' . Config::$siteName . '</em> nie ma strony "' . $pageName . '".</div>';