-
Notifications
You must be signed in to change notification settings - Fork 204
/
edit.php
48 lines (43 loc) · 1.59 KB
/
edit.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
if (!defined('FLUX_ROOT')) exit;
$this->loginRequired();
$title = Flux::message('CMSPageEditTitle');
$pages = Flux::config('FluxTables.CMSPagesTable');
$id = $params->get('id');
$sql = "SELECT id, title, path, body, modified FROM {$server->loginDatabase}.$pages WHERE id = ?";
$sth = $server->connection->getStatement($sql);
$sth->execute(array($id));
$page = $sth->fetch();
$tinymce_key = Flux::config('TinyMCEKey');
if($page) {
$title = $page->title;
$path = $page->path;
$body = $page->body;
if(count($_POST)) {
$title = trim($params->get('page_title'));
$path = trim($params->get('page_path'));
$body = trim($params->get('page_body'));
if($title === '') {
$errorMessage = Flux::Message('CMSPageTitleError');
}
elseif($path === '') {
$errorMessage = Flux::Message('CMSPagePathError');
}
elseif($body === '') {
$errorMessage = Flux::Message('CMSPageBodyError');
}
else {
$sql = "UPDATE {$server->loginDatabase}.$pages SET title = ?, path = ?, body = ?, modified = NOW() WHERE id = ?";
$sth = $server->connection->getStatement($sql);
$sth->execute(array($title, $path, $body, $id));
$session->setMessageData(Flux::message('CMSPageUpdated'));
if ($auth->actionAllowed('pages', 'index')) {
$this->redirect($this->url('pages','index'));
}
else {
$this->redirect();
}
}
}
}
?>