From 53449ff6555bac2f2391506252400d8975737519 Mon Sep 17 00:00:00 2001 From: a74589669 <290198252@qq.com> Date: Tue, 1 Oct 2019 21:40:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=92=8C=E6=AD=A3=E5=BC=8F=E7=8E=AF=E5=A2=83=E9=80=82?= =?UTF-8?q?=E9=85=8D=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BF=9D=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Config.php | 1 + App/Controllers/Blog.php | 26 ++++++++++++++++++++------ App/Models/Doc.php | 2 +- App/Views/blog/basic.html | 20 +++++++++++++++++++- App/Views/blog/js/jquery.query.js | 0 App/Views/blog/js/scripts.js | 17 +++++++++++++---- Core/Controller.php | 9 ++++++--- public/index.php | 7 +++++-- 8 files changed, 65 insertions(+), 17 deletions(-) create mode 100644 App/Views/blog/js/jquery.query.js diff --git a/App/Config.php b/App/Config.php index 8bef0fa..3995620 100644 --- a/App/Config.php +++ b/App/Config.php @@ -38,5 +38,6 @@ class Config * @var boolean */ const SHOW_ERRORS = true; + static public $DEBUG = false; } diff --git a/App/Controllers/Blog.php b/App/Controllers/Blog.php index c159954..732b270 100644 --- a/App/Controllers/Blog.php +++ b/App/Controllers/Blog.php @@ -6,7 +6,7 @@ use App\Models; use Core\Controller; use Core\View; use Parsedown; - +use App\Config; class Blog extends Controller { function indexAction(){ @@ -17,27 +17,41 @@ class Blog extends Controller $obj['title'] = $value['title']; $obj['id'] = $value['id']; $obj['content'] = $value['content']; + $obj['type'] = $value['type']; //数据加工 $markdown = new Parsedown; $content = $markdown->text($value['content']); $obj['content'] = $content; array_push($docs,$obj); } - View::renderTemplate("/blog/basic.html",['docs'=>$docs,'index'=>true]); + if(\App\Config::$DEBUG) + View::renderTemplate("/blog/basic.html",['docs'=>$docs,'index'=>true,'debug'=>true]); + else{ + View::renderTemplate("/blog/basic.html",['docs'=>$docs,'index'=>true,'debug'=>false]); + } } function articleAction(){ if(sizeof($this->querys) != 0){ echo '
'; - print_r( rawurldecode( $this->querys['title'])); //将字符串的编码从GB2312转到UTF-8($this->querys['title']); $docModel = new Models\Doc(); $doc = $docModel->titleDoc(rawurldecode( $this->querys['title'])); $markdown = new Parsedown; $content = $markdown->text($doc[0]['content']); echo ''; - View::renderTemplate("/blog/basic.html",['title'=>rawurldecode( $this->querys['title']), + if(\App\Config::$DEBUG) + View::renderTemplate("/blog/basic.html",['title'=>rawurldecode( $this->querys['title']), 'index'=>false, - 'content'=>$content]); - }else{ + 'content'=>$content, + 'type' => $this->querys['type'], + 'debug' => true, + ]); + else + View::renderTemplate("/blog/basic.html",['title'=>rawurldecode( $this->querys['title']), + 'index'=>false, + 'content'=>$content, + 'type' => $this->querys['type']]); + + }else{ View::renderTemplate("/blog/basic.html",['title'=>'test','index'=>false]); } } diff --git a/App/Models/Doc.php b/App/Models/Doc.php index fae3a91..b3a7eb8 100644 --- a/App/Models/Doc.php +++ b/App/Models/Doc.php @@ -37,7 +37,7 @@ class Doc extends Model $result = []; if(is_integer($id)){ $db = static::getDB(); - $stmt = $db->query('select id,title from doc where type = '.$id); + $stmt = $db->query('select id,title,type from doc where type = '.$id); $recv = $stmt->fetchAll(); foreach ($recv as $key => $value){ $s['id']= $value['id']; diff --git a/App/Views/blog/basic.html b/App/Views/blog/basic.html index 8a97531..ea02921 100644 --- a/App/Views/blog/basic.html +++ b/App/Views/blog/basic.html @@ -103,9 +103,15 @@