예제 #1
0
<?php

// WATCH OUT!
// Apart from the runs to the database via commands, for the most part this is a copy-paste hack-job of list-pages.php
// You might find a few variables/functions that say 'news' when they mean 'event' here, but function/variable names are all the same to the user, and we have deadlines!
include '../init.php';
//setup some helpers
include 'inc/fckeditor/fckeditor.php';
$fh = RequestRegistry::getFormHelper();
//if we're getting an event id out of $_GET['newsevent-id'], set $newsevent to that
if (isset($_GET['newsevent-id'])) {
    $newsevent = CommandRunner::run('get-news-event')->get('newsevent');
}
//if we're saving an event, send it to the database and set it as the event to show in the form
if (isset($_POST['save-button'])) {
    $parameters = array('newsevent-id' => $_POST['id']);
    $newsevent = CommandRunner::run('get-news-event', $parameters)->get('newsevent');
    $newsevent->setContentType(NewsEvent::TYPE_NEWS);
    $newsevent->setDateDisplayed($fh->timestampFromPost());
    $newsevent->setTitle($_POST['title']);
    $newsevent->setKeywords($_POST['meta-keywords']);
    $newsevent->setDescription($_POST['meta-description']);
    $newsevent->setText($_POST['content']);
    $newsevent->setStatus($_POST['status']);
    CommandRunner::run('update-news-event', array('newsevent' => $newsevent));
}
//if not then we'll take either the most forthcoming event (the one nearest in the future)
//or we'll take the most recent if we can't find one, remember this is deciding what to display initially in the form
if (!isset($newsevent)) {
    $newsevent = CommandRunner::run('get-soonest-event')->get('newsevent');
    if ($newsevent == null) {