/
page.php
63 lines (55 loc) · 1.69 KB
/
page.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Concrete\Controller\Backend\UserInterface;
use Concrete\Core\Error\UserMessageException;
use Concrete\Core\Page\Page as ConcretePage;
use Concrete\Core\Permission\Checker as Permissions;
abstract class Page extends \Concrete\Controller\Backend\UserInterface
{
/**
* @var ConcretePage A page object
*/
protected $page;
/**
* @var Permissions This page's permissions
*/
protected $permissions;
public function on_start()
{
$request = $this->request;
$cID = $request->query->get('cID');
if (!$cID) {
$cID = $request->request->get('cID');
}
if ($cID) {
$page = ConcretePage::getByID($cID);
} else {
$page = null;
}
if (!is_object($page) || $page->getError() == COLLECTION_NOT_FOUND) {
throw new UserMessageException(t('Unable to find the specified page.'));
}
if ($page->isError()) {
throw new \Exception(t('Access Denied'));
}
$this->setPageObject($page);
$request->setCurrentPage($this->page);
}
public function setPageObject(ConcretePage $c)
{
$this->page = $c;
$this->permissions = new Permissions($this->page);
$this->set('c', $this->page);
$this->set('cp', $this->permissions);
}
public function action()
{
if ($this->page->getCollectionPointerOriginalID()) {
$cID = $this->page->getCollectionPointerOriginalID();
} else {
$cID = $this->page->getCollectionID();
}
$url = call_user_func_array('parent::action', func_get_args());
$url .= '&cID=' . $cID;
return $url;
}
}