Beispiel #1
0
/**
 * Typeframe News application
 *
 * client-side preview controller
 */
// save some typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// requires post
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    Typeframe::Redirect('Invalid request method.', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $typef_app_dir);
    return;
}
// create news article object
$article = new News_Article();
// set author user id and name
$article->set('authorid', Typeframe::User()->get('userid'));
$article->set('author', @$_POST['author']);
// get and validate category id
$categoryid = @$_POST['categoryid'];
$category = new News_Category($categoryid);
if (!$category->exists()) {
    $category = null;
}
// get, validate, and set incoming the values
$article->set('categoryid', $categoryid);
$article->set('title', $_POST['title']);
$article->set('article', $_POST['article']);
$article->set('status', News_Article::ValidateField('status', @$_POST['status']));
$article->set('pubdate', News_Article::ValidateField('pubdate', @$_POST['pubdate']));
$article->set('expdate', @$_POST['expdate']);
// handle (auto)summary