<!doctype html>
<html>
<head>
? ? <meta charset="UTF-8">
? ? <title>后臺管理</title>
? ? <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/common.css"/>
? ? <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/main.css"/>
? ? <script type="text/javascript" src="__PUBLIC__/js/libs/modernizr.min.js"></script>
? ? <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
? ? <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.min.js"></script>
? ? <script type="text/javascript" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
? <include file="Public/head" />
? <div class="container clearfix">
? <include file="Public/left" />
? ? <div class="main-wrap">
? ? ? ? <div class="crumb-wrap">
? ? ? ? ? ? <div class="crumb-list"><i class="icon-font"></i><a href="/jscss/admin/design/">首頁</a><span class="crumb-step">></span><a class="crumb-name" href="/jscss/admin/design/">文章管理</a><span class="crumb-step">></span><span>新增文章</span></div>
? ? ? ? </div>
? ? ? ? <div class="result-wrap">
? ? ? ? ? ? <div class="result-content">
? ? ? ? ? ? ? ? <form action="" method="post" id="myform" name="myform" enctype="multipart/form-data">
? ? ? ? ? ? ? ? ? <input type="hidden" name="id" value="{$articler.id}">
? ? ? ? ? ? ? ? ? ? <table class="insert-tab" width="100%">
? ? ? ? ? ? ? ? ? ? ? ? <tbody>
? ? ? ? ? ? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <th><i class="require-red">*</i>文章名稱:</th>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input class="common-text required" id="catename" name="title" size="50" value="{$articler.title}" type="text">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <th><i class="require-red">*</i>文章描述:</th>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <textarea style="width:420px;height:100px;" name="desc">{$articler.desc}</textarea>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <th><i class="require-red">*</i>縮略圖:</th>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input id="pic" name="pic" size="50" value="" type="file">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <if condition="$articler['pic'] neq ''">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <img src="__ROOT__{$articler.pic}" height="50">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <else/>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 暫無圖片
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </if>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <th><i class="require-red">*</i>所屬欄目:</th>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <select name="cateid">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <option >選擇分類</option>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <volist name="cateres" id="vo">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <option? <if condition="$vo['id'] eq $articler['cateid']">selected="selected"</if> value="{$vo.id}">{$vo.catename}</option>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </volist>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </select>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <th><i class="require-red">*</i>文章內容:</th>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <textarea name="content" id="content" >{$articler.content}</textarea>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <th></th>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <td>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? ? ? ? ? </tbody></table>
? ? ? ? ? ? ? ? </form>
? ? ? ? ? ? </div>
? ? ? ? </div>
? ? </div>
? ? <!--/main-->
</div>
<script type="text/javascript">
? UE.getEditor('content',{initialFrameWidth:1000,initialFrameHeight:200,});
</script>
</body>
</html>
<?php
namespace Admin\Controller;
use Think\Controller;
class ArticleController extends Controller {
public function lst( ){
//Instantiation
$article=D('ArticleView');
$count= $article->count();// The query satisfies The total number of records required
$Page= new \Think\Page($count,5);// Instantiate the paging class and pass in the total number of records and the number of records displayed on each page (25)
$show= $Page->show();// Display output in paging
$list = $article->order('id desc')->limit($Page-> ;firstRow.','.$Page->listRows)->select();
$this->assign('list',$list);// Assignment data set
$this->assign('page',$show);// Assign paging output
$this->display();
}
Public function add(){
//Instantiation
$article=D('article');
if(IS_POST){
$date['title']=I('title');
$date['content']=I('content');
$date['desc']= I('desc');
? ? ? ? ? ? ? $date['cateid']=I('cateid'); ''){
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? use using ? to use ? ? ? ? ? ? using ? ? ? ‐ ? ? ? ‐ ? ? ?‐ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?.
# ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ’ ./'; // Set the root directory for uploading attachments??????????? $upload->savePath ='/Public/Uploads/'; //??????Set the (sub) directory for uploading attachments?????????????????????????????????????????????????????????????????????????????????Single file $ info = $ upload-& gt; uploadone ($ _ files ['pic']);? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?=$info['savepath'].$info['savename'];
???????????????????????????????????????????????????????????????????????????????????????????????????????????????##
? ? ? ? if($article->create($date)){
? ? ? ? ? ? if($article->add()){
? ? ? ? ? ? ? $this->success('添加文章成功',U('lst'));
? ? ? ? ? ? }else{
? ? ? ? ? ? ? $this->error('添加文章失敗!');
? ? ? ? ? ? }
? ? ? ? }else{
? ? ? ? ? ? $this->error($article->getError());
? ? ? ? }
? ? ? ? return;
? ? ? }
? ? ? $cateres=D('cate')->select();
? ? ? $this->assign('cateres',$cateres);
? ? ? $this->display();
? ? }
? ? public function edit(){
? ? ? //實例化
? ? ? $article=D('article');
? ? ? if(IS_POST){
? ? ? ? $date['title']=I('title');
? ? ? ? $date['content']=I('content');
? ? ? ? $date['desc']=I('desc');
? ? ? ? $date['cateid']=I('cateid');
? ? ? ? if($_FILES['pic']['tmp_name']!=''){
? ? ? ? ? ? $upload = new \Think\Upload();// 實例化上傳類
? ? ? ? ? ? $upload->maxSize=3145728 ;// 設置附件上傳大小
? ? ? ? ? ? $upload->exts =array('jpg', 'gif', 'png', 'jpeg');// 設置附件上傳類型
? ? ? ? ? ? $upload->rootPath= './'; // 設置附件上傳根目錄
? ? ? ? ? ? $upload->savePath ='/Public/Uploads/'; // 設置附件上傳(子)目錄
? ? ? ? ? ? // 上傳單個文件
? ? ? ? ? ? $info = $upload->uploadOne($_FILES['pic']);
? ? ? ? ? ? if(!$info) {// 上傳錯誤提示錯誤信息
? ? ? ? ? ? ? ? ? $this->error($upload->getError());
? ? ? ? ? ? }else{// 上傳成功 獲取上傳文件信息
? ? ? ? ? ? ? ? ?$date['pic']=$info['savepath'].$info['savename'];
? ? ? ? ? ? }
? ? ? ? }else{
? ? ? ? }
if($article->create($date)){
if($article->save()){
$this->success('Modify Article successful',U('lst'));
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
##} else { $ this-& gt; error ($ Article-& GT; Geterror ());##}
## Return; } ? ? ? ? $articler=$article->find(I('id')); ? ? ? ? ? $this->assign('articler',$articler); $cateres=D('cate')->select(); $this->assign('cateres',$cateres); $this- >display(); } ## public function del(){ //Instantiation $article=D('article');
if($article->delete(I('id'))){
$this->success('Delete article Success! ',U('lst'));
}else{
?$this->error('Failed to delete article!');
?}
}
public function sort(){
//var_dump($_POST); //In a row
//dump($_POST ); //Cash from the branch
$article=D('article');
foreach ($_POST as $id => $sort) {
// code...
?????????????????????????????????????????????????????????????????????????????? $article->where(array('id'=>$id))->setField('sort',$sort);
}
$this->success('Sorting update successful! ',U('lst'));
}
}