<?php
// +----------------------------------------------------------------------
// | Quotes [未来可期]
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | Author: 自助建站系统 https://www.kancloud.cn/btwcms-com/btwcms/2265967 作者QQ：1617643
// +----------------------------------------------------------------------
// | Date: 2020年2月5日
// +----------------------------------------------------------------------
include('header.php');


$id = daddslashes($_GET['id']);
if ($id) {
    $row = $DB->query("SELECT * FROM  `wcms_news` WHERE `id`='{$id}'  limit 1")->fetch();
    $result = 1; //查看单条通知
} else {
    $numrows = $DB->query("SELECT * from `wcms_news` WHERE `type`='1' ")->rowCount();
    $list = $DB->query("SELECT * FROM  `wcms_news` WHERE `type`='1' order by date desc")->fetchAll();
    if ($list.length < 1) {
        $list = $DB->query("SELECT * FROM  `wcms_news` order by date desc")->fetchAll();
    }
    $result = 2;//通知列表
}

?>
<?php if ($result == 1) { ?>
    <!-- Page Content-->
    <div class="page-content">
    <div class="container-fluid">
        <!-- Page-Title -->
        <div class="row">
            <div class="col-sm-12">
                <div class="page-title-box">
                    <div class="float-right">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="javascript:void(0);">新闻中心</a></li>
                            <li class="breadcrumb-item active">文章列表</li>
                        </ol>
                    </div>
                    <h4 class="page-title">新闻中心</h4>
                </div><!--end page-title-box-->
            </div><!--end col-->
        </div>
        <!-- end page title end breadcrumb -->
        <div class="row">
            <div class="col-12">
                <div class="card" id="tourJumbotron">
                    <div class="card-body">
                        <h4 class="mt-0 header-title">文章列表</h4>
                        <p class="text-muted mb-4">article
                        </p>
                        <div class="jumbotron bg-light mb-0">
                            <h1 class="display-5 font-weight-normal"><?php echo $row['title'] ?></h1>
                            <div class="meta-box">
                                <ul class="p-0 mt-4 list-inline">
                                    <li class="list-inline-item"><?php echo $row['date'] ?></li>
                                    <li class="list-inline-item">管理员 发布</li>
                                </ul>
                            </div><!--end meta-box-->
                            <hr class="my-4">
                            <?php echo $row['content'] ?>
                        </div>
                    </div><!--end card-body-->
                </div><!--end card-->
            </div><!--end col-->
        </div><!--end row-->


    </div><!-- container -->
<?php } ?>
<?php if ($result == 2){ ?>
    <!-- Page Content-->
    <div class="page-content">

    <div class="container-fluid">
        <!-- Page-Title -->
        <div class="row">
            <div class="col-sm-12">
                <div class="page-title-box">
                    <div class="float-right">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="javascript:void(0);">服务中心</a></li>
                            <li class="breadcrumb-item active">新闻中心</li>
                        </ol>
                    </div>
                    新闻中心
                </div><!--end page-title-box-->
            </div><!--end col-->
        </div>
        <!-- end page title end breadcrumb -->
        <div class="row">
            <?php
            foreach ($list as $res) {
                $title = mb_substr($res['title'], 0, 10, 'utf-8');
                $res['title'] = $title . "...";
                $content = mb_substr($res['content'], 0, 30, 'utf-8');
                $res['content'] = $content . "...";
                echo '
                        <div class="col-lg-4">
                            <div class="card">
                                <div class="card-body">
                                    <div class="blog-card">
                                        <img src="https://btwcms.coding.net/p/static/d/static/git/raw/master/baota/img/article.png" alt="" class="img-fluid"/>
                                        <div class="meta-box">
                                            <ul class="p-0 mt-4 list-inline">
                                                <li class="list-inline-item">' . $res['date'] . '</li>
                                                <li class="list-inline-item">管理员 发布</li>
                                            </ul>
                                        </div><!--end meta-box-->
                                        <h4 class="mt-2 mb-3">
                                            <a href="article.php?id=' . $res['id'] . '">' . $res['title'] . '</a>
                                        </h4>
                                        <p class="text-muted">' . $res['content'] . '</p>
                                        <a href="article.php?id=' . $res['id'] . '" class="text-primary">阅读文章 <i class="fas fa-long-arrow-alt-right"></i></a>
                                    </div><!--end blog-card-->
                                </div><!--end card-body-->
                            </div><!--end card-->
                        </div> <!--end col-->
                    ';


            }

            ?>
        </div><!--end row-->
    </div><!-- container -->

<?php } ?>

<?php
include('footer.php');
?>