Merge branch 'master' of https://git.oschina.net/sentcms/sentcms
This commit is contained in:
@@ -248,4 +248,42 @@ class Category extends Admin {
|
||||
return $this->error("设置失败!");
|
||||
}
|
||||
}
|
||||
|
||||
public function add_channel() {
|
||||
if (IS_POST) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->param();
|
||||
if ($data) {
|
||||
$id = $Channel->save($data);
|
||||
if ($id) {
|
||||
$map['id'] = array('IN', $data['mid']);
|
||||
$result = db('Category')->where($map)->setField('ismenu',$Channel->id);
|
||||
return $this->success('生成成功',url('index'));
|
||||
//记录行为
|
||||
action_log('update_channel', 'channel', $id, session('user_auth.uid'));
|
||||
} else {
|
||||
return $this->error('生成失败');
|
||||
}
|
||||
} else {
|
||||
$this->error($Channel->getError());
|
||||
}
|
||||
} else {
|
||||
$data = $this->request->param();
|
||||
$modelname = db('Model')->where( array('id' => $data['model_id']) )->field('id,name')->find();
|
||||
$data['url'] = $modelname['name'].'/list/'.$data['mid'];
|
||||
$pid = input('pid', 0);
|
||||
//获取父导航
|
||||
if (!empty($pid)) {
|
||||
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
|
||||
$this->assign('parent', $parent);
|
||||
}
|
||||
$pnav = db('Channel')->where(array('pid' => '0'))->select();
|
||||
$this->assign('pnav', $pnav);
|
||||
$this->assign('pid', $pid);
|
||||
$this->assign('info', $data);
|
||||
$this->assign('data',null );
|
||||
$this->setMeta('生成导航');
|
||||
return $this->fetch('edit_channel');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,6 +140,9 @@ class Channel extends Admin {
|
||||
|
||||
$map = array('id' => array('in', $id));
|
||||
if (db('Channel')->where($map)->delete()) {
|
||||
//删除category中的ismenu字段记录
|
||||
$map = array('ismenu' => array('in', $id));
|
||||
db('Category')->where($map)->setField('ismenu',0);
|
||||
//记录行为
|
||||
action_log('update_channel', 'channel', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功');
|
||||
|
||||
114
application/admin/view/category/edit_channel.html
Normal file
114
application/admin/view/category/edit_channel.html
Normal file
@@ -0,0 +1,114 @@
|
||||
{extend name="public/base"/}
|
||||
{block name="body"}
|
||||
<!-- datepicker end -->
|
||||
<div class="main-box clearfix">
|
||||
<header class="main-box-header clearfix">
|
||||
<div class="pull-left">
|
||||
<h2>
|
||||
生成到导航
|
||||
</h2>
|
||||
</div>
|
||||
</header>
|
||||
<div class="main-box-body clearfix">
|
||||
<form method="post" class="form form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">导航标题</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="title" value="{$info.title|default=''}">
|
||||
<span class="help-block">(用于显示的文字)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">当前标识</label>
|
||||
<div class="col-lg-6">
|
||||
<input type="text" class="form-control" name="active" value="{$info.active|default=''}">
|
||||
<span class="help-block">(当前标识)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">导航连接</label>
|
||||
<div class="col-lg-8">
|
||||
<input type="text" class="form-control" name="url" value="{$info.url|default=''}">
|
||||
<span class="help-block">(用于调转的URL,支持带http://的URL或U函数参数格式)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">导航类型</label>
|
||||
<div class="col-lg-8">
|
||||
<select name="type" id="type" class="form-control" style="width:auto;">
|
||||
{volist name=":config('nav_type_list')" id="item"}
|
||||
<option value="{$key}" {if isset($info['type']) && $info['type'] == $key}selected{/if}>{$item}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">父导航</label>
|
||||
<div class="col-lg-5">
|
||||
<select name="pid" class="form-control" style="width:auto;">
|
||||
<option value="0">--一级导航--</option>
|
||||
{volist name=":parse_field_bind('Channel',$data['pid'],'')" id="item"}
|
||||
{if condition="$item['id'] neq $data['id']"}
|
||||
<option value="{$item['id']}" {if condition="$pid eq $item['id']"}selected{/if}>{$item['title_show']}</option>
|
||||
{/if}
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">新窗口打开</label>
|
||||
<div class="col-lg-2">
|
||||
<select name="target" class="form-control" style="width:auto;">
|
||||
<option value="0" >否</option>
|
||||
<option value="1" {eq name="data.target" value="1"}selected{/eq}>是</option>
|
||||
</select>
|
||||
<span class="help-block">(是否新窗口打开链接)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">图标</label>
|
||||
<div class="col-lg-2">
|
||||
<input type="text" class="form-control" name="icon" value="{$info.icon|default=''}">
|
||||
<span class="help-block">输入图标英文</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">优先级</label>
|
||||
<div class="col-lg-2">
|
||||
<input type="text" class="form-control" name="sort" value="{$info.sort|default='1'}">
|
||||
<span class="help-block">(导航显示顺序)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">文字颜色</label>
|
||||
<div class="col-lg-2">
|
||||
<input type="text" class="form-control" name="color" value="{$info['color']|default=''}">
|
||||
<span class="help-block">(右上角的标志点颜色,支持各类css表示方式)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">标志点颜色</label>
|
||||
<div class="col-lg-2">
|
||||
<input type="text" class="form-control" name="band_color" value="{$info['band_color']|default=''}">
|
||||
<span class="help-block">(右上角的标志点颜色,支持各类css表示方式)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">标志点文字</label>
|
||||
<div class="col-lg-3">
|
||||
<input type="text" class="form-control" name="band_text" value="{$info['band_text']|default=''}">
|
||||
<span class="help-block">(右上角的标志点文字,不要太长,没有自动隐藏)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-lg-offset-2 col-lg-10">
|
||||
<input type="hidden" name="id" value="{$data.id|default=''}">
|
||||
<button class="btn btn-success submit-btn ajax-post" type="submit" target-form="form-horizontal">确 定</button>
|
||||
<button class="btn btn-danger btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
@@ -35,6 +35,7 @@
|
||||
<th width="120">排序</th>
|
||||
<th width="120">发布</th>
|
||||
<th width="120">状态</th>
|
||||
<th width="120">生成导航</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -59,6 +60,13 @@
|
||||
<span class="label label-danger">禁用</span>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
{if $list['ismenu']}
|
||||
<a href="{:url('admin/channel/del?id='.$list['ismenu'])}" class="ajax-get"><span class="label label-primary">已生成</span></a>
|
||||
{else/}
|
||||
<a href="{:url('add_channel?title='.$list['title'].'&model_id='.$list['model_id'].'&active='.$list['name'].'&mid='.$list['id'])}" ><span class="label label-danger">未生成</span></a>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
<a title="编辑" href="{:url('edit?id='.$list['id'].'&pid='.$list['pid'])}">编辑</a>
|
||||
{if $list['status']}
|
||||
|
||||
@@ -59,6 +59,9 @@
|
||||
<option value="{$key}" {eq name="item['value']" value="$key"}selected{/eq}>{$vo}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
{/case}
|
||||
{case value="image"}
|
||||
{:widget('common/Form/showConfig',array($item,$item))}
|
||||
{/case}
|
||||
{/switch}
|
||||
{if condition="$item['remark']"}
|
||||
|
||||
@@ -988,6 +988,44 @@ function get_category_child($id) {
|
||||
return array_unique($ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 栏目文章当前位置
|
||||
* @param integer $id 当前栏目ID
|
||||
* @param string $ext 文章标题
|
||||
* @return here 当前栏目树
|
||||
* @author K先森 <77413254@qq.com>
|
||||
**/
|
||||
function get_category_pos($id,$ext=''){
|
||||
$cat = db('Category');
|
||||
$here = '<a href="/">首页</a>';
|
||||
$uplevels = $cat->field("id,title,pid,model_id")->where("id=$id")->find();
|
||||
if(empty($uplevels)){
|
||||
return '栏目不存在';
|
||||
}
|
||||
if($uplevels['pid'] != 0)
|
||||
$here .= get_category_uplevels($uplevels['pid']);
|
||||
$modelid = $uplevels['model_id'];
|
||||
$modelname = db('Model')->field("name")->where("id = $modelid")->find();
|
||||
$links = url('index/content/lists?model='.$modelname['name'],array('id'=>$uplevels['id']));
|
||||
$here .= ' >> <a href="'.$links.'">'.$uplevels['title']."</a>";
|
||||
if($ext != '') $here .= ' >> '.$ext;
|
||||
return $here;
|
||||
}
|
||||
function get_category_uplevels($id){
|
||||
$cat = db('Category');
|
||||
$here = '';
|
||||
$uplevels = $cat->field("id,title,pid,model_id")->where("id=$id")->find();
|
||||
$modelid = $uplevels['model_id'];
|
||||
$modelname = db('Model')->field("name")->where("id = $modelid")->find();
|
||||
$links = url('index/content/lists?model='.$modelname['name'],array('id'=>$uplevels['id']));
|
||||
$here .= ' >> <a href="'.$links.'">'.$uplevels['title']."</a>";
|
||||
if($uplevels['pid'] != 0){
|
||||
$here = get_category_uplevels($uplevels['pid']).$here;
|
||||
}
|
||||
return $here;
|
||||
}
|
||||
|
||||
|
||||
function send_email($to, $subject, $message) {
|
||||
$config = array(
|
||||
'protocol' => 'smtp',
|
||||
|
||||
46
application/common/view/default/form/image_Config.html
Normal file
46
application/common/view/default/form/image_Config.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<div class="picker-box">
|
||||
<div id="picker_{$field}" class="picker_button">上传图片</div>
|
||||
{if isset($value) && $value}
|
||||
<input type="hidden" name="config[{$field}]" id="field_{$field}" value="{$value}">
|
||||
{else/}
|
||||
<input type="hidden" name="config[{$field}]" id="field_{$field}" value="">
|
||||
{/if}
|
||||
<div id="fileList_{$field}" class="upload-file-list-info" style="width:280px;">
|
||||
{if $value}
|
||||
{php}
|
||||
$images = get_cover($value);
|
||||
{/php}
|
||||
<li class="affix-list-item" id="WU_FILE_0">
|
||||
<div class="upload-file-info">
|
||||
<span class="webuploader-pick-file-close" data-queued-id="WU_FILE_0" data-id="{$value}" data-fileurl="{$images['path']}"><i class="close"></i></span>
|
||||
<span class="fname"></span>
|
||||
<span class="fsize">上传时间:{$images['create_time']|date='Y-m-d H:i:s',###}</span>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="filebox image">
|
||||
<img src="{:config('base_url')}{$images['path']}" class="img-responsive">
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
uploadsize = 2;
|
||||
$(function(){
|
||||
$("#picker_{$field}").SentUploader({
|
||||
fileNumLimit:1,
|
||||
uploadEvents: {
|
||||
uploadComplete:function(file){}
|
||||
},
|
||||
listName : 'fileList_{$field}',
|
||||
hiddenName: 'field_{$field}',
|
||||
hiddenValType:1,
|
||||
fileSingleSizeLimit:uploadsize*1024*1024,
|
||||
closeX:true
|
||||
},
|
||||
{
|
||||
fileType: 'service',
|
||||
filename : 'images',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -37,4 +37,27 @@ class Form {
|
||||
$view->assign($data);
|
||||
return $view->fetch('common@default/form/' . $type);
|
||||
}
|
||||
public function showConfig($field, $info) {
|
||||
$type = isset($field['type']) ? $field['type'].'_Config' : 'text';
|
||||
//类型合并
|
||||
if (in_array($type, array('string'))) {
|
||||
$type = 'text';
|
||||
}
|
||||
if (in_array($type, array('picture'))) {
|
||||
$type = 'image';
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'type' => $type,
|
||||
'field' => isset($field['name']) ? $field['name'] : '',
|
||||
'value' => isset($info[$field['name']]) ? $info[$field['name']] : (isset($field['value']) ? $field['value'] : ''),
|
||||
'size' => isset($field['size']) ? $field['size'] : 12,
|
||||
'option' => isset($field['option']) ? $field['option'] : '',
|
||||
);
|
||||
$no_tem = array('readonly', 'text', 'password','checkbox', 'textarea', 'select', 'bind', 'checkbox', 'radio', 'num', 'bool', 'decimal');
|
||||
$type = !in_array($type, $no_tem) ? $type : 'show';
|
||||
$view = new \think\View();
|
||||
$view->assign($data);
|
||||
return $view->fetch('common@default/form/'.$type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user