91 lines
2.3 KiB
PHP
91 lines
2.3 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
|
// +----------------------------------------------------------------------
|
|
namespace app\controller\user;
|
|
|
|
use think\facade\Db;
|
|
use app\model\Model;
|
|
use app\model\Attribute;
|
|
|
|
/**
|
|
* @title 内容模块
|
|
*/
|
|
class Content extends Base {
|
|
|
|
public $modelInfo = [];
|
|
public $model = null;
|
|
|
|
public function initialize() {
|
|
parent::initialize();
|
|
$this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list', 'attr_group'])->toArray();
|
|
$this->model = Db::name($this->modelInfo['name']);
|
|
}
|
|
|
|
/**
|
|
* @title 内容首页
|
|
* @return [type] [description]
|
|
*/
|
|
public function index() {
|
|
if ($this->modelInfo['list_grid'] == '') {
|
|
return $this->error("列表定义不正确!", url('/user/model/edit', array('id' => $this->modelInfo['id'])));
|
|
}
|
|
$order = "id desc";
|
|
$map = [];
|
|
$map[] = ['uid', '=', session('userInfo.uid')];
|
|
|
|
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
|
'query' => $this->request->param(),
|
|
));
|
|
|
|
$this->data = array(
|
|
'grid' => $this->modelInfo['grid_list'],
|
|
'list' => $list,
|
|
'page' => $list->render(),
|
|
'model_name' => $this->modelInfo['name'],
|
|
'model_id' => $this->modelInfo['id'],
|
|
'meta_title' => $this->modelInfo['title'].'列表'
|
|
);
|
|
if ($this->modelInfo['template_list']) {
|
|
$template = 'user@content/' . $this->modelInfo['template_list'];
|
|
} else {
|
|
$template = 'user@content/index';
|
|
}
|
|
return $this->fetch($template);
|
|
}
|
|
|
|
/**
|
|
* @title 添加内容
|
|
* @return [type] [description]
|
|
*/
|
|
public function add() {
|
|
if ($this->request->isPost()) {
|
|
# code...
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 修改内容
|
|
* @return [type] [description]
|
|
*/
|
|
public function edit() {
|
|
if ($this->request->isPost()) {
|
|
# code...
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 删除内容
|
|
* @return [type] [description]
|
|
*/
|
|
public function del() {
|
|
}
|
|
} |