Repository navigation
Expand file tree
/
Copy pathPage.php
More file actions
43 lines (33 loc) · 1.41 KB
/
Copy pathPage.php
File metadata and controls
43 lines (33 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* Created by PhpStorm.
* User: galych
* Date: 16.01.15
* Time: 13:51
*/
namespace Mirage;
class Page extends Controller {
public function show($id) {
$page = DB::findOne('pages', ' _key = ? AND is_active=1 ', [$id]);
$file = $page ? str_replace("/", '-', $page['_key']) : "";
if($page && file_exists(App::get('root_dir')."/public/uploads/custom_page/".$file.'.tpl')) {
$tpl = App::get('view');
$tpl->addTemplateDir(App::get('root_dir')."/public/uploads/custom_page/", 'custom');
$tpl->assign('title', htmlspecialchars_decode($page['title']));
//$tpl->assign('text', htmlspecialchars_decode(file_get_contents(App::get('root_dir')."/public/uploads/custom_page/".$file.'.tpl')));
$tpl->assign('text', $tpl->fetch("[custom]".$file.".tpl"));
$tpl->assign('seo_title', !empty($page['seo_title']) ? htmlspecialchars_decode($page['seo_title']) : false);
$tpl->assign('seo_keywords', !empty($page['seo_keywords']) ? htmlspecialchars_decode($page['seo_keywords']) : false);
$tpl->assign('seo_description', !empty($page['seo_description']) ? htmlspecialchars_decode($page['seo_description']) : false);
$tpl->display('custom_page.tpl');
} else {
$this->error();
}
}
public function error() {
function_exists('http_response_code') ? http_response_code(404) : header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
$tpl = App::get('view');
$tpl->display('404.tpl');
exit();
}
}