From 8477e6fafd9bbb111b64bcee67352b93c19419d5 Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:00:38 +0800 Subject: [PATCH 01/27] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=8D=A2=E6=88=90=E5=88=B7=E6=96=B0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/common/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/admin/view/common/header.html b/application/admin/view/common/header.html index 485ce99a6..768e1753f 100644 --- a/application/admin/view/common/header.html +++ b/application/admin/view/common/header.html @@ -43,7 +43,7 @@
  • - +
  • -- Gitee From ba7199fce80c11ca24157a98f182fe614199bbfb Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:02:23 +0800 Subject: [PATCH 02/27] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/backend/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/public/assets/js/backend/index.js b/public/assets/js/backend/index.js index 7a22fe96a..6f4135f6a 100755 --- a/public/assets/js/backend/index.js +++ b/public/assets/js/backend/index.js @@ -126,6 +126,16 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi checkupdate('', true); }); + //刷新页面 + $(document).on('click', "[data-toggle='refresh']",function(){ + var contentwin = $('.content-wrapper').find('.tab-pane.active>iframe'); + try{ + contentwin.contentWindow.location.reload(true); + }catch(e){ + $(contentwin).attr('src', $(contentwin).attr('src')); + } + }); + //切换左侧sidebar显示隐藏 $(document).on("click fa.event.toggleitem", ".sidebar-menu li > a", function (e) { $(".sidebar-menu li").removeClass("active"); -- Gitee From c2793f1fb2dcabdc223b40d723a7f79eb134de50 Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:04:49 +0800 Subject: [PATCH 03/27] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=8A=8A=E6=96=87=E7=AB=A0=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E7=9A=84=E9=99=84=E4=BB=B6=E3=80=81=E5=B0=81=E9=9D=A2=E7=AD=89?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E7=9A=84=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E2=80=9C=E5=8F=AF=E5=88=A0=E9=99=A4=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/seven/behavior/ArchiveDel.php | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 extend/seven/behavior/ArchiveDel.php diff --git a/extend/seven/behavior/ArchiveDel.php b/extend/seven/behavior/ArchiveDel.php new file mode 100644 index 000000000..7afbf423e --- /dev/null +++ b/extend/seven/behavior/ArchiveDel.php @@ -0,0 +1,58 @@ + + * @Since: 2018/1/28 10:27 + */ + +namespace seven\behavior; + +use app\admin\model\Archives; +use think\Model; + +class ArchiveDel +{ + public function run(&$params) + { + if ($params instanceof Archives){ + $pk = $params->getPk(); + $attachments = []; + array_push($attachments, $params['cover']); + //读取模型字段 + $extra = model('PostsModelx')->get(['name'=>$params['type']]); + if(isset($extra['extra']) && !empty($extra['extra'])) { + //读取模型数据 + $archive_model = model('extra' . $params['type'])->get(['item_id' => $params[$pk]]); + foreach (json_decode($extra['extra'],true) as $k=>$v) + { + if(!isset($archive_model[$v['field']]) || + (isset($archive_model[$v['field']]) && empty($archive_model[$v['field']]))) { + continue; + } + if($v['type']=='image'){ + array_push($attachments, $archive_model[$v['field']]); + } + elseif($v['type']=='images'){ + $arr = explode(",", $archive_model[$v['field']]); + $attachments= array_merge($attachments, $arr); + } + elseif(in_array($v['type'], ['file','files'])){ + $arr= json_decode($archive_model[$v['field']],true); + foreach($arr as $key=>$val){ + array_push($attachments, $val['url']); + } + } + } + } + model('extra' . $params['type'])->where(['item_id' => $params[$pk]])->delete(); + + //打上可删除标识 + foreach ($attachments as $k => $v){ + if(!empty($v)){ + model('Attachment')->where('url', $v)->update(['canDelete'=>1]); + } + } + } + } + +} \ No newline at end of file -- Gitee From 8bc0b5e06bc690dba0e9e88d47993f022436073e Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:05:26 +0800 Subject: [PATCH 04/27] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E7=9A=84=E4=BA=8C=E7=BA=A7=E5=9F=9F=E5=90=8D=E3=80=81=E5=A4=96?= =?UTF-8?q?=E9=83=A8=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/seven/behavior/BindDomain.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 extend/seven/behavior/BindDomain.php diff --git a/extend/seven/behavior/BindDomain.php b/extend/seven/behavior/BindDomain.php new file mode 100644 index 000000000..e53db4392 --- /dev/null +++ b/extend/seven/behavior/BindDomain.php @@ -0,0 +1,28 @@ + + * @Since: 2018/1/28 15:18 + */ + +namespace seven\behavior; + +use think\Route; +use think\Cache; + +class BindDomain +{ + public function run() + { + $rules = Cache::get('rules'); + if(!$rules) { + $rules = \app\common\model\Sites::refreshRulesCache(); + } + + foreach($rules as $k => $v){ + Route::domain($v['s'], 'index'. $v['p']); + Route::domain('admin.'.$v['s'], 'admin'. $v['p']); + } + } + +} \ No newline at end of file -- Gitee From 5e6c05ea592e10f40be81691d2b561b000fe28bf Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:06:22 +0800 Subject: [PATCH 05/27] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=BD=91=E7=AB=99=E7=9A=84ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/seven/behavior/GetSiteId.php | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 extend/seven/behavior/GetSiteId.php diff --git a/extend/seven/behavior/GetSiteId.php b/extend/seven/behavior/GetSiteId.php new file mode 100644 index 000000000..1f7e4e6b1 --- /dev/null +++ b/extend/seven/behavior/GetSiteId.php @@ -0,0 +1,35 @@ + + * @Since: 2018/2/1 21:43 + */ + +namespace seven\behavior; + +use think\Session; + +class GetSiteId +{ + public function run() + { + $siteId = request()->param('user_site_id'); + if(!is_null($siteId)) { + Session::set("user_site_id", $siteId); + return; + } + $auth =\app\admin\library\Auth::instance(); + if($auth->isSuperAdmin()){ + Session::delete("user_site_id"); + return; + } + $user = $auth->getUserInfo(); + $site = \app\common\model\Sites::get(['user_id'=>$user['id']]); //\think\Db::name('sites')->where('user_id', $user['id'])->find(); + if($site!=false) { + Session::set("user_site_id", $site['id']); + }else{ + Session::set("user_site_id", -1); + } + } + +} \ No newline at end of file -- Gitee From 5e5e7cd53dad50129c282f7cfa7261173f13642e Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:06:34 +0800 Subject: [PATCH 06/27] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/seven/taglib/Xs.php | 123 +++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 extend/seven/taglib/Xs.php diff --git a/extend/seven/taglib/Xs.php b/extend/seven/taglib/Xs.php new file mode 100644 index 000000000..833ada58b --- /dev/null +++ b/extend/seven/taglib/Xs.php @@ -0,0 +1,123 @@ + + * @Since: 2018/2/1 19:33 + */ + +namespace seven\taglib; + + +use think\template\TagLib; +use think\Db; + + +class Xs extends Taglib +{ + + protected $tags = [ + 'nav' => ['attr' => 'name,showlevel', 'close'=> 0], + 'posts' => ['attr' => 'name,ids,cid,field,limit,order,where,ispage,pagesize,type,key', 'close' => 0], + 'ad' => ['attr' => 'id', 'close' => 0], + ]; + + public function tagAd($tag) + { + if (isset($tag['id']) && !empty($tag['id'])) { + $id = intval($tag['id']); + $parseStr = '"; + return $parseStr; + } + return; + } + + public function tagNav($tag) + { + $name = isset($tag['name']) ? $tag['name'] : '' ; //导航ID + $class = isset($tag['class']) ? $tag['class'] : ''; //导航css + $extend = isset($tag['extend']) ? $tag['extend'] : ''; //导航附加属性 + $name = preg_replace('/(\w+)/i','${1}',$name); + $class = str_replace('"', "'", $class); + $extend = str_replace('"', "'", $extend); + $navwrapattr= 'id:'.$name.';class:'.$class.';extend:'.$extend.';'; + + $itemclass = isset($tag['itemclass']) ? $tag['itemclass'] : ''; //菜单项css + $itemextend = isset($tag['itemextend']) ? $tag['itemextend'] : ''; //菜单项附加属性 + $itemclass = str_replace('"', "'", $itemclass); + $itemextend = str_replace('"', "'", $itemextend); + + $childwrap = isset($tag['childwrap']) ? $tag['childwrap'] : ''; //子菜单项的外围标签 + $childclass = isset($tag['childclass']) ? $tag['childclass'] : ''; //子菜单项的外围标签css + $childextend = isset($tag['childextend']) ? $tag['childextend'] : ''; //子菜单项的外围附加属性 + $childwrap = preg_replace('/(\w+)/i','${1}',$childwrap); + $childextend = str_replace('"', "'", $childextend); + $childclass = str_replace('"', "'", $childclass); + $childwrapattr = 'wrap:'.$childwrap.';class:'.$childclass.';extend:'.$childextend.';'; + + $itemtpl = ''; + if($itemclass!='' && $itemextend!='') + $itemtpl = "
  • #name #childlist
  • "; + + $parseStr = '"; + if (!empty($parseStr)) { + return $parseStr; + } + return; + } + + + /** + * 返回文章(列表/单篇) + * @param $tag + * @return string + */ + public function tagPosts($tag) + { + $name = $tag['name']; //供后期volist/foreach调用的名称 + $ids = isset($tag['ids']) ? $tag['ids'] : ''; //获取单篇文章id + $cid = isset($tag['cid']) ? $tag['cid'] : ''; //栏目id + $field = isset($tag['field']) ? $tag['field'] : ''; //获取字段 + $limit = isset($tag['limit']) ? $tag['limit'] : ''; //获取数量 + $order = isset($tag['order']) ? $tag['order'] : ''; //排序 + $where = isset($tag['where']) ? $tag['where'] : ''; //条件 + $ispage = isset($tag['ispage']) ? $tag['ispage'] : 'false'; //是否分页,默认不分页 + $pagesize = !empty($tag['ispage']) && !empty($tag['pagesize']) && is_numeric($tag['pagesize']) + ? intval($tag['pagesize']) + : 10; //config('posts.pagesize'); + + //$where=var_export($where, true); + + $options= "ids:".$ids.';cid:'.$cid.';field:'.$field.';limit:'.$limit.';order:'.$order.';where:'.$where.';'; + + $parseStr = '"; + + if (!empty($parseStr)) { + return $parseStr; + } + return; + } + + /** + * 返回singlepage的menu + * @param $tag + * @return string + */ + public function tagMenu($tag) + { + $name = $tag['name']; + $menuid = isset($tag['menuid']) ? $tag['menuid'] : ''; + $parseStr = '"; + if (!empty($parseStr)) { + return $parseStr; + } + return; + } +} \ No newline at end of file -- Gitee From 1dc9f0da91d23cfb50c7617508d6a113afec5458 Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:06:59 +0800 Subject: [PATCH 07/27] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E7=A8=8B=E5=BA=8F=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/seven/Seven.php | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 extend/seven/Seven.php diff --git a/extend/seven/Seven.php b/extend/seven/Seven.php new file mode 100644 index 000000000..61d80b469 --- /dev/null +++ b/extend/seven/Seven.php @@ -0,0 +1,72 @@ + + * @Since: 2018/1/25 22:40 + */ + +namespace seven; + +use fast\Form; +use app\admin\model\Sites; + +class Seven +{ + /** + * 生成多国语言版本的选择项 + * @param string $name input名称 + * @param string $type input类型(radio|checkbox) + * @param null $selected 选定项 + * @param array $options 扩展选项 + * @return string + */ + public static function build_langs($name, $selected=null, $options=[]) + { + $request = request(); + $MultiLanguages = include EXTEND_PATH.'seven/multilanguage.php'; + $list = []; + + $siteid = isset($options['siteid'])?$options['siteid'] : ''; + $type = isset($options['type'])? $options['type'] : 'radio'; + + //从站点后台进入,只显示当前站点允许的语言版本 + if (!empty($siteid) || !empty($request->param('domain'))) { + if(!empty($siteid)) { + $domain = Sites::get(['id' => $siteid]); + }else{ + $domain = Sites::get(['domain' => $request->param('domain')]); + } + $langs = explode(',', $domain['lang']); + foreach ($langs as $k => $v) { + $list[$v] = $MultiLanguages[$v]; + } + } else { + foreach ($MultiLanguages as $k => $v) { + $list[$k] = $v; + } + } + + $html=[]; + $selected = empty($selected) ? 'zh-cn' : $selected; + //$class = empty($class)? $type.'-inline' : $class; + if ($type == "checkbox") { + $name .= substr($name, -2) != '[]' ? '[]' : ''; + $selected = is_null($selected) ? [] : $selected; + $selected = is_array($selected) ? $selected : explode(',', $selected); + foreach ($list as $k => $v) + { + $html[] = sprintf(Form::label("{$name}-{$k}", "%s {$v}"), Form::checkbox($name, $k, in_array($k, $selected), ['id' => "{$name}-{$k}"])); + } + return '
    ' . implode(' ', $html) . '
    '; + + } else { + $selected = is_null($selected) ? key($list) : $selected; + $selected = is_array($selected) ? $selected : explode(',', $selected); + foreach ($list as $k => $v) + { + $html[] = sprintf(Form::label("{$name}-{$k}", "%s {$v}"), Form::radio($name, $k, in_array($k, $selected), ['id' => "{$name}-{$k}"])); + } + return '
    ' . implode(' ', $html) . '
    '; + } + } +} \ No newline at end of file -- Gitee From cce28873834a6ed44db318e1158efac66e00f5ed Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:07:40 +0800 Subject: [PATCH 08/27] =?UTF-8?q?=E5=A4=9A=E7=AB=99=E7=82=B9CMS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/backend/posts/archives.js | 306 +++++++++++++++++++++ public/assets/js/backend/posts/channel.js | 127 +++++++++ public/assets/js/backend/posts/modelx.js | 242 ++++++++++++++++ public/assets/js/backend/posts/page.js | 74 +++++ public/assets/js/backend/posts/sites.js | 116 ++++++++ 5 files changed, 865 insertions(+) create mode 100644 public/assets/js/backend/posts/archives.js create mode 100644 public/assets/js/backend/posts/channel.js create mode 100644 public/assets/js/backend/posts/modelx.js create mode 100644 public/assets/js/backend/posts/page.js create mode 100644 public/assets/js/backend/posts/sites.js diff --git a/public/assets/js/backend/posts/archives.js b/public/assets/js/backend/posts/archives.js new file mode 100644 index 000000000..69c7d3323 --- /dev/null +++ b/public/assets/js/backend/posts/archives.js @@ -0,0 +1,306 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'posts/archives/index', + add_url: 'posts/archives/add', + edit_url: 'posts/archives/edit', + del_url: 'posts/archives/del', + multi_url: 'posts/archives/multi', + table: 'archives', + } + }); + + var table = $("#table"); + //在普通搜索渲染后 + table.on('post-common-search.bs.table', function (event, table) { + Form.events.cxselect($("form", table.$commonsearch)); + }); + + table.on('post-body.bs.table', function (e, settings, json, xhr) { + $(".btn-editone", this) + .off("click") + .removeClass("btn-editone") + .addClass("btn-addtabs") + .prop("title", __('Edit')); + }); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'weigh', + sortOrder: 'desc', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('id'), operate: false}, + {field: 'channel_id', title: __('Channel_id'),formatter: function (value, row, index) { + return row.channel==null?'':'' + row.channel.name + ''; + }, + searchList: $.getJSON('posts/channel/getlist') + }, + {field: 'type', title: __('type'), formatter: function (value,row,index){ + return ''+value+''; + }, operate:false }, + {field: 'title', align:'left', title: __('title'), operate: 'LIKE %...%', + formatter: function(value,row, index){ + return value + (row.cover==''?'' : ' '); + }}, + {field: 'status', title: __('status'), searchList: {new: __('New'), normal: __('Normal'), hidden: __('Hidden')}, formatter: Table.api.formatter.status}, + {field: 'updatetime', title: __('updatetime'),operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime}, + {field: 'views', title: __('Views'), operate:false}, + {field: 'weigh', title: __('Weigh'), operate:false}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + //buttons: [ + // {name: 'edit', extend: 'title="'+ __('Edit')+'"', classname: 'btn btn-xs btn-success btn-addtabs', icon: 'fa fa-pencil', url: $.fn.bootstrapTable.defaults.extend.edit_url} + //], + formatter: Table.api.formatter.operate + } + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + + $(document).on('click', '.btn-move', function () { + var ids = Table.api.selectedids(table); + Layer.open({ + title: __('Move'), + content: Template("channeltpl", {}), + btn: [__('Move')], + yes: function (index, layero) { + var channel_id = $("select[name='channel']", layero).val(); + if (channel_id == 0) { + Toastr.error(__('Please select channel')); + return; + } + Fast.api.ajax({ + url: "posts/archives/move/ids/" + ids.join(","), + type: "post", + data: {channel_id: channel_id}, + }, function () { + table.bootstrapTable('refresh', {}); + Layer.close(index); + }); + }, + success: function (layero, index) { + } + }); + }); + + + }, + recyclebin: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + multi_url: 'posts/archives/multi', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: 'posts/archives/recyclebin', + pk: 'id', + sortName: 'weigh', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('id'), operate: false}, + {field: 'site_id', title: __('Site_id'), operate: false, formatter:function(value,row,index){ + return row.sites==null? __('Main site') : row.sites.name + ' (' + row.sites.domain + ')'; + }}, + {field: 'channel_id', title: __('channel'), + formatter: function(value,row,index){return row.channel.name;}, + searchList: $.getJSON('posts/channel/getlist') + }, + {field: 'title', title: __('title'), operate: 'LIKE %...%'}, + {field: 'deletetime', title: __('deletetime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime}, + {field: 'operate', width: '130px', title: __('Operate'), table: table, events: Table.api.events.operate, + buttons: [ + {name: 'Restore', text: __('Restore'), classname: 'btn btn-xs btn-info btn-restoreit', icon: 'fa fa-rotate-left', url: 'posts/archives/restore'}, + {name: 'Destroy', text: __('Destroy'), classname: 'btn btn-xs btn-danger btn-destroyit', icon: 'fa fa-times', url: 'posts/archives/destroy'} + ], + formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + + //清空回收站、批量/单个销毁 + $(document).on('click', '.btn-destroyall,.btn-destroy,.btn-destroyit', function (e) { + var that = this; + var top = $(that).offset().top - $(window).scrollTop(); + var left = $(that).offset().left - $(window).scrollLeft(); + //顶部按钮显示下按钮下方 + if(!$(that).hasClass('btn-destroyit')) top += $(that).height(); + //表格中的删除,显示于左侧 + if($(that).hasClass('btn-destroyit')) left -= 260; + if (top + 154 > $(window).height()) { + top = top - 154; + } + if ($(window).width() < 480) { + top = left = undefined; + } + var index=Layer.confirm(__('Are you sure you want to delete this item?'), + {icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true}, + function () { + var options = $(that).attr("href"); + if($(that).hasClass('btn-destroy')){ //批量销毁 + var ids = Table.api.selectedids(table); + options = {url: $(this).attr("href"), data: { ids: ids}}; + } + Fast.api.ajax($(that).attr("href"), function () { + Layer.close(index); + table.bootstrapTable('refresh'); + }); + }); + return false; + }); + //全部恢复、批量/单个恢复 + $(document).on('click', '.btn-restoreall,.btn-restoreit,.btn-restore', function (e) { + var options = $(this).attr("href"); + if($(that).hasClass('btn-restore')){ //批量恢复 + var ids = Table.api.selectedids(table); + options = {url: $(this).attr("href"), data: {ids: ids}}; + } + Fast.api.ajax($(this).attr("href"), function () { + table.bootstrapTable('refresh'); + }); + return false; + }); + }, + add: function () { + //$("form#add-form").data("validator-options", {ignore: ':hidden'}); + + $(document).on("change", "select[name='row[site_id]']", function () { + siteid=$(this).val(); + /* + $("#c-channel_id option:selected").prop("selected", false); + $("#c-channel_id option").addClass("hide"); + $("#c-channel_id option[data-siteid='" + $(that).val() + "']").removeClass("hide"); + + try{ + $("#c-channel_id").selectpicker("refresh"); + }catch(e){} + $('#c-channel_id').trigger('change'); + + Fast.api.ajax({url: 'posts/sites/get_site_langs', data: {"lang": $(that).val()}}, function (data) { + $("#language_choose").html(data.html); + Form.api.bindevent($("#language_choose")); + return false; + }); + */ + + $pid = $('#c-channel_id'); + + Fast.api.ajax({url: 'posts/sites/get_site_info', data: {"site_id": siteid}}, function (x,ret) { + if(ret.code=="1"){ + $pid.empty(); + $.each(ret.data.list, function(i,k){ + $pid.append(""); + }); + $pid.selectpicker("refresh"); + $pid.trigger('change'); + $("#language_choose").html(ret.data.lang); + } + Form.api.bindevent($("#language_choose")); + return false; + }); + + /* + var ml = $('option:selected', this).data('lang'); + if(ml==undefined) { + $('input[name="row[lang]"]').prop('disabled', false).closest('label').show(); + return false; + } + + $('input[name="row[lang]"]').prop('disabled', true).closest('label').hide(); + $.each(ml.split(','), function(key,value){ + $('input[name="row[lang]"][value="'+value+'"]').prop('disabled', false).closest('label').show(); + }); + */ + }); + + $(document).on("change", "select[name='row[channel_id]']", function () { + var model = $('option:selected',this).data('model'); + if($('input[name="row[type]"]').val()!=model) { + Fast.api.ajax({url: 'posts/archives/get_model_fields', data: {model: model}}, function (data) { + $("#extra").html(data.html); + Form.api.bindevent($("#extra")); + return false; + }); + } + $('input[name="row[type]"]').val(model); + }); + + Controller.edit(); + //if($('#c-site_id').size()>0) $('#c-site_id').trigger('change'); + $("select[name='row[channel_id]']").trigger('change'); + }, + edit: function () { + $("form").data("validator-options", {ignore: ':hidden'}); + + $.validator.config({ + rules: { + diyname: function (element) { + if (element.value.toString().match(/^\d+$/)) { + return __('Can not be digital'); + } + return $.ajax({ + url: 'posts/archives/check_element_available', + type: 'POST', + data: {name: element.name, value: element.value}, + dataType: 'json' + }); + } + } + }); + + + $(document).on("click", ".fieldlist .btn-append", function () { + var rel = parseInt($(this).closest("dl").attr("rel")) + 1; + var name = $(this).closest("dl").data("name"); + var objID = name.replace('[', '_').replace(']','_') + rel; + $(this).closest("dl").attr("rel", rel); + var appendHtml = '
    '; + appendHtml += ''; + appendHtml += ' '; + appendHtml += ' '; + appendHtml += ' '; + appendHtml += ' '; + appendHtml += '
    '; + $(appendHtml).insertBefore($(this).parent()); + Controller.api.bindevent(); + }); + $(document).on("click", ".fieldlist dd .btn-remove", function () { + var rel = parseInt($(this).closest("dl").attr("rel")); + rel = rel>1? rel-1: 0; + $(this).closest("dl").attr("rel", rel); + $(this).parent().off().remove(); + }); + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]"), function () { + var obj = top.window.$("#nav ul li.active"); + top.window.Toastr.success(__('Operation completed')); + top.window.$(".sidebar-menu a[url$='/posts/archives'][addtabs]").click(); + top.window.$(".sidebar-menu a[url$='/posts/archives'][addtabs]").dblclick(); + obj.find(".fa-remove").trigger("click"); + }); + } + } + }; + return Controller; +}); \ No newline at end of file diff --git a/public/assets/js/backend/posts/channel.js b/public/assets/js/backend/posts/channel.js new file mode 100644 index 000000000..fcfa96286 --- /dev/null +++ b/public/assets/js/backend/posts/channel.js @@ -0,0 +1,127 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'posts/channel/index', + add_url: 'posts/channel/add', + edit_url: 'posts/channel/edit', + del_url: 'posts/channel/del', + multi_url: 'posts/channel/multi', + table: 'channel', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + escape: false, + pk: 'id', + sortName: 'weigh', + pagination: false, + escape: false, + commonSearch: false, + search: false, + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'sites.name', title: __('Site_id')}, + {field: 'type', title: __('Type'), custom: {channel: 'info', list: 'success', redirect: 'primary'}, formatter: Table.api.formatter.flag}, + {field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.catename}, + {field: 'diyname', title: __('Redirect'), formatter:function(value,row,index){ + return value==''? '' : ''; + }}, + {field: 'flag', title: __('Flag'), operate: false, formatter: Table.api.formatter.flag}, + {field: 'weigh', title: __('Weigh'), visible:true}, + {field: 'archives.items', title: __('Items'), formatter:function(value,row,index){return (typeof value === 'number') ? value : 0;}}, + {field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + formatter: { + catename: function(value,row,index){ + imgtag = row.image ? '' : ''; + return value + ' ' + imgtag; + } + }, + bindevent: function () { + $.validator.config({ + rules: { + diyname: function (element) { + if (element.value.toString().match(/^\d+$/)) { + return __('Can not be digital'); + } + return $.ajax({ + url: 'posts/channel/check_element_available', + type: 'POST', + data: {id: $("#channel-id").val(), name: element.name, value: element.value}, + dataType: 'json' + }); + } + } + }); + $(document).on("click", "input[name='row[type]']", function () { + $(".tf").addClass("hidden"); + $(".tf.tf-" + $(this).val()).removeClass("hidden"); + $("select[name='row[model]']").trigger("change"); + $('#c-template').val($("input[name='row[model]']:checked").data($(this).val()+'tpl')); + }); + + $(document).on("change", "select[name='row[site_id]']", function () { + siteid=$(this).val(); + //$("#c-pid option:first").prop("selected", true); + //$("#c-pid option").addClass("hide"); + //$("#c-pid option[data-siteid='" + $(that).val() + "']").removeClass("hide"); + $pid = $('#c-pid'); + + Fast.api.ajax({url: 'posts/sites/get_site_info', data: {"site_id": siteid}}, function (x,ret) { + if(ret.code=="1"){ + $pid.empty(); + $pid.append(""); + $.each(ret.data.list, function(i,k){ + $pid.append(""); + }); + $pid.selectpicker("refresh"); + $pid.trigger('change'); + $("#language_choose").html(ret.data.lang); + } + Form.api.bindevent($("#language_choose")); + return false; + }); + + }); + $(document).on("change", "#c-pid", function () { + $("#c-model_"+$('option:selected', this).data('model')).prop("checked", true); + }); + + $(document).on("click", "input[name='row[model]']", function () { + type = $("input[name='row[type]']:checked").val(); + $('#c-template').val($(this).data(type+'tpl')); + }); + + $("select[name='row[model]']").trigger("change"); + $("input[name='row[type]']:checked").trigger("click"); + + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); \ No newline at end of file diff --git a/public/assets/js/backend/posts/modelx.js b/public/assets/js/backend/posts/modelx.js new file mode 100644 index 000000000..79f9b5af8 --- /dev/null +++ b/public/assets/js/backend/posts/modelx.js @@ -0,0 +1,242 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'posts/modelx/index', + add_url: 'posts/modelx/add', + edit_url: 'posts/modelx/edit', + del_url: 'posts/modelx/del', + multi_url: 'posts/modelx/multi', + table: 'postsmodelx', + } + }); + + var table = $("#table"); + + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + commonSearch: false, + search: false, + pagination: false, + columns: [ + [ + {field: 'name', title: __('Name')}, + {field: 'title', title: __('Title')}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + buttons: [ + {name: 'fieldset', extend: 'title="'+ __('Fieldset')+'"', classname: 'btn btn-xs btn-success btn-dialog', icon: 'fa fa-pencil', url: $.fn.bootstrapTable.defaults.extend.edit_url} + ], + formatter: function(value,row,index){ + $btns = $('
    ').html(Table.api.formatter.operate.call(this, value, row, index)); + $('.btn-editone', $btns).remove(); + return $btns.html(); + } + } + ] + ] + }); + + + $(document).on('click', '.btn-update', function (e) { + e.preventDefault(); + var inx = $(this).data('row'), status=$(this).data('status'); + var fun=function(ret,data){ + if(data!='success') return false; + table.bootstrapTable('updateRow', { + index:inx, + row:{'status': status} + }); + } + + Backend.api.ajax({url : 'posts/modelx/chgstatus', + data:{ids: $(this).data('updateid'), 'status':status } , + complete: fun + }); + }); + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + $(document).on('click', '.btn-param', function(e){ + e.preventDefault(); + + var fid = $(this).data('fieldid'); + var opennerLayer = parent.Layer.getFrameIndex(window.name); + var params = fid?'¶ms='+fid:''; + //编辑窗口layer的index + parent.Backend.api.open('posts/modelx/fieldset?zl='+opennerLayer+params, $(this).attr('title'), {callback: Controller.api.saveParams}); + + return false; + }); + $(document).on('click', '.btn-change', function(e){ + var that=this; + Backend.api.ajax({ + url: 'posts/modelx/chgstatus', + data: {"ids": $(that).data('ids'), "field": $(that).data('field')} + }, function(ret,data){ + if(data.code==1){ + if ($(that).find('i').hasClass('fa-toggle-on')){ + $(that).find('i').removeClass('fa-toggle-on').addClass('fa-toggle-off'); + }else{ + $(that).find('i').removeClass('fa-toggle-off').addClass('fa-toggle-on'); + } + } + }) + }); + $(document).on('click', '.btn-delparam', function(e){ + e.preventDefault(); + $(this).closest('li').off().remove(); + }); + $(document).on('click', '.btn-submit', function(e){ + e.preventDefault(); + //var data={fieldset: []}; + var data=[]; + if($('#fieldset li').size()>0){ + $('#fieldset li').each(function(i){ + //data.fieldset.push( $(this).data() ); + data.push($(this).data()); + }); + //$('input[name="row[extra]"]').val(JSON.stringify(data)); + + Backend.api.ajax({ + url: 'posts/modelx/fieldset', + data: {ids: $('input[name="ids"]').val(), fieldset: JSON.stringify(data)} + }, function(){ + var index = parent.Layer.getFrameIndex(window.name); + parent.Layer.close(index); + }); + } + //$('#edit-form').submit(); + }); + Controller.api.bindevent(); + }, + fieldset: function(){ + var fieldid = Fast.api.query('params'), + opennerLayer = Fast.api.query('zl'); + + $.validator.config({ + rules: { + fieldname: function (element) { + _value = $.trim(element.value.toString()); + if($(element).attr('name')=='field'){ + _old=$('[name="field-old"]').val(); + if(_value==_old) return ''; + } + if (_value.match(/^\d+$/)) { + return __('Can not be digital'); + } + if (_value.length<3 || _value.length>30) { + return __('Please enter a value between %d and %d characters long',3,30); + } + + let exists = false; + var c = parent.Layer.getChildFrame('body', opennerLayer); + $('#fieldset li',c).each(function(){ + if(_value == $(this).data('field')){ + exists=true; + return false; + } + }); + if(exists) return __('Field already exist'); + + return $.ajax({ + url: 'posts/modelx/check_element_available', + type: 'POST', + data: {"id": $("[name='ids']", c).val(), "value": _value}, + dataType: 'json' + }); + } + } + }); + + $('select#c-type').on('change', function(e){ + $('.tf').addClass("hidden"); + $('.tf.tf-' + $('option:selected', this).val()).removeClass("hidden"); + }); + + $(document).on('click', '.btn-reset', function(e){ + e.preventDefault(); + if(fieldid!=undefined){ + var c = parent.Layer.getChildFrame('body', opennerLayer); + $('input[name="fieldid"]').val(fieldid); + var arr = ['field','fieldname','type','value','rule','tip','extend','length','vars','float','min','max','length','success','error','status']; + $.each(arr, function(index,item){ + let val = $('#fieldset li#'+fieldid, c).attr('data-'+item+''); + val = val!=undefined ? val.indexOf('||') ? val.replace(/(\|\|)/g, '\r\n') : val : ''; + if(item=='status'){ + $('[name="'+item+'"][value="'+val+'"]').prop('checked',true); + }else{ + $('[name="'+item+'"]').val( val ); + } + }); + $('[name="field-old"]').val($('[name="field"]').val()); + } + }); + $('.btn-reset').trigger('click'); + $('select#c-type').trigger('change'); + + Form.api.submit = function(){ + var data={}; + $('select:visible,input:visible,textarea:visible,input[name="fieldid"],input[name="rule"]').each(function(){ + data[$(this).attr('name')]=$(this).val().replace(/([\r\n])/g, '||'); + }); + data['status']=$('input[name="status"]:checked').val(); + Backend.api.close(data); + return false; + } + Controller.api.bindevent(); + }, + api: { + formatter: { + status: function(value,row,index){ + var texts=['' + __('Enabled') + '  ', + '' + __('Disabled') + '  ']; + var btns = ['' + __('Enable') + '', + '' + __('Disable') + '']; + return (value==1)? texts[0]+btns[1] : texts[1]+btns[0]; + } + }, + saveParams: function(res){ + var lidata='', newli=false; + if(res.fieldid==''){ + res.fieldid = 'p'+new Date().getTime(); + newli=true; + } + $.each(res, function(key,value){ + lidata+= (key!='fieldid')? ' data-'+key+ (value==''?'':'='+value) :''; + }); + + var li = Template('fieldTpl', { + fieldid: res.fieldid, + field: res.field, + title: res.fieldname, + type: __(res.type), + status: __(res.status), + datapart: lidata + }); + + if(newli){ + $('#fieldset div#btnAddParam').before($(li)); + }else{ + $('#fieldset li#'+res.fieldid).off().before($(li)).remove(); + } + + Controller.api.bindevent(); + }, + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); \ No newline at end of file diff --git a/public/assets/js/backend/posts/page.js b/public/assets/js/backend/posts/page.js new file mode 100644 index 000000000..b5f68ea0e --- /dev/null +++ b/public/assets/js/backend/posts/page.js @@ -0,0 +1,74 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'posts/page/index', + add_url: 'posts/page/add', + edit_url: 'posts/page/edit', + del_url: 'posts/page/del', + multi_url: 'posts/page/multi', + table: 'page', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + sortName: 'weigh', + columns: [ + [ + {field: 'state', checkbox: true}, + {field: 'id', title: __('Id'), operate: false}, + {field: 'site_id', title: __('Site_id'), operate: false, formatter:function(value,row,index){ + return value==0? '-': row.sites.name; + }}, + {field: 'title', title: __('Title'), align:'left', operate: 'LIKE %...%', placeholder: '关键字,模糊搜索', + formatter: function(value,row,index){ + return value + (row.image==''?'' : ''); + }}, + {field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag, operate: false}, + {field: 'lang', title: __('lang'), formatter: Table.api.formatter.langs, operate: false}, + {field: 'views', title: __('Views'), operate: false}, + //{field: 'comments', title: __('Comments'), operate: false}, + {field: 'weigh', title: __('Weigh'), operate: false}, + {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {'normal': __('Normal'), 'hidden': __('Hidden')}, style: 'min-width:100px;'}, + {field: 'createtime', title: __('Create Time'), formatter: Table.api.formatter.datetime, operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"'}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ], + //普通搜索 + commonSearch: true, + titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索 + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + $(document).on("change", "#c-site_id", function () { + that=this; + Fast.api.ajax({url: 'posts/sites/get_site_langs', data: {"lang": $(that).val()}}, function (data) { + $("#language_choose").html(data.html); + Form.api.bindevent($("#language_choose")); + return false; + }); + }); + + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); \ No newline at end of file diff --git a/public/assets/js/backend/posts/sites.js b/public/assets/js/backend/posts/sites.js new file mode 100644 index 000000000..1d3dde859 --- /dev/null +++ b/public/assets/js/backend/posts/sites.js @@ -0,0 +1,116 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'posts/sites/index', + add_url: 'posts/sites/add', + edit_url: 'posts/sites/edit', + del_url: 'posts/sites/del', + multi_url: 'posts/sites/multi', + table: 'sites', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'username', title: __('User_id')}, + {field: 'name', title: __('name')}, + {field: 'domain', title: __('Domain')}, + {field: 'lang', title: __('Lang')}, + {field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, + {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + config: function(){ + + $.validator.config({ + rules: { + domain: function(ele){ + _value = $.trim(element.value.toString()); + if (!_value.match(/^[A-Za-z0-9]+$/)) { + return __('Please enter a valid URL'); + } + return $.ajax({ + url: 'posts/sites/check_element_available', + type: 'POST', + data: {"domain": _value}, + dataType: 'json' + }); + }, + url: function (element) { + _value = $.trim(element.value.toString()); + if (!_value.match(/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_\.]+$/)) { + return __('Please enter a valid URL'); + } + return $.ajax({ + url: 'posts/sites/check_element_available', + type: 'POST', + data: {"domain": _value}, + dataType: 'json' + }); + } + } + }); + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + $(document).on("click", ".fieldlist .btn-append", function () { + var rel = parseInt($(this).closest("dl").children('dd').length)-2; + $(this).closest("dl").attr("rel", rel); + $('
    ').insertBefore($(this).parent()); + }); + $(document).on("click", ".fieldlist dd .btn-remove", function () { + var that=this; + $(that).parent().remove(); + return; + }); + + $(document).on('click', 'input[name*="row[lang]"]', function(e){ + if($(this).val()=='zh-cn'){ + $(this).prop('checked', true); + return false; + } + $('#extraLanguage').html(''); + if($('input[name*="row[lang]"]:checked').length>1){ + $('input[name*="row[lang]"]:checked').each(function(){ + if($(this).val()!='zh-cn'){ + var language = $(this).val(); + var languageText = $(this).closest('label').text(); + var html = Template('seotpl', {lang: language, langName: languageText}); + $('#extraLanguage').append(html) + } + }); + } + }); + + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); \ No newline at end of file -- Gitee From 5766f4ea5b3034259872040df5ac6c9f2d93c496 Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:08:00 +0800 Subject: [PATCH 09/27] =?UTF-8?q?=E5=A4=9A=E7=AB=99=E7=82=B9CMS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/posts/Archives.php | 478 ++++++++++++++++++ .../admin/controller/posts/Channel.php | 220 ++++++++ application/admin/controller/posts/Modelx.php | 356 +++++++++++++ application/admin/controller/posts/Page.php | 156 ++++++ application/admin/controller/posts/Sites.php | 353 +++++++++++++ 5 files changed, 1563 insertions(+) create mode 100644 application/admin/controller/posts/Archives.php create mode 100644 application/admin/controller/posts/Channel.php create mode 100644 application/admin/controller/posts/Modelx.php create mode 100644 application/admin/controller/posts/Page.php create mode 100644 application/admin/controller/posts/Sites.php diff --git a/application/admin/controller/posts/Archives.php b/application/admin/controller/posts/Archives.php new file mode 100644 index 000000000..06d4eaf83 --- /dev/null +++ b/application/admin/controller/posts/Archives.php @@ -0,0 +1,478 @@ +model = model('Archives'); + + /* + if(!$this->auth->isSuperAdmin()){ + $this->model->where('site_id', 'in', function ($query) { + $admin = $this->auth->getUserInfo(); + $query->table(config("database.prefix") . 'sites')->where('user_id', $admin['id'])->field('id'); + }); + }*/ + } + + /** + * 读取栏目列表 + */ + private function initForm() + { + //从总后台进入 + if ($this->auth->isSuperAdmin()){ + $sitelist = model('Sites')->all(); + $this->view->assign('siteList', $sitelist); + $first_siteid = $sitelist?$sitelist[0]['id']:null; + } + //从站点后台进入 + else { + $this->view->assign('siteList', null); + $first_siteid = Session::get('user_site_id'); + } + $tree = Tree::instance(); + $tree->init(model('channel')->with('sites')->order('site_id asc,weigh desc,id desc')->select(), 'pid'); + $this->channellist = $tree->getTreeList($tree->getTreeArray(0), 'name'); + $channeldata = []; //0 => ['mode' => 'default','site_id'=>0, 'name' => __('None')]]; + foreach ($this->channellist as $k => $v) + { + if(isset($first_siteid) && !is_null($first_siteid) && $v['site_id']!=$first_siteid) { + //do nothing + }else { + $channeldata[$v['id']] = $v; + $channeldata[$v['id']]['disabled'] = 0; + $channeldata[$v['id']]['sitename'] = $v['sites']['name'] == '' ? __('Main site') : $v['sites']['name']; + if ($v['type'] != 'list') { + $channeldata[$v['id']]['disabled'] = 1; + } + } + } + $this->view->assign("channelList", $channeldata); + $this->view->assign("extra", ''); + $ml = Seven::build_langs('row[lang]',null,['siteid'=>$first_siteid]); + $this->view->assign('multilanguage',$ml); + } + + /** + * 查看 + */ + public function index() + { + //设置过滤方法 + $this->request->filter(['strip_tags']); + if ($this->request->isAjax()) + { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('pkey_name')) + { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(false, true); + $total = $this->model + ->where($where) + //->where('site_id', Session::get('admin.siteid')) + ->where('isDelete',0) + ->order($sort, $order) + ->count(); + + $tablename = $this->model->getQuery()->getTable(); + $list = $this->model + ->where($where) + //->where('site_id', Session::get('admin.siteid')) + ->where('isDelete',0) + ->with('channel') + ->field('subtitle,content',true, $tablename) + ->order($sort, $order) + ->limit($offset, $limit) + ->select(); + + $result = array("total" => $total, "rows" => $list); + + return json($result); + } + $this->initForm(); + return $this->view->fetch(); + } + + /** + * 回收站 + */ + public function recyclebin() + { + //设置过滤方法 + $this->request->filter(['strip_tags']); + if ($this->request->isAjax()) + { + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $total = $this->model + ->where('isDelete','>',0) + ->where($where) + ->order($sort, $order) + ->count(); + + $tablename = $this->model->getQuery()->getTable(); + $list = $this->model + ->where('isDelete','>',0) + ->where($where) + ->with('channel') + ->field('id,channel_id,title,cover,type,isDelete',false, $tablename) + ->order($sort, $order) + ->limit($offset, $limit) + ->select(); + + $result = array("total" => $total, "rows" => $list); + + return json($result); + } + return $this->view->fetch(); + } + + /** + * 添加 + */ + public function add() + { + if ($this->request->isPost()) + { + $params = $this->request->post("row/a"); + if ($params) + { + + if ($this->dataLimit) + { + $params[$this->dataLimitField] = $this->auth->id; + } + if(empty($params['updatetime'])) $params['updatetime'] = time(); + + if (!isset($params['site_id'])) { + $params['site_id'] = Session::get('user_site_id'); + } + $params['authorid']=Session::get("admin.id"); + + try + { + //是否采用模型验证 + if ($this->modelValidate) + { + $name = basename(str_replace('\\', '/', get_class($this->model))); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; + $this->model->validate($validate); + } + $result = $this->model->allowField(true)->save($params); + if ($result !== false) + { + Counter::create(['item_id'=>$this->model->id,'item_type'=>'archive','views'=>$params['views']]); + Modelx::saveExtraForm($params['type'],$this->model->id, $params); + $this->success(); + } + else + { + $this->error($this->model->getError()); + } + } + catch (\think\exception\PDOException $e) + { + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + + $this->initForm(); + return $this->view->fetch(); + } + + /** + * 编辑 + */ + public function edit($ids = NULL) + { + $row = $this->model->get($ids); + if (!$row) + $this->error(__('No Results were found')); + + if ($this->request->isPost()) + { + $params = $this->request->post("row/a"); + if ($params) + { + //没有自定义“修改时间”,将以实际修改时间为准 + if($params['updatetime_old']==$params['updatetime']){ + $params['updatetime']=time(); + }else{ + $params['updatetime']=strtotime($params['updatetime']); + } + unset($params['updatetime_old']); + try + { + //是否采用模型验证 + if ($this->modelValidate) + { + $name = basename(str_replace('\\', '/', get_class($this->model))); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate; + $row->validate($validate); + } + $result = $row->allowField(true)->save($params); + + if ($result !== false) + { + Counter::where(['item_id'=>$ids, 'item_type'=>'archive'])->update(['views'=>$params['views']]); + Modelx::saveExtraForm($row['type'], $ids, $params); + + $this->success(); + } + else + { + $this->error($row->getError()); + } + } + catch (think\exception\PDOException $e) + { + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + $this->initForm(); + $channeldata = []; //0 => ['mode' => 'default','site_id'=>0, 'name' => __('None')]]; + foreach ($this->channellist as $k => $v) + { + if($v['site_id']==$row['site_id']) { + $channeldata[$v['id']] = $v; + $channeldata[$v['id']]['disabled'] = 0; + if ($v['type'] != 'list') { + $channeldata[$v['id']]['disabled'] = 1; + } + if ($row['type'] != $v['model']) { + $channeldata[$v['id']]['disabled'] = 1; + } + } + } + $this->view->assign("channelList", $channeldata); + $this->view->assign("extra", Modelx::getExtraForm($row->type, $ids)); + $this->view->assign('multilanguage', Seven::build_langs('row[lang]',$row['lang'],['siteid'=>$row->site_id])); + + $this->view->assign("row", $row); + return $this->view->fetch(); + } + + /** + * 删除 + */ + public function del($ids = "") + { + if ($ids) + { + $pk = $this->model->getPk(); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) + { + $this->model->where($this->dataLimitField,'in', $adminIds); + } + $result=$this->model->where($pk, 'in', $ids)->update(['isDelete'=>time()]); + + if ($result!=false) + { + $this->success(); + } + else + { + $this->error(__('No rows were deleted')); + } + } + $this->error(__('Parameter %s can not be empty', 'ids')); + } + /* + * Destroy + * 销毁,无参数时清空回收站 + * 删除后一并将访问统计、模型表相对应数据清除 + */ + public function destroy($ids="") + { + $pk = $this->model->getPk(); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) + { + $this->model->where($this->dataLimitField, 'in', $adminIds); + } + + if($ids=='') + { + $this->model->where(['isDelete'=>['>',0]]); + } + else + { + $this->model->where($pk, 'in', $ids); + } + $list = $this->model->select(); + + if(!$list){ + $this->error(__('No rows were deleted')); + } + $count = 0; + foreach ($list as $k => $v) + { + $result = $v->delete(); + //删除相关附件,扩展&模型表 + if($result!=false) { + Hook::listen('archive_del', $v); + Counter::where(['item_type'=>'archive', 'item_id' => $v[$pk]])->delete(); + $count++; + } + } + if ($count) + { + $this->success(); + }else { + $this->error($this->model->getError()); + } + $this->error(__('Operation failed')); + } + + /** + * 还原 + */ + public function restore($ids = "") + { + $pk = $this->model->getPk(); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) + { + $this->model->where($this->dataLimitField, 'in', $adminIds); + } + if ($ids=='') + { + $this->model->where('isDelete','>', 0); + } else { + $this->model->where($pk, 'in', $ids); + } + $count = $this->model->restore('1=1'); + if ($count) + { + $this->success(); + } + $this->error(__('No rows were updated')); + } + + /** + * 批量移动到其他分类 + */ + public function move($ids="") + { + $ids = $ids ? $ids : $this->request->param("ids"); + $channel_id = $this->request->param('channel_id'); + $moveable = []; + + $dstCate = \app\admin\model\Channel::get($channel_id); + + if(!$dstCate){ + $this->success(__('You have no permission')); + } + if ($ids) + { + + $pk = $this->model->getPk(); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) + { + $this->model->where($this->dataLimitField, 'in', $adminIds); + } + $lists = $this->model->where($pk, 'in', $ids)->select(); + $count=0; + foreach($lists as $k => $v) + { + //忽略不同模型 + if ($v['type']==$dstCate['model'] && $v['channel_id']!=$dstCate['id']){ + $moveable[] = $v[$pk]; + } + } + \app\admin\model\AdminLog::setTitle(__('Move')); + foreach($moveable as $k=>$v) { + if(sesion('admin.id')!=1) { + $count += $this->model->where($pk, $v)->update(['channel_id' => $channel_id, 'site_id' => $dstCate['site_id']]); + }else { //非超级管理员,不能跨站移动 + $count += $this->model->where($pk, $v)->update(['channel_id' => $channel_id]); + } + } + if($count){ + $this->success(); + }else { + $this->success(__('No rows were updated')); + } + } + $this->success(__('Parameter %s can not be empty', 'ids')); + } + + + /** + * 输出模型表单 + */ + public function get_model_fields() + { + $result = ['name'=>'', 'html'=>'']; + if($this->request->isAjax()) + { + $modelname=$this->request->post('model'); + $form = Modelx::getExtraForm($modelname); + if($form != ''){ + $result['name'] = $modelname; + $result['html'] = $form; + } + $this->success('', '', $result); + } + } + + /** + * 校验字段的值的唯一性 + */ + public function check_element_available() + { + $field = $this->request->post('name'); + $value = $this->request->post('value'); + if($field && $value) { + //$params = ['diyname' => $value]; + $params = [preg_replace('/row\[(\w+)\]/i', '$1', $field) => $value]; + $result = $this->model->get($params); + if ($result != false) { + $this->error(__('Name already exist')); + } else { + $this->success(); + } + }else{ + $this->error(__('Parameter %s can not be empty', '')); + } + } +} diff --git a/application/admin/controller/posts/Channel.php b/application/admin/controller/posts/Channel.php new file mode 100644 index 000000000..e5fc2b169 --- /dev/null +++ b/application/admin/controller/posts/Channel.php @@ -0,0 +1,220 @@ +request->filter(['strip_tags']); + $this->model = model('Channel'); + + $tree = Tree::instance(); + $tree->init($this->model->order('weigh desc,id desc')->with('Sites')->with('archives')->select(), 'pid'); + + $this->channellist = $tree->getTreeList($tree->getTreeArray(0), 'name'); + } + + private function initForm(){ + //从总后台进入 + if ($this->auth->isSuperAdmin()){ + $sitelist = Sites::all(); + $this->view->assign('siteList', $sitelist); + $first_siteid = $sitelist?$sitelist[0]['id']:null; + } + //从站点后台进入 + else { + $this->view->assign('siteList', null); + } + + + $channeldata = [0 => ['site_id'=>0, 'name' => __('None')]]; + foreach ($this->channellist as $k => $v) + { + if(isset($first_siteid) && !is_null($first_siteid) && $v['site_id']!=$first_siteid) { + //do nothing + }else { + $channeldata[$v['id']] = $v; + } + } + $this->view->assign("parentList", $channeldata); + + /* + $tpldir=APP_PATH.'index/view/channel'; + $templatelist=scandir($tpldir); + foreach($templatelist as $k=>$file){ + if($file=='.' || $file=='..'){ + unset($templatelist[$k]); + }else { + $templatelist[$k] = str_replace('.html', '', $file); + } + } + $this->view->assign('templatelist', $templatelist); + */ + + $this->view->assign("flagList", $this->model->getFlagList()); + $this->view->assign("typeList", $this->model->getTypeList()); + $this->view->assign("modelList", model('PostsModelx')->all()); + + $ml = Seven::build_langs('row[lang]',null,['siteid'=>Session::get("admin.siteid")]); + $this->view->assign('multilanguage',$ml); + + } + + /** + * 查看 + */ + public function index() + { + if ($this->request->isAjax()) + { + $search = $this->request->request("search"); + //构造父类select列表选项数据 + $list = []; + if ($search) + { + foreach ($this->channellist as $k => $v) + { + if (stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) + { + $list[] = $v; + } + } + } + else + { + $list = $this->channellist; + } + $total = count($list); + $result = array("total" => $total, "rows" => $list); + + return json($result); + } + return $this->view->fetch(); + } + + /** + * Add + */ + public function add() + { + $this->initForm(); + return parent::add(); + } + + + /** + * 编辑 + */ + public function edit($ids = NULL) + { + $row = $this->model->get($ids); + if (!$row) + $this->error(__('No Results were found')); + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) + { + if (!in_array($row[$this->dataLimitField], $adminIds)) + { + $this->error(__('You have no permission')); + } + } + if ($this->request->isPost()) + { + $params = $this->request->post("row/a"); + if ($params) + { + /* + * 已经弃用,如果为了兼容老版可取消注释 + foreach ($params as $k => &$v) + { + $v = is_array($v) ? implode(',', $v) : $v; + } + */ + try + { + //是否采用模型验证 + if ($this->modelValidate) + { + $name = basename(str_replace('\\', '/', get_class($this->model))); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate; + $row->validate($validate); + } + $result = $row->allowField(true)->save($params); + if ($result !== false) + { + $this->success(); + } + else + { + $this->error($row->getError()); + } + } + catch (\think\exception\PDOException $e) + { + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + $this->initForm(); + $this->view->assign('multilanguage', Seven::build_langs('row[lang]',$row['lang'],['siteid'=>$row->site_id])); + $this->view->assign("row", $row); + return $this->view->fetch(); + } + + + + /** + * 返回栏目列表,供Ajax调用 + */ + public function getlist() + { + if($this->request->isAjax()){ + foreach ($this->channellist as $k => $v){ + $list[$v['id']]=$v['name']; + } + return json($list); + } + } + + /** + * 校验字段的值的唯一性 + */ + public function check_element_available() + { + $field = $this->request->post('name'); + $value = $this->request->post('value'); + if($field && $value) { + $params = [preg_replace('/row\[(\w+)\]/i', '$1', $field) => $value]; + $result = $this->model->get($params); + if ($result != false) { + $this->error(__('Name already exist')); + } else { + $this->success(); + } + }else{ + $this->error(__('Parameter %s can not be empty', '')); + } + } +} diff --git a/application/admin/controller/posts/Modelx.php b/application/admin/controller/posts/Modelx.php new file mode 100644 index 000000000..3162674ad --- /dev/null +++ b/application/admin/controller/posts/Modelx.php @@ -0,0 +1,356 @@ +model = model('PostsModelx'); + + } + + /** + * Index + */ + public function index() + { + //设置过滤方法 + $this->request->filter(['strip_tags']); + if ($this->request->isAjax()) + { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('pkey_name')) + { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $total = $this->model + ->where($where) + ->order($sort, $order) + ->count(); + + $list = $this->model + ->where($where) + ->field('extra', true) + ->order($sort, $order) + ->limit($offset, $limit) + ->select(); + + $result = array("total" => $total, "rows" => $list); + + return json($result); + } + $this->view->assign('typeList', $this->model->getTypeList()); + return $this->view->fetch(); + } + + /** + * Edit + */ + public function edit($ids = NULL) + { + $row = $this->model->get($ids); + if (!$row) + $this->error(__('No Results were found')); + if ($this->request->isPost()) + { + $params = $this->request->post("row/a"); + if ($params) + { + try + { + //是否采用模型验证 + if ($this->modelValidate) + { + $name = basename(str_replace('\\', '/', get_class($this->model))); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate; + $row->validate($validate); + } + $result = $row->allowField(true)->save($params); + if ($result !== false) + { + $this->success(); + } + else + { + $this->error($row->getError()); + } + } + catch (think\exception\PDOException $e) + { + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + $params = json_decode($row['extra'], true); + unset($row['extra']); + $row['extra']=$params; + $this->view->assign("row", $row); + $this->view->assign('typeList', $this->model->getTypeList()); + return $this->view->fetch(); + } + + + /** + * 字段设置 + */ + public function fieldset() + { + if($this->request->isAjax()) { + $ids = $this->request->post('ids/a'); + $fieldset = $this->request->post('fieldset'); + if(!empty($fieldset)){ + $row = $this->model->get($ids); + if(!$row) + $this->error(__('No Results were found')); + + $modelx = $row['name']; + $modelname = $row['title']; + $tablename = config('database.prefix') . 'extra' . $row->name; + + //do check && make sql + $json = json_decode($fieldset,true); + $sql = $cols = []; + foreach ($json as $k=>$v){ + switch (strtolower($v['type'])){ + case "string": + $v['length'] = isset($v['length']) ? $v['length']>0 && $v['length']<256 ? $v['length'] : 255: 255; + $cols[$v['field']] = 'varchar(' . $v['length'] . ')'; + $sql[$v['field']] = "`". $v['field'] . "` VARCHAR(" . $v['length'] . ") NOT NULL DEFAULT '' COMMENT '". $v['fieldname'] . "' "; + break; + case "number": + $v['float'] = isset($v['float']) ? $v['float']<=0? 0 : $v['float']<3 ? $v['float']: 2: 0; + if($v['float']==0) { + $sql[$v['field']] = "`" . $v['field'] . "` INT(10) NOT NULL DEFAULT '0' COMMENT '". $v['fieldname'] . "' "; + $cols[$v['field']] = 'int(10)'; + }else{ + $cols[$v['field']] = 'float(10,'.$v['float'].')'; + $sql[$v['field']] = "`" . $v['field'] . "` FLOAT(10,". $v['float'] . ") NOT NULL DEFAULT '0.0' COMMENT '". $v['fieldname'] . "' "; + } + break; + case "datetime": + $sql[$v['field']] = "`". $v['field'] . "` INT(10) NOT NULL DEFAULT '0' COMMENT '". $v['fieldname'] . "' "; + $cols[$v['field']] = 'int(10)'; + break; + case "textarea": case"richtext": case"editor": + $sql[$v['field']] = "`". $v['field'] . "` TEXT NOT NULL DEFAULT '' COMMENT '". $v['fieldname'] . "' "; + $cols[$v['field']] = 'text'; + break; + case "images": case"files": + $sql[$v['field']] = "`". $v['field'] . "` TEXT NOT NULL DEFAULT '' COMMENT '". $v['fieldname'] . "' "; + $cols[$v['field']] = 'text'; + break; + case "image": case "file": + $sql[$v['field']] = "`". $v['field'] . "` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '". $v['fieldname'] . "' "; + $cols[$v['field']] = 'varchar(255)'; + break; + case "select": case "selects": case "checkbox": case"radio": + $sql[$v['field']] = "`". $v['field'] . "` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '". $v['fieldname'] . "' "; + $cols[$v['field']] = 'varchar(255)'; + break; + default: + break; + } + } + //save + $result = $row->save(['extra'=>$fieldset]); + if ($result === false){ + $this->error($row->getError()); + } + unset($row); + + if(Db::query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='". config('database.database') . "' AND TABLE_NAME='". $tablename . "';")) + { + $columns=[]; + foreach (Db::query("SHOW COLUMNS FROM `" . $tablename . "`;") as $k=>$v){ + if($v['Field']!='id' && $v['Field']!='item_id'){ + $columns[$v['Field']] = $v['Type']; + } + } + + $arr = array_diff_key($cols, $columns); + $alterSql = []; + foreach ($arr as $k=>$v){ + $alterSql[$k] = " ADD COLUMN " . $sql[$k]; + unset($cols[$k]); + } + $arr=array_intersect_assoc($columns, $cols); + foreach ($arr as $k => $v) { + unset($cols[$k]); + unset($columns[$k]); + } + foreach($columns as $k=>$v){ + if(isset($cols[$k])) { + $alterSql[$k] = " MODIFY COLUMN " . $sql[$k] ; + } else { + $alterSql[$k] = " DROP COLUMN `" . $k . "` "; + } + } + $execSql = "ALTER TABLE `".$tablename."` ". join(',',$alterSql) . ";"; + }else { + $fieldset = join(", ", $sql); + $execSql = <<error($e->getMessage()); + } + + } catch (\think\exception\PDOException $e) { + $this->error($e->getMessage()); + } + $this->success(); + } + } + + //$this->view->assign("params", $params); + $this->view->assign('typeList', $this->model->getTypeList()); + return $this->view->fetch(); + } + + /** + * 修改字段状态 + */ + public function chgstatus($ids=null) + { + if ($this->request->isAjax()) + { + $row = $this->model->get($ids); + if (!$row) + $this->error(); + + if(empty($row['extra'])) + $this->error(); + + $field = $this->request->post('field'); + $params = json_decode($row['extra'],true); + + foreach($params as $k => &$v){ + if($v['field']==$field){ + $v['status'] = $v['status']=='hidden' ? 'normal' : 'hidden'; + } + } + $params = json_encode($params, JSON_UNESCAPED_UNICODE); + + $result = $row->save(['extra'=>$params]); + if ($result !== false) + { + $this->success(); + } + else + { + $this->error($row->getError()); + } + } + } + + public function rulelist() + { + $search = $this->request->post('searchValue'); + $rules = $this->model->getRules(); + if($search){ + $result[] = ['id'=> $search, 'name'=> $rules[$search]]; + }else { + foreach ($rules as $k => $v) { + $result[] = ['id' => $k, 'name' => $v]; + } + } + return ['list'=>$result]; + + } + + /** + * 检查模型名称是否可用 + */ + public function check() + { + $params = $this->request->post("row/a"); + if ($params) + { + + $result = $this->model->get($params); + if ($result!=false) + { + $this->error( __('Name already exist')); + } + else + { + $this->success(); + } + } + else + { + $this->error( __('Invalid parameters')); + } + } + + public function check_element_available() + { + if($this->request->isAjax()) { + $modelid = $this->request->post('id'); + $val = $this->request->post('value'); + + $m = $this->model->get($modelid); + $tablename = config('database.prefix') . 'extra' . $m->name; + + if (Db::query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='" . config('database.database') . "' AND TABLE_NAME='" . $tablename . "';")) { + + foreach (Db::query("SHOW COLUMNS FROM `" . $tablename . "`;") as $k => $v) { + if ($v['Field'] == $val) { + //return json(['error' => __('Field already exist')]); + $this->error(__('Field already exist')); + } + } + } + //return json(['ok' => '']); + $this->success(); + } + } +} diff --git a/application/admin/controller/posts/Page.php b/application/admin/controller/posts/Page.php new file mode 100644 index 000000000..40a65c011 --- /dev/null +++ b/application/admin/controller/posts/Page.php @@ -0,0 +1,156 @@ +model = model('Page'); + } + + /** + * 查看 + */ + public function index() + { + //设置过滤方法 + $this->request->filter(['strip_tags']); + if ($this->request->isAjax()) + { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('pkey_name')) + { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $total = $this->model + ->where($where) + ->order($sort, $order) + ->count(); + + $list = $this->model + ->where($where) + ->with('sites') + ->field('keywords,description,content', true) + ->order($sort, $order) + ->limit($offset, $limit) + ->select(); + + $result = array("total" => $total, "rows" => $list); + + return json($result); + } + return $this->view->fetch(); + } + + + /** + * 添加/修改 通用参数 + */ + private function initForm() + { + //从总后台进入 + if ($this->auth->isSuperAdmin()){ + $sitelist = Sites::all(); + $this->view->assign('siteList', $sitelist); + $first_siteid = $sitelist?$sitelist[0]['id']:null; + } + //从站点后台进入 + else { + $this->view->assign('siteList', null); + $first_siteid = \think\Session::get('user_site_id'); + } + $this->view->assign("flagList", ['hot' => __('Hot'), 'recommend' => __('Recommend')] ); + + $ml = Seven::build_langs('row[lang]',null,['siteid'=>$first_siteid]); + + $this->view->assign('multilanguage',$ml); + } + + /** + * Add + */ + public function add() + { + $this->initForm(); + return parent::add(); + } + + /** + * 编辑 + */ + public function edit($ids = NULL) + { + $row = $this->model->get($ids); + if (!$row) + $this->error(__('No Results were found')); + + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds)) + { + if (!in_array($row[$this->dataLimitField], $adminIds)) + { + $this->error(__('You have no permission')); + } + } + if ($this->request->isPost()) + { + $params = $this->request->post("row/a"); + if ($params) + { + foreach ($params as $k => &$v) + { + $v = is_array($v) ? implode(',', $v) : $v; + } + try + { + //是否采用模型验证 + if ($this->modelValidate) + { + $name = basename(str_replace('\\', '/', get_class($this->model))); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate; + $row->validate($validate); + } + $result = $row->allowField(true)->save($params); + if ($result !== false) + { + $this->success(); + } + else + { + $this->error($row->getError()); + } + } + catch (think\exception\PDOException $e) + { + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + $this->view->assign("row", $row); + $this->initForm(); + $this->view->assign('multilanguage', Seven::build_langs('row[lang]',$row['lang'])); + return $this->view->fetch(); + } + +} diff --git a/application/admin/controller/posts/Sites.php b/application/admin/controller/posts/Sites.php new file mode 100644 index 000000000..d1906b8d5 --- /dev/null +++ b/application/admin/controller/posts/Sites.php @@ -0,0 +1,353 @@ +model = model('Sites'); + + $modulelist = []; + $this->view->assign('moduleList', $modulelist); + $this->view->assign('hostname', config('url_domain_root')); + } + + /** + * Index + */ + public function index() + { + //从站点管理登录,进入自己的站点配置页 + if(Session::has("user_site_id")) { + $this->redirect('posts/sites/config?addtabs=1'); + } + //超级管理员从总后台登录 + else { + //设置过滤方法 + $this->request->filter(['strip_tags']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('pkey_name')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $total = $this->model + ->where($where) + ->order($sort, $order) + ->count(); + + $list = $this->model + ->alias('s') + ->where($where) + ->join('admin a','a.id=s.user_id') + ->field('a.username, s.*') + ->order($sort, $order) + ->limit($offset, $limit) + ->select(); + + $result = array("total" => $total, "rows" => $list); + + return json($result); + } + return $this->view->fetch(); + + } + } + + /** + * Config + */ + public function config() + { + $row = $this->model->get(Session::get("user_site_id")); + + $settings = ['seo' => [ + 'zh-cn' => [ + 'title'=>'', + 'keywords'=>'', + 'description'=>'' + ] + ], 'custom' => '']; + + if($this->request->isPost()){ + + $params = $this->request->post("row/a"); + if ($params) { + foreach ($params as $k => $v) { + if( in_array($k, ['name','domain','lang'])){ + if($k=='lang') + $params[$k] = implode(',', $v); + }else{ + unset($params[$k]); + } + } + $seo = $this->request->post("seo/a"); + $custom = $this->request->post("custom/a"); + if ($seo) { + $settings['seo'] = json_encode($seo, JSON_UNESCAPED_UNICODE); + } + if ($custom) { + $arr = []; + foreach ($custom as $k => $v) { + $arr[$v['field']] = $v['value']; + } + $settings['custom'] = json_encode($arr, JSON_UNESCAPED_UNICODE); + } + if($row) $params['id'] = $row['id']; + try + { + //是否采用模型验证 + if ($this->modelValidate) + { + $name = basename(str_replace('\\', '/', get_class($this->model))); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; + $this->model->validate($validate); + } + $result = $this->model->allowField(true)->save($params); + + if ($result !== false) + { + $this->model->config()->save($settings); + $this->model->refreshRulesCache(); + $this->success(); + } + else + { + $this->error($this->model->getError()); + } + } + catch (\think\exception\PDOException $e) + { + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + + $this->view->assign('row', $row); + + if($row) { + $settings['seo'] = !empty($row->config->seo) ? json_decode($row->config->seo, true) : null; + $settings['custom'] = !empty($row->config->custom) ? json_decode($row->config->custom, true) : null; + } + $this->view->assign('settings', $settings); + $this->view->assign('multilanguage', Seven::build_langs('row[lang]', $row?$row['lang']:'', ['type'=>'checkbox'])); + return $this->view->fetch(); + + } + + /** + * Add + */ + public function add() + { + if(!$this->auth->isSuperAdmin()) { + $this->error(__('You have no permission')); + } + if ($this->request->isPost()) + { + $params = $this->request->post("row/a"); + if ($params) + { + foreach ($params as $k => &$v) + { + $v = is_array($v) ? implode(',', $v) : $v; + } + + $seo = $this->request->post("seo/a"); + $custom = $this->request->post("custom/a"); + $settings = ['seo'=>'', 'custom'=>'']; + if($seo){ + $settings['seo'] = json_encode($seo, JSON_UNESCAPED_UNICODE); + } + if($custom){ + $arr = []; + foreach ($custom as $k=>$v){ + $arr[ $v['field'] ] = $v['value']; + } + $settings['custom'] = json_encode($arr, JSON_UNESCAPED_UNICODE); + } + + try + { + //是否采用模型验证 + if ($this->modelValidate) + { + $name = basename(str_replace('\\', '/', get_class($this->model))); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; + $this->model->validate($validate); + } + $result = $this->model->allowField(true)->save($params); + + if ($result !== false) + { + $this->model->config()->save($settings); + $this->model->refreshRulesCache(); + $this->success(); + } + else + { + $this->error($this->model->getError()); + } + } + catch (\think\exception\PDOException $e) + { + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + $this->view->assign('multilanguage', Seven::build_langs('row[lang]', '', ['type'=>'checkbox'])); + return $this->view->fetch(); + } + + /** + * 编辑 + */ + public function edit($ids = NULL) + { + if(!$this->auth->isSuperAdmin()) { + $this->error(__('You have no permission')); + } + $row = $this->model->get($ids); + if (!$row) + $this->error(__('No Results were found')); + + + if ($this->request->isPost()) + { + $params = $this->request->post("row/a"); + if ($params) + { + //foreach ($params as $k => &$v) + //{ + // $v = is_array($v) ? implode(',', $v) : $v; + //} + $seo = $this->request->post("seo/a"); + $custom = $this->request->post("custom/a"); + $settings = ['seo'=>'', 'custom'=>'']; + if($seo){ + $settings['seo'] = json_encode($seo, JSON_UNESCAPED_UNICODE); + } + if($custom){ + $arr = []; + foreach ($custom as $k=>$v){ + $arr[ $v['field'] ] = $v['value']; + } + $settings['custom'] = json_encode($arr, JSON_UNESCAPED_UNICODE); + } + + try + { + //是否采用模型验证 + if ($this->modelValidate) + { + $name = basename(str_replace('\\', '/', get_class($this->model))); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate; + $row->validate($validate); + } + $result = $row->allowField(true)->save($params); + if ($result !== false) + { + $row->config()->save($settings); + $this->model->refreshRulesCache(); + $this->success(); + } + else + { + $this->error($row->getError()); + } + } + catch (think\exception\PDOException $e) + { + $this->error($e->getMessage()); + } + } + $this->error(__('Parameter %s can not be empty', '')); + } + $arr['seo'] = !empty($row->config->seo) ? json_decode($row->config->seo,true) : null; + $arr['custom'] = !empty($row->config->custom) ? json_decode($row->config->custom,true) : null; + $this->view->assign("row", $row); + $this->view->assign('settings', $arr); + $this->view->assign('multilanguage', Seven::build_langs('row[lang]', $row['lang'], ['type'=>'checkbox'])); + return $this->view->fetch(); + } + + public function get_site_langs() + { + $value = $this->request->post('lang'); + if($this->request->isAjax()){ + $result['html'] = Seven::build_langs('row[lang]',null,['siteid'=>$value]); + $this->success('','', $result); + } + } + + /** + * 返回站点的栏目列表/可选语言版本 + * 供栏目和文章的 添加&编辑 ajax调用 + */ + public function get_site_info() + { + if($this->request->isAjax()) { + $site_id = $this->request->post('site_id'); + $result['lang'] = Seven::build_langs('row[lang]', null, ['siteid' => $site_id]); + $result['list'] = []; + $list = model('channel')->where('site_id', $site_id)->field('id,pid,type,name')->select(); + if ($list) { + $tree = \fast\Tree::instance(); + $tree->init($list, 'pid'); + $result['list'] = $tree->getTreeList($tree->getTreeArray(0), 'name'); + foreach ($result['list'] as $k => &$v) { + $v['disabled'] = 0; + if ($v['type'] != 'list') { + $v['disabled'] = 1; + } + } + } + $this->success('', null, $result); + } + } + + public function check_element_available() + { + $params = $this->request->post("domain"); + //保留域名 + $invail = ['www','admin']; + if ($params) + { + if (in_array($params, $invail)) { + $this->error( __('Domain already exist')); + } + $result = $this->model->get(['domain'=>$params]); + if ($result!=false) + { + $this->error( __('Domain already exist')); + } + else + { + $this->success(); + } + } + else + { + $this->error( __('Invalid parameters')); + } + } + +} -- Gitee From 08355f6d31640a78fc7e50a222314f55f3148d50 Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:08:42 +0800 Subject: [PATCH 10/27] =?UTF-8?q?selectpage=E5=8F=AA=E4=BF=9D=E7=95=99id?= =?UTF-8?q?=E5=92=8Cusername=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/auth/Admin.php | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/application/admin/controller/auth/Admin.php b/application/admin/controller/auth/Admin.php index 73d3bf55f..c7aae6a77 100644 --- a/application/admin/controller/auth/Admin.php +++ b/application/admin/controller/auth/Admin.php @@ -107,6 +107,32 @@ class Admin extends Backend return $this->view->fetch(); } + /** + * 管理员列表 + */ + public function selectpage() + { + if ($this->request->isAjax()) + { + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $total = $this->model + ->where($where) + ->order($sort, $order) + ->count(); + + $list = $this->model + ->where($where) + ->field(['id', 'username as name']) + ->order($sort, $order) + ->limit($offset, $limit) + ->select(); + + $result = array("total" => $total, "list" => $list); + + return json($result); + } + return null; + } /** * 添加 */ -- Gitee From 91915bcff87b2a32389f41e3e93d9931922521ac Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:09:38 +0800 Subject: [PATCH 11/27] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=8C=85=E6=97=B6=E5=85=B3=E9=97=ADapp=5Ftrace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Ajax.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index 5c40c065b..00f6f9893 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -33,6 +33,7 @@ class Ajax extends Backend */ public function lang() { + \think\Config::set('app_trace', false); header('Content-Type: application/javascript'); $controllername = input("controllername"); //默认只加载了控制器对应的语言名,你还根据控制器名来加载额外的语言包 -- Gitee From d8fb4f188435cc8c342bef41990a3d4d3a797a0d Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:10:15 +0800 Subject: [PATCH 12/27] =?UTF-8?q?=E5=A4=9A=E7=AB=99=E7=82=B9CMS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/model/Archives.php | 77 ++++++ application/admin/model/Channel.php | 114 +++++++++ application/admin/model/Page.php | 39 +++ application/admin/model/PostsModelx.php | 302 ++++++++++++++++++++++++ application/admin/model/Sites.php | 16 ++ 5 files changed, 548 insertions(+) create mode 100644 application/admin/model/Archives.php create mode 100644 application/admin/model/Channel.php create mode 100644 application/admin/model/Page.php create mode 100644 application/admin/model/PostsModelx.php create mode 100644 application/admin/model/Sites.php diff --git a/application/admin/model/Archives.php b/application/admin/model/Archives.php new file mode 100644 index 000000000..53d46b97e --- /dev/null +++ b/application/admin/model/Archives.php @@ -0,0 +1,77 @@ +where('site_id', Session::get("user_site_id")); + } + //$query->alias('a')->join('counter c', 'c.item_id=a.id')->where('c.item_type','archive')->field('c.views, c.good, c.bad, c.comments'); + } + + public function Sites() + { + return $this->belongsTo('Sites', 'site_id')->field('id,name,domain'); + } + public function Channel() + { + return $this->belongsTo('Channel', 'channel_id')->field('id,name'); + } + + protected static function init() + { + self::afterInsert(function ($row) { + $pk = $row->getPk(); + $row->getQuery()->where($pk, $row[$pk]) + ->update(['weigh' => $row[$pk]]); + }); + + self::beforeDelete(function($row){ + if (intval($row->isDelete)==0) { + $row->isDelete = time(); + $row->save(); + return false; + } + }); + } + + public function restore() + { + return $this->update(['isDelete'=>0]); + } + + public function getViewsAttr($value,$data) + { + if(!isset($data['id'])) return 0; + $result = Counter::get(['item_id'=>$data['id']]); + return $result?$result['views']:0; + } + +} diff --git a/application/admin/model/Channel.php b/application/admin/model/Channel.php new file mode 100644 index 000000000..e12d43ef8 --- /dev/null +++ b/application/admin/model/Channel.php @@ -0,0 +1,114 @@ +where(['site_id'=> Session::get("user_site_id")]); + } + } + + + public function Sites() + { + return $this->belongsTo('Sites', 'site_id')->field('id,name'); + } + + public function Archives() + { + //return $this->belongsTo('Archives', 'id', 'channel_id')->field('channel_id,count(1) as items'); + return $this->hasOne('Archives','channel_id','id')->field('channel_id,count(1) as items'); + } + + /** + * 读取分类类型 + * @return array + */ + public static function getTypeList() + { + //$typelist = config('site.categorytype'); + return ['channel'=>__('Channel'), 'list'=>__('List'), 'redirect'=>__('Redirect')]; + } + + + public static function getFlagList() + { + return ['hot' => __('Hot'), 'recommend' => __('Recommend')]; + } + + public function getFlagTextAttr($value, $data) + { + if(!isset($data['flag'])) return ''; + $value = $value ? $value : $data['flag']; + $valueArr = explode(',', $value); + $list = $this->getFlagList(); + return implode(',', array_intersect_key($list, array_flip($valueArr))); + } + + /** + * 读取分类列表 + * @param string $type 指定类型 + * @param string $status 指定状态 + * @return array + */ + public static function getChannelArray($type = NULL, $status = NULL) + { + $list = collection(self::where(function($query) use($type, $status) { + if (!is_null($type)) + { + $query->where('type', '=', $type); + } + if (!is_null($status)) + { + $query->where('status', '=', $status); + } + })->order('weigh', 'desc')->select())->toArray(); + return $list; + } + + + /* + protected static function init() + { + self::afterInsert(function ($row) { + $pk = $row->getPk(); + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); + }); + } + */ + + + + + + + + + +} diff --git a/application/admin/model/Page.php b/application/admin/model/Page.php new file mode 100644 index 000000000..d2f90bd34 --- /dev/null +++ b/application/admin/model/Page.php @@ -0,0 +1,39 @@ +where('site_id', Session::get("user_site_id")); + } + } + + public function Sites() + { + return $this->belongsTo('Sites', 'site_id')->field('id,name'); + } + + +} diff --git a/application/admin/model/PostsModelx.php b/application/admin/model/PostsModelx.php new file mode 100644 index 000000000..64940d9c3 --- /dev/null +++ b/application/admin/model/PostsModelx.php @@ -0,0 +1,302 @@ + __('String'), + 'text' => __('Text'), + 'richtext' => __('Richtext'), + 'number' => __('Number'), + 'datetime' => __('Datetime'), + 'select' => __('Select'), + 'selects' => __('Selects'), + 'image' => __('Image'), + 'images' => __('Images'), + 'file' => __('File'), + 'files' => __('Files'), + 'checkbox' => __('Checkbox'), + 'radio' => __('Radio'), + ]; + return $typeList; + } + + /** + * 校验规则名称 + */ + public static function getRules(){ + return [ + "required" => __('Required'), + "digits"=>"数字", + "letters"=>"字母", + "date"=>"日期", + "time"=>"时间", + "email"=>"邮箱", + "url"=>"网址", + "qq"=>"QQ号", + "IDcard"=>"身份证", + "tel"=>"座机电话", + "mobile"=>"手机号", + "zipcode"=>"邮编", + "chinese"=>"中文", + "username"=>"用户名", + "password"=>"密码" + ]; + } + + /** + * 保存模型数据 + * @param string $modelname 模型 + * @param int $archiveid 文章ID + * @param array $params 表单数据 + * @return bool + */ + public static function saveExtraForm($modelname='', $archiveid=0, $params=[]) + { + if (empty($modelname) || $archiveid==0 || empty($params)) return false; + + $mod = self::get(['name' => $modelname]); + if (!$mod) return false; + + $fields = json_decode($mod['extra'],true); + + //格式化模型数据 + foreach ($fields as $k => $v) { + if ($v['type']=='file' || $v['type']=='files'){ + foreach($params[$v['field']] as $item=>&$val){ + if($val['url']==''){ + unset($params[$v['field']][$item]); + } + } + $params[$v['field']] = empty($params[$v['field']])? '' + : json_encode($params[$v['field']], JSON_UNESCAPED_UNICODE); + } + } + + foreach ($params as $k => &$v) + { + $v = is_array($v) ? implode(',', $v) : $v; + } + $params['item_id'] = $archiveid ; + + $row = model('extra'.$modelname)->get(['item_id'=>$archiveid]); + if($row) { + $row->allowField(true)->save($params); + }else { + model('extra'.$modelname)->allowField(true)->save($params); + } + + return true; + } + + /** + * 生成模型表单 + * @param $modelname 模型名称 + * @param $archiveid 文章ID + * @return string + */ + public static function getExtraForm($modelname, $archiveid=null) + { + $mod = self::get(['name'=>$modelname]); + if(!$mod) return ''; + if(!isset($mod['extra']) || empty($mod['extra'])) return ''; + + $row = empty($archiveid)? null : + model('extra'.$mod['name'])->get(['item_id'=> $archiveid]); + + $params = json_decode($mod['extra'], true); + + $controls = $controlid = $cssname = ''; + $controlPrefix = 'row'; + $btnUpload = __('Upload'); $btnChoose = __('Choose'); $btnAppend = __('Append'); + $input = ''; + $textarea = ''; + $checkbox = ''; + $radio = ''; + + $html = []; + foreach ($params as $k => $v){ + if(isset($v['status']) && $v['status']=='hidden') continue; + $defaultValue = !isset($row[$v['field']]) ? $v['value'] + : empty($row[$v['field']]) ? $v['value'] : $row[$v['field']] ; + + $controlid = $v['field'] . substr(md5($v['field'].microtime()),0,6); + + switch(strtolower($v['type'])){ + case 'string': + case 'number': + case 'datetime': + $cssname = $v['type']=='datetime'?'datetimepicker':''; + $controls = sprintf($input, ($v['type']=='number'?'number':'text'), $controlid, $v['field'], $defaultValue, $cssname, $v['rule'], $v['tip'], $v['extend']); + break; + case 'text': + case 'richtext': + $cssname = $v['type']=='richtext'?'editor':''; + $controls = sprintf($textarea, $v['field'], $controlid, $cssname, $v['rule'], $v['tip'], $v['extend'], $defaultValue); + break; + case 'checkbox': + case 'radio': + $items = explode('||', $v['vars']); + $controls=''; + $defaultValue=explode(',',$defaultValue); + for($i=0;$i%s', $v['type'], $controls); + break; + case 'select': + case 'selects': + $items = explode('||', $v['vars']); + $options = ''; + $defaultValue=explode(',',$defaultValue); + for($i=0;$i%s', $item[1], $isChecked, $item[0]); + } + + $extend = $v['type']=='selects'?'multiple ':' '; + $extend .= $v['extend']; + $controls = << + {$options} + +EOF; + break; + case 'image': + case 'images': + $multi = $v['type']=='image'? 'false' : 'true'; + $controls = << + + + +
      + +EOF; + + break; + case 'file': + case 'files': + $mimetype = '*/*'; + $lab1 = __('Title'); $lab2 = __('File'); + + $edit = ''; + $index=0; + if (!empty($defaultValue)){ + $defaultValue=json_decode($defaultValue, true); + foreach($defaultValue as $key => $file) + { + $controlid = substr($v['type'],0,1).substr(md5($file['id'].microtime()),0,6); + + if ($v['type']=='file'){ + $btns = << + +EOF; + }else { + $btns = << +EOF; + } + + $edit .= << + + + + {$btns} + +EOF; + $index++; + } + } + else { + $controlid = substr($v['type'],0,1).substr(md5(microtime()),0,5); + $edit = << + + + + + + +EOF; + } + + $append = $v['type']=='files'?'
      '.$btnAppend.'
      ':''; + + $controls = << +
      +
      + {$lab1} + {$lab2} +
      + {$edit} + {$append} +
      + +EOF; + + $controlid = 'none'; + break; + } + + $html[] = << + +
      + {$controls} +
      + +EOF; + } + return sprintf('
      %s
      ', $mod['name'], implode('',$html)); + } + + + + + + +} diff --git a/application/admin/model/Sites.php b/application/admin/model/Sites.php new file mode 100644 index 000000000..876153cc3 --- /dev/null +++ b/application/admin/model/Sites.php @@ -0,0 +1,16 @@ + + * @Since: 2018/2/5 15:37 + */ + +namespace app\admin\model; + + +use think\Model; + +class Sites extends Model +{ + +} \ No newline at end of file -- Gitee From 812bbb55c294372524d2124fd3e4158c2a2bf478 Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:11:50 +0800 Subject: [PATCH 13/27] =?UTF-8?q?=E5=A4=9A=E7=AB=99=E7=82=B9CMS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/view/posts/archives/add.html | 148 ++++++++++++++++ .../admin/view/posts/archives/edit.html | 137 +++++++++++++++ .../admin/view/posts/archives/index.html | 48 ++++++ .../admin/view/posts/archives/recyclebin.html | 25 +++ application/admin/view/posts/channel/add.html | 161 +++++++++++++++++ .../admin/view/posts/channel/edit.html | 162 ++++++++++++++++++ .../admin/view/posts/channel/index.html | 28 +++ application/admin/view/posts/modelx/add.html | 24 +++ application/admin/view/posts/modelx/edit.html | 92 ++++++++++ .../admin/view/posts/modelx/fieldset.html | 105 ++++++++++++ .../admin/view/posts/modelx/index.html | 21 +++ application/admin/view/posts/page/add.html | 112 ++++++++++++ application/admin/view/posts/page/edit.html | 112 ++++++++++++ application/admin/view/posts/page/index.html | 28 +++ application/admin/view/posts/sites/add.html | 132 ++++++++++++++ application/admin/view/posts/sites/edit.html | 154 +++++++++++++++++ application/admin/view/posts/sites/index.html | 28 +++ 17 files changed, 1517 insertions(+) create mode 100644 application/admin/view/posts/archives/add.html create mode 100644 application/admin/view/posts/archives/edit.html create mode 100644 application/admin/view/posts/archives/index.html create mode 100644 application/admin/view/posts/archives/recyclebin.html create mode 100644 application/admin/view/posts/channel/add.html create mode 100644 application/admin/view/posts/channel/edit.html create mode 100644 application/admin/view/posts/channel/index.html create mode 100644 application/admin/view/posts/modelx/add.html create mode 100644 application/admin/view/posts/modelx/edit.html create mode 100644 application/admin/view/posts/modelx/fieldset.html create mode 100644 application/admin/view/posts/modelx/index.html create mode 100644 application/admin/view/posts/page/add.html create mode 100644 application/admin/view/posts/page/edit.html create mode 100644 application/admin/view/posts/page/index.html create mode 100644 application/admin/view/posts/sites/add.html create mode 100644 application/admin/view/posts/sites/edit.html create mode 100644 application/admin/view/posts/sites/index.html diff --git a/application/admin/view/posts/archives/add.html b/application/admin/view/posts/archives/add.html new file mode 100644 index 000000000..b71591f34 --- /dev/null +++ b/application/admin/view/posts/archives/add.html @@ -0,0 +1,148 @@ + +
      +
      +
      +
      + +
      + +
      +
      + {notempty name="siteList"} +
      + +
      + +
      +
      + {/notempty} +
      + +
      + +
      + +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      +
      + + + +
        +
        +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        + +
        + + +
        +
        + +
        +
        +
        +
        +
        {:__('Other')}
        +
        +
        +
        +
        +
        + +
        +
        + + + +
        +
        +
        +
        + +
        + {:build_radios('row[status]', ['new'=>__('New'), 'normal'=>__('Normal'), 'hidden'=>__('Hidden')], 'new','radio-info')} +
        +
        +
        + +
        + {:build_radios('row[comment_status]', ['0'=>__('Open'), '1'=>__('Close')],0,'radio-info')} +
        +
        +
        + +
        + {$multilanguage} +
        +
        +
        + +
        +
        + + + + +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        diff --git a/application/admin/view/posts/archives/edit.html b/application/admin/view/posts/archives/edit.html new file mode 100644 index 000000000..7e2885ca3 --- /dev/null +++ b/application/admin/view/posts/archives/edit.html @@ -0,0 +1,137 @@ + +
        +
        +
        +
        + +
        + +
        +
        + +
        + +
        + +
        + +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        +
        + + + +
          +
          +
          +
          +
          + +
          + +
          +
          +
          + +
          + {$extra} +
          +
          + + +
          +
          + +
          +
          +
          +
          +
          {:__('Other')}
          +
          +
          +
          +
          +
          + +
          +
          + + + +
          +
          +
          +
          + +
          + {:build_radios('row[status]', ['new'=>__('New'), 'normal'=>__('normal'), 'hidden'=>__('hidden')], $row['status'],'radio-info')} +
          +
          +
          + +
          + {:build_radios('row[comment_status]', ['open'=>__('Open'), 'close'=>__('Close')], $row['comment_status'],'radio-info')} +
          +
          +
          + +
          + {$multilanguage} +
          +
          +
          + +
          +
          + + + + + +
          +
          +
          +
          +
          +
          +
          +
          +
          +
          diff --git a/application/admin/view/posts/archives/index.html b/application/admin/view/posts/archives/index.html new file mode 100644 index 000000000..abf963695 --- /dev/null +++ b/application/admin/view/posts/archives/index.html @@ -0,0 +1,48 @@ +
          + {:build_heading()} + +
          +
          +
          +
          +
          + {:build_toolbar(['refresh','add','move','del'], ['add'=>[url('posts/archives/add'), 'btn btn-success btn-addtabs', 'fa fa-plus', __('Add'), __('Add')], 'move'=>['javascript:;', 'btn btn-info btn-move btn-disabled', 'fa fa-arrow-right', __('Move'), __('Move')]])} + + + {:__('Recyclebin')} +
          + +
          +
          +
          + +
          +
          +
          + + \ No newline at end of file diff --git a/application/admin/view/posts/archives/recyclebin.html b/application/admin/view/posts/archives/recyclebin.html new file mode 100644 index 000000000..223c6809f --- /dev/null +++ b/application/admin/view/posts/archives/recyclebin.html @@ -0,0 +1,25 @@ +
          + {:build_heading()} + +
          +
          +
          + +
          + +
          +
          +
          diff --git a/application/admin/view/posts/channel/add.html b/application/admin/view/posts/channel/add.html new file mode 100644 index 000000000..d718c3969 --- /dev/null +++ b/application/admin/view/posts/channel/add.html @@ -0,0 +1,161 @@ +
          +
          +
          +
          + +
          + +
          +
          +
          + +
          +
          + {foreach name="typeList" item="vo"} + + {/foreach} +
          +
          +
          + + 栏目: 栏目类型下不可以发布文章,但可以添加子栏目、列表、链接
          + 列表: 列表类型下可以发布文章,但不能添加子栏目
          + 链接: 链接类型下不可以发布文章和子级栏目
          +
          +
          +
          +
          +
          + +
          +
          + {foreach name="modelList" item="vo"} + + + {/foreach} +
          +
          +
          + + {notempty name="siteList"} +
          + +
          + +
          +
          + {/notempty} +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + +
          +
          +
          + +
          + {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')],null,'radio-inline radio-success')} +
          +
          +
          + +
          + +
          + +
          +
          + + + +
            +
            +
            +
            +
            + +
            + +
            +
            + +
            + +
            + +
            +
            +
            + +
            + +
            +
            +
            + +
            + {$multilanguage} +
            +
            +
            + +
            +
            +
            +
            +
            + +
            diff --git a/application/admin/view/posts/channel/edit.html b/application/admin/view/posts/channel/edit.html new file mode 100644 index 000000000..75ae4fac5 --- /dev/null +++ b/application/admin/view/posts/channel/edit.html @@ -0,0 +1,162 @@ + +
            +
            +
            +
            + +
            + +
            +
            +
            + +
            +
            + {foreach name="typeList" item="vo"} + + {/foreach} +
            +
            +
            + + 栏目: 栏目类型下不可以发布文章,但可以添加子栏目、列表、链接
            + 列表: 列表类型下可以发布文章,但不能添加子栏目
            + 链接: 链接类型下不可以发布文章和子级栏目
            +
            +
            +
            +
            +
            + +
            +
            + {foreach name="modelList" item="vo"} + + + {/foreach} +
            +
            +
            + {notempty name="siteList"} +
            + +
            + +
            +
            + {/notempty} +
            + +
            + + + +
            +
            +
            + +
            + +
            +
            +
            + +
            + +
            +
            +
            + +
            + +
            +
            +
            + +
            + +
            +
            +
            + +
            + +
            +
            +
            + +
            + {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])} +
            +
            +
            + +
            +
            + +
            +
            + + + +
              +
              +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + {$multilanguage} +
              +
              +
              + +
              +
              +
              +
              +
              + + +
              diff --git a/application/admin/view/posts/channel/index.html b/application/admin/view/posts/channel/index.html new file mode 100644 index 000000000..7c8368134 --- /dev/null +++ b/application/admin/view/posts/channel/index.html @@ -0,0 +1,28 @@ +
              + {:build_heading()} + +
              +
              +
              +
              + + +
              +
              +
              + +
              +
              +
              diff --git a/application/admin/view/posts/modelx/add.html b/application/admin/view/posts/modelx/add.html new file mode 100644 index 000000000..bf6634d50 --- /dev/null +++ b/application/admin/view/posts/modelx/add.html @@ -0,0 +1,24 @@ +
              + +
              + +
              + +
              +
              +
              + +
              + +
              +
              + +
              diff --git a/application/admin/view/posts/modelx/edit.html b/application/admin/view/posts/modelx/edit.html new file mode 100644 index 000000000..e380469fa --- /dev/null +++ b/application/admin/view/posts/modelx/edit.html @@ -0,0 +1,92 @@ + +
              +
              +
              +

              {$row.title}{:__('Name')} ({$row.name})

              +
              +
              + + 重要提示:添加删除 字段后,需要点击"保存及应用"才会生效! +
              +
              + + +
              +
              + {:__('field')} + {:__('fieldname')} + {:__('type')} + {:__('status')} + {:__('operate')} +
              +
                + {notempty name="$row.extra"} + {foreach $row.extra as $index=>$vo} +
              • $field} + data-{$key}="{$field}" + {/foreach} + > + + {$vo.field} + {$vo.fieldname} + {:__($vo.type)} + + + + + + + + + +
              • + {/foreach} + {/notempty} + +
              +
              +
              + + +
              + + diff --git a/application/admin/view/posts/modelx/fieldset.html b/application/admin/view/posts/modelx/fieldset.html new file mode 100644 index 000000000..38760a5bb --- /dev/null +++ b/application/admin/view/posts/modelx/fieldset.html @@ -0,0 +1,105 @@ +
              + +
              + +
              + +
              +
              +
              + +
              + + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              + {:build_radios('status', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], 'normal')} +
              +
              + +
              \ No newline at end of file diff --git a/application/admin/view/posts/modelx/index.html b/application/admin/view/posts/modelx/index.html new file mode 100644 index 000000000..f36d29564 --- /dev/null +++ b/application/admin/view/posts/modelx/index.html @@ -0,0 +1,21 @@ +
              + {:build_heading()} + +
              +
              +
              +
              +
              + {:build_toolbar()} +
              + +
              +
              +
              + +
              +
              +
              \ No newline at end of file diff --git a/application/admin/view/posts/page/add.html b/application/admin/view/posts/page/add.html new file mode 100644 index 000000000..825c90776 --- /dev/null +++ b/application/admin/view/posts/page/add.html @@ -0,0 +1,112 @@ +
              + {notempty name="siteList"} +
              + +
              + +
              +
              + {/notempty} + +
              + +
              + +
              +
              +
              + +
              +
              + /a/ + +
              +
              +
              +
              + +
              + +
              +
              +
              + +
              + +
              +
              +
              + +
              +
              + + + +
                +
                +
                +
                +
                + +
                + +
                +
                +
                + +
                + +
                +
                +
                + +
                + +
                +
                +
                + +
                + +
                +
                +
                + +
                + +
                +
                +
                + +
                + +
                +
                +
                + +
                + {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')])} +
                +
                +
                + +
                + {$multilanguage} +
                +
                + +
                diff --git a/application/admin/view/posts/page/edit.html b/application/admin/view/posts/page/edit.html new file mode 100644 index 000000000..6b0bbd296 --- /dev/null +++ b/application/admin/view/posts/page/edit.html @@ -0,0 +1,112 @@ +
                + {notempty name="siteList"} +
                + +
                + +
                +
                + {/notempty} + +
                + +
                + +
                +
                +
                + +
                +
                + /a/ + +
                +
                +
                +
                + +
                + +
                +
                +
                + +
                + +
                +
                +
                + +
                +
                + + + +
                  +
                  +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])} +
                  +
                  +
                  + +
                  + {$multilanguage} +
                  +
                  + +
                  diff --git a/application/admin/view/posts/page/index.html b/application/admin/view/posts/page/index.html new file mode 100644 index 000000000..6d6310317 --- /dev/null +++ b/application/admin/view/posts/page/index.html @@ -0,0 +1,28 @@ +
                  + {:build_heading()} + +
                  +
                  +
                  +
                  + + +
                  +
                  +
                  + +
                  +
                  +
                  diff --git a/application/admin/view/posts/sites/add.html b/application/admin/view/posts/sites/add.html new file mode 100644 index 000000000..ea6d70dd4 --- /dev/null +++ b/application/admin/view/posts/sites/add.html @@ -0,0 +1,132 @@ +
                  +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + {$multilanguage} +
                  +
                  +
                  + +
                  + {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], 'normal', 'radio-success')} +
                  +
                  +
                  + +
                  + +
                  + {volist id="vo" name="moduleList"} +
                  + + {$vo.descript} +
                  + {/volist} +
                  +
                  +
                  +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  +
                  + +
                  +
                  + +
                  +
                  +
                  + 变量名 + 变量值 +
                  +
                  {:__('Append')}
                  +
                  +
                  +
                  +
                  +
                  +
                  +
                  + + +
                  + + \ No newline at end of file diff --git a/application/admin/view/posts/sites/edit.html b/application/admin/view/posts/sites/edit.html new file mode 100644 index 000000000..9f1428bb4 --- /dev/null +++ b/application/admin/view/posts/sites/edit.html @@ -0,0 +1,154 @@ +
                  +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  + +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + {$multilanguage} +
                  +
                  +
                  + +
                  + {:build_radios('row[status]', ['normal'=>__('Normal'), 'hidden'=>__('Hidden')], $row['status'])} +
                  +
                  +
                  + +
                  +
                  +
                  +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  +
                  + {foreach name="settings['seo']" item="lang" key="language"} + {notin name="language" value="zh-cn"} +

                  {:__('Lang')} - {:config('site.multilanguages')[$language]}({$language})

                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  +
                  + +
                  + +
                  +
                  + {/notin} + {/foreach} +
                  +
                  + +
                  +
                  +
                  + 变量名 + 变量值 +
                  + {foreach name="$settings['custom']" item="vo" key="key"} +
                  + + + +
                  + {/foreach} +
                  {:__('Append')}
                  +
                  +
                  +
                  +
                  +
                  +
                  +
                  + + +
                  + + + \ No newline at end of file diff --git a/application/admin/view/posts/sites/index.html b/application/admin/view/posts/sites/index.html new file mode 100644 index 000000000..613270afd --- /dev/null +++ b/application/admin/view/posts/sites/index.html @@ -0,0 +1,28 @@ +
                  + {:build_heading()} + +
                  +
                  +
                  +
                  + + +
                  +
                  +
                  + +
                  +
                  +
                  -- Gitee From 977551a7c5aeb5d9b9a2bcfddb38716c08476955 Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:14:31 +0800 Subject: [PATCH 14/27] =?UTF-8?q?=E5=A4=9A=E7=AB=99=E7=82=B9CMS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/lang/zh-cn/posts/archives.php | 35 +++++++++++++ .../admin/lang/zh-cn/posts/channel.php | 24 +++++++++ application/admin/lang/zh-cn/posts/modelx.php | 50 +++++++++++++++++++ application/admin/lang/zh-cn/posts/page.php | 21 ++++++++ application/admin/lang/zh-cn/posts/sites.php | 22 ++++++++ 5 files changed, 152 insertions(+) create mode 100644 application/admin/lang/zh-cn/posts/archives.php create mode 100644 application/admin/lang/zh-cn/posts/channel.php create mode 100644 application/admin/lang/zh-cn/posts/modelx.php create mode 100644 application/admin/lang/zh-cn/posts/page.php create mode 100644 application/admin/lang/zh-cn/posts/sites.php diff --git a/application/admin/lang/zh-cn/posts/archives.php b/application/admin/lang/zh-cn/posts/archives.php new file mode 100644 index 000000000..2d78396f5 --- /dev/null +++ b/application/admin/lang/zh-cn/posts/archives.php @@ -0,0 +1,35 @@ + '所属站点', + 'Channel_id' => '栏目', + 'Title' => '标题', + 'Subtitle' => '摘要', + 'Content' => '内容', + 'Cover' => '封面主图', + 'Status' => '状态', + 'Type' => '文章类型', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Deletetime' => '删除时间', + 'Comment_status' => '评论开启状态', + 'Diyname' => '自定义URL', + 'Lang' => '多国语言版本', + 'Weigh' => '权重', + + 'Views' => '查看数', + + 'Restore' => '恢复', + 'Destroy' => '销毁', + 'Recyclebin' => '回收站', + 'Restore all' =>'全部恢复', + 'Empty recyclebin' =>'清空回收站', + + 'Select channel' => '选择栏目', + 'Please select channel' => '请选择栏目', + + 'Other' => '相关信息', + 'New' => '待审核', + 'Open' => '开放', + +]; diff --git a/application/admin/lang/zh-cn/posts/channel.php b/application/admin/lang/zh-cn/posts/channel.php new file mode 100644 index 000000000..a2deac0af --- /dev/null +++ b/application/admin/lang/zh-cn/posts/channel.php @@ -0,0 +1,24 @@ + '所属站点', + 'Pid' => '父ID', + 'Type' => '栏目类型', + 'Model' => '栏目模型', + 'Name' => '栏目名称', + 'Flag' => '标识', + 'Image' => '图片', + 'Keywords' => '关键字', + 'Description' => '描述', + 'Diyname' => '自定义名称', + 'Template' => '模板', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Weigh' => '权重', + 'Status' => '状态', + 'Items' => '文档数量', + + 'List' => '列表', + 'Channel' => '栏目', + 'Redirect' => '链接', +]; diff --git a/application/admin/lang/zh-cn/posts/modelx.php b/application/admin/lang/zh-cn/posts/modelx.php new file mode 100644 index 000000000..11e11f8fa --- /dev/null +++ b/application/admin/lang/zh-cn/posts/modelx.php @@ -0,0 +1,50 @@ + '模型', + 'Title' => '模型名称', + 'Extra' => '模型参数', + 'Status' => '启用状态', + + 'Add field' => '添加字段', + 'Edit field'=>'编辑字段', + 'FieldSet' => '字段设置', + + 'Field' => '字段', + 'FieldName' => '字段名称', + 'Type' => '字段类型', + 'Length' => '字段长度', + 'Display' => '显示方式', + 'Vars' => '预置选项', + 'Float' => '小数位数', + 'Min'=>'最少选择', + 'Max'=>'最多选择', + 'Value' => '默认值', + 'Tip' => '提示信息', + 'Success' => '正确信息', + 'Error' => '错误信息', + 'Rule' => '检验规则', + 'Extend' => '扩展信息', + + +//显示方式 + 'String' => '字符', + 'Text' => '文本', + 'Richtext' => '编辑器', + 'Number' => '数字', + 'Datetime'=> '日期时间', + 'Image' => '图片', + 'Images' => '图片(多)', + 'File' => '文件', + 'Files' => '文件(多)', + 'Select' => '列表', + 'Selects' => '列表(多选)', + 'Checkbox'=> '复选', + 'Radio' => '单选', + + 'Required' => '必选', + + 'Can not be digital' => '不能是数字', + 'Field already exist' => '字段已经存在', + 'Please enter a value between %d and %d characters long' => '请填写%d到%d个字符', +]; diff --git a/application/admin/lang/zh-cn/posts/page.php b/application/admin/lang/zh-cn/posts/page.php new file mode 100644 index 000000000..3764b84d0 --- /dev/null +++ b/application/admin/lang/zh-cn/posts/page.php @@ -0,0 +1,21 @@ + 'ID', + 'Title' => '标题', + 'Keywords' => '关键字', + 'Description' => '描述', + 'Content' => '内容', + 'Flag' => '标志', + 'Image' => '头像', + 'Diyname' => '自定义名称', + 'Icon' => '图标', + 'Views' => '点击', + 'Comments' => '评论', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间', + 'Weigh' => '权重', + 'Status' => '状态', + 'Site_id' => '所属站点', + 'Lang' => '多国语言版本', +]; diff --git a/application/admin/lang/zh-cn/posts/sites.php b/application/admin/lang/zh-cn/posts/sites.php new file mode 100644 index 000000000..a2d3ec56c --- /dev/null +++ b/application/admin/lang/zh-cn/posts/sites.php @@ -0,0 +1,22 @@ + '关联用户', + 'name' => '站点名称', + 'Domain' => '二级域名', + 'Url' => '网址', + 'Lang' => '多语言', + 'Status' => '状态', + 'Createtime' => '创建时间', + 'Modules' => '模块', + + + 'Title' => '网站标题 (Title)', + 'Keywords' => '网站关键字 (Keywords)', + 'Description' => '网站描述 (Description)', + + 'Please enter a valid domain' => '请填写有效的域名', + 'Domain already exist' => '域名已经存在', + 'Please enter a valid URL' => '请填写有效的网址', + 'Url already exist' => '该网址已经绑定了', +]; -- Gitee From b2254f2a7e10fde939c1334daf9e00a9e40bf63b Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:15:42 +0800 Subject: [PATCH 15/27] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=9E=E6=94=B6?= =?UTF-8?q?=E7=AB=99=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/lang/zh-cn.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index d01376e40..e00fe6e55 100644 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -165,4 +165,17 @@ return [ 'Admin log tips' => '管理员可以查看自己所拥有的权限的管理员日志', 'Group tips' => '角色组可以有多个,角色有上下级层级关系,如果子角色有角色组和管理员的权限则可以派生属于自己组别的下级角色组或管理员', 'Rule tips' => '规则通常对应一个控制器的方法,同时左侧的菜单栏数据也从规则中体现,通常建议通过命令行进行生成规则节点', + + + 'Multi-Language' => '多国语言', + 'Basic' => '基础信息', + 'Extra' => '扩展信息', + + 'Restore' => '恢复', + 'Destroy' => '销毁', + 'Recyclebin' => '回收站', + + 'Save & Apply' => '保存及应用', + + 'Diyname_tip' => '只允许 a-z,A-Z,0-9,-,_ 等字符且必须是字母起始', ]; -- Gitee From 0abf374fda560a2105afa2618fdc47dd36df659a Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:16:49 +0800 Subject: [PATCH 16/27] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/tags.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/application/admin/tags.php b/application/admin/tags.php index 4e901f3a1..7cd28324e 100644 --- a/application/admin/tags.php +++ b/application/admin/tags.php @@ -15,4 +15,15 @@ return [ 'app_end' => [ 'app\\admin\\behavior\\AdminLog', ], + + 'archive_del' => [ + 'seven\\behavior\\ArchiveDel', + ], + + 'module_init' => [ + 'seven\\behavior\\GetSiteId', + ], + + 'action_begin' => [ + ], ]; -- Gitee From 91f5dcf7f649c1b56f794ba4f682de5cd4e7266a Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 11:19:03 +0800 Subject: [PATCH 17/27] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=8C=85=E6=97=B6=E5=85=B3=E9=97=ADapp=5Ftrace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/controller/Ajax.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/index/controller/Ajax.php b/application/index/controller/Ajax.php index c4e2e865f..a5d2c18de 100644 --- a/application/index/controller/Ajax.php +++ b/application/index/controller/Ajax.php @@ -21,6 +21,7 @@ class Ajax extends Frontend */ public function lang() { + \think\Config::set('app_trace', false); header('Content-Type: application/javascript'); $callback = $this->request->get('callback'); $controllername = input("controllername"); -- Gitee From 34cdae7a3c591a33ba030e14b15463c6876f962f Mon Sep 17 00:00:00 2001 From: devlike Date: Thu, 8 Feb 2018 18:44:11 +0800 Subject: [PATCH 18/27] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=90=9C=E7=B4=A2=E7=BB=86=E8=8A=82=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/posts/Archives.php | 37 +++++++------ .../admin/controller/posts/Channel.php | 55 +++++++++++++------ application/admin/controller/posts/Page.php | 8 +-- .../admin/view/posts/archives/index.html | 4 +- application/admin/view/posts/channel/add.html | 2 +- .../admin/view/posts/channel/edit.html | 8 +-- .../admin/view/posts/channel/index.html | 10 ++++ application/admin/view/posts/page/edit.html | 13 ----- public/assets/js/backend/posts/archives.js | 15 +++-- public/assets/js/backend/posts/channel.js | 52 ++++++++++++++---- public/assets/js/backend/posts/page.js | 22 +++++--- public/assets/js/backend/posts/sites.js | 12 ++-- 12 files changed, 149 insertions(+), 89 deletions(-) diff --git a/application/admin/controller/posts/Archives.php b/application/admin/controller/posts/Archives.php index 06d4eaf83..44d2f2a6a 100644 --- a/application/admin/controller/posts/Archives.php +++ b/application/admin/controller/posts/Archives.php @@ -50,34 +50,36 @@ class Archives extends Backend /** * 读取栏目列表 */ - private function initForm() + private function initForm($siteId=null) { - //从总后台进入 - if ($this->auth->isSuperAdmin()){ + $where=$first_siteid=''; + if ($this->auth->isSuperAdmin()) { $sitelist = model('Sites')->all(); $this->view->assign('siteList', $sitelist); - $first_siteid = $sitelist?$sitelist[0]['id']:null; + + //记住下拉列表中第一个网站的ID,添加文章时,只读取对应的栏目等信息 + if ($sitelist && $this->request->action()=='add') { + $first_siteid = $sitelist[0]['id']; + $where = ['site_id' => $first_siteid]; + } } - //从站点后台进入 else { $this->view->assign('siteList', null); $first_siteid = Session::get('user_site_id'); } + if (!is_null($siteId)) $first_siteid=$siteId; + $tree = Tree::instance(); - $tree->init(model('channel')->with('sites')->order('site_id asc,weigh desc,id desc')->select(), 'pid'); + $tree->init(model('channel')->with('sites')->where($where)->order('site_id asc,weigh desc,id desc')->select(), 'pid'); $this->channellist = $tree->getTreeList($tree->getTreeArray(0), 'name'); $channeldata = []; //0 => ['mode' => 'default','site_id'=>0, 'name' => __('None')]]; foreach ($this->channellist as $k => $v) { - if(isset($first_siteid) && !is_null($first_siteid) && $v['site_id']!=$first_siteid) { - //do nothing - }else { - $channeldata[$v['id']] = $v; - $channeldata[$v['id']]['disabled'] = 0; - $channeldata[$v['id']]['sitename'] = $v['sites']['name'] == '' ? __('Main site') : $v['sites']['name']; - if ($v['type'] != 'list') { - $channeldata[$v['id']]['disabled'] = 1; - } + $channeldata[$v['id']] = $v; + $channeldata[$v['id']]['disabled'] = 0; + $channeldata[$v['id']]['sitename'] = $v['sites']['name'] == '' ? __('Main site') : $v['sites']['name']; + if ($v['type'] != 'list') { + $channeldata[$v['id']]['disabled'] = 1; } } $this->view->assign("channelList", $channeldata); @@ -113,7 +115,7 @@ class Archives extends Backend ->where($where) //->where('site_id', Session::get('admin.siteid')) ->where('isDelete',0) - ->with('channel') + ->with('sites,channel') ->field('subtitle,content',true, $tablename) ->order($sort, $order) ->limit($offset, $limit) @@ -124,6 +126,7 @@ class Archives extends Backend return json($result); } $this->initForm(); + $this->assignconfig('show_sitename', $this->auth->isSuperAdmin()); return $this->view->fetch(); } @@ -266,7 +269,7 @@ class Archives extends Backend } $this->error(__('Parameter %s can not be empty', '')); } - $this->initForm(); + $this->initForm($row->site_id); $channeldata = []; //0 => ['mode' => 'default','site_id'=>0, 'name' => __('None')]]; foreach ($this->channellist as $k => $v) { diff --git a/application/admin/controller/posts/Channel.php b/application/admin/controller/posts/Channel.php index e5fc2b169..669212c1e 100644 --- a/application/admin/controller/posts/Channel.php +++ b/application/admin/controller/posts/Channel.php @@ -19,7 +19,6 @@ class Channel extends Backend { protected $model = null; - protected $channellist = []; protected $noNeedRight = ['check_element_available','getlist']; @@ -29,29 +28,33 @@ class Channel extends Backend $this->request->filter(['strip_tags']); $this->model = model('Channel'); - $tree = Tree::instance(); - $tree->init($this->model->order('weigh desc,id desc')->with('Sites')->with('archives')->select(), 'pid'); - - $this->channellist = $tree->getTreeList($tree->getTreeArray(0), 'name'); } - private function initForm(){ - //从总后台进入 + private function initForm($siteId=null) + { + $first_siteid=null; if ($this->auth->isSuperAdmin()){ $sitelist = Sites::all(); $this->view->assign('siteList', $sitelist); - $first_siteid = $sitelist?$sitelist[0]['id']:null; + if ($sitelist && $this->request->action()=='add') { + $first_siteid = $sitelist[0]['id'] ; + } } - //从站点后台进入 else { $this->view->assign('siteList', null); + $first_siteid = Session::get('user_site_id'); } + if (!is_null($siteId)) $first_siteid=$siteId; + $where = ['site_id'=>$first_siteid]; - + $tree = Tree::instance(); + $tree->init($this->model->order('weigh desc,id desc')->where($where)->with('Sites,archives')->select(), 'pid'); + $channellist = $tree->getTreeList($tree->getTreeArray(0), 'name'); $channeldata = [0 => ['site_id'=>0, 'name' => __('None')]]; - foreach ($this->channellist as $k => $v) + foreach ($channellist as $k => $v) { - if(isset($first_siteid) && !is_null($first_siteid) && $v['site_id']!=$first_siteid) { + //添加&编辑页面, 排除非首选网站的栏目 + if(!is_null($first_siteid) && $v['site_id']!=$first_siteid) { //do nothing }else { $channeldata[$v['id']] = $v; @@ -76,7 +79,7 @@ class Channel extends Backend $this->view->assign("typeList", $this->model->getTypeList()); $this->view->assign("modelList", model('PostsModelx')->all()); - $ml = Seven::build_langs('row[lang]',null,['siteid'=>Session::get("admin.siteid")]); + $ml = Seven::build_langs('row[lang]',null,['siteid'=>$first_siteid]); $this->view->assign('multilanguage',$ml); } @@ -90,10 +93,18 @@ class Channel extends Backend { $search = $this->request->request("search"); //构造父类select列表选项数据 + + list($where, $sort, $order, $offset, $limit) = $this->buildparams(false, true); + + $tree = Tree::instance(); + $tree->init($this->model->order('weigh desc,id desc')->where($where)->with('Sites,archives')->select(), 'pid'); + + $channellist = $tree->getTreeList($tree->getTreeArray(0), 'name'); + $list = []; if ($search) { - foreach ($this->channellist as $k => $v) + foreach ($channellist as $k => $v) { if (stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) { @@ -103,13 +114,18 @@ class Channel extends Backend } else { - $list = $this->channellist; + $list = $channellist; } $total = count($list); $result = array("total" => $total, "rows" => $list); return json($result); } + if ($this->auth->isSuperAdmin()){ + $sitelist = Sites::all(); + $this->view->assign('siteList', $sitelist); + } + $this->assignconfig('show_sitename', $this->auth->isSuperAdmin()); return $this->view->fetch(); } @@ -177,7 +193,7 @@ class Channel extends Backend } $this->error(__('Parameter %s can not be empty', '')); } - $this->initForm(); + $this->initForm($row->site_id); $this->view->assign('multilanguage', Seven::build_langs('row[lang]',$row['lang'],['siteid'=>$row->site_id])); $this->view->assign("row", $row); return $this->view->fetch(); @@ -186,12 +202,15 @@ class Channel extends Backend /** - * 返回栏目列表,供Ajax调用 + * 返回栏目列表,供文章列表搜索框Ajax调用 */ public function getlist() { if($this->request->isAjax()){ - foreach ($this->channellist as $k => $v){ + $tree = Tree::instance(); + $channellist=$tree->init($this->model->order('weigh desc,id desc')->with('Sites,archives')->select(), 'pid'); + $channellist = $tree->getTreeList($tree->getTreeArray(0), 'name'); + foreach ($channellist as $k => $v){ $list[$v['id']]=$v['name']; } return json($list); diff --git a/application/admin/controller/posts/Page.php b/application/admin/controller/posts/Page.php index 40a65c011..ed8cb9c95 100644 --- a/application/admin/controller/posts/Page.php +++ b/application/admin/controller/posts/Page.php @@ -59,6 +59,7 @@ class Page extends Backend return json($result); } + $this->assignconfig('show_sitename', $this->auth->isSuperAdmin()); return $this->view->fetch(); } @@ -68,13 +69,12 @@ class Page extends Backend */ private function initForm() { - //从总后台进入 + $first_siteid=null; if ($this->auth->isSuperAdmin()){ $sitelist = Sites::all(); $this->view->assign('siteList', $sitelist); - $first_siteid = $sitelist?$sitelist[0]['id']:null; + $first_siteid=$sitelist?$sitelist[0]['id']:$first_siteid; } - //从站点后台进入 else { $this->view->assign('siteList', null); $first_siteid = \think\Session::get('user_site_id'); @@ -149,7 +149,7 @@ class Page extends Backend } $this->view->assign("row", $row); $this->initForm(); - $this->view->assign('multilanguage', Seven::build_langs('row[lang]',$row['lang'])); + $this->view->assign('multilanguage', Seven::build_langs('row[lang]',$row['lang'],['siteid'=>$row->site_id])); return $this->view->fetch(); } diff --git a/application/admin/view/posts/archives/index.html b/application/admin/view/posts/archives/index.html index abf963695..c97742119 100644 --- a/application/admin/view/posts/archives/index.html +++ b/application/admin/view/posts/archives/index.html @@ -11,8 +11,8 @@ {:__('Recyclebin')} diff --git a/application/admin/view/posts/channel/add.html b/application/admin/view/posts/channel/add.html index d718c3969..5c4e15b5d 100644 --- a/application/admin/view/posts/channel/add.html +++ b/application/admin/view/posts/channel/add.html @@ -57,7 +57,7 @@
                  - {foreach name="parentList" item="vo"} {/foreach} diff --git a/application/admin/view/posts/channel/edit.html b/application/admin/view/posts/channel/edit.html index 75ae4fac5..64fa3c5ee 100644 --- a/application/admin/view/posts/channel/edit.html +++ b/application/admin/view/posts/channel/edit.html @@ -36,7 +36,7 @@
                  {foreach name="modelList" item="vo"} - + {/foreach}
                  @@ -48,7 +48,7 @@
                  @@ -58,9 +58,9 @@
                  - {foreach name="parentList" item="vo"} - + {/foreach} diff --git a/application/admin/view/posts/channel/index.html b/application/admin/view/posts/channel/index.html index 7c8368134..936c9452f 100644 --- a/application/admin/view/posts/channel/index.html +++ b/application/admin/view/posts/channel/index.html @@ -14,6 +14,16 @@
                • {:__('Set to hidden')}
                • + {notempty name="siteList"} +
                  + +
                  + {/notempty}
                  - {notempty name="siteList"} -
                  - -
                  - -
                  -
                  - {/notempty} -
                  diff --git a/public/assets/js/backend/posts/archives.js b/public/assets/js/backend/posts/archives.js index 69c7d3323..04663c0d2 100644 --- a/public/assets/js/backend/posts/archives.js +++ b/public/assets/js/backend/posts/archives.js @@ -38,19 +38,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function [ {checkbox: true}, {field: 'id', title: __('id'), operate: false}, - {field: 'channel_id', title: __('Channel_id'),formatter: function (value, row, index) { + {field: 'site_id', title: __('Site_id'), visible:Config.show_sitename, + formatter: function (value, row, index) { + return row.sites==null?'':'' + row.sites.name + ''; + } + }, + {field: 'channel_id', title: __('Channel_id'),searchList: $.getJSON('posts/channel/getlist'), + formatter: function (value, row, index) { return row.channel==null?'':'' + row.channel.name + ''; - }, - searchList: $.getJSON('posts/channel/getlist') + } }, {field: 'type', title: __('type'), formatter: function (value,row,index){ return ''+value+''; }, operate:false }, - {field: 'title', align:'left', title: __('title'), operate: 'LIKE %...%', + {field: 'title', align:'left', title: __('title'), operate: 'LIKE %...%',placeholder: '关键字,模糊搜索', formatter: function(value,row, index){ return value + (row.cover==''?'' : ' '); }}, - {field: 'status', title: __('status'), searchList: {new: __('New'), normal: __('Normal'), hidden: __('Hidden')}, formatter: Table.api.formatter.status}, + {field: 'status', title: __('status'), searchList: {normal: __('Normal'), hidden: __('Hidden')}, formatter: Table.api.formatter.status}, {field: 'updatetime', title: __('updatetime'),operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime}, {field: 'views', title: __('Views'), operate:false}, {field: 'weigh', title: __('Weigh'), operate:false}, diff --git a/public/assets/js/backend/posts/channel.js b/public/assets/js/backend/posts/channel.js index fcfa96286..58b26d0e4 100644 --- a/public/assets/js/backend/posts/channel.js +++ b/public/assets/js/backend/posts/channel.js @@ -24,29 +24,59 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin sortName: 'weigh', pagination: false, escape: false, - commonSearch: false, + commonSearch: true, search: false, columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, - {field: 'sites.name', title: __('Site_id')}, - {field: 'type', title: __('Type'), custom: {channel: 'info', list: 'success', redirect: 'primary'}, formatter: Table.api.formatter.flag}, - {field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.catename}, - {field: 'diyname', title: __('Redirect'), formatter:function(value,row,index){ - return value==''? '' : ''; - }}, + {field: 'id', title: __('Id'),operate:false}, + {field: 'site_id', title: __('Site_id'), visible:Config.show_sitename, + formatter: function (value, row, index) { + return row.sites==null?'':'' + row.sites.name + ''; + } + }, + {field: 'type', title: __('Type'), searchList: {channel: __('Channel'), list: __('list'), redirect: __('Redirect')},custom: {channel: 'info', list: 'success', redirect: 'primary'}, formatter: Table.api.formatter.flag}, + {field: 'name', title: __('Name'), align: 'left', operate: 'LIKE %...%',placeholder: '关键字,模糊搜索', formatter: Controller.api.formatter.catename}, + {field: 'diyname', title: __('Redirect'), operate:false, + formatter:function(value,row,index){ + diyname = row['type']=='redirect' ? row['redirect'] : value==''? '': '/list/'+value+'.html'; + return diyname==''? '' : ''; + } + }, {field: 'flag', title: __('Flag'), operate: false, formatter: Table.api.formatter.flag}, - {field: 'weigh', title: __('Weigh'), visible:true}, - {field: 'archives.items', title: __('Items'), formatter:function(value,row,index){return (typeof value === 'number') ? value : 0;}}, - {field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status}, + {field: 'weigh', title: __('Weigh'), visible:true,operate:false}, + {field: 'archives.items', title: __('Items'),operate:false, + formatter:function(value,row,index){ + return (typeof value === 'number') ? ''+ value +'' : 0; + }}, + {field: 'status', title: __('Status'), searchList: {normal: __('Normal'), hidden: __('Hidden')}, formatter: Table.api.formatter.status}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); + $(document).on('change','#c-site_id', function(){ + var self = this; + if($(self).val()==0) return false; + var options = table.bootstrapTable('getOptions'); + options.pageNumber = 1; + options.queryParams = function (params) { + return { + sort: params.sort, + order: params.order, + filter: JSON.stringify({site_id: $(self).val()}), + op: JSON.stringify({site_id: '='}), + offset: params.offset, + limit: params.limit, + }; + }; + //Toastr.info("数据加载中,请稍候..."); + table.bootstrapTable('refresh'); + }); + // 为表格绑定事件 Table.api.bindevent(table); + Form.api.bindevent($("#formg")); }, add: function () { Controller.api.bindevent(); diff --git a/public/assets/js/backend/posts/page.js b/public/assets/js/backend/posts/page.js index b5f68ea0e..4d0dba12d 100644 --- a/public/assets/js/backend/posts/page.js +++ b/public/assets/js/backend/posts/page.js @@ -24,15 +24,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {field: 'state', checkbox: true}, {field: 'id', title: __('Id'), operate: false}, - {field: 'site_id', title: __('Site_id'), operate: false, formatter:function(value,row,index){ - return value==0? '-': row.sites.name; - }}, + {field: 'site_id', title: __('Site_id'), + formatter: function (value, row, index) { + return row.sites==null?'':'' + row.sites.name + ''; + },visible:Config.show_sitename}, {field: 'title', title: __('Title'), align:'left', operate: 'LIKE %...%', placeholder: '关键字,模糊搜索', - formatter: function(value,row,index){ - return value + (row.image==''?'' : ''); - }}, + formatter: function(value,row,index){ + return value + (row.image==''?'' : ' '); + } + }, {field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag, operate: false}, - {field: 'lang', title: __('lang'), formatter: Table.api.formatter.langs, operate: false}, + {field: 'lang', title: __('lang'), operate: false, + formatter: function(value,row,index){ + return __(value); + } + }, {field: 'views', title: __('Views'), operate: false}, //{field: 'comments', title: __('Comments'), operate: false}, {field: 'weigh', title: __('Weigh'), operate: false}, @@ -59,7 +65,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin bindevent: function () { $(document).on("change", "#c-site_id", function () { that=this; - Fast.api.ajax({url: 'posts/sites/get_site_langs', data: {"lang": $(that).val()}}, function (data) { + Fast.api.ajax({url: 'posts/sites/get_site_langs', data: {"lang": $(that).val()}}, function (r,data) { $("#language_choose").html(data.html); Form.api.bindevent($("#language_choose")); return false; diff --git a/public/assets/js/backend/posts/sites.js b/public/assets/js/backend/posts/sites.js index 1d3dde859..a02b5c397 100644 --- a/public/assets/js/backend/posts/sites.js +++ b/public/assets/js/backend/posts/sites.js @@ -25,12 +25,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'username', title: __('User_id')}, - {field: 'name', title: __('name')}, - {field: 'domain', title: __('Domain')}, - {field: 'lang', title: __('Lang')}, - {field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, - {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime}, + {field: 'username', title: __('User_id'), operate:false}, + {field: 'name', title: __('name'),operate: 'LIKE %...%',placeholder: '关键字,模糊搜索',}, + {field: 'domain', title: __('Domain'),operate: 'LIKE %...%',placeholder: '关键字,模糊搜索',}, + {field: 'lang', title: __('Lang'), operate:false}, + {field: 'status', title: __('Status'),searchList: {normal: __('Normal'), hidden: __('Hidden')}, formatter: Table.api.formatter.status}, + {field: 'createtime', title: __('Createtime'), operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"', formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] -- Gitee From 0dd970e7ff46950445ae29502ea42d6109249add Mon Sep 17 00:00:00 2001 From: devlike Date: Fri, 9 Feb 2018 19:51:10 +0800 Subject: [PATCH 19/27] =?UTF-8?q?=E7=AB=99=E7=82=B9=E9=85=8D=E7=BD=AE->?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8F=82=E6=95=B0=E5=8F=AF=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/posts/Sites.php | 113 ++++--------------- application/admin/view/posts/sites/edit.html | 111 ++++++++++++++---- public/assets/js/backend/posts/sites.js | 48 ++++++-- 3 files changed, 149 insertions(+), 123 deletions(-) diff --git a/application/admin/controller/posts/Sites.php b/application/admin/controller/posts/Sites.php index d1906b8d5..59cd60804 100644 --- a/application/admin/controller/posts/Sites.php +++ b/application/admin/controller/posts/Sites.php @@ -35,7 +35,7 @@ class Sites extends Backend { //从站点管理登录,进入自己的站点配置页 if(Session::has("user_site_id")) { - $this->redirect('posts/sites/config?addtabs=1'); + $this->redirect('posts/sites/edit?addtabs=1'); } //超级管理员从总后台登录 else { @@ -70,88 +70,6 @@ class Sites extends Backend } } - /** - * Config - */ - public function config() - { - $row = $this->model->get(Session::get("user_site_id")); - - $settings = ['seo' => [ - 'zh-cn' => [ - 'title'=>'', - 'keywords'=>'', - 'description'=>'' - ] - ], 'custom' => '']; - - if($this->request->isPost()){ - - $params = $this->request->post("row/a"); - if ($params) { - foreach ($params as $k => $v) { - if( in_array($k, ['name','domain','lang'])){ - if($k=='lang') - $params[$k] = implode(',', $v); - }else{ - unset($params[$k]); - } - } - $seo = $this->request->post("seo/a"); - $custom = $this->request->post("custom/a"); - if ($seo) { - $settings['seo'] = json_encode($seo, JSON_UNESCAPED_UNICODE); - } - if ($custom) { - $arr = []; - foreach ($custom as $k => $v) { - $arr[$v['field']] = $v['value']; - } - $settings['custom'] = json_encode($arr, JSON_UNESCAPED_UNICODE); - } - if($row) $params['id'] = $row['id']; - try - { - //是否采用模型验证 - if ($this->modelValidate) - { - $name = basename(str_replace('\\', '/', get_class($this->model))); - $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; - $this->model->validate($validate); - } - $result = $this->model->allowField(true)->save($params); - - if ($result !== false) - { - $this->model->config()->save($settings); - $this->model->refreshRulesCache(); - $this->success(); - } - else - { - $this->error($this->model->getError()); - } - } - catch (\think\exception\PDOException $e) - { - $this->error($e->getMessage()); - } - } - $this->error(__('Parameter %s can not be empty', '')); - } - - $this->view->assign('row', $row); - - if($row) { - $settings['seo'] = !empty($row->config->seo) ? json_decode($row->config->seo, true) : null; - $settings['custom'] = !empty($row->config->custom) ? json_decode($row->config->custom, true) : null; - } - $this->view->assign('settings', $settings); - $this->view->assign('multilanguage', Seven::build_langs('row[lang]', $row?$row['lang']:'', ['type'=>'checkbox'])); - return $this->view->fetch(); - - } - /** * Add */ @@ -222,13 +140,26 @@ class Sites extends Backend */ public function edit($ids = NULL) { - if(!$this->auth->isSuperAdmin()) { - $this->error(__('You have no permission')); - } + if(!$this->auth->isSuperAdmin()){ + $ids=Session::get("user_site_id"); + } + $row = $this->model->get($ids); if (!$row) $this->error(__('No Results were found')); + $settings = ['seo' => [ + 'zh-cn' => [ + 'title'=>'', + 'keywords'=>'', + 'description'=>'' + ] + ], 'custom' => [ + 'logo' => '', + 'favicon' => '', + ] + ]; + if ($this->request->isPost()) { @@ -252,6 +183,8 @@ class Sites extends Backend } $settings['custom'] = json_encode($arr, JSON_UNESCAPED_UNICODE); } + + if(!$row) $row=$this->model; try { @@ -265,7 +198,7 @@ class Sites extends Backend $result = $row->allowField(true)->save($params); if ($result !== false) { - $row->config()->save($settings); + $row->config->save($settings); $this->model->refreshRulesCache(); $this->success(); } @@ -281,10 +214,10 @@ class Sites extends Backend } $this->error(__('Parameter %s can not be empty', '')); } - $arr['seo'] = !empty($row->config->seo) ? json_decode($row->config->seo,true) : null; - $arr['custom'] = !empty($row->config->custom) ? json_decode($row->config->custom,true) : null; + $row['seo'] = !empty($row->config->seo) ? json_decode($row->config->seo,true) : null; + $row['custom'] = !empty($row->config->custom) ? json_decode($row->config->custom,true) : null; $this->view->assign("row", $row); - $this->view->assign('settings', $arr); + $this->view->assign('editstyle', $this->auth->isSuperAdmin()?'1':'0'); $this->view->assign('multilanguage', Seven::build_langs('row[lang]', $row['lang'], ['type'=>'checkbox'])); return $this->view->fetch(); } diff --git a/application/admin/view/posts/sites/edit.html b/application/admin/view/posts/sites/edit.html index 9f1428bb4..a5c24138e 100644 --- a/application/admin/view/posts/sites/edit.html +++ b/application/admin/view/posts/sites/edit.html @@ -1,7 +1,18 @@ +
                  + {if $editstyle==1}
                  + {/if}
                  + {if $editstyle!=1} +
                  +

                  {:__('Basic')}

                  +
                  + {else /}
                  + {/if} + +
                  @@ -38,6 +58,7 @@ {$multilanguage}
                  + {if $editstyle==1}
                  @@ -49,31 +70,37 @@
                  + {/if}
                  -
                  +
                  + {if $editstyle!=1} +
                  +

                  SEO配置

                  +
                  + {/if}
                  - +
                  - +
                  - +
                  - {foreach name="settings['seo']" item="lang" key="language"} + {foreach name="row['seo']" item="lang" key="language"} {notin name="language" value="zh-cn"}

                  {:__('Lang')} - {:config('site.multilanguages')[$language]}({$language})

                  @@ -99,21 +126,41 @@
                  -
                  -
                  -
                  - 变量名 - 变量值 -
                  - {foreach name="$settings['custom']" item="vo" key="key"} -
                  - - - -
                  - {/foreach} -
                  {:__('Append')}
                  -
                  +
                  + {if $editstyle!=1} +
                  +

                  自定义变量

                  +
                  + {/if} +
                  +
                  +
                  +
                  变量名
                  +
                  类型
                  +
                  变量值
                  +
                  +
                  + {foreach name="$row['custom']" item="vo" key="key"} +
                  +
                  +
                  + +
                  +
                  +
                  +
                  + +
                  +
                  + +
                  +
                  +
                  + {/foreach} +
                  + {:__('Append')} +
                  +
                  @@ -121,7 +168,7 @@
                  -