aboutsummaryrefslogtreecommitdiff
path: root/mod/pages/pages/pages/edit.php
blob: a925cdc55cca383d521ca38ef9ff44266a31a583 (plain)
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
<?php
/**
 * Edit a page
 *
 * @package ElggPages
 */

gatekeeper();

$page_guid = (int)get_input('guid');
$revision = (int)get_input('annotation_id');
$page = get_entity($page_guid);
if (!$page) {
	register_error(elgg_echo('noaccess'));
	forward('');
}

$container = $page->getContainerEntity();
if (!$container) {
	register_error(elgg_echo('noaccess'));
	forward('');
}

elgg_set_page_owner_guid($container->getGUID());

elgg_push_breadcrumb($page->title, $page->getURL());
elgg_push_breadcrumb(elgg_echo('edit'));

$title = elgg_echo("pages:edit");

if ($page->canEdit()) {

	if ($revision) {
		$revision = elgg_get_annotation_from_id($revision);
		if (!$revision || !($revision->entity_guid == $page_guid)) {
			register_error(elgg_echo('pages:revision:not_found'));
			forward(REFERER);
		}
	}

	$vars = pages_prepare_form_vars($page, $page->parent_guid, $revision);
	
	$content = elgg_view_form('pages/edit', array(), $vars);
} else {
	$content = elgg_echo("pages:noaccess");
}

$body = elgg_view_layout('content', array(
	'filter' => '',
	'content' => $content,
	'title' => $title,
));

echo elgg_view_page($title, $body);