Example #1
0
}
//if logged in show data
if ($logged_in) {
    //initiate news Tools Class
    include_once 'includes/newsTools.class.inc.php';
    $newsTools = new newsTools($csv_location . $csv_name);
    //get header message
    $page_content .= $pageMaker->headerMessage($user_name);
    $form_action = !empty($_GET['action']) ? $_GET['action'] : '';
    $form_action_type = !empty($_POST['type']) ? $_POST['type'] : '';
    //show add form if requested.
    if ($form_action == 'add') {
        if ($form_action_type == 'add') {
            //handle new posting
            if (!empty($_POST['title']) && !empty($_POST['article'])) {
                $newsTools->saveNewNewsArticle(time(), $_POST['title'], $_POST['article']);
                $page_content .= $pageMaker->notifyMessage('The News Article was saved.');
                $page_content .= $pageMaker->getNewsHTML($newsTools->getNewsArray());
            } else {
                $page_content .= $pageMaker->pageSubHeader('Add News');
                $page_content .= $pageMaker->errorMessage('You did not complete all required fields.');
                $page_content .= $pageMaker->newsForm(array('', '', $_POST['title'], $_POST['article']), 'add');
            }
        } else {
            //display add form
            $page_content .= $pageMaker->pageSubHeader('Add News');
            $page_content .= $pageMaker->newsForm('', 'add');
        }
    } elseif ($form_action == 'update') {
        if ($form_action_type == 'update') {
            if (!empty($_POST['title']) && !empty($_POST['article'])) {