コード例 #1
0
ファイル: preview.php プロジェクト: ssrsfs/blg
<?php

/**
 * 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']));
コード例 #2
0
ファイル: view.php プロジェクト: ssrsfs/blg
}
// create news category object
$category = new News_Category($categoryid);
// redirect if category id is invalid
if (!$category->exists()) {
    Typeframe::Redirect('Invalid category specified.', Typeframe::CurrentPage()->applicationUri(), 1);
    return;
}
// determine if there are 0 or more than 1 categories; add flag to template
if (in_array(0, $settings['categoryid']) || count($settings['categoryid']) > 1) {
    $pm->setVariable('multicats', true);
}
// add category name, id, and object to template
$pm->setVariable('categoryname', $category->get('categoryname'));
$pm->setVariable('categoryid', $category->get('categoryid'));
$pm->setVariable('category', $category);
// create news article object
$articles = News_Article::DAOFactory();
// filter by category id
News::SetCategoryId($articles, $category->get('categoryid'));
// add articles to template
$pm->setVariable('news', $articles);
// get comment types
$comment_types = CommentType::DAOFactory();
$comment_types->select()->order('name');
// add comment types to template
$pm->setVariable('comment_types', $comment_types);
// add page title and header to template
$title = News::GetTitle();
$pm->setVariable('page_title', $title);
$pm->setVariable('page_header', $title);