exit; } $title = Flux::message('NewsAddTitle'); // Form values. $news = Flux::config('FluxTables.CMSNewsTable'); $title = trim($params->get('news_title')); $body = trim($params->get('news_body')); $link = trim($params->get('news_link')); $author = trim($params->get('news_author')); if (count($_POST)) { if ($title === '') { $errorMessage = Flux::Message('XCMSNewsTitleError'); } elseif ($body === '') { $errorMessage = Flux::Message('XCMSNewsBody'); } elseif ($author === '') { $errorMessage = Flux::Message('XCMSNewsAuthor'); } else { if ($link) { if (!preg_match('!^http://!i', $link)) { $news_link = "http://{$link}"; } } $sql = "INSERT INTO {$server->loginDatabase}.{$news} (title, body, link, author, created, modified)"; $sql .= "VALUES (?, ?, ?, ?, NOW(), NOW())"; $sth = $server->connection->getStatement($sql); $sth->execute(array($title, $body, $link, $author)); $session->setMessageData(Flux::message('XCMSNewsAdded')); if ($auth->actionAllowed('news', 'index')) { $this->redirect($this->url('news', 'index')); } else { $this->redirect();
$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(); 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('XCMSPageTitleError'); } elseif ($path === '') { $errorMessage = Flux::Message('XCMSPagePathError'); } elseif ($body === '') { $errorMessage = Flux::Message('XCMSPageBodyError'); } 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('XCMSPageUpdated')); if ($auth->actionAllowed('pages', 'index')) { $this->redirect($this->url('pages', 'index')); } else { $this->redirect(); } } } }