Example #1
0
function action_add()
{
    global $link;
    if (!empty($_POST)) {
        articles_new($link, $_POST['title'], $_POST['date'], $_POST['content']);
        header("Location: index.php");
    }
    $article['title'] = "";
    $article['content'] = "";
    $article['date'] = "";
    require "../views/article_admin.php";
}
Example #2
0
 public function action_new()
 {
     $title_art = "";
     $content_art = "";
     $error = false;
     // Обработка отправки формы
     if (isset($_POST['submit'])) {
         if ($_POST['title_art'] != "" && $_POST['content_art'] != "") {
             articles_new($_POST['title_art'], $_POST['date_art'], $_POST['content_art']);
             die(header('Location: index.php'));
         }
         $title_art = $_POST['title_art'];
         $content_art = $_POST['content_art'];
         $error = true;
     }
     $this->title .= '::Добавить статью';
     $this->content = $this->Template('v/v_new.php');
 }
Example #3
0
<?php

require_once "../database.php";
require_once "../models/articles.php";
$link = db_connect();
if (isset($_GET['action'])) {
    $action = $_GET['action'];
} else {
    $action = "";
}
if ($action == "add") {
    if (!empty($_POST)) {
        articles_new($link, $_POST['title'], $_POST['date'], $_POST['content']);
        header("Location: index.php");
    }
    include "../views/article_admin.php";
} else {
    if ($action == "edit") {
        if (!isset($_GET['id'])) {
            header("Location: index.php");
        }
        $id = (int) $_GET['id'];
        if (!empty($_POST) && $id > 0) {
            articles_edit($link, $id, $_POST['title'], $_POST['date'], $_POST['content']);
            header("Location: index.php");
        }
        $article = articles_get($link, $id);
        include "../views/article_admin.php";
    } else {
        if ($action == 'delete') {
            $id = $_GET['id'];
Example #4
0
} else {
    $action = "";
}
function show_articles_list($link, $dir, $id_category)
{
    $articles = articles_of_category($link, $id_category);
    $title_icon = '<span class="icon-bookmark banners"></span>';
    $title_form = 'Статьи привязанные к категории:';
    require_once "../views/header.php";
    include $dir . "views/articles_admin.php";
    require_once "../views/footer.php";
}
//Добавление статьи
if ($action == "add") {
    if (!empty($_POST)) {
        $id_art = articles_new($link, $_POST['title'], $_POST['date'], $_POST['content'], $_GET['id_category']);
    }
    $id_category = (int) $_GET['id_category'];
    show_articles_list($link, $dir, $id_category);
} else {
    if ($action == "edit") {
        if (!isset($_GET['id'])) {
            $articles = articles_all($link);
            include $dir . "views/articles_admin.php";
        } else {
            $id = (int) $_GET['id'];
            if (!empty($_POST) && $id > 0) {
                articles_edit($link, $id, $_POST['title']);
                $articles = articles_get($link, $id);
                header("Location: articles.php?id_category=" . $articles['categories_id']);
            }
Example #5
0
<?php

require_once 'startup.php';
require_once 'model.php';
// подключаемся к БД
startup();
// Определяем переменные для шаблона
$title = '';
$content = '';
$error = false;
// Обработка отправки формы
if (!empty($_POST) && isset($_POST['title']) && isset($_POST['content'])) {
    // успешно данные добавлены, редирект
    if (articles_new($_POST['title'], $_POST['content'])) {
        die(header('Location: editor.php'));
    }
    $title = $_POST['title'];
    $content = $_POST['content'];
    $error = true;
}
// кодировку
header('Content-type: text/html; charset=utf-8');
// вывод в шаблон
include 'theme/new.php';
Example #6
0
<?php

include_once 'startup.php';
include_once 'model/m_view.php';
include_once 'model/m_base.php';
// Установка параметров, подключение к БД, запуск сессии.
startup();
// Обработка отправки формы.
if (!empty($_POST)) {
    if (articles_new($_POST['title'], $_POST['text'])) {
        header('Location: editor.php');
        die;
    }
    $articles['title'] = $title = $_POST['title'];
    $articles['text'] = $text = $_POST['text'];
    $articles['error'] = true;
} else {
    $articles['title'] = '';
    $articles['text'] = '';
    $articles['error'] = false;
}
//	var_dump($articles);
// Кодировка.
header('Content-type: text/html; charset=utf-8');
// Внутренний шаблон.
$content = view_include('theme/v_new.php', $articles);
// Внешний шаблон.
$page = view_include('theme/v_base.php', array('title1' => 'Новая статья добавить', 'content' => $content));
// Вывод.
echo $page;