一大波修复和优化

This commit is contained in:
muzi_ys 2022-07-10 01:24:04 +08:00
parent c491923d38
commit e0d951cc27
26 changed files with 191 additions and 521 deletions

View File

@ -2,21 +2,21 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\model\Admin as aModel;
use app\common\model\AdminRole as rModel;
use app\common\model\User as userModel;
use app\Request;
use app\admin\extend\Util as Util;
use FormBuilder\Exception\FormBuilderException;
use FormBuilder\Factory\Elm;
use app\admin\extend\FormBuilder as Form;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\facade\Db;
use think\facade\Route as Url;
use think\Facade\Log;
use think\facade\Route as Url;
/**
* 账号管理
@ -161,7 +161,7 @@ class Admin extends AuthController
aModel::insert($data);
//添加前台用户
$userId = userModel::addAdminUser($data);
$res = aModel::update(['uid'=>$userId], ['id' => $id]);
$res = aModel::update(['uid' => $userId], ['id' => $id]);
} else {
$userInfo = aModel::get($id);
if ($userInfo['password'] != $data['password']) $data['password'] = md5(md5($data['password']));
@ -169,12 +169,12 @@ class Admin extends AuthController
$data['update_time'] = time();
aModel::update($data, ['id' => $id]);
//同步更新前台用户
$res = userModel::updateAdminUser($userInfo['uid'],$data);
$res = userModel::updateAdminUser($userInfo['uid'], $data);
}
// 提交事务
Db::commit();
}catch (Exception $exception){
Log::error('用户添加失败,失败原因'.$exception->getMessage());
} catch (Exception $exception) {
Log::error('用户添加失败,失败原因' . $exception->getMessage());
// 回滚事务
Db::rollback();
$res = false;

View File

@ -2,13 +2,13 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\model\AdminAuth as aModel;
use app\Request;
use Exception;
use FormBuilder\Exception\FormBuilderException;
use app\admin\extend\Util as Util;
use FormBuilder\Factory\Elm;
use app\admin\extend\FormBuilder as Form;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

View File

@ -2,9 +2,9 @@
namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\model\AdminLog as lModel;
use app\Request;
use app\admin\extend\Util as Util;
use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;

View File

@ -2,13 +2,13 @@
namespace app\admin\controller;
use app\common\model\AdminRole as rModel;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\model\AdminAuth as aModel;
use app\common\model\AdminRole as rModel;
use app\Request;
use FormBuilder\Exception\FormBuilderException;
use app\admin\extend\Util as Util;
use FormBuilder\Factory\Elm;
use app\admin\extend\FormBuilder as Form;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

View File

@ -2,18 +2,13 @@
namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\model\Comment as CommentModel;
use app\common\model\Document;
use app\common\model\DocumentCategory as cModel;
use app\common\model\Tag as TagModel;
use app\common\model\DocumentArticle;
use app\common\model\Comment as CommentModel;
use app\admin\extend\Util as Util;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\facade\Db;
use think\facade\Log;
/**
* Class Article
@ -73,7 +68,7 @@ class Article extends AuthController
* @author 木子的忧伤
* @date 2021-02-28 22:43
*/
public function save($id = "")
public function save()
{
$data = Util::postMore([
['id', ''],
@ -98,13 +93,12 @@ class Article extends AuthController
['author', $this->adminInfo['nickname']],
['uid', $this->adminId],
]);
if ($data['title'] == "") return app("json")->fail("文章名称不能为空");
if ($data['category_id'] == "") return app("json")->fail("栏目分类不能为空");
if ($data['cover_path'] == "") return app("json")->fail("主图不能为空");
$model = new Document();
$res = $model->updateInfo($data,Document::DOCUMENT_TYPE_ARTICLE);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:".$model->getError());
$res = $model->updateInfo($data, Document::DOCUMENT_TYPE_ARTICLE);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:" . $model->getError());
}
@ -155,14 +149,13 @@ class Article extends AuthController
*/
public function edit()
{
$where = Util::postMore([
['name', ''],
$where = Util::getMore([
['id', '']
]);
if ($where['id'] == '') {
$this->error('参数错误');
}
$info = (new Document())->getInfo($where["id"],Document::DOCUMENT_TYPE_ARTICLE);
$info = (new Document())->getInfo($where["id"], Document::DOCUMENT_TYPE_ARTICLE);
if (empty($info)) {
$this->error('数据不存在');
}

View File

@ -2,11 +2,10 @@
namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\constant\Data;
use app\common\model\DocumentCategory as aModel;
use app\common\model\DocumentCategoryContent;
use app\Request;
use app\admin\extend\Util as Util;
use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
@ -54,30 +53,29 @@ class Category extends AuthController
* @param $id
* @return
*/
public function save($id = "")
public function save()
{
$data = Util::postMore([
['id', ''],
['title', ''],
['alias', ''],
['type', ''],
['pid', 0],
['meta_title', ''],
['keywords', ''],
['description', ''],
['template', ''],
['link_str', ''],
['sort', 0],
['status', 1]
]);
if ($data['title'] == "") return app("json")->fail("分类名称不能为空");
if ($data['type'] == "") return app("json")->fail("类型不能为空");
if ($data['template'] == "") return app("json")->fail("模板不能为空");
//判断是否写了别名,没写则需要生成
if ($data['alias'] == "") $data['alias'] = get_rand_str(8);
if ($id == "") {
if ($data['id'] == "") {
$model = new aModel();
$res = $model->insert($data);
} else {
$res = aModel::update($data, ['id' => $id]);
$res = aModel::update($data, ['id' => $data['id']]);
}
cache(Data::DATA_DOCUMENT_CATEGORY_LIST, null);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");

View File

@ -9,6 +9,8 @@
namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\extend\Database;
use app\Request;
use Exception;
use FilesystemIterator;
@ -16,8 +18,6 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use app\common\extend\Database;
use app\admin\extend\Util as Util;
/*
* 数据库备份还原控制器

View File

@ -3,9 +3,9 @@
namespace app\admin\controller;
use app\common\model\Attachment;
use app\admin\extend\storage\QcloudCoService;
use app\admin\extend\Util as Util;
use app\common\model\Attachment;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
@ -32,8 +32,8 @@ class File extends AuthController
$saveName = Filesystem::putFile($fileType, $file);
$filePath = Filesystem::url($saveName);
//转换因为win导致的兼容问题
if(strtoupper(substr(PHP_OS,0,3))==='WIN'){
$filePath = str_replace( DIRECTORY_SEPARATOR, '/',$filePath);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$filePath = str_replace(DIRECTORY_SEPARATOR, '/', $filePath);
}
break;
case 2:
@ -62,8 +62,8 @@ class File extends AuthController
if (!file_exists($path)) mkdir($path, 0755, true);
$saveName = $path . md5(time()) . ".{$type}";
//转换因为win导致的兼容问题
if(strtoupper(substr(PHP_OS,0,3))==='WIN'){
$saveName = str_replace( DIRECTORY_SEPARATOR, '/',$saveName);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$saveName = str_replace(DIRECTORY_SEPARATOR, '/', $saveName);
}
if (file_put_contents($saveName, base64_decode(str_replace($result[1], '', $data['image'])))) return app("json")->success("上传成功", ['src' => "/" . $saveName]);
else return app("json")->fail("上传失败,写入文件失败!");
@ -81,7 +81,7 @@ class File extends AuthController
if ($request->isPost()) {
// 获取表单上传文件 例如上传了001.jpg
$file = $this->request->file('file');//根据表单name替换imgFile
$fileType = $this->request->post("type")?:'file';
$fileType = $this->request->post("type") ?: 'file';
switch ($fileType) {
case 'file':
$fileSize = 10 * 1024 * 1024;
@ -120,8 +120,8 @@ class File extends AuthController
$saveName = Filesystem::putFile($fileType, $file);
$filePath = Filesystem::url($saveName);
//转换因为win导致的兼容问题
if(strtoupper(substr(PHP_OS,0,3))==='WIN'){
$filePath = str_replace( DIRECTORY_SEPARATOR, '/',$filePath);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$filePath = str_replace(DIRECTORY_SEPARATOR, '/', $filePath);
}
return $saveName ? app("json")->code()->success("上传成功", ['filePath' => $filePath, "name" => basename($saveName)]) : app("json")->fail("上传失败");
} catch (ValidateException $e) {

View File

@ -2,11 +2,11 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\constant\Data;
use app\common\model\FriendLink as aModel;
use app\admin\extend\FormBuilder as Form;
use app\Request;
use app\admin\extend\Util as Util;
use Exception;
use FormBuilder\Exception\FormBuilderException;
use FormBuilder\Factory\Elm;

View File

@ -3,13 +3,13 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\model\Attachment;
use app\common\model\AttachmentCategory;
use Exception;
use FormBuilder\Exception\FormBuilderException;
use FormBuilder\Factory\Elm;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
@ -184,7 +184,7 @@ class Image extends AuthController
switch ($image['storage']) {
case 1:
$filePath = app()->getRootPath() . 'public' . $image['path'];
if (file_exists($filePath)){
if (file_exists($filePath)) {
unlink(app()->getRootPath() . 'public' . $image['path']);
}
break;

View File

@ -7,13 +7,13 @@ use app\common\model\Document;
use app\common\model\Document as DocumentModel;
use app\common\model\DocumentCategory;
use app\common\model\DocumentCategory as DocumentCategoryModel;
use app\common\model\FriendLink;
use app\common\model\MessageForm;
use app\common\model\User;
use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use \app\common\model\User;
use \app\common\model\FriendLink;
class Index extends AuthController
{
@ -87,7 +87,7 @@ class Index extends AuthController
}
$str = '';
if ($page == 1) {
if(file_exists('sitemap.xml'))
if (file_exists('sitemap.xml'))
unlink('sitemap.xml');
$str .= '<?xml version="1.0" encoding="utf-8"?>';
$str .= '<urlset>';
@ -102,7 +102,7 @@ class Index extends AuthController
$pagesize = 100;
//获取文章分类url
$documentCategoryModel=new DocumentCategoryModel();
$documentCategoryModel = new DocumentCategoryModel();
$categoryInfo = $documentCategoryModel->field('id,title,create_time')
->where('display', 1)->where('status', 1)
->page($page, $pagesize)
@ -111,14 +111,14 @@ class Index extends AuthController
foreach ($categoryInfo as $v) {
$str .= '<url>';
$str .= '<loc>' . $domain . url('article/lists?id=' . $v['id']) . '</loc>';
$str .= '<lastmod>' . $v['create_time']. '</lastmod>';
$str .= '<lastmod>' . $v['create_time'] . '</lastmod>';
$str .= '<changefreq>always</changefreq>';
$str .= '<priority>0.8</priority>';
$str .= '</url>';
}
//获取详细页分类url
$documentModel=new DocumentModel();
$documentInfo =$documentModel->field('id,create_time')
$documentModel = new DocumentModel();
$documentInfo = $documentModel->field('id,create_time')
->where('status', 1)
->page($page, $pagesize)
->order('id desc')->select();
@ -136,7 +136,7 @@ class Index extends AuthController
if (!(file_put_contents('sitemap.xml', $str, FILE_APPEND | LOCK_EX))) {
$this->error('站点地图更新失败!');
} else {
$this->success('站点地图全部更新完成!', null,'stop');
$this->success('站点地图全部更新完成!', null, 'stop');
}
}
//写入

View File

@ -2,9 +2,9 @@
namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\model\InvitationCode as aModel;
use app\Request;
use app\admin\extend\Util as Util;
use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;

View File

@ -3,8 +3,8 @@
namespace app\admin\controller;
use app\common\model\Admin as adminModel;
use app\admin\extend\Util as Util;
use app\common\model\Admin as adminModel;
use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;

View File

@ -2,9 +2,9 @@
namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\model\MessageForm as aModel;
use app\Request;
use app\admin\extend\Util as Util;
use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;

View File

@ -3,17 +3,16 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\constant\Data;
use app\common\model\Nav as aModel;
use app\Request;
use app\admin\extend\Util as Util;
use Exception;
use FormBuilder\Exception\FormBuilderException;
use FormBuilder\Factory\Elm;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Route as Url;
/**
* Class Nav
@ -60,7 +59,7 @@ class Nav extends AuthController
$form = array();
$form[] = Elm::select('pid', '上级导航', (int)$pid)->options(aModel::returnOptions())->col(10);
$form[] = Elm::input('title', '导航名称')->col(10);
// $form[] = Elm::frameInput('icon', '图标', Url::buildUrl('admin/icon/index', array('fodder' => 'icon')))->icon("ios-ionic")->width('96%')->height('390px')->col(10);
// $form[] = Elm::frameInput('icon', '图标', Url::buildUrl('admin/icon/index', array('fodder' => 'icon')))->icon("ios-ionic")->width('96%')->height('390px')->col(10);
$form[] = Elm::input('url', '链接地址')->col(10);
$form[] = Elm::input('params', '参数')->placeholder("php数组,不懂不要填写")->col(10);
$form[] = Elm::number('sort', '排序')->col(10);

View File

@ -2,9 +2,9 @@
namespace app\admin\controller;
use app\common\model\Document;
use app\common\model\Comment as CommentModel;
use app\admin\extend\Util as Util;
use app\common\model\Comment as CommentModel;
use app\common\model\Document;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
@ -84,7 +84,7 @@ class Page extends AuthController
['is_recommend', 0],
['is_top', 0],
['is_hot', 0],
['theme',''],
['theme', ''],
['link_str', ''],
['cover_path', ''],
['display', 1],
@ -98,8 +98,8 @@ class Page extends AuthController
if ($data['theme'] == "") return app("json")->fail("文章模板不能为空");
if ($data['cover_path'] == "") return app("json")->fail("主图不能为空");
$model = new Document();
$res = $model->updateInfo($data,Document::DOCUMENT_TYPE_PAGE);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:".$model->getError());
$res = $model->updateInfo($data, Document::DOCUMENT_TYPE_PAGE);
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败,错误原因:" . $model->getError());
}
@ -151,7 +151,7 @@ class Page extends AuthController
if ($where['id'] == '') {
$this->error('数据不存在');
}
$info = (new Document())->getInfo($where["id"],Document::DOCUMENT_TYPE_PAGE);
$info = (new Document())->getInfo($where["id"], Document::DOCUMENT_TYPE_PAGE);
if (empty($info)) {
$this->error('数据不存在');
}

View File

@ -2,6 +2,8 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\constant\Data;
use app\common\model\SystemConfig as cModel;
use app\common\model\SystemConfigTab as tModel;
@ -9,8 +11,6 @@ use app\Request;
use Exception;
use FormBuilder\Exception\FormBuilderException;
use FormBuilder\Factory\Elm;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use Psr\SimpleCache\InvalidArgumentException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;

View File

@ -3,13 +3,13 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\model\SystemConfig as cModel;
use app\common\model\SystemConfigTab as tModel;
use app\Request;
use FormBuilder\Exception\FormBuilderException;
use FormBuilder\Factory\Elm;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\model\SystemConfigTab as tModel;
use app\common\model\SystemConfig as cModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

View File

@ -2,8 +2,8 @@
namespace app\admin\controller;
use app\Request;
use app\admin\extend\Util as Util;
use app\Request;
/**
* Trait TemplateTrait

View File

@ -2,9 +2,8 @@
namespace app\admin\controller;
use app\common\model\SystemConfig as cModel;
use app\Request;
use app\admin\extend\Util as Util;
use app\common\model\SystemConfig as cModel;
use Exception;
/**

View File

@ -2,13 +2,13 @@
namespace app\admin\controller;
use app\admin\extend\FormBuilder as Form;
use app\admin\extend\Util as Util;
use app\common\model\User as aModel;
use app\Request;
use app\admin\extend\Util as Util;
use Exception;
use FormBuilder\Exception\FormBuilderException;
use FormBuilder\Factory\Elm;
use app\admin\extend\FormBuilder as Form;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

View File

@ -23,12 +23,12 @@
<div class="tab-pane fade active in" id="home">
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label>文章名称</label>
<input type="text" class="form-control" id="title" name="title" value="{$info.title}" placeholder="文章名称"/>
<label for="title">文章名称</label>
<input type="text" class="form-control" id="title" name="title" placeholder="文章名称"/>
</div>
<div class="form-group col-md-12">
<label>别名</label>
<input type="text" class="form-control" id="alias" name="alias" value="{$info.alias}" placeholder="别名索引"/>
<label for="alias">别名</label>
<input type="text" class="form-control" id="alias" name="alias" placeholder="别名索引"/>
</div>
<div class="form-group col-md-12">
<label for="category_id">栏目分类</label>
@ -69,8 +69,8 @@
placeholder="请输入摘要">
</div>
<div class="form-group col-md-12">
<label for="abstract">标签</label>
<input class="form-control js-tags-input" type="text" name="tags" data-height="38px"
<label for="tags">标签</label>
<input class="form-control js-tags-input" id="tags" type="text" name="tags" data-height="38px"
placeholder="请输入标签">
</div>
<div class="form-group col-md-12">
@ -113,8 +113,8 @@
</div>
</div>
<div class="form-group col-md-12">
<label for="abstract">排序</label>
<input type="text" class="form-control" name="sort" placeholder="请输入排序" value="99">
<label for="sort">排序</label>
<input type="text" class="form-control" id="sort" name="sort" placeholder="请输入排序" value="99">
</div>
<div class="form-group col-md-12">
<label for="link_str">外链</label>

View File

@ -23,12 +23,12 @@
<div class="tab-pane fade active in" id="home">
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label>文章名称</label>
<label for="title">文章名称</label>
<input type="hidden" name="id" value="{$info.id}">
<input type="text" class="form-control" id="title" name="title" placeholder="文章名称" value="{$info.title}"/>
</div>
<div class="form-group col-md-12">
<label>别名</label>
<label for="alias">别名</label>
<input type="text" class="form-control" id="alias" name="alias" value="{$info.alias}"
placeholder="别名索引"/>
</div>

View File

@ -3,66 +3,42 @@
<head>
<title>添加分类 - {:system_config('title')}后台管理系统</title>
{include file="public/header" /}
<!--标签插件-->
<link rel="stylesheet" href="/static/admin/js/jquery-tags-input/jquery.tagsinput.min.css">
<!--富文本输入框-->
<link rel="stylesheet" href="/static/admin/js/summernote/summernote.min.css">
</head>
<body>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<ul id="myTabs" class="nav nav-tabs" role="tablist">
<li class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab">基本信息</a></li>
<li><a href="#profile" role="tab" id="profile-tab" data-toggle="tab">SEO设置</a></li>
<li class="tab-right"><a data-toggle="tooltip" data-original-title="返回"
onclick="history.back(-1);return false;"><i class="mdi mdi-undo"></i></a></li>
<div class="card-header">
<h4>基本信息</h4>
<ul class="card-actions">
<li>
<button type="button" data-toggle="tooltip" title="" data-original-title="返回"
onclick="history.back(-1);return false;"><i class="mdi mdi-undo"></i></button>
</li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="home">
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label>分类名称</label>
<input type="text" class="form-control" id="title" name="title" value=""
placeholder="分类名称"/>
</div>
<div class="form-group col-md-12">
<label>别名</label>
<input type="text" class="form-control" id="alias" name="alias" value=""
placeholder="别名"/>
</div>
<div class="form-group col-md-12">
</div>
<div class="card-body">
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label for="title">分类名称</label>
<input type="text" class="form-control" id="title" name="title" value="" placeholder="分类名称"/>
</div>
<div class="form-group col-md-12">
<div class="row">
<div class="col-xs-3">
<label for="pid">上级分类</label>
<div class="form-controls">
<select name="pid" id="pid" class="form-control">
<option value="">请选择</option>
<option value="0">顶级分类</option>
{volist name="category" id="vo"}
<option value="{$vo.id}" {notempty name="pid" }{if $vo.id== $pid}selected{
/if}{/notempty}>{$vo.html}{$vo.title}</option>
<option value="{$vo.id}" {notempty name="pid" }{if $vo.id== $pid}selected{/if}{/notempty}>{$vo.html}{$vo.title}</option>
{/volist}
</select>
</div>
</div>
<div class="form-group col-md-12">
<label>排序</label>
<input type="text" class="form-control" name="sort" placeholder="请输入排序">
</div>
<div class="form-group col-md-12">
<label>属性</label>
<div class="form-controls">
<select name="type" id="type" class="form-control">
<!-- <option value="0">请选择</option>-->
<option value="1">列表</option>
<option value="2">单页</option>
<option value="3">外联</option>
</select>
</div>
</div>
<div class="form-group col-md-12">
<label>主题风格</label>
<div class="form-controls">
<div class="col-xs-3">
<label>展示模板</label>
<div class="form-group form-controls">
<select name="template" class="form-control">
{volist name="template_list" id="vo"}
<option value="{$vo.template}">{$vo.name}</option>
@ -70,44 +46,33 @@
</select>
</div>
</div>
<div class="form-group col-md-12" id="page-link-str" style="display: none">
<label>外链</label>
<input type="text" class="form-control" name="link_str" placeholder="外链">
<div class="col-xs-3">
<label for="alias">URL名称</label>
<input class="form-control" id="alias" name="alias" type="text" placeholder="URL名称">
</div>
<div class="form-group col-md-12" id="page-content" style="display: none">
<label>单页内容</label>
<textarea id="content" name="content" data-provide="summernote" data-min-height="480"></textarea>
<div class="col-xs-3">
<label for="sort">排序</label>
<input type="text" class="form-control" id="sort" name="sort" placeholder="请输入排序" value="99">
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary ajax-post" target-form="add-form">立即提交
</button>
</div>
</form>
</div>
</div>
<div class="tab-pane fade" id="profile">
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label for="meta_title">seo标题</label>
<input type="text" class="form-control" id="meta_title" name="meta_title"
placeholder="请输入seo关键字">
</div>
<div class="form-group col-md-12">
<label for="keywords">seo关键字</label>
<input type="text" class="form-control" id="keywords" name="keywords"
placeholder="请输入seo关键字">
</div>
<div class="form-group col-md-12">
<label for="description">seo描述</label>
<input type="text" class="form-control" name="description" id="description"
placeholder="seo描述">
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary ajax-post" target-form="add-form">立即提交
</button>
</div>
</form>
<div class="form-group col-md-12">
<label for="meta_title">seo标题</label>
<input type="text" class="form-control" id="meta_title" name="meta_title" placeholder="请输入seo关键字">
</div>
</div>
<div class="form-group col-md-12">
<label for="keywords">seo关键字</label>
<input type="text" class="form-control" id="keywords" name="keywords" placeholder="请输入seo关键字">
</div>
<div class="form-group col-md-12">
<label for="description">seo描述</label>
<input type="text" class="form-control" name="description" id="description" placeholder="seo描述">
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary ajax-post" target-form="add-form">立即提交
</button>
</div>
</form>
</div>
</div>
</div>
@ -115,104 +80,7 @@
{include file="public/footer"/}
<!--select2-->
<script type="text/javascript" src="/static/admin/js/select2.min.js"></script>
<!--富文本输入框-->
<script type="text/javascript" src="/static/admin/js/summernote/summernote.min.js"></script>
<script type="text/javascript" src="/static/admin/js/summernote/lang/summernote-zh-CN.min.js"></script>
<!--标签-->
<script src="/static/admin/js/jquery-tags-input/jquery.tagsinput.min.js"></script>
<script>
$(function () {
$('#tag').select2();
});
$(document).ready(function(){
$('[data-provide="summernote"]').each(function() {
var options = {
dialogsInBody: true,
lang: 'zh-CN',
dialogsFade: true
};
var config = {};
$.each( $(this).data(), function(key, value){
key = key.replace(/-([a-z])/g, function(x){return x[1].toUpperCase();});
if ( key == 'provide' ) {
return;
}
config[key] = value;
});
options = $.extend(options, config);
options.toolbar = [
// [groupName, [list of button]]
['para_style', ['style']],
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontname', 'fontsize', 'height']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph', 'hr']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['do', ['undo', 'redo']],
['misc', ['fullscreen', 'codeview']]
];
$(this).summernote(options);
});
$(document).on('click', '[data-summernote-edit]', function(){
var target = $(this).data('summernote-edit');
$(target).summernote({focus: true});
});
$(document).on('click', '[data-summernote-save]', function(){
var target = $(this).data('summernote-save');
var markup = $(target).summernote('code');
$(target).summernote('destroy');
alert('修改完成');
});
});
/**
* 选择文件
* @param inputName
*/
function btnClick(inputName) {
$("#file_" + inputName).click()
}
/**
* 异步上传
* @param inputName
*/
function upload(inputName) {
var formData = new FormData();
formData.append("type", 'image');
formData.append("file", $("#file_" + inputName)[0].files[0]);
$.ajax({
type: 'POST',
url: '/admin/file/upload',
data: formData,
cache: false,
processData: false,
contentType: false,
success: function (res) {
if (res.code == 200) {
$("#" + inputName).val(res.data.filePath);
let html = ' <figure>\n' +
' <img src="' + res.data.filePath + '" alt="' + res.data.name + '">\n' +
' <figcaption>\n' +
' <a class="btn btn-round btn-square btn-danger btn-image-delete" href="#!"><i class="mdi mdi-delete"></i></a>\n' +
' </figcaption>\n' +
' </figure>';
$('#pic-image').html(html);
$('#pic-image').show().next('li').hide();
} else {
lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
return false;
}
}
});
}
$(".add-form").submit(function () {
let Arr = $('.add-form').serializeArray();
let checkResult = true;
@ -224,6 +92,11 @@
throw "分类名称不能为空";
}
break;
case 'template':
if (!item.value) {
throw "展示模板不能为空";
}
break;
}
} catch (error) {
lightyear.notify(error, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
@ -245,37 +118,6 @@
});
return true;
})
//删除事件
$('body').on('click', '.btn-image-delete', function () {
$('#pic-image').hide().next('li').show();
$('#cover_path').val('');
})
// 切换类型选择事件
$("body").on("change", "#type", function () {
let type = parseInt($(this).val());
switch (type) {
case 1:
//普通
$('#page-link-str').hide().children('input').val();
$('#page-content').hide().children('textarea').val();
break;
case 2:
$('#page-content').show();
$('#page-link-str').hide().children('input').val();
break;
case 3:
//单页
//外联
$('#page-link-str').show();
$('#page-content').hide().children('textarea').val();
break;
default:
break;
}
return true;
})
</script>
</body>
</html>

View File

@ -3,121 +3,77 @@
<head>
<title>添加文章 - {:system_config('title')}后台管理系统</title>
{include file="public/header" /}
<!--标签插件-->
<link rel="stylesheet" href="/static/admin/js/jquery-tags-input/jquery.tagsinput.min.css">
<!--富文本输入框-->
<link rel="stylesheet" href="/static/admin/js/summernote/summernote.min.css">
</head>
<body>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<ul id="myTabs" class="nav nav-tabs" role="tablist">
<li class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab">基本信息</a></li>
<li><a href="#profile" role="tab" id="profile-tab" data-toggle="tab">SEO设置</a></li>
<li class="tab-right"><a data-toggle="tooltip" data-original-title="返回"
onclick="history.back(-1);return false;"><i class="mdi mdi-undo"></i></a></li>
<div class="card-header">
<h4>基本信息</h4>
<ul class="card-actions">
<li>
<button type="button" data-toggle="tooltip" title="" data-original-title="返回"
onclick="history.back(-1);return false;"><i class="mdi mdi-undo"></i></button>
</li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="home">
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label>分类名称</label>
<input type="text" class="form-control" id="title" name="title" value="{$info.title}"
placeholder="分类名称"/>
</div>
<div class="form-group col-md-12">
<label>别名</label>
<input type="text" class="form-control" id="alias" name="alias"
value="{$info.alias}" placeholder="别名"/>
</div>
<div class="form-group col-md-12">
</div>
<div class="card-body">
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label for="title">分类名称</label>
<input type="hidden" name="id" value="{$info.id}">
<input type="text" class="form-control" id="title" name="title" value="{$info.title}" placeholder="分类名称"/>
</div>
<div class="form-group col-md-12">
<div class="row">
<div class="col-xs-3">
<label for="pid">上级分类</label>
<div class="form-controls">
<select name="pid" id="pid" class="form-control">
<option value="">请选择</option>
<option value="0">顶级分类</option>
{volist name="category" id="vo"}
<option value="{$vo.id}" {if $vo.id== $info.pid}selected{
/if}>{$vo.html}{$vo.title}</option>
<option value="{$vo.id}" {notempty name="pid" }{if $vo.id== $pid}selected{/if}{/notempty}>{$vo.html}{$vo.title}</option>
{/volist}
</select>
</div>
</div>
<div class="form-group col-md-12">
<label>排序</label>
<input type="text" class="form-control" name="sort" placeholder="请输入排序"
value="{$info.sort}">
</div>
<div class="form-group col-md-12">
<label>属性</label>
<div class="form-controls">
<select name="type" id="type" class="form-control">
<option value="0" {if 0== $info.type}selected{
/if}>请选择</option>
<option value="1" {if 1== $info.type}selected{
/if}>列表</option>
<option value="2" {if 2== $info.type}selected{
/if}>单页</option>
<option value="3" {if 3== $info.type}selected{
/if}>外联</option>
</select>
</div>
</div>
<div class="form-group col-md-12">
<label>主题风格</label>
<div class="form-controls">
<div class="col-xs-3">
<label>展示模板</label>
<div class="form-group form-controls">
<select name="template" class="form-control">
{volist name="template_list" id="vo"}
<option value="{$vo.template}" {notempty name="info.template" }{if
$vo.template== $info.template}selected{
/if}{/notempty}>{$vo.name}</option>
<option value="{$vo.template}" {notempty name="info.template" }{if $vo.template== $info.template}selected{/if}{/notempty}>{$vo.name}</option>
{/volist}
</select>
</div>
</div>
<div class="form-group col-md-12" id="page-link-str" {if
3!=$info.type}style="display:none;"{/if}>
<label>外链</label>
<input type="text" class="form-control" name="link_str" placeholder="外链"
value="{$info.link_str}">
<div class="col-xs-3">
<label for="alias">URL名称</label>
<input class="form-control" id="alias" name="alias" type="text" value="{$info.alias}" placeholder="URL名称">
</div>
<div class="form-group col-md-12" id="page-content" {if
2!=$info.type}style="display:none;"{/if}>
<label>单页内容</label>
<textarea id="content" name="content" data-min-height="480" data-provide="summernote">{$info.content}</textarea>
<div class="col-xs-3">
<label for="sort">排序</label>
<input type="text" class="form-control" id="sort" name="sort" placeholder="请输入排序" value="{$info.sort}">
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary ajax-post" target-form="add-form">立即提交
</button>
</div>
</form>
</div>
</div>
<div class="tab-pane fade" id="profile">
<form action="#!" method="post" class="row add-form" onsubmit="return false;">
<div class="form-group col-md-12">
<label for="meta_title">seo标题</label>
<input type="text" class="form-control" id="meta_title" name="meta_title"
placeholder="请输入seo关键字" value="{$info.meta_title}">
</div>
<div class="form-group col-md-12">
<label for="keywords">seo关键字</label>
<input type="text" class="form-control" id="keywords" name="keywords"
placeholder="请输入seo关键字" value="{$info.keywords}">
</div>
<div class="form-group col-md-12">
<label for="description">seo描述</label>
<input type="text" class="form-control" name="description" id="description"
placeholder="seo描述" value="{$info.description}">
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary ajax-post" target-form="add-form">立即提交
</button>
</div>
</form>
<div class="form-group col-md-12">
<label for="meta_title">seo标题</label>
<input type="text" class="form-control" id="meta_title" name="meta_title" placeholder="请输入seo关键字" value="{$info.meta_title}">
</div>
</div>
<div class="form-group col-md-12">
<label for="keywords">seo关键字</label>
<input type="text" class="form-control" id="keywords" name="keywords" placeholder="请输入seo关键字" value="{$info.keywords}">
</div>
<div class="form-group col-md-12">
<label for="description">seo描述</label>
<input type="text" class="form-control" name="description" id="description" placeholder="seo描述" value="{$info.description}">
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-primary ajax-post" target-form="add-form">立即提交
</button>
</div>
</form>
</div>
</div>
</div>
@ -125,104 +81,7 @@
{include file="public/footer"/}
<!--select2-->
<script type="text/javascript" src="/static/admin/js/select2.min.js"></script>
<!--富文本输入框-->
<script type="text/javascript" src="/static/admin/js/summernote/summernote.min.js"></script>
<script type="text/javascript" src="/static/admin/js/summernote/lang/summernote-zh-CN.min.js"></script>
<!--标签-->
<script src="/static/admin/js/jquery-tags-input/jquery.tagsinput.min.js"></script>
<script>
$(function () {
$('#tag').select2();
});
$(document).ready(function(){
$('[data-provide="summernote"]').each(function() {
var options = {
dialogsInBody: true,
lang: 'zh-CN',
dialogsFade: true
};
var config = {};
$.each( $(this).data(), function(key, value){
key = key.replace(/-([a-z])/g, function(x){return x[1].toUpperCase();});
if ( key == 'provide' ) {
return;
}
config[key] = value;
});
options = $.extend(options, config);
options.toolbar = [
// [groupName, [list of button]]
['para_style', ['style']],
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontname', 'fontsize', 'height']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph', 'hr']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['do', ['undo', 'redo']],
['misc', ['fullscreen', 'codeview']]
];
$(this).summernote(options);
});
$(document).on('click', '[data-summernote-edit]', function(){
var target = $(this).data('summernote-edit');
$(target).summernote({focus: true});
});
$(document).on('click', '[data-summernote-save]', function(){
var target = $(this).data('summernote-save');
var markup = $(target).summernote('code');
$(target).summernote('destroy');
alert('修改完成');
});
});
/**
* 选择文件
* @param inputName
*/
function btnClick(inputName) {
$("#file_" + inputName).click()
}
/**
* 异步上传
* @param inputName
*/
function upload(inputName) {
var formData = new FormData();
formData.append("type", 'image');
formData.append("file", $("#file_" + inputName)[0].files[0]);
$.ajax({
type: 'POST',
url: '/admin/file/upload',
data: formData,
cache: false,
processData: false,
contentType: false,
success: function (res) {
if (res.code == 200) {
$("#" + inputName).val(res.data.filePath);
let html = ' <figure>\n' +
' <img src="' + res.data.filePath + '" alt="' + res.data.name + '">\n' +
' <figcaption>\n' +
' <a class="btn btn-round btn-square btn-danger btn-image-delete" href="#!"><i class="mdi mdi-delete"></i></a>\n' +
' </figcaption>\n' +
' </figure>';
$('#pic-image').html(html);
$('#pic-image').show().next('li').hide();
} else {
lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
return false;
}
}
});
}
$(".add-form").submit(function () {
let Arr = $('.add-form').serializeArray();
let checkResult = true;
@ -234,6 +93,11 @@
throw "分类名称不能为空";
}
break;
case 'template':
if (!item.value) {
throw "展示模板不能为空";
}
break;
}
} catch (error) {
lightyear.notify(error, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
@ -245,47 +109,16 @@
if (!checkResult) {
return false;
}
$.post(url = "/admin/category/save?id={$info.id}", $('.add-form').serialize(), function (res) {
$.post(url = "/admin/category/save", $('.add-form').serialize(), function (res) {
if (res.code == 200) {
lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
setTimeout(function () {
parent.location.reload();
location.href = '/admin/category/index';
}, 2000)
} else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
});
return true;
})
//删除事件
$('body').on('click', '.btn-image-delete', function () {
$('#pic-image').hide().next('li').show();
$('#cover_path').val('');
})
// 切换类型选择事件
$("body").on("change", "#type", function () {
let type = parseInt($(this).val());
switch (type) {
case 1:
//普通
$('#page-link-str').hide().children('input').val();
$('#page-content').hide().children('textarea').val();
break;
case 2:
$('#page-content').show();
$('#page-link-str').hide().children('input').val();
break;
case 3:
//单页
//外联
$('#page-link-str').show();
$('#page-content').hide().children('textarea').val();
break;
default:
break;
}
return true;
})
</script>
</body>
</html>

View File

@ -59,14 +59,14 @@ class Document extends BaseModel
* @param string $status
* @return array
*/
public function getInfo($id,$type= self::DOCUMENT_TYPE_ARTICLE,$status = ''): array
public function getInfo($id,$type= self::DOCUMENT_TYPE_ARTICLE,$status = 1): array
{
if (empty($id)){
return [];
}
$model = self::alias('a')
->leftJoin('document_article p','a.id = p.id')
->where("a.type",Document::DOCUMENT_TYPE_PAGE);
->field("a.*,p.content")
->leftJoin('document_article p','a.id = p.id');
if (is_numeric($id)){
$model->where("a.id",$id);
}else{
@ -102,6 +102,12 @@ class Document extends BaseModel
if ($data['is_hot']) $data['is_hot'] = 1;
if ($data['display']) $data['display'] = 1;
if ($data['is_top']) $data['is_top'] = 1;
//判断是否主键冲突
$info = $this->where("alias",$data['alias'])->find();
if ($info && (!empty($data['id']) && $info->id != $data['id'] )){
self::setErrorInfo("别名已存在,请修改后重试");
return false;
}
// 启动事务
Db::startTrans();
if (empty($data['id'])) {