/
single.php
69 lines (59 loc) · 2.38 KB
/
single.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
64
65
66
67
68
69
<?php
namespace Concrete\Controller\SinglePage\Dashboard\Pages;
use Concrete\Core\Http\Request;
use Concrete\Core\Page\Controller\DashboardPageController;
use Concrete\Core\Page\Page;
use Concrete\Core\Page\Single as SinglePage;
use Concrete\Core\Permission\Checker;
class Single extends DashboardPageController
{
public function single_page_added()
{
$this->set('message', t('Page Successfully Added.'));
$this->view();
}
public function view()
{
$this->set('generated', SinglePage::getList());
if ($this->request->isMethod(Request::METHOD_POST)) {
if ($this->token->validate('add_single_page')) {
$pathToNode = SinglePage::getPathToNode($this->request->request->get('pageURL'), false);
$path = SinglePage::sanitizePath($this->request->request->get('pageURL'));
if (strlen($pathToNode) > 0) {
// now we check to see if this is already added
$pc = Page::getByPath('/' . $path, 'RECENT');
if ($pc->getError() == COLLECTION_NOT_FOUND) {
SinglePage::add(h($this->request->request->get('pageURL')));
return $this->buildRedirect($this->action('single_page_added'));
}
$this->error->add(t('That page has already been added.'));
} else {
$this->error->add(t('That specified path doesn\'t appear to be a valid static page.'));
}
}
}
}
public function single_page_refreshed()
{
$this->set('message', t('Page Successfully Refreshed.'));
$this->view();
}
public function refresh($cID = 0, $token = '')
{
if ((int) $cID > 0) {
if ($this->token->validate('refresh', $token)) {
$p = SinglePage::getByID($cID);
$cp = new Checker($p);
if ($cp->canAdmin()) {
SinglePage::refresh($p);
return $this->buildRedirect($this->action('single_page_refreshed'));
}
$this->error->add(t('You do not have permissions to refresh this page.'));
} else {
$this->error->add($this->token->getErrorMessage());
}
} else {
$this->error->add(t('Page Unsuccessfully Refreshed.'));
}
}
}