This commit is contained in:
liyukun 2021-07-04 23:56:37 +08:00
parent dea2db3a18
commit 9c53d73287
32 changed files with 118 additions and 112 deletions

View File

@ -5,9 +5,9 @@ namespace app\admin\controller;
use app\common\model\Admin as aModel; use app\common\model\Admin as aModel;
use app\common\model\AdminRole as rModel; use app\common\model\AdminRole as rModel;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
use think\facade\Route as Url; use think\facade\Route as Url;
/** /**

View File

@ -5,9 +5,9 @@ namespace app\admin\controller;
use app\common\model\AdminAuth as aModel; use app\common\model\AdminAuth as aModel;
use app\Request; use app\Request;
use FormBuilder\Exception\FormBuilderException; use FormBuilder\Exception\FormBuilderException;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
use think\facade\Route as Url; use think\facade\Route as Url;
/** /**

View File

@ -4,7 +4,7 @@ namespace app\admin\controller;
use app\common\model\AdminLog as lModel; use app\common\model\AdminLog as lModel;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
/** /**
* 日志 * 日志

View File

@ -2,7 +2,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use app\common\model\AdminNotify as nModel; use app\common\model\AdminNotify as nModel;
/** /**
* 消息提醒 * 消息提醒

View File

@ -6,9 +6,9 @@ use app\common\model\AdminRole as rModel;
use app\common\model\AdminAuth as aModel; use app\common\model\AdminAuth as aModel;
use app\Request; use app\Request;
use FormBuilder\Exception\FormBuilderException; use FormBuilder\Exception\FormBuilderException;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
class AdminRole extends AuthController class AdminRole extends AuthController
{ {

View File

@ -6,7 +6,7 @@ use app\common\model\Document as aModel;
use app\common\model\DocumentCategory as cModel; use app\common\model\DocumentCategory as cModel;
use app\common\model\DocumentArticle; use app\common\model\DocumentArticle;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use think\Exception; use think\Exception;
use think\facade\Log; use think\facade\Log;

View File

@ -5,7 +5,7 @@ namespace app\admin\controller;
use app\common\model\DocumentCategory as aModel; use app\common\model\DocumentCategory as aModel;
use app\common\model\DocumentCategoryContent; use app\common\model\DocumentCategoryContent;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
/** /**
* Class Article * Class Article

View File

@ -4,8 +4,8 @@ namespace app\admin\controller;
use app\common\model\Attachment; use app\common\model\Attachment;
use app\admin\services\storage\QcloudCoService; use app\admin\service\storage\QcloudCoService;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\facade\Filesystem; use think\facade\Filesystem;
use think\Request; use think\Request;

View File

@ -3,9 +3,9 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\common\model\FriendLink as aModel; use app\common\model\FriendLink as aModel;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use think\facade\Route as Url; use think\facade\Route as Url;

View File

@ -6,9 +6,9 @@ namespace app\admin\controller;
use app\common\model\Attachment; use app\common\model\Attachment;
use app\common\model\AttachmentCategory; use app\common\model\AttachmentCategory;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
use app\admin\services\storage\QcloudCoService; use app\admin\service\storage\QcloudCoService;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use app\common\utils\Json; use app\common\utils\Json;
/** /**

View File

@ -5,7 +5,7 @@ namespace app\admin\controller;
use app\common\model\AdminAuth; use app\common\model\AdminAuth;
use app\common\model\AdminNotify; use app\common\model\AdminNotify;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
class Index extends AuthController class Index extends AuthController
{ {

View File

@ -4,7 +4,7 @@ namespace app\admin\controller;
use app\common\model\InvitationCode as aModel; use app\common\model\InvitationCode as aModel;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
/** /**
* Class Invitation * Class Invitation

View File

@ -5,7 +5,7 @@ namespace app\admin\controller;
use app\common\model\Admin; use app\common\model\Admin;
use app\common\model\Admin as adminModel; use app\common\model\Admin as adminModel;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
class Login extends AuthController class Login extends AuthController
{ {

View File

@ -4,7 +4,7 @@ namespace app\admin\controller;
use app\admin\model\MessageForm as aModel; use app\admin\model\MessageForm as aModel;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
/** /**
* Class Message * Class Message

View File

@ -3,9 +3,9 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\common\model\Slides as aModel; use app\common\model\Slides as aModel;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use think\facade\Route as Url; use think\facade\Route as Url;

View File

@ -6,8 +6,8 @@ use app\common\model\SystemConfig as cModel;
use app\common\model\SystemConfigTab as tModel; use app\common\model\SystemConfigTab as tModel;
use app\Request; use app\Request;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
/** /**
* 系统配置 * 系统配置

View File

@ -5,8 +5,8 @@ namespace app\admin\controller;
use app\Request; use app\Request;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use app\common\model\SystemConfigTab as tModel; use app\common\model\SystemConfigTab as tModel;
use app\common\model\SystemConfig as cModel; use app\common\model\SystemConfig as cModel;

View File

@ -3,7 +3,7 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
/** /**
* Trait TemplateTrait * Trait TemplateTrait

View File

@ -4,7 +4,7 @@ namespace app\admin\controller;
use app\common\model\SystemConfig as cModel; use app\common\model\SystemConfig as cModel;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
/** /**
* Class Theme * Class Theme

View File

@ -4,9 +4,9 @@ namespace app\admin\controller;
use app\common\model\User as aModel; use app\common\model\User as aModel;
use app\Request; use app\Request;
use app\admin\services\UtilService as Util; use app\admin\service\UtilService as Util;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
use app\admin\services\FormBuilderService as Form; use app\admin\service\FormBuilderService as Form;
use think\facade\Route as Url; use think\facade\Route as Url;
/** /**

View File

@ -1,14 +1,14 @@
<?php <?php
namespace app\admin\services; namespace app\admin\service;
use FormBuilder\Form\IviewForm; use FormBuilder\Form\IviewForm;
/** /**
* 表单构建 * 表单构建
* Class FormBuilderService * Class FormBuilderService
* @package app\admin\services * @package app\admin\service
*/ */
class FormBuilderService class FormBuilderService
{ {

View File

@ -1,12 +1,12 @@
<?php <?php
namespace app\admin\services; namespace app\admin\service;
/** /**
* UTIL * UTIL
* Class UtilService * Class UtilService
* @package app\admin\services * @package app\admin\service
*/ */
class UtilService class UtilService
{ {

View File

@ -1,7 +1,7 @@
<?php <?php
namespace app\common\utils; namespace app\common\service;
/** /**
* Class Curl * Class Curl

View File

@ -1,7 +1,7 @@
<?php <?php
namespace app\common\utils; namespace app\common\service;
use Firebase\JWT\JWT as jt; use Firebase\JWT\JWT as jt;
/** /**

View File

@ -1,7 +1,7 @@
<?php <?php
namespace app\common\utils; namespace app\common\service;
/** /**
* 宝塔邮件发送 * 宝塔邮件发送

View File

@ -1,7 +1,7 @@
<?php <?php
namespace app\common\utils; namespace app\common\service;
use think\facade\Session as systemSession; use think\facade\Session as systemSession;

View File

@ -13,9 +13,9 @@ function cn_substr($str,$len){
/** /**
* 时间戳格式化 * 时间戳格式化
*/ */
function MyDate($ft,$data){ //function date_format($ft,$data){
return date($ft,$data); // return date($ft,$data);
} //}
/** /**
* 过滤html标签 * 过滤html标签
*/ */
@ -28,7 +28,7 @@ function html2text($str){
* $strip=true过滤html * $strip=true过滤html
*/ */
function get_type_content($id,$strip=false){ function get_type_content($id,$strip=false){
$dc=Db::name('document_category_content')->find($id); $dc=\app\common\model\DocumentCategoryContent::find($id);
if(!$dc){ if(!$dc){
return ''; return '';
} }
@ -42,19 +42,19 @@ function get_type_content($id,$strip=false){
*/ */
function get_document_category_list(){ function get_document_category_list(){
//缓存文章菜单 //缓存文章菜单
$docuemtCategory=cache('DATA_DOCUMENT_CATEGORY_LIST'); $documentCategory=cache('DATA_DOCUMENT_CATEGORY_LIST');
if($docuemtCategory===null){ if($documentCategory===null){
$docuemtCategoryList= \app\common\model\DocumentCategory::where('status',1)->order('sort asc')->select()->toArray(); $documentCategoryList= \app\common\model\DocumentCategory::where('status',1)->order('sort asc')->select()->toArray();
//转换让id作为数组的键 //转换让id作为数组的键
$docuemtCategory=[]; $documentCategory=[];
foreach ($docuemtCategoryList as $key=>$item){ foreach ($documentCategoryList as $key=>$item){
//根据栏目类型生成栏目url //根据栏目类型生成栏目url
$item['url']=curl($item); $item['url']=curl($item);
$docuemtCategory[$item['id']]=$item; $documentCategory[$item['id']]=$item;
} }
cache('DATA_DOCUMENT_CATEGORY_LIST',$docuemtCategory); cache('DATA_DOCUMENT_CATEGORY_LIST',$documentCategory);
} }
return $docuemtCategory; return $documentCategory;
} }
@ -66,15 +66,15 @@ function get_document_category($x,$field=false){
throw new Exception('请指定要获取的栏目分类id'); throw new Exception('请指定要获取的栏目分类id');
} }
//获取缓存的文章菜单 //获取缓存的文章菜单
$docuemtCategoryList=get_document_category_list(); $documentCategoryList=get_document_category_list();
if(!isset($docuemtCategoryList[$x])){ if(!isset($documentCategoryList[$x])){
return false; return false;
} }
if($field){ if($field){
return $docuemtCategoryList[$x][$field]; return $documentCategoryList[$x][$field];
} }
else{ else{
return $docuemtCategoryList[$x]; return $documentCategoryList[$x];
} }
} }
@ -86,22 +86,22 @@ function get_document_category_by_name($name,$field=false){
throw new Exception('请指定要获取的栏目分类标识!'); throw new Exception('请指定要获取的栏目分类标识!');
} }
//获取缓存的文章菜单 //获取缓存的文章菜单
$docuemtCategoryList=get_document_category_list(); $documentCategoryList=get_document_category_list();
$docuemtCategory=false; $documentCategory=false;
foreach ($docuemtCategoryList as $item){ foreach ($documentCategoryList as $item){
if($item['name']==$name){ if($item['name']==$name){
$docuemtCategory=$item; $documentCategory=$item;
break; break;
} }
} }
if(!$docuemtCategory){ if(!$documentCategory){
return false; return false;
} }
if($field){ if($field){
return $docuemtCategory[$field]; return $documentCategory[$field];
} }
else{ else{
return $docuemtCategory; return $documentCategory;
} }
} }
@ -142,7 +142,7 @@ function tpl_get_channel($type,$typeid,$row=100,$where='',$orderby='',$display=1
if(!$dc){ if(!$dc){
throw new Exception('分类不存在或已删除!'); throw new Exception('分类不存在或已删除!');
} }
$tempArr=Db::name('document_category')->where('id','in',$dc['child'])->where('status',1)->limit($row); $tempArr=\app\common\model\DocumentCategory::where('id','in',$dc['child'])->where('status',1)->limit($row);
if($display){ if($display){
$tempArr=$tempArr->where('display',1); $tempArr=$tempArr->where('display',1);
} }
@ -173,7 +173,7 @@ function tpl_get_channel($type,$typeid,$row=100,$where='',$orderby='',$display=1
$dc=get_document_category($typeid); $dc=get_document_category($typeid);
if($dc['pid']!=0){ if($dc['pid']!=0){
//获取根分类,此操作读取数据库,非缓存! //获取根分类,此操作读取数据库,非缓存!
$dc=Db::name('document_category')-where('pid',0)->where('status',1) $dc=\app\common\model\DocumentCategory::where('pid',0)->where('status',1)
-> where("CONCAT(',',child,',') like '%,$typeid,%'")->limit($row); -> where("CONCAT(',',child,',') like '%,$typeid,%'")->limit($row);
if($display){ if($display){
$dc=$dc->where('display',1); $dc=$dc->where('display',1);
@ -190,7 +190,7 @@ function tpl_get_channel($type,$typeid,$row=100,$where='',$orderby='',$display=1
break; break;
case 'where': case 'where':
//根据自定义条件获取分类where语句此操作读取数据库非缓存 //根据自定义条件获取分类where语句此操作读取数据库非缓存
$tempArr=Db::name('document_category')->where('status',1)-> where($where)->order($orderby)->limit($row); $tempArr=\app\common\model\DocumentCategory::where('status',1)-> where($where)->order($orderby)->limit($row);
if($display){ if($display){
$tempArr=$tempArr->where('display',1); $tempArr=$tempArr->where('display',1);
} }
@ -204,7 +204,7 @@ function tpl_get_channel($type,$typeid,$row=100,$where='',$orderby='',$display=1
break; break;
case 'ids': case 'ids':
//根据多个栏目id逗号隔开的那种获得栏目列表 //根据多个栏目id逗号隔开的那种获得栏目列表
$tempArr=Db::name('document_category')->where('status',1)-> where('id','in',$typeid)->order($orderby)->limit($row); $tempArr=\app\common\model\DocumentCategory::where('status',1)-> where('id','in',$typeid)->order($orderby)->limit($row);
if($display){ if($display){
$tempArr=$tempArr->where('display',1); $tempArr=$tempArr->where('display',1);
} }
@ -228,10 +228,10 @@ function tpl_get_channel($type,$typeid,$row=100,$where='',$orderby='',$display=1
* $row=获取多少数目 * $row=获取多少数目
*/ */
function get_document_category_by_parent($pid,$row,$display=1){ function get_document_category_by_parent($pid,$row,$display=1){
$docmentCategoryList=get_document_category_list(); $documentCategoryList=get_document_category_list();
$x=1; $x=1;
$tempArr=array(); $tempArr=array();
foreach ($docmentCategoryList as $item){ foreach ($documentCategoryList as $item){
if($x>$row){ if($x>$row){
break; break;
} }
@ -254,7 +254,7 @@ function tpl_get_prenext($get,$cid=false,$none){
$get='next'; $get='next';
} }
$document=Db::name('document')->where('display',1)->where('status',1); $document=\app\common\model\Document::where('display',1)->where('status',1);
$document=$get=='pre'?$document->where("id",'<',$id):$document->where("id",'>',$id); $document=$get=='pre'?$document->where("id",'<',$id):$document->where("id",'>',$id);
//如果表明在同一分类下查询 //如果表明在同一分类下查询
@ -403,14 +403,13 @@ function aurl($item){
* 模板-根据指定的文章id获取文章内容 * 模板-根据指定的文章id获取文章内容
*/ */
function tpl_get_article($id,$table){ function tpl_get_article($id,$table){
$docmentModel=Db::name('document') $documentModel=\app\common\model\Document::alias('a')
->alias('a')
->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT') ->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT')
->join(config('database.prefix')."document_$table c",'a.id=c.id','LEFT') ->join(config('database.prefix')."document_$table c",'a.id=c.id','LEFT')
->where('a.status',1)->where('a.id',$id)->where("a.type='$table'") ->where('a.status',1)->where('a.id',$id)->where("a.type='$table'")
->field('a.*,b.title as category_title,c.*'); ->field('a.*,b.title as category_title,c.*');
$doc=$docmentModel->find(); $doc=$documentModel->find();
if(!$doc){ if(!$doc){
return false; return false;
@ -433,8 +432,7 @@ function tpl_get_article($id,$table){
*/ */
function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$where=false,$display=1,$ids=''){ function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$where=false,$display=1,$ids=''){
$documentListModel=Db::name('document') $documentListModel=\app\common\model\Document::alias('a')
->alias('a')
->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT') ->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT')
->join(config('database.prefix')."document_$table c",'a.id=c.id','RIGHT') ->join(config('database.prefix')."document_$table c",'a.id=c.id','RIGHT')
->where("a.type='$table'")->where('a.status',1)->where('b.status',1) ->where("a.type='$table'")->where('a.status',1)->where('b.status',1)
@ -504,7 +502,7 @@ function tpl_get_product_list($cid,$row,$orderby,$table='article',$type='son',$w
function tpl_get_friend_link($type,$row){ function tpl_get_friend_link($type,$row){
$flinkList=cache('DATA_FRIEND_LINK'); $flinkList=cache('DATA_FRIEND_LINK');
if($flinkList===null){ if($flinkList===null){
$flinkList=Db::name('friend_link')->where('status',1)->order('sort asc')->limit($row)->select(); $flinkList= \app\common\model\FriendLink::where('status',1)->order('sort asc')->limit($row)->select();
cache('DATA_FRIEND_LINK',$flinkList); cache('DATA_FRIEND_LINK',$flinkList);
} }
if($type===0){ if($type===0){

View File

@ -9,7 +9,8 @@
namespace app\index\controller; namespace app\index\controller;
use app\common\model\Document; use app\common\model\Document;
use think\facade\Db; use app\common\model\DocumentCategory;
use app\common\model\DocumentCategoryContent;
use think\facade\Log; use think\facade\Log;
/** /**
@ -19,8 +20,7 @@ use think\facade\Log;
*/ */
class Article extends Base class Article extends Base
{ {
public function lists() public function lists(){
{
$dc=false; $dc=false;
//栏目分类id //栏目分类id
$id=input('id/d'); $id=input('id/d');
@ -40,11 +40,12 @@ class Article extends Base
} }
//赋值分类id可能是通过栏目分类id获取的栏目分类数据 //赋值分类id可能是通过栏目分类id获取的栏目分类数据
$id=$dc['id']; $id=$dc['id'];
$documentCategoryModel=new DocumentCategory();
//栏目存在 增加访问量 //栏目存在 增加访问量
Db::name('document_category')->where('id',$id)->inc('view')->update(); $documentCategoryModel->where('id',$id)->inc('view')->update();
//判断后台统计配置是否开启 1 开启 //判断后台统计配置是否开启 1 开启
if($this->systemConfig["web_statistics"] ==1){ if(web_config("web_statistics") ==1){
//统计url //统计url
$this->urlrecord($dc['title']); $this->urlrecord($dc['title']);
} }
@ -62,13 +63,14 @@ class Article extends Base
$this->error('请在栏目分类中,指定当前栏目的单篇模板!'); $this->error('请在栏目分类中,指定当前栏目的单篇模板!');
} }
//如果是单篇栏目,加载内容 //如果是单篇栏目,加载内容
$dcContent= Db::name('document_category_content')->find($id); $contentModel=new DocumentCategoryContent();
$dcContent= $contentModel->find($id);
$dc['content']=$dcContent['content']; $dc['content']=$dcContent['content'];
} }
if(!is_file(TPL.$listTmp)){ if(!is_file(config('view.view_path').'article/'.$listTmp)){
$this->error('模板文件不存在!'); $this->error('模板文件不存在!');
} }
trace('列表页模板路径:'.TPL.$listTmp,'debug'); trace('列表页模板路径:'.config('view.view_path').'article/'.$listTmp,'debug');
//文章兼容字段 //文章兼容字段
$dc['category_id']=$dc['id']; $dc['category_id']=$dc['id'];
//判断seo标题是否存在 //判断seo标题是否存在
@ -93,7 +95,8 @@ class Article extends Base
$this->error('参数错误!'); $this->error('参数错误!');
} }
//获取该文章 //获取该文章
$article = (new Document())->where('status',1)->where('id',$id)->find(); $documentModel=new Document();
$article=$documentModel->where('status',1)->where('id',$id)->find();
if(!$article){ if(!$article){
$this->error('文章不存在或已删除!'); $this->error('文章不存在或已删除!');
} }
@ -106,17 +109,18 @@ class Article extends Base
//获取该文章内容 //获取该文章内容
//根据文章类型,加载不同的内容。 //根据文章类型,加载不同的内容。
$articleType= $article['type']?$article['type']:'article'; $articleType= $article['type']?$article['type']:'article';
$articleExt= Db::name('document_'.$articleType)->where('id',$id)->find(); $articleExt = $documentModel::name('document_'.$articleType)->where('id',$id)->find();
if(!$articleExt){ if(!$articleExt){
$this->error('文章不存在或已删除!'); $this->error('文章不存在或已删除!');
} }
$articleExt = $articleExt->toArray();
$article=array_merge($article,$articleExt); $article=array_merge($article,$articleExt);
//添加当前页面的位置信息 //添加当前页面的位置信息
$article['position']=tpl_get_position($dc); $article['position']=tpl_get_position($dc);
//更新浏览次数 //更新浏览次数
(new Document())->where('id', $article['id'])->inc('view')->update(); $documentModel->where('id', $article['id'])->inc('view')->update();
//读取详情页模板 //读取详情页模板
$detailTmp=$dc['template']; $detailTmp=$dc['template_detail'];
if(!$detailTmp){ if(!$detailTmp){
$this->error('请在栏目分类中,指定当前栏目的详情模板!'); $this->error('请在栏目分类中,指定当前栏目的详情模板!');
} }
@ -130,11 +134,11 @@ class Article extends Base
//当前页面所属分类id //当前页面所属分类id
$this->assign('cid',$article['category_id']); $this->assign('cid',$article['category_id']);
//缓存当前页面栏目分类树ids //缓存当前页面栏目分类树ids
cache('curr_category_patent_id',$dc['pid']?$dc['pid'].','.$article['category_id']:$article['category_id']); cache('CURR_CATEGORY_PATENT_ID',$dc['parent_id']?$dc['parent_id'].','.$article['category_id']:$article['category_id']);
//设置文章的url //设置文章的url
$article['link_str']=aurl($article); $article['link_str']=aurl($article);
//判断后台统计配置是否开启 1 开启 //判断后台统计配置是否开启 1 开启
if(system_config("web_statistics") ==1){ if(web_config("web_statistics") ==1){
//统计url //统计url
$this->urlrecord($article['title']); $this->urlrecord($article['title']);
} }
@ -160,9 +164,11 @@ class Article extends Base
$this->assign('cid',false); $this->assign('cid',false);
//读取模板配置,获得模板后缀名 //读取模板配置,获得模板后缀名
$view_suffix=config('view.view_suffix'); $view_suffix=config('view.view_suffix');
Log::info('详情页模板路径:'.TPL.'content_'.$zzField['tpl'].'.'.$view_suffix); Log::info('详情页模板路径:'.config('view.view_path').'article/'.'content_'.$zzField['tpl'].'.'.$view_suffix);
cache('curr_category_patent_id',false); cache('curr_category_patent_id',false);
return $this->fetch(TPL.'content_'.$zzField['tpl'].'.'.$view_suffix); $detailTmp = substr($detailTmp,0,strpos($detailTmp,'.'));
return $this->fetch('article/'.$detailTmp);
return $this->fetch();
} }
//文章标签页面 //文章标签页面
@ -178,8 +184,8 @@ class Article extends Base
$zzField['id']='0'; $zzField['id']='0';
$zzField['title'] = $tag; $zzField['title'] = $tag;
$zzField['meta_title'] = $tag; $zzField['meta_title'] = $tag;
$zzField['keywords'] = $this->systemConfig['keywords']; $zzField['keywords'] =web_config('keywords');
$zzField['description'] = $this->systemConfig['description']; $zzField['description'] =web_config('description');
$zzField['position'] ='<a href="/">首页</a> > <a>'.$tag.'</a>'; $zzField['position'] ='<a href="/">首页</a> > <a>'.$tag.'</a>';
$this->assign('zzField',$zzField); $this->assign('zzField',$zzField);
$this->assign('tag',$tag); $this->assign('tag',$tag);
@ -205,8 +211,8 @@ class Article extends Base
$zzField['id'] = '0'; $zzField['id'] = '0';
$zzField['title'] = '搜索'; $zzField['title'] = '搜索';
$zzField['meta_title'] = '搜索'; $zzField['meta_title'] = '搜索';
$zzField['keywords'] = $this->systemConfig['keywords']; $zzField['keywords'] = web_config('keywords');
$zzField['description'] = $this->systemConfig['description']; $zzField['description'] = web_config('description');
$zzField['position'] = '<a href="/">首页</a> > <a>搜索</a>'; $zzField['position'] = '<a href="/">首页</a> > <a>搜索</a>';
$this->assign('zzField',$zzField); $this->assign('zzField',$zzField);
$this->assign('kw',$kw); $this->assign('kw',$kw);

View File

@ -16,19 +16,19 @@ class Base extends BaseController
protected function initialize(){ protected function initialize(){
parent::initialize(); parent::initialize();
//判断是否关闭站点。 //判断是否关闭站点。
if(!system_config('web_close')){ if(!web_config('web_close')){
$this->error('网站暂时关闭!','','stop'); $this->error('网站暂时关闭!','','stop');
} }
//判断后台统计配置是否开启 1 开启 //判断后台统计配置是否开启 1 开启
if (system_config("web_statistics") == 1) { if (web_config("web_statistics") == 1) {
//pv表 zz_pv_log 栏目存在 点击进入页面后 //pv表 zz_pv_log 栏目存在 点击进入页面后
$pvLogModel=new PvLog(); $pvLogModel=new PvLog();
$pvLogModel->set_view(); $pvLogModel->set_view();
} }
//判断是否开启了伪静态 //判断是否开启了伪静态
if (system_config('web_rewrite')=='0') { if (web_config('web_rewrite')=='0') {
$this->request->setRoot('/?s='); $this->request->setRoot('/?s=');
} elseif(system_config('web_rewrite')=='1') { } elseif(web_config('web_rewrite')=='1') {
$this->request->setRoot('/'); $this->request->setRoot('/');
} else { } else {
$this->request->setRoot('/index.php'); $this->request->setRoot('/index.php');

View File

@ -22,7 +22,7 @@ class Index extends Base
public function index() public function index()
{ {
//判断后台统计配置是否开启 1 开启 //判断后台统计配置是否开启 1 开启
if(system_config("web_statistics") ==1){ if(web_config("web_statistics") ==1){
//统计url //统计url
$this->urlrecord('网站首页'); $this->urlrecord('网站首页');
} }

View File

@ -20,17 +20,19 @@ class Messageform extends Base
public function addMessageform(){ public function addMessageform(){
if(request()->isPost()){ if(request()->isPost()){
$data=$_POST; $data=$_POST;
//验证 $model=new MessageFormModel();
$messageformValidate=new MessageformValidate(); $postData=$this->request->param();
if (!$messageformValidate->check($data)) { //验证器
$this->error($messageformValidate->getError()); $messageFormValidate=new MessageFormValidate();
} if (!$messageFormValidate->check($postData)) {
$msgData['name']=isset($data['name'])?$data['name']:''; $this->error($messageFormValidate->getError());
$msgData['tel']=isset($data['tel'])?$data['tel']:''; }
$msgData['email']=isset($data['email'])?$data['email']:''; $msgData['name']=isset($postData['name'])?$postData['name']:'';
$msgData['content']=$data['content']; $msgData['tel']=isset($postData['tel'])?$postData['tel']:'';
$msgData['create_time']=time(); $msgData['email']=isset($postData['email'])?$postData['email']:'';
$re=Db::name('message_form')->save($msgData); $msgData['content']=$postData['content'];
$msgData['create_time']=time();
$re=$model->add($msgData);
if($re){ if($re){
$this->success('留言成功'); $this->success('留言成功');
} else { } else {