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 @@
这是一个纯手敲出来的博客
@@ -126,7 +132,11 @@

2019-08-04

-

{{doc.title}}

+ {% if debug == true %} +

{{doc.title}}

+ {%else%} +

{{doc.title}}

+ {% endif %}

管理員

@@ -149,6 +159,14 @@ {% endif %}
+