Ejemplo n.º 1
0
 public function main()
 {
     $news = getAllNews();
     function fillPreview(&$article)
     {
         if (empty($article['preview'])) {
             $article['preview'] = News::make_article_preview($article['text']);
         }
     }
     array_walk($news, "fillPreview");
     $this->data['all-news'] = $news;
     $this->render('templates/news-main.phtml', 'Новости');
 }
Ejemplo n.º 2
0
<?php

include_once 'database/connection.php';
include_once 'database/news.php';
$news_list = getAllNews();
include 'templates/header.php';
include 'templates/list_news.php';
include 'templates/footer.php';
?>

Ejemplo n.º 3
0
<?php

include 'adminheader.php';
print '<div id="edit_wrapper">';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    print '<div class="msg" style="width: 300px; margin-left: 30px">';
    if (isset($_POST['addNews'])) {
        addNews();
    }
    if (isset($_POST['delete'])) {
        delete('news', 'news_id', 'news_title');
    }
    print '</div><div style="clear: both"></div>';
}
print '<h1>redigera nyheter</h1>';
$news = getAllNews();
if (!empty($news)) {
    foreach ($news as $news) {
        print '<div class="edit">';
        print mb_strtolower('<h2>"' . $news['news_title'] . '"</h2>', 'UTF-8');
        print '<form method="post" enctype="multipart/form-data">
					<input type="hidden" name="update" value="update">
					<input type="hidden" name="news_id" value="' . $news['news_id'] . '">
					<input type="text" name="news_title" value="' . $news['news_title'] . '"><br>
					<input type="text" name="news_date" value="' . $news['news_date'] . '"><br>
					<textarea name="news" rows="10" cols="22">' . $news['news'] . '</textarea><br>';
        if ($news['news_pic']) {
            print '<div class="inputdiv file">
							<input type="file" name="news_pic"> <img src="img/news/' . $news['news_pic'] . '" width="100px"><br>
							</div>';
        } else {
Ejemplo n.º 4
0
<?php

/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 17.02.2015
 * Time: 15:04
 */
require_once '../models/news.php';
$news = isset($_GET['id']) ? GetNewsById($_GET['id']) : getAllNews();
if (!isset($_GET['id'])) {
    require_once '../views/news_view.php';
} else {
    require_once '../views/show_news.php';
}