1、更换编辑器
2、seo优化功能 3、表单的bug
This commit is contained in:
@@ -56,7 +56,7 @@ class Content extends Admin{
|
||||
}
|
||||
|
||||
$list = $this->model->where($map)->order($order)->paginate(15, false, array(
|
||||
'query' => $this->request->param()
|
||||
'query' => $this->param
|
||||
));
|
||||
|
||||
$data = array(
|
||||
|
||||
@@ -12,31 +12,20 @@ use app\common\controller\Admin;
|
||||
|
||||
class Seo extends Admin{
|
||||
|
||||
protected $model;
|
||||
protected $keyList;
|
||||
protected $seo;
|
||||
protected $rewrite;
|
||||
|
||||
public function _initialize(){
|
||||
parent::_initialize();
|
||||
$app=array(''=>'-所有模块-','index'=>'前台模块','user'=>'用户中心');
|
||||
$this->keyList = array(
|
||||
array('name'=>'id','title'=>'标识','type'=>'hidden'),
|
||||
array('name'=>'title','title'=>'规则名称','type'=>'text','option'=>'','help'=>'规则名称,方便记忆'),
|
||||
array('name'=>'app','title'=>'模块名','type'=>'select','option'=>$app,'help'=>'不选表示所有模块'),
|
||||
array('name'=>'controller','title'=>'控制器','type'=>'text','option'=>'','help'=>'不填表示所有控制器'),
|
||||
array('name'=>'act','title'=>'方法','type'=>'text','option'=>'','help'=>'不填表示所有方法'),
|
||||
array('name'=>'seo_title','title'=>'SEO标题','type'=>'text','option'=>'','help'=>'不填表示使用默认'),
|
||||
array('name'=>'seo_keywords','title'=>'SEO关键字','type'=>'text','option'=>'','help'=>'不填表示使用默认'),
|
||||
array('name'=>'seo_description','title'=>'SEO描述','type'=>'text','option'=>'','help'=>'不填表示使用默认'),
|
||||
array('name'=>'status', 'title'=>'状态', 'type'=>'select','option'=>array('0'=>'禁用','1'=>'启用'),'help'=>''),
|
||||
array('name'=>'sort','title'=>'排序','type'=>'text','option'=>'','help'=>'')
|
||||
);
|
||||
$this->seo = model('SeoRule');
|
||||
$this->rewrite = model('Rewrite');
|
||||
}
|
||||
|
||||
public function index($page = 1, $r = 20){
|
||||
//读取规则列表
|
||||
$map = array('status' => array('EGT', 0));
|
||||
|
||||
$list = model('SeoRule')->where($map)->order('sort asc')->paginate(10);
|
||||
$list = $this->seo->where($map)->order('sort asc')->paginate(10);
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
@@ -50,19 +39,15 @@ class Seo extends Admin{
|
||||
public function add(){
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$result = model('SeoRule')->save($data);
|
||||
if ($result) {
|
||||
return $this->success("添加成功!");
|
||||
}else{
|
||||
return $this->error("添加失败!");
|
||||
}
|
||||
$result = $this->seo->save($data);
|
||||
if ($result) {
|
||||
return $this->success("添加成功!");
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
return $this->error("添加失败!");
|
||||
}
|
||||
}else{
|
||||
$data = array(
|
||||
'keyList' => $this->keyList
|
||||
'keyList' => $this->seo->keyList
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("添加规则");
|
||||
@@ -73,22 +58,18 @@ class Seo extends Admin{
|
||||
public function edit($id = null){
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$result = model('SeoRule')->save($data,array('id'=>$data['id']));
|
||||
if (false !== $result) {
|
||||
return $this->success("修改成功!");
|
||||
}else{
|
||||
return $this->error("修改失败!");
|
||||
}
|
||||
$result = $this->seo->save($data,array('id'=>$data['id']));
|
||||
if (false !== $result) {
|
||||
return $this->success("修改成功!");
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
return $this->error("修改失败!");
|
||||
}
|
||||
}else{
|
||||
$id = input('id','','trim,intval');
|
||||
$info = db('SeoRule')->where(array('id'=>$id))->find();
|
||||
$info = $this->seo->where(array('id'=>$id))->find();
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $this->keyList
|
||||
'keyList' => $this->seo->keyList
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑规则");
|
||||
@@ -101,7 +82,61 @@ class Seo extends Admin{
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$result = db('SeoRule')->where(array('id'=>array('IN',$id)))->delete();
|
||||
$result = $this->seo->where(array('id'=>array('IN',$id)))->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
}else{
|
||||
return $this->error("删除失败!");
|
||||
}
|
||||
}
|
||||
|
||||
public function rewrite(){
|
||||
$list = db('Rewrite')->paginate(10);
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render()
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("路由规则");
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function addrewrite(){
|
||||
if (IS_POST) {
|
||||
# code...
|
||||
}else{
|
||||
$data = array(
|
||||
'keyList' => $this->rewrite->keyList
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("添加路由规则");
|
||||
return $this->fetch('public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
public function editrewrite(){
|
||||
if (IS_POST) {
|
||||
# code...
|
||||
}else{
|
||||
$id = input('id','','trim,intval');
|
||||
$info = db('Rewrite')->where(array('id'=>$id))->find();
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $this->rewrite->keyList
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑路由规则");
|
||||
return $this->fetch('public/edit');
|
||||
}
|
||||
}
|
||||
|
||||
public function delrewrite(){
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$result = db('Rewrite')->where(array('id'=>array('IN',$id)))->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
}else{
|
||||
|
||||
@@ -4,8 +4,12 @@
|
||||
<script src="__PUBLIC__/plugs/tagsinput/bootstrap-tagsinput.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/webuploader/webuploader.css">
|
||||
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/plugs/ueditor/ueditor.config.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/plugs/ueditor/ueditor.all.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/editor/css/simditor.css" />
|
||||
|
||||
<script type="text/javascript" src="__PUBLIC__/plugs/editor/js/module.js"></script>
|
||||
<script type="text/javascript" src="__PUBLIC__/plugs/editor/js/hotkeys.js"></script>
|
||||
<script type="text/javascript" src="__PUBLIC__/plugs/editor/js/uploader.js"></script>
|
||||
<script type="text/javascript" src="__PUBLIC__/plugs/editor/js/simditor.js"></script>
|
||||
<!-- datepicker statr -->
|
||||
<link href="__PUBLIC__/plugs/datepicker/css/foundation-datepicker.min.css" rel="stylesheet" type="text/css">
|
||||
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.js"></script>
|
||||
@@ -41,7 +45,7 @@
|
||||
{else/}
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">{$field['title']|htmlspecialchars}</label>
|
||||
<div class="col-lg-8 col-sm-10">
|
||||
<div class="col-lg-10 col-sm-10">
|
||||
{:widget('common/Form/show',array($field,$info))}
|
||||
<div class="help-block">{$field['help']|default=''}</div>
|
||||
</div>
|
||||
@@ -59,7 +63,7 @@
|
||||
{else/}
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">{$field['title']|htmlspecialchars}</label>
|
||||
<div class="col-lg-8 col-sm-10">
|
||||
<div class="col-lg-10 col-sm-10">
|
||||
{:widget('common/Form/show',array($field,$info))}
|
||||
<div class="help-block">{$field['help']|default=''}</div>
|
||||
</div>
|
||||
|
||||
49
application/admin/view/seo/rewrite.html
Normal file
49
application/admin/view/seo/rewrite.html
Normal file
@@ -0,0 +1,49 @@
|
||||
{extend name="public/base"/}
|
||||
{block name="style"}
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
|
||||
{/block}
|
||||
{block name="body"}
|
||||
<div class="main-box clearfix">
|
||||
<header class="main-box-header clearfix">
|
||||
<div class="pull-left">
|
||||
<h2>{$meta_title}</h2>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-primary" href="{:url('addrewrite')}">新 增</a>
|
||||
<button class="btn btn-danger ajax-post confirm" url="{:url('delrewrite')}" target-form="ids">删 除</button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="main-box-body clearfix">
|
||||
<div class="table-responsive clearfix">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
|
||||
<th width="60">ID</th>
|
||||
<th>规则</th>
|
||||
<th>地址</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{volist name="list" id="item"}
|
||||
<tr>
|
||||
<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
|
||||
<td>{$item['id']}</td>
|
||||
<td>{$item['rule']}</td>
|
||||
<td>{$item['url']}</td>
|
||||
<td>
|
||||
<a href="{:url('editrewrite?id='.$item['id'])}">编辑</a>
|
||||
<a href="{:url('delrewrite?id='.$item['id'])}" class="confirm ajax-get">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
{/block}
|
||||
@@ -90,10 +90,10 @@ class Base extends \think\Controller{
|
||||
foreach ($seo as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
$meta[$key] = str_replace("[".$k."]", $v, $meta[$key]);
|
||||
$meta[$key] = str_replace("[".$k."]", $v . '|', $meta[$key]);
|
||||
}
|
||||
}else{
|
||||
$meta[$key] = str_replace("[".$key."]", $value, $meta[$key]);
|
||||
$meta[$key] = str_replace("[".$key."]", $value . '|', $meta[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,20 @@ class Upload {
|
||||
echo $data->output();
|
||||
}
|
||||
|
||||
public function editor(){
|
||||
$file = request()->file('upload_file');
|
||||
$info = $file->move(config('editor_upload.rootPath'), true, false);
|
||||
if ($info) {
|
||||
$data = $this->parse_file($info);
|
||||
$data['success'] = true;
|
||||
$data['file_path'] = $data['url'];
|
||||
}else{
|
||||
$data['success'] = false;
|
||||
$data['msg'] = "error message";
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$data = array(
|
||||
'status' => 1,
|
||||
|
||||
21
application/common/model/Rewrite.php
Normal file
21
application/common/model/Rewrite.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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\common\model;
|
||||
|
||||
/**
|
||||
* 伪静态
|
||||
*/
|
||||
class Rewrite extends Base{
|
||||
|
||||
public $keyList = array(
|
||||
array('name'=>'id','title'=>'标识','type'=>'hidden'),
|
||||
array('name'=>'title','title'=>'规则名称','type'=>'text','option'=>'','help'=>'规则名称,方便记忆'),
|
||||
);
|
||||
}
|
||||
@@ -14,6 +14,31 @@ namespace app\common\model;
|
||||
*/
|
||||
class SeoRule extends Base{
|
||||
|
||||
public $keyList = array(
|
||||
array('name'=>'id','title'=>'标识','type'=>'hidden'),
|
||||
array('name'=>'title','title'=>'规则名称','type'=>'text','option'=>'','help'=>'规则名称,方便记忆'),
|
||||
array('name'=>'app','title'=>'模块名','type'=>'select','option'=>array('*'=>'-所有模块-','index'=>'前台模块','user'=>'用户中心'),'help'=>'不选表示所有模块'),
|
||||
array('name'=>'controller','title'=>'控制器','type'=>'text','option'=>'','help'=>'不填表示所有控制器'),
|
||||
array('name'=>'action','title'=>'方法','type'=>'text','option'=>'','help'=>'不填表示所有方法'),
|
||||
array('name'=>'seo_title','title'=>'SEO标题','type'=>'text','option'=>'','help'=>'不填表示使用默认'),
|
||||
array('name'=>'seo_keywords','title'=>'SEO关键字','type'=>'text','option'=>'','help'=>'不填表示使用默认'),
|
||||
array('name'=>'seo_description','title'=>'SEO描述','type'=>'text','option'=>'','help'=>'不填表示使用默认'),
|
||||
array('name'=>'status', 'title'=>'状态', 'type'=>'select','option'=>array('0'=>'禁用','1'=>'启用'),'help'=>''),
|
||||
array('name'=>'sort','title'=>'排序','type'=>'text','option'=>'','help'=>'')
|
||||
);
|
||||
|
||||
protected function setAppAttr($value){
|
||||
return $value ? $value : '*';
|
||||
}
|
||||
|
||||
protected function setControllerAttr($value){
|
||||
return $value ? $value : '*';
|
||||
}
|
||||
|
||||
protected function setActionAttr($value){
|
||||
return (isset($value) && $value) ? $value : '*';
|
||||
}
|
||||
|
||||
protected function getAppAttr($value){
|
||||
return $value ? $value : '*';
|
||||
}
|
||||
@@ -37,13 +62,6 @@ class SeoRule extends Base{
|
||||
}
|
||||
|
||||
private function getMeta($module, $controller, $action, $seo){
|
||||
//查询缓存,如果已有,则直接返回
|
||||
$cacheKey = "sent_seo_meta_{$module}_{$controller}_{$action}";
|
||||
$cache = cache($cacheKey);
|
||||
if($cache !== false) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
//获取相关的规则
|
||||
$rules = $this->getRelatedRules($module, $controller, $action);
|
||||
|
||||
@@ -82,19 +100,15 @@ class SeoRule extends Base{
|
||||
//生成结果
|
||||
$result = array('title' => $title, 'keywords' => $keywords, 'description' => $description);
|
||||
|
||||
//写入缓存
|
||||
cache($cacheKey, $result);
|
||||
|
||||
//返回结果
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getRelatedRules($module, $controller, $action){
|
||||
//查询与当前页面相关的SEO规则
|
||||
$map = array();
|
||||
$map = "(app='' or app='$module') and (controller='' or controller='$controller') and (action='' or action='$action') and status=1";
|
||||
$map = "(app='*' or app='$module') and (controller='*' or controller='$controller') and (action='*' or action='$action') and status=1";
|
||||
|
||||
$rules = $this->db()->where($map)->order('sort asc')->select();
|
||||
$rules = $this->where($map)->order('sort asc')->select();
|
||||
|
||||
//返回规则列表
|
||||
return $rules;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="{$field}" name="{$field}" value="{$value}" readonly size="15">
|
||||
<input type="text" class="form-control" id="{$field}" name="{$field}" value="{$value|default=time()|date='Y-m-d H:i:s',###}" readonly size="15">
|
||||
<span class="input-group-addon"><i class="fa fa-th"></i></span>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
<textarea name="{$field}" id="{$field}">{$value}</textarea>
|
||||
<script type="text/javascript">
|
||||
serverUrl = "{:url('upload/ueditor')}";
|
||||
{if $option == 'all' || $option == ''}
|
||||
var ue = UE.getEditor("{$field}",{
|
||||
serverUrl : serverUrl,
|
||||
initialFrameWidth : "100%",
|
||||
initialFrameHeight : "300"
|
||||
});
|
||||
{elseif $option == 'mini'/}
|
||||
var ue = UE.getEditor("{$field}",{
|
||||
toolbars: [
|
||||
['source', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', '|','link', 'unlink', '|','simpleupload',]
|
||||
],
|
||||
initialFrameWidth : "100%",
|
||||
initialFrameHeight : "120"
|
||||
});
|
||||
{/if}
|
||||
</script>
|
||||
<textarea name="{$field}" id="{$field}">{$value}</textarea>
|
||||
<script type="text/javascript">
|
||||
var editor = new Simditor({
|
||||
textarea: $('#{$field}'),
|
||||
defaultImage : '__PUBLIC__/images/wechat.jpg',
|
||||
upload : {
|
||||
placeholder : '欢迎使用SentCMS网站管理系统',
|
||||
url: "{:url('upload/editor')}",
|
||||
fileKey: "upload_file"
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -39,7 +39,7 @@ return array(
|
||||
// 子目录创建方式,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'subName' => ['date', 'Ymd'],
|
||||
//保存根路径
|
||||
'rootPath' => './uploads/attachment/',
|
||||
'rootPath' => './uploads/attachment',
|
||||
// 保存路径
|
||||
'savePath' => '',
|
||||
// 上传文件命名规则,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
@@ -58,7 +58,7 @@ return array(
|
||||
// 子目录创建方式,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'subName' => ['date', 'Ymd'],
|
||||
//保存根路径
|
||||
'rootPath' => './uploads/editor/',
|
||||
'rootPath' => './uploads/editor',
|
||||
// 保存路径
|
||||
'savePath' => '',
|
||||
// 上传文件命名规则,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
@@ -77,7 +77,7 @@ return array(
|
||||
// 子目录创建方式,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
'subName' => ['date', 'Ymd'],
|
||||
//保存根路径
|
||||
'rootPath' => './uploads/picture/',
|
||||
'rootPath' => './uploads/picture',
|
||||
// 保存路径
|
||||
'savePath' => '',
|
||||
// 上传文件命名规则,[0]-函数名,[1]-参数,多个参数使用数组
|
||||
|
||||
@@ -64,6 +64,7 @@ class Content extends Fornt{
|
||||
$teamplate = 'content/'.$this->modelInfo['name'].'/index';
|
||||
}
|
||||
$this->assign($data);
|
||||
$this->setSeo($cate['name']);
|
||||
return $this->fetch($teamplate);
|
||||
}
|
||||
|
||||
@@ -133,6 +134,10 @@ class Content extends Fornt{
|
||||
$teamplate = 'content/'.$this->modelInfo['name'].'/detail';
|
||||
}
|
||||
$this->assign($data);
|
||||
$title = isset($info['title']) ? $info['title'] : '';
|
||||
$tags = isset($info['tags']) ? $info['tags'] : '';
|
||||
$description = isset($info['description']) ? $info['description'] : '';
|
||||
$this->setSeo($title, $tags, $description);
|
||||
return $this->fetch($teamplate);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ class Index extends Fornt{
|
||||
|
||||
//网站首页
|
||||
public function index(){
|
||||
//设置SEO
|
||||
$this->setSeo(config('web_site_title'), config('web_site_keyword'), config('web_site_description'));
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user