后端模块更新
前端模板路径设置
This commit is contained in:
@@ -120,4 +120,46 @@ class Base {
|
|||||||
View::assign($this->data);
|
View::assign($this->data);
|
||||||
return View::fetch($template);
|
return View::fetch($template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为手机访问
|
||||||
|
* @return boolean [description]
|
||||||
|
*/
|
||||||
|
public function isMobile() {//return true;
|
||||||
|
// 如果有HTTP_X_WAP_PROFILE则一定是移动设备
|
||||||
|
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
|
||||||
|
if (isset($_SERVER['HTTP_VIA'])) {
|
||||||
|
// 找不到为flase,否则为true
|
||||||
|
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
|
||||||
|
}
|
||||||
|
// 脑残法,判断手机发送的客户端标志,兼容性有待提高
|
||||||
|
if (isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||||
|
$clientkeywords = array('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile');
|
||||||
|
// 从HTTP_USER_AGENT中查找手机浏览器的关键字
|
||||||
|
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 协议法,因为有可能不准确,放到最后判断
|
||||||
|
if (isset($_SERVER['HTTP_ACCEPT'])) {
|
||||||
|
// 如果只支持wml并且不支持html那一定是移动设备
|
||||||
|
// 如果支持wml和html但是wml在html之前则是移动设备
|
||||||
|
if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_wechat() {
|
||||||
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class Channel extends Base {
|
|||||||
/* 获取频道列表 */
|
/* 获取频道列表 */
|
||||||
$map[] = ['status', '>', -1];
|
$map[] = ['status', '>', -1];
|
||||||
if ($type) {
|
if ($type) {
|
||||||
$map['type'] = $type;
|
$map[] = ['type', '=', $type];
|
||||||
}
|
}
|
||||||
$list = $channel->where($map)->order('sort asc,id asc')->select()->append(['status_text'])->toArray();
|
$list = $channel->where($map)->order('sort asc,id asc')->select()->append(['status_text'])->toArray();
|
||||||
|
|
||||||
@@ -157,36 +157,38 @@ class Channel extends Base {
|
|||||||
* @author huajie <banhuajie@163.com>
|
* @author huajie <banhuajie@163.com>
|
||||||
*/
|
*/
|
||||||
public function sort() {
|
public function sort() {
|
||||||
if ($this->request->isGet()) {
|
if ($this->request->isPost()) {
|
||||||
$ids = input('ids');
|
$ids = $this->request->param('ids', '');
|
||||||
$pid = input('pid');
|
|
||||||
//获取排序的数据
|
|
||||||
$map = array('status' => array('gt', -1));
|
|
||||||
if (!empty($ids)) {
|
|
||||||
$map['id'] = array('in', $ids);
|
|
||||||
} else {
|
|
||||||
if ($pid !== '') {
|
|
||||||
$map['pid'] = $pid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$list = db('Channel')->where($map)->field('id,title')->order('sort asc,id asc')->select();
|
|
||||||
|
|
||||||
$this->assign('list', $list);
|
|
||||||
$this->setMeta('导航排序');
|
|
||||||
return $this->fetch();
|
|
||||||
} elseif ($this->request->isPost()) {
|
|
||||||
$ids = input('post.ids');
|
|
||||||
$ids = explode(',', $ids);
|
$ids = explode(',', $ids);
|
||||||
|
$data = [];
|
||||||
foreach ($ids as $key => $value) {
|
foreach ($ids as $key => $value) {
|
||||||
$res = db('Channel')->where(array('id' => $value))->setField('sort', $key + 1);
|
$data[] = ['id' => $value, 'sort' => $key];
|
||||||
}
|
}
|
||||||
if ($res !== false) {
|
$result = (new ChannelM())->saveAll($data);
|
||||||
return $this->success('排序成功!', url('admin/channel/index'));
|
if ($result !== false) {
|
||||||
|
return $this->success('排序成功!', url('/admin/channel/index'));
|
||||||
} else {
|
} else {
|
||||||
return $this->error('排序失败!');
|
return $this->error('排序失败!');
|
||||||
}
|
}
|
||||||
} else {
|
}else{
|
||||||
return $this->error('非法请求!');
|
$ids = $this->request->param('ids', '');
|
||||||
|
$pid = $this->request->param('pid', '');
|
||||||
|
$map = [];
|
||||||
|
//获取排序的数据
|
||||||
|
$map[] = ['status', '>', -1];
|
||||||
|
if ($ids && strrpos($ids, ",")) {
|
||||||
|
$map[] = ['id', 'IN', explode(",", $ids)];
|
||||||
|
}else{
|
||||||
|
if ($pid) {
|
||||||
|
$map[] = ['pid', '=', $pid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$list = ChannelM::where($map)->field('id,title')->order('sort asc,id asc')->select();
|
||||||
|
|
||||||
|
$this->data = [
|
||||||
|
'list' => $list
|
||||||
|
];
|
||||||
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,32 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace app\controller;
|
namespace app\controller\front;
|
||||||
|
|
||||||
use \app\Base as BaseC;
|
use think\facade\View;
|
||||||
|
use think\facade\Cache;
|
||||||
|
use \app\controller\Base as BaseC;
|
||||||
|
|
||||||
class Base extends BaseC {
|
class Base extends BaseC {
|
||||||
|
|
||||||
|
protected function fetch($template = '') {
|
||||||
|
$config = Cache::get('system_config_data');
|
||||||
|
$this->tpl_config['view_depr'] = '_';
|
||||||
|
$pc_themes = $config['pc_themes'] ? $config['pc_themes'] . DIRECTORY_SEPARATOR : "";
|
||||||
|
$this->tpl_config['view_dir_name'] = 'public' . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . $pc_themes;
|
||||||
|
if ($this->isMobile() && $config['mobile_themes']) {
|
||||||
|
$mobile_themes = $config['mobile_themes'] ? $config['mobile_themes'] . DIRECTORY_SEPARATOR : "";
|
||||||
|
$this->tpl_config['view_dir_name'] = 'public' . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . $mobile_themes;
|
||||||
|
if (!is_dir($this->app->getRootPath() . $this->tpl_config['view_dir_name'])) {
|
||||||
|
$this->tpl_config['view_dir_name'] = 'public' . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . $pc_themes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($template == '') {
|
||||||
|
$template = str_replace(".", "@", strtolower($this->request->controller())) . "/" . $this->request->action();
|
||||||
|
}
|
||||||
|
|
||||||
|
View::config($this->tpl_config);
|
||||||
|
View::assign($this->data);
|
||||||
|
return View::fetch($template);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ namespace app\controller\front;
|
|||||||
use \app\model\Form;
|
use \app\model\Form;
|
||||||
|
|
||||||
|
|
||||||
class Front extends Base {
|
class Index extends Base {
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
|
|||||||
11
public/template/default/info.php
Normal file
11
public/template/default/info.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'name' => '官方默认模板',
|
||||||
|
'version' => '1.0',
|
||||||
|
'authors' => [
|
||||||
|
'name' => 'molong',
|
||||||
|
'email' => 'molong@tensent.cn'
|
||||||
|
],
|
||||||
|
'type' => 'pc',
|
||||||
|
'preview' => 'preview.png'
|
||||||
|
];
|
||||||
@@ -1 +0,0 @@
|
|||||||
{$formHtml|raw}
|
|
||||||
@@ -35,8 +35,8 @@
|
|||||||
<label class="col-lg-2 control-label">导航类型</label>
|
<label class="col-lg-2 control-label">导航类型</label>
|
||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
<select name="type" id="type" class="form-control" style="width:auto;">
|
<select name="type" id="type" class="form-control" style="width:auto;">
|
||||||
{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'] == $key}selected{/if}>{$item}</option>
|
<option value="{$key}" {if isset($info['type']) && $info['type'] == $item['key']}selected{/if}>{$item['label']}</option>
|
||||||
{/volist}
|
{/volist}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
<div class="tabs-wrapper">
|
<div class="tabs-wrapper">
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li {if 0 eq $type}class="active"{/if}><a href="{:url('/admin/channel/index',array('type'=>0))}">全部</a></li>
|
<li {if 0 eq $type}class="active"{/if}><a href="{:url('/admin/channel/index',array('type'=>0))}">全部</a></li>
|
||||||
{volist name=":config('nav_type_list')" id="item"}
|
{volist name="config['nav_type_list']" id="item"}
|
||||||
<li {if $key eq $type}class="active"{/if}>
|
<li {if $item['key'] == $type}class="active"{/if}>
|
||||||
<a href="{:url('/admin/channel/index',array('type'=>$key))}">{$item}</a>
|
<a href="{:url('/admin/channel/index',array('type'=>$item['key']))}">{$item['label']}</a>
|
||||||
</li>
|
</li>
|
||||||
{/volist}
|
{/volist}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<div class="main-box clearfix">
|
<div class="main-box clearfix">
|
||||||
<header class="main-box-header clearfix">
|
<header class="main-box-header clearfix">
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<h2>菜单排序 [ <a href="{:url('index',array('pid'=>input('pid')))}">返回列表</a> ]</h2>
|
<h2>菜单排序 [ <a href="{:url('/admin/channel/index')}">返回列表</a> ]</h2>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="main-box-body clearfix">
|
<div class="main-box-body clearfix">
|
||||||
<form action="{:url('sort')}" method="post" class="form form-horizontal">
|
<form method="post" class="form form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-lg-2">
|
<div class="col-lg-2">
|
||||||
<select value="" size="8" class="form-control">
|
<select value="" size="8" class="form-control">
|
||||||
@@ -84,20 +84,18 @@
|
|||||||
$('input[name=ids]').val(arr.join(','));
|
$('input[name=ids]').val(arr.join(','));
|
||||||
$.post(
|
$.post(
|
||||||
$('form').attr('action'),
|
$('form').attr('action'),
|
||||||
{
|
{'ids' : arr.join(',')},
|
||||||
'ids' : arr.join(',')
|
|
||||||
},
|
|
||||||
function(data){
|
function(data){
|
||||||
if (data.code) {
|
if (data.code) {
|
||||||
updateAlert(data.msg + ' 页面即将自动跳转~','alert-success');
|
updateAlert(data.msg + ' 页面即将自动跳转~','alert-success');
|
||||||
}else{
|
}else{
|
||||||
updateAlert(data.msg,'alert-success');
|
updateAlert(data.msg,'alert-success');
|
||||||
}
|
}
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
if (data.code) {
|
if (data.code) {
|
||||||
$('.sort_cancel').click();
|
window.location.href = data.url;
|
||||||
}
|
}
|
||||||
},1500);
|
},1500);
|
||||||
},
|
},
|
||||||
'json'
|
'json'
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user