简单标签使用demo
解决已知bug
This commit is contained in:
@@ -61,6 +61,12 @@ class Content extends Base {
|
|||||||
|
|
||||||
$category = Category::where('model_id', $this->modelInfo['id'])->column("*", "id");
|
$category = Category::where('model_id', $this->modelInfo['id'])->column("*", "id");
|
||||||
|
|
||||||
|
//当前栏目
|
||||||
|
$cate = isset($category[$param['id']]) ? $category[$param['id']] : [];
|
||||||
|
if(empty($cate)){
|
||||||
|
return $this->error("当前栏目不能为空或无此栏目!");
|
||||||
|
}
|
||||||
|
|
||||||
$ids = (new \sent\tree\Tree())->getChilds($category, (int) $param['id']);
|
$ids = (new \sent\tree\Tree())->getChilds($category, (int) $param['id']);
|
||||||
array_push($ids, (int) $param['id']);
|
array_push($ids, (int) $param['id']);
|
||||||
|
|
||||||
@@ -71,8 +77,6 @@ class Content extends Base {
|
|||||||
|
|
||||||
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig);
|
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig);
|
||||||
|
|
||||||
//当前栏目
|
|
||||||
$cate = $category[$param['id']];
|
|
||||||
if (isset($cate['template_lists']) && $cate['template_lists']) {
|
if (isset($cate['template_lists']) && $cate['template_lists']) {
|
||||||
$teamplate = 'front@content/' . $this->modelInfo['name'] . '/' . $cate['template_lists'];
|
$teamplate = 'front@content/' . $this->modelInfo['name'] . '/' . $cate['template_lists'];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace app\model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分类模型
|
|
||||||
*/
|
|
||||||
class Action {
|
|
||||||
|
|
||||||
protected function getStatusTextAttr($value, $data) {
|
|
||||||
$status = array(-1 => '删除', 0 => '禁用', 1 => '正常', 2 => '待审核');
|
|
||||||
return $status[$data['status']];
|
|
||||||
}
|
|
||||||
|
|
||||||
public $fieldlist = array(
|
|
||||||
array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'),
|
|
||||||
array('name' => 'name', 'title' => '行为标识', 'type' => 'text', 'help' => '输入行为标识 英文字母'),
|
|
||||||
array('name' => 'title', 'title' => '行为名称', 'type' => 'text', 'help' => '输入行为名称'),
|
|
||||||
array('name' => 'type', 'title' => '行为类型', 'type' => 'select', 'help' => '选择行为类型', 'option' => ''),
|
|
||||||
array('name' => 'remark', 'title' => '行为描述', 'type' => 'textarea', 'help' => '输入行为描述'),
|
|
||||||
array('name' => 'rule', 'title' => '行为规则', 'type' => 'textarea', 'help' => '输入行为规则,不写则只记录日志'),
|
|
||||||
array('name' => 'log', 'title' => '日志规则', 'type' => 'textarea', 'help' => '记录日志备注时按此规则来生成,支持[变量|函数]。目前变量有:user,time,model,record,data'),
|
|
||||||
);
|
|
||||||
|
|
||||||
public function _initialize() {
|
|
||||||
parent::_initialize();
|
|
||||||
foreach ($this->fieldlist as $key => $value) {
|
|
||||||
if ($value['name'] == 'type') {
|
|
||||||
$value['option'] = get_action_type(null, true);
|
|
||||||
}
|
|
||||||
$this->fieldlist[$key] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,8 +25,8 @@ class AuthRule extends Model{
|
|||||||
|
|
||||||
public $keyList = [
|
public $keyList = [
|
||||||
['name'=>'module','title'=>'所属模块','type'=>'hidden'],
|
['name'=>'module','title'=>'所属模块','type'=>'hidden'],
|
||||||
['name'=>'title','title'=>'节点名称','type'=>'text','help'=>''],
|
['name'=>'title','title'=>'节点名称','type'=>'text', 'is_must'=>true,'help'=>''],
|
||||||
['name'=>'name','title'=>'节点标识','type'=>'text','help'=>''],
|
['name'=>'name','title'=>'节点标识','type'=>'text', 'is_must'=>true,'help'=>''],
|
||||||
['name'=>'group','title'=>'功能组','type'=>'text','help'=>'功能分组'],
|
['name'=>'group','title'=>'功能组','type'=>'text','help'=>'功能分组'],
|
||||||
['name'=>'status','title'=>'状态','type'=>'select','option'=>[['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'启用']],'help'=>''],
|
['name'=>'status','title'=>'状态','type'=>'select','option'=>[['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'启用']],'help'=>''],
|
||||||
['name'=>'condition','title'=>'条件','type'=>'text','help'=>'']
|
['name'=>'condition','title'=>'条件','type'=>'text','help'=>'']
|
||||||
|
|||||||
@@ -18,22 +18,35 @@ class Channel extends \think\Model {
|
|||||||
'id' => 'integer',
|
'id' => 'integer',
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $auto = array('update_time', 'status' => 1);
|
protected function setStatusAttr($value){
|
||||||
protected $insert = array('create_time');
|
return ($value !== '') ? $value : 1;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getStatusTextAttr($value, $data){
|
protected function getStatusTextAttr($value, $data){
|
||||||
$status = [0 => '禁用', 1 => '启用'];
|
$status = [0 => '禁用', 1 => '启用'];
|
||||||
return isset($status[$data['status']]) ? $status[$data['status']] : '禁用';
|
return isset($status[$data['status']]) ? $status[$data['status']] : '禁用';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getChannelList($pid, $tree){
|
public static function getChannelList($type, $pid = '', $tree = false){
|
||||||
$map = [];
|
$map = [];
|
||||||
$map[] = ['status', '=', 1];
|
$map[] = ['status', '=', 1];
|
||||||
if ($pid !== '') {
|
if ($pid !== '') {
|
||||||
$map[] = ['pid', '=', $pid];
|
$map[] = ['pid', '=', $pid];
|
||||||
}
|
}
|
||||||
|
if($type !== ''){
|
||||||
$list = self::where($map)->order('sort asc, id desc')->column("*");
|
$map[] = ['type', '=', $type];
|
||||||
|
}
|
||||||
|
$list = self::where($map)->order('sort asc, id desc')->select()->each(function($item){
|
||||||
|
if(strpos($item['url'], "?")){
|
||||||
|
$url = parse_url($item['url']);
|
||||||
|
$param = [];
|
||||||
|
parse_str($url['query'], $param);
|
||||||
|
$item['url'] = url($url['path'], $param);
|
||||||
|
}else{
|
||||||
|
$item['url'] = url($item['url']);
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
})->toArray();
|
||||||
if ($tree) {
|
if ($tree) {
|
||||||
$list = (new \sent\tree\Tree())->listToTree($list);
|
$list = (new \sent\tree\Tree())->listToTree($list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
<?php
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
|
||||||
// +----------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace app\model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分类模型
|
|
||||||
*/
|
|
||||||
class Record extends \think\Model {
|
|
||||||
|
|
||||||
protected $type = [
|
|
||||||
'new_data' => 'json',
|
|
||||||
'old_data' => 'json',
|
|
||||||
'order_num' => 'float'
|
|
||||||
];
|
|
||||||
|
|
||||||
public function getDataList($request) {
|
|
||||||
$map = [];
|
|
||||||
$order = "id desc";
|
|
||||||
$param = $request->param();
|
|
||||||
|
|
||||||
if (isset($param['name']) && $param['name'] != '') {
|
|
||||||
$map[] = ['data_name', 'LIKE', '%' . $param['name'] . '%'];
|
|
||||||
}
|
|
||||||
if (isset($param['nickname']) && $param['nickname'] != '') {
|
|
||||||
$searchUser = db('Member')->where('nickname', $param['nickname'])->field('uid,department')->find();
|
|
||||||
if ($searchUser) {
|
|
||||||
$map[] = ['uid', '=', $searchUser['uid']];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isset($param['data']) && count($param['data']) == 2 && $param['data'][0] && $param['data'][1]) {
|
|
||||||
$data = [strtotime($param['data'][0]), strtotime($param['data'][1])];
|
|
||||||
$map[] = ['create_time', 'between time', $data];
|
|
||||||
}
|
|
||||||
//数据权限
|
|
||||||
if ($request->user['role']['data_auth'] == 1) {
|
|
||||||
// 部门数据...
|
|
||||||
$user = Db::name('Member')->field('uid')
|
|
||||||
->where('department', $request->user['department'])
|
|
||||||
->buildSql();
|
|
||||||
$map[] = ["uid", "EXP", "in " . $user];
|
|
||||||
} elseif ($request->user['role']['data_auth'] == 2) {
|
|
||||||
// 个人数据...
|
|
||||||
$map[] = ['uid', '=', $request->user['uid']];
|
|
||||||
}
|
|
||||||
|
|
||||||
$list = self::with(['member'])->where($map)
|
|
||||||
->order($order)->paginate($request->pageConfig);
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* title : 添加记录
|
|
||||||
* param : old 旧数据,new 新数据 type 类型
|
|
||||||
*/
|
|
||||||
public function adds($old = array(), $new = array(), $type = 'customer') {
|
|
||||||
$edit = array(); //修改过的字段
|
|
||||||
foreach ($new as $key => $value) {
|
|
||||||
if (isset($old[$key]) && $value != $old[$key]) {
|
|
||||||
$edit[] = $key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!empty($edit)) {
|
|
||||||
$data['data_id'] = $old['id'];
|
|
||||||
$data['data_name'] = $old['name'];
|
|
||||||
$data['type'] = $type;
|
|
||||||
$data['uid'] = session('user_auth.uid');
|
|
||||||
$data['old_data'] = json_encode($old);
|
|
||||||
$data['new_data'] = json_encode($new);
|
|
||||||
$data['fields'] = json_encode($edit);
|
|
||||||
$data['create_time'] = time();
|
|
||||||
return $this->insert($data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function member() {
|
|
||||||
return $this->hasOne('Member', 'uid', 'uid')->field('uid,username,nickname');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,8 +18,8 @@ class Rewrite extends \think\Model {
|
|||||||
|
|
||||||
public static $keyList = array(
|
public static $keyList = array(
|
||||||
array('name' => 'id', 'title' => '标识', 'type' => 'hidden'),
|
array('name' => 'id', 'title' => '标识', 'type' => 'hidden'),
|
||||||
array('name' => 'rule', 'title' => '规则名称', 'type' => 'text', 'option' => '', 'help' => '规则名称,方便记忆'),
|
array('name' => 'rule', 'title' => '规则名称', 'type' => 'text', 'is_must'=> true, 'option' => '', 'help' => '规则名称,方便记忆'),
|
||||||
array('name' => 'url', 'title' => '规则地址', 'type' => 'text', 'option' => '', 'help' => '规则地址'),
|
array('name' => 'url', 'title' => '规则地址', 'type' => 'text', 'is_must'=> true, 'option' => '', 'help' => '规则地址'),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ class SeoRule extends \think\Model {
|
|||||||
|
|
||||||
public static $keyList = [
|
public static $keyList = [
|
||||||
['name' => 'id', 'title' => '标识', 'type' => 'hidden'],
|
['name' => 'id', 'title' => '标识', 'type' => 'hidden'],
|
||||||
['name' => 'title', 'title' => '规则名称', 'type' => 'text', 'option' => '', 'help' => '规则名称,方便记忆'],
|
['name' => 'title', 'title' => '规则名称', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '规则名称,方便记忆'],
|
||||||
['name' => 'app', 'title' => '模块名', 'type' => 'select', 'option' => [['key'=>'*', 'label' => '-所有模块-'], ['key'=>'front', 'label' => '前台模块'], ['key'=>'user', 'label' => '用户中心']], 'help' => '不选表示所有模块'],
|
['name' => 'app', 'title' => '模块名', 'type' => 'select', 'option' => [['key'=>'*', 'label' => '-所有模块-'], ['key'=>'front', 'label' => '前台模块'], ['key'=>'user', 'label' => '用户中心']], 'help' => '不选表示所有模块'],
|
||||||
['name' => 'controller', 'title' => '控制器', 'type' => 'text', 'option' => '', 'help' => '不填表示所有控制器'],
|
['name' => 'controller', 'title' => '控制器', 'type' => 'text', 'option' => '', 'help' => '不填表示所有控制器'],
|
||||||
['name' => 'action', 'title' => '方法', 'type' => 'text', 'option' => '', 'help' => '不填表示所有方法'],
|
['name' => 'action', 'title' => '方法', 'type' => 'text', 'option' => '', 'help' => '不填表示所有方法'],
|
||||||
['name' => 'seo_title', 'title' => 'SEO标题', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'],
|
['name' => 'seo_title', 'title' => 'SEO标题', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'],
|
||||||
['name' => 'seo_keywords', 'title' => 'SEO关键字', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'],
|
['name' => 'seo_keywords', 'title' => 'SEO关键字', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'],
|
||||||
['name' => 'seo_description', 'title' => 'SEO描述', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'],
|
['name' => 'seo_description', 'title' => 'SEO描述', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'],
|
||||||
['name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => [['key'=>'0', 'label' => '禁用'], ['key'=>'1', 'label' => '启用']], 'help' => ''],
|
['name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => [['key'=>'0', 'label' => '禁用'], ['key'=>'1', 'label' => '启用']], 'help' => ''],
|
||||||
['name' => 'sort', 'title' => '排序', 'type' => 'text', 'option' => '', 'help' => ''],
|
['name' => 'sort', 'title' => '排序', 'type' => 'text', 'option' => '', 'help' => ''],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -23,10 +23,11 @@ class Sent extends \think\template\TagLib {
|
|||||||
);
|
);
|
||||||
|
|
||||||
public function tagnav($tag, $content){
|
public function tagnav($tag, $content){
|
||||||
|
$type = isset($tag['type']) ? $tag['type'] : '';
|
||||||
$pid = isset($tag['pid']) ? $tag['pid'] : '';
|
$pid = isset($tag['pid']) ? $tag['pid'] : '';
|
||||||
$tree = isset($tag['tree']) ? $tag['tree'] : 1;
|
$tree = isset($tag['tree']) ? $tag['tree'] : false;
|
||||||
$parse = '<?php ';
|
$parse = '<?php ';
|
||||||
$parse .= '$__NAV__ = \\app\\model\\Channel::getChannelList('.$pid.', '.$tree.');';
|
$parse .= '$__NAV__ = \\app\\model\\Channel::getChannelList('.$type.', "'.$pid.'", '.$tree.');';
|
||||||
$parse .= 'foreach ($__NAV__ as $key => $'.$tag['name'].') {';
|
$parse .= 'foreach ($__NAV__ as $key => $'.$tag['name'].') {';
|
||||||
$parse .= '?>';
|
$parse .= '?>';
|
||||||
$parse .= $content;
|
$parse .= $content;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans
|
|||||||
<li><a href="{:url('/'.$model['name'].'/detail-'.$item['id'])}">{$item['title']}</a></li>
|
<li><a href="{:url('/'.$model['name'].'/detail-'.$item['id'])}">{$item['title']}</a></li>
|
||||||
{/volist}
|
{/volist}
|
||||||
</ul>
|
</ul>
|
||||||
|
{$page|raw}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
0
public/template/default/front/content_topic.html
Normal file
0
public/template/default/front/content_topic.html
Normal file
@@ -27,6 +27,9 @@ html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans
|
|||||||
<a href="{:url('/user/index/register')}">注册</a>
|
<a href="{:url('/user/index/register')}">注册</a>
|
||||||
<a href="{:url('/user/index/login')}">登录</a>
|
<a href="{:url('/user/index/login')}">登录</a>
|
||||||
</div>
|
</div>
|
||||||
|
{sent:nav tree="false" type="1" name="item"}
|
||||||
|
<li><a href="{$item['url']}">{$item['title']}</a></li>
|
||||||
|
{/sent:nav}
|
||||||
<div class="flex-center position-ref full-height">
|
<div class="flex-center position-ref full-height">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="title m-b-md">
|
<div class="title m-b-md">
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
<select name="type" id="type" class="form-control selectpicker" style="width:auto; min-width: 150px;">
|
<select name="type" id="type" class="form-control selectpicker" style="width:auto; min-width: 150px;">
|
||||||
{volist name="config['nav_type_list']" id="item"}
|
{volist name="config['nav_type_list']" id="item"}
|
||||||
<option value="{$key}" {if isset($info['type']) && $info['type'] == $item['key']}selected{/if}>{$item['label']}</option>
|
<option value="{$item['key']}" {if isset($info['type']) && $info['type'] == $item['key']}selected{/if}>{$item['label']}</option>
|
||||||
{/volist}
|
{/volist}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user