function run()
 {
     require_once $this->sysRoot . '/Model/mysqlModel.php';
     require_once $this->sysRoot . '/Model/newsModel.php';
     $newsModel = new newsModel($this->year, $this->news_id);
     $newsData = $newsModel->run();
     if (!empty($newsData)) {
         // データが存在
         require_once $this->sysRoot . '/Controller/templateController.php';
         $imageAreaCode = '';
         for ($i = 0; $i < $newsData['images']; $i++) {
             $imageAreaCode .= '<img src="' . NEWS_IMAGE_PATH . $newsData['image_src' . ($i + 1)] . '" alt="' . $newsData['image_alt' . ($i + 1)] . '" class="newsImg">';
         }
         $tpl = new templateController($this->sysRoot);
         $tpl->news_id = $newsData['news_id'];
         $tpl->title = $newsData['title'];
         $tpl->created = $newsData['created'];
         $tpl->jpcreated = $newsData['jpcreated'];
         $tpl->content = $newsData['content'];
         $tpl->author = $newsData['author'];
         $tpl->year = $this->year;
         $tpl->newsLink = $this->helpers->newsLink();
         $tpl->imageArea = $imageAreaCode;
         $tpl->show($this->sysRoot . '/View/news.php');
     } else {
         // データが存在しない
         // So, redirect
         header('Location: /news/');
     }
 }
Example #2
0
 public function modifyREC()
 {
     $rec = newsModel::findID($_POST['num']);
     $rec->name = $_POST['newname'];
     // далее для отвязки от AbsractModel ничего лучше не придумал
     newsModel::$record = array('name' => $_POST['newname']);
     // тут можно передать любое количесво полей
     newsModel::$where = array('where_field' => 'num', 'where_condition' => $_POST['num']);
     //любое условие
     $rec->Save();
     header("Location: http://localhost/lesson2_1/index.php");
 }
Example #3
0
<?php

define('ACC', true);
require './include/init.php';
// 得到newsModel实例
$news = new newsModel();
$id = $_GET['id'];
$list = $news->findById($id);
include ROOT . 'view/edit.html';
?>
    

    


Example #4
0
<?php

define('ACC', true);
require './include/init.php';
// 得到newsModel实例
$news = new newsModel();
$list = $news->find();
$cnt = $news->count();
include ROOT . 'view/index.html';
Example #5
0
<?php

define('ACC', true);
require './include/init.php';
// 得到newsModel实例,并判断是否从地址栏上取得了参数
$news = new newsModel();
if (is_array($_GET) && count($_GET) > 0) {
    $list = $news->news_cat($_GET['cat']);
} else {
    $list = $news->find();
}
include ROOT . 'view/index.html';
Example #6
0
<?php

define('ACC', true);
require './include/init.php';
//1.得到newsModel实例
$news = new newsModel();
//2.通过action的值做地应操作
switch ($_GET['action']) {
    case "add":
        //增加操作
        $newstitle = $_POST['newstitle'];
        $newscontent = $_POST['newscontent'];
        $cat = $_POST['cat'];
        $data = array('newstitle' => $newstitle, 'newscontent' => $newscontent, 'cat' => $cat);
        if ($news->addNews($data)) {
            echo json_encode(array('msg' => '提交成功', 'errorCode' => 'ok', 'address' => '../index.php'));
        } else {
            echo json_encode(array('msg' => '提交失败', 'errorCode' => 'no', 'address' => '../contentAdd.php'));
        }
        break;
        //删除操作
    //删除操作
    case "del":
        $id = $_GET['id'];
        $news->delNews($id);
        header("Location:index.php");
        break;
    case "edit":
        //1.获取表单信息
        $newstitle = $_POST['newstitle'];
        $newscontent = $_POST['newscontent'];