< ;/div>;
<表单操作="" method="post" id="myform" name="myform" enctype="multipart/form-data">
<th><i class="require-red">*</i>意外:</th>
< ;input id="pic" name="pic" size="50" value="" type="file">
暂无图片
<th><i class="require-red">*</i>所属栏目:</th>
<选择名称="cateid">
<选项>选择分类选项>
<选项 selected="selected" value="{$vo.id}">{$vo.catename}</option>
< ;/select>
<第>
< /div>
<script type="text/javascript">
UE.getEditor('content',{initialFrameWidth:1000,initialFrameHeight:200,});
;
<?php
namespace AdminController;
use ThinkController;
class ArticleController extends Controller {
public function lst(){
//实例化
$article=D('ArticleView');
$count= $article->count();// 查询满足要求的总记录数
$Page= new ThinkPage($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show= $Page->show();// 分页显示输出
$list = $article->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('list',$list);// 赋值数据集
$this->assign('page',$show);// 赋值分页输出
$this->display();
}
public function add(){
$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 ThinkUpload();// 实例化上传类
$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->add()){
$this->success('添加文章文章成功',U('lst') );
$this->error('文章添加失败!');
$this->error($article->getError()) ;
return;
$cateres=D('cate')->select();
$this->分配('cateres',$cateres);
$这个->display();
public function edit(){
// 实例化
$date['title ']=I('title');
$date[' cateid']=I('cateid');
$upload = new ThinkUpload();//实例化上传类
$upload->maxSize=3145728 ;//设置附件上传大小
$upload->exts =array('jpg', 'gif', 'png', 'jpeg');//设置附件上传类型
if(!$info) {// 上传错误提示提示
$ this-&gt; error($ upload-&gt; getError());
} else {//上传上传上传获取上传信息信息
$ $ date ['pic''= $ info ['save'savepath '].$info['savename'];
}其他{
if($article->save()){
$this->success('修改文章成功',U('lst') );
$this->error('文章修改失败!');
$articler=$article->find(I('id'));
$this->assign('articler',$articler);
$this->assign('cateres',$cateres);
public function del(){
if($article->delete(I('id'))){
$this ->success('删除文章成功!',U('lst'));
$this->error('删除文章失败!');
公共函数 sort(){
//var_dump($_POST); //打成一排
//dump($_POST); //分行打现来
foreach ($_POST as $id => $sort) {
// 代码...
$article->where (array('id'=>$id))->setField('sort',$sort);
$this->success('排序更新成功!',U('lst' ));
<?php
namespace AdminController;
use ThinkController;
class ArticleController extends Controller {
public function lst(){
//实例化
$article=D('ArticleView');
$count= $article->count();// 查询满足要求的总记录数
$Page= new ThinkPage($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show= $Page->show();// 分页显示输出
$list = $article->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('list',$list);// 赋值数据集
$this->assign('page',$show);// 赋值分页输出
$this->display();
}
public function add(){
//实例化
$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 ThinkUpload();// 实例化上传类
$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->add()){
$this->success('添加文章文章成功',U('lst') );
}else{
$this->error('文章添加失败!');
}
}else{
$this->error($article->getError()) ;
}
return;
}
$cateres=D('cate')->select();
$this->分配('cateres',$cateres);
$这个->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 ThinkUpload();//实例化上传类
$upload->maxSize=3145728 ;//设置附件上传大小
$upload->exts =array('jpg', 'gif', 'png', 'jpeg');//设置附件上传类型
$upload->rootPath= './'; // 设置附件上传根目录
$upload->savePath ='/Public/Uploads/'; // 设置附件上传(子)目录
// 上传单个文件
$info = $upload->uploadOne($_FILES['pic']);
if(!$info) {// 上传错误提示提示
$ this-&gt; error($ upload-&gt; getError());
} else {//上传上传上传获取上传信息信息
$ $ date ['pic''= $ info ['save'savepath '].$info['savename'];
}
}其他{
}
if($article->create($date)){
if($article->save()){
$this->success('修改文章成功',U('lst') );
}其他{
$this->error('文章修改失败!');
}
}其他{
$this->error($article->getError()) ;
}
return;
}
$articler=$article->find(I('id'));
$this->assign('articler',$articler);
$cateres=D('cate')->select();
$this->assign('cateres',$cateres);
$this->display();
}
public function del(){
//实例化
$article=D('article');
if($article->delete(I('id'))){
$this ->success('删除文章成功!',U('lst'));
}else{
$this->error('删除文章失败!');
}
}
公共函数 sort(){
//var_dump($_POST); //打成一排
//dump($_POST); //分行打现来
$article=D('article');
foreach ($_POST as $id => $sort) {
// 代码...
$article->where (array('id'=>$id))->setField('sort',$sort);
}
$this->success('排序更新成功!',U('lst' ));
}
}