diff --git a/app/common.php b/app/common.php index 5af1fe01..86fdda6f 100755 --- a/app/common.php +++ b/app/common.php @@ -25,6 +25,8 @@ function is_administrator() { function hook() {} +function widget() {} + /** * 获取客户端IP地址 * @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字 diff --git a/app/controller/admin/Database.php b/app/controller/admin/Database.php index 3bce5733..855962ab 100644 --- a/app/controller/admin/Database.php +++ b/app/controller/admin/Database.php @@ -76,6 +76,7 @@ class Database extends Admin { $this->assign('list', $list); return $this->fetch($type); } + /** * @title 优化表 * @param String $tables 表名 diff --git a/app/controller/admin/Form.php b/app/controller/admin/Form.php index 9527087e..6be170e5 100644 --- a/app/controller/admin/Form.php +++ b/app/controller/admin/Form.php @@ -6,9 +6,10 @@ // +---------------------------------------------------------------------- // | Author: molong // +---------------------------------------------------------------------- +namespace app\controller\admin; -namespace app\admin\controller; -use app\common\controller\Admin; +use app\controller\Admin; +use app\model\Form as FormM; /** * @title 自定义表单 @@ -16,33 +17,20 @@ use app\common\controller\Admin; */ class Form extends Admin { - public function _initialize() { - parent::_initialize(); - $this->model = model('Form'); - $this->Fattr = model('FormAttr'); - //遍历属性列表 - foreach (get_attribute_type() as $key => $value) { - $this->attr[$key] = $value[0]; - } - $this->field = $this->getField(); - } - /** * @title 表单列表 */ public function index() { - $map = array(); + $map = []; + $order = "id desc"; - $list = $this->model->where($map)->order($order)->paginate(25, false, array( - 'query' => $this->request->param() - )); - $data = array( + $list = FormM::where($map)->order($order)->paginate($this->request->pageConfig); + + $this->data = [ 'list' => $list, 'page' => $list->render(), - ); - $this->setMeta('自定义表单'); - $this->assign($data); + ]; return $this->fetch(); } diff --git a/app/controller/admin/Index.php b/app/controller/admin/Index.php index 3d8466a2..344bf536 100755 --- a/app/controller/admin/Index.php +++ b/app/controller/admin/Index.php @@ -77,7 +77,7 @@ class Index extends Admin { \think\Log::clear(); } } - return $this->success("更新成功!", url('admin/index/index')); + return $this->success("更新成功!", url('/admin/index/index')); } else { $keylist = array( array('name' => 'clear', 'title' => '更新缓存', 'type' => 'checkbox', 'help' => '', 'option' => array( diff --git a/app/controller/admin/Menu.php b/app/controller/admin/Menu.php index 3129c616..4f47031f 100644 --- a/app/controller/admin/Menu.php +++ b/app/controller/admin/Menu.php @@ -43,7 +43,9 @@ class Menu extends Admin { /** * @title 编辑菜单字段 */ - public function editable($name = null, $value = null, $pk = null) { + public function editable() { + $data = $this->request->param(); + if ($name && ($value != null || $value != '') && $pk) { db('Menu')->where(array('id' => $pk))->setField($name, $value); } @@ -67,18 +69,20 @@ class Menu extends Admin { return $this->error('新增失败'); } } else { - $this->assign('info', array('pid' => input('pid'))); - $menus = db('Menu')->select(); - $tree = new \com\Tree(); + $menus = MenuM::select()->toArray(); + + $tree = new \sent\tree\Tree(); $menus = $tree->toFormatTree($menus); + if (!empty($menus)) { $menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus); } else { $menus = array(0 => array('id' => 0, 'title_show' => '顶级菜单')); } - - $this->assign('Menus', $menus); - $this->setMeta('新增菜单'); + $this->data = [ + 'info' => ['pid' => $this->request->param('pid', 0)], + 'Menus' => $menus + ]; return $this->fetch('edit'); } } @@ -89,31 +93,34 @@ class Menu extends Admin { */ public function edit($id = 0) { if ($this->request->isPost()) { - $Menu = model('Menu'); - $data = input('post.'); - if ($Menu->save($data, array('id' => $data['id'])) !== false) { - session('admin_menu_list', null); - //记录行为 - action_log('update_menu', 'Menu', $data['id'], session('user_auth.uid')); - return $this->success('更新成功', Cookie('__forward__')); + $data = $this->request->post(); + + $result = MenuM::update($data, ['id' => $data['id']]); + + if (false !== $result) { + return $this->success('更新成功', '/admin/menu/index'); } else { return $this->error('更新失败'); } } else { - $info = array(); + $info = []; /* 获取数据 */ - $info = db('Menu')->field(true)->find($id); - $menus = db('Menu')->field(true)->select(); - $tree = new \com\Tree(); + $info = MenuM::find($id); + + $menus = MenuM::select()->toArray(); + + $tree = new \sent\tree\Tree(); $menus = $tree->toFormatTree($menus); $menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus); - $this->assign('Menus', $menus); if (false === $info) { return $this->error('获取后台菜单信息错误'); } - $this->assign('info', $info); - $this->setMeta('编辑后台菜单'); + + $this->data = [ + 'Menus' => $menus, + 'info' => $info + ]; return $this->fetch(); } } diff --git a/app/controller/admin/Seo.php b/app/controller/admin/Seo.php index 5e83d6b6..8eacd158 100644 --- a/app/controller/admin/Seo.php +++ b/app/controller/admin/Seo.php @@ -6,41 +6,32 @@ // +---------------------------------------------------------------------- // | Author: molong // +---------------------------------------------------------------------- - namespace app\controller\admin; + use app\controller\Admin; +use app\model\SeoRule; +use app\model\Rewrite; /** * @title SEO管理 */ class Seo extends Admin { - protected $seo; - protected $rewrite; - - public function _initialize() { - parent::_initialize(); - $this->seo = model('SeoRule'); - $this->rewrite = model('Rewrite'); - } - /** * @title SEO列表 */ public function index($page = 1, $r = 20) { + $map = []; + //读取规则列表 - $map = array('status' => array('EGT', 0)); + $map[] = ['status', '>=', 0]; - $list = $this->seo->where($map)->order('sort asc')->paginate(10, false, array( - 'query' => $this->request->param(), - )); + $list = SeoRule::where($map)->order('sort asc')->paginate($this->request->pageConfig); - $data = array( + $this->data = [ 'list' => $list, 'page' => $list->render(), - ); - $this->assign($data); - $this->setMeta("规则列表"); + ]; return $this->fetch(); } @@ -111,14 +102,14 @@ class Seo extends Admin { * @title 伪静态列表 */ public function rewrite() { - $list = db('Rewrite')->paginate(10); + $map = []; - $data = array( + $list = Rewrite::where($map)->paginate($this->request->pageConfig); + + $this->data = [ 'list' => $list, 'page' => $list->render(), - ); - $this->assign($data); - $this->setMeta("路由规则"); + ]; return $this->fetch(); } diff --git a/app/http/middleware/Admin.php b/app/http/middleware/Admin.php index c499221e..c4d84da1 100755 --- a/app/http/middleware/Admin.php +++ b/app/http/middleware/Admin.php @@ -22,6 +22,7 @@ class Admin { $request->pageConfig = array( 'list_rows' => $request->param('limit', 20), 'page' => $request->param('page', 1), + 'query' => $request->param() ); $response = $next($request); diff --git a/app/model/Form.php b/app/model/Form.php index 6eda049e..44fae7c8 100644 --- a/app/model/Form.php +++ b/app/model/Form.php @@ -12,7 +12,7 @@ namespace app\model; /** * 表单 */ -class Form { +class Form extends \think\Model { protected $auto = ['update_time']; protected $insert = ['name', 'create_time', 'status' => 1, 'list_grid' => "id:ID\r\ntitle:标题\r\ncreate_time:添加时间|time_format\r\nupdate_time:更新时间|time_format"]; @@ -34,53 +34,53 @@ class Form { array('name' => 'list_grid', 'title' => '列表定义', 'type' => 'textarea', 'help' => ''), ); - protected static function init() { - self::beforeInsert(function ($event) { - $data = $event->toArray(); - $tablename = 'form_' . strtolower($data['name']); - //实例化一个数据库操作类 - $db = new \com\Datatable(); - //检查表是否存在并创建 - if (!$db->CheckTable($tablename)) { - //创建新表 - return $db->initTable($tablename, $data['title'], 'id')->query(); - } else { - return false; - } - }); - self::afterInsert(function ($event) { - $data = $event->toArray(); + // protected static function init() { + // self::beforeInsert(function ($event) { + // $data = $event->toArray(); + // $tablename = 'form_' . strtolower($data['name']); + // //实例化一个数据库操作类 + // $db = new \com\Datatable(); + // //检查表是否存在并创建 + // if (!$db->CheckTable($tablename)) { + // //创建新表 + // return $db->initTable($tablename, $data['title'], 'id')->query(); + // } else { + // return false; + // } + // }); + // self::afterInsert(function ($event) { + // $data = $event->toArray(); - $fields = include (APP_PATH . 'admin/fields.php'); - if (!empty($fields)) { - foreach ($fields as $key => $value) { - if (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) { - $fields[$key]['form_id'] = $data['id']; - } else { - unset($fields[$key]); - } - } - model('FormAttr')->saveAll($fields); - } - return true; - }); - // self::beforeUpdate(function($event){ - // $data = $event->toArray(); - // if (isset($data['attribute_sort']) && $data['attribute_sort']) { - // $attribute_sort = json_decode($data['attribute_sort'], true); + // $fields = include (APP_PATH . 'admin/fields.php'); + // if (!empty($fields)) { + // foreach ($fields as $key => $value) { + // if (in_array($key, array('uid', 'status', 'view', 'create_time', 'update_time'))) { + // $fields[$key]['form_id'] = $data['id']; + // } else { + // unset($fields[$key]); + // } + // } + // model('FormAttr')->saveAll($fields); + // } + // return true; + // }); + // // self::beforeUpdate(function($event){ + // // $data = $event->toArray(); + // // if (isset($data['attribute_sort']) && $data['attribute_sort']) { + // // $attribute_sort = json_decode($data['attribute_sort'], true); - // if (!empty($attribute_sort)) { - // foreach ($attribute_sort as $key => $value) { - // db('FormAttr')->where('id', 'IN', $value)->setField('group_id', $key); - // foreach ($value as $k => $v) { - // db('FormAttr')->where('id', $v)->setField('sort', $k); - // } - // } - // } - // } - // return true; - // }); - } + // // if (!empty($attribute_sort)) { + // // foreach ($attribute_sort as $key => $value) { + // // db('FormAttr')->where('id', 'IN', $value)->setField('group_id', $key); + // // foreach ($value as $k => $v) { + // // db('FormAttr')->where('id', $v)->setField('sort', $k); + // // } + // // } + // // } + // // } + // // return true; + // // }); + // } public function getStatusTextAttr($value, $data) { $status = array( diff --git a/app/model/Rewrite.php b/app/model/Rewrite.php index 50e67579..1f0f3c77 100644 --- a/app/model/Rewrite.php +++ b/app/model/Rewrite.php @@ -12,7 +12,7 @@ namespace app\model; /** * 伪静态 */ -class Rewrite { +class Rewrite extends \think\Model { protected $autoWriteTimestamp = true; diff --git a/app/model/SeoRule.php b/app/model/SeoRule.php index f8499a41..73ddb5ab 100644 --- a/app/model/SeoRule.php +++ b/app/model/SeoRule.php @@ -12,7 +12,7 @@ namespace app\model; /** * 用户模型 */ -class SeoRule { +class SeoRule extends \think\Model { public $keyList = array( array('name' => 'id', 'title' => '标识', 'type' => 'hidden'), diff --git a/view/admin/ad/index.html b/view/admin/ad/index.html index 8857ec84..162d9666 100644 --- a/view/admin/ad/index.html +++ b/view/admin/ad/index.html @@ -1,6 +1,6 @@ {extend name="admin/public/base"/} {block name="style"} - + {/block} {block name="body"}
@@ -51,7 +51,7 @@
{/block} {block name="script"} - + + + - + - + - + - - - - + + + + {/block} {block name="body"} @@ -81,8 +81,8 @@ {/block} {block name="script"} - - - - + + + + {/block} \ No newline at end of file diff --git a/view/admin/seo/index.html b/view/admin/seo/index.html index f7b5acfd..a992d55f 100644 --- a/view/admin/seo/index.html +++ b/view/admin/seo/index.html @@ -1,6 +1,6 @@ {extend name="admin/public/base"/} {block name="style"} - + {/block} {block name="body"}
@@ -51,7 +51,7 @@ {/block} {block name="script"} - +