forked from Felli/Pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PagesController.class.php
executable file
·48 lines (39 loc) · 1.17 KB
/
PagesController.class.php
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
44
45
46
47
48
<?php
// Copyright 2014 Aleksandr Tsiolko
if (!defined("IN_ESOTALK")) exit;
class PagesController extends ETController {
protected function model()
{
return ET::getInstance("pagesModel");
}
protected function plugin()
{
return ET::$plugins["Pages"];
}
public function index($pageSlug = false)
{
list($pageId,$slug) = explode('-',trim($pageSlug));
if(!is_numeric($pageId)){
$this->redirect(URL(""));
}
$page = $this->model()->getById((int)$pageId);
// Stop here with a 404 header if the page wasn't found.
if (!$page) {
$this->render404(T("message.pageNotFound"), true);
return false;
}elseif(!ET::$session->userId and $page['hideFromGuests']){
$this->render404(T("message.pageNotFound"), true);
return false;
}
$this->title = $page["title"];
if (strlen($page['content']) > 155) {
$description = substr($page['content'], 0, 155) . " ...";
$description = str_replace(array("\n\n", "\n"), " ", $description);
}else{
$description = $page["content"];
}
$this->addToHead("<meta name='description' content='".sanitizeHTML($description)."'>");
$this->data("page", $page);
$this->render($this->plugin()->getView("page"));
}
}