143 lines
4.6 KiB
PHP
143 lines
4.6 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Controllers;
|
|
use App\Models;
|
|
use Core\Controller;
|
|
use Core\View;
|
|
use Parsedown;
|
|
use App\Config;
|
|
|
|
class Blog extends Controller
|
|
{
|
|
function indexAction(){
|
|
$docModel = new Models\Doc();
|
|
$fisrtpage = $docModel->topDoc();
|
|
|
|
$firstpagedocs = [];
|
|
$typedocs = $docModel->getAllTypeDocs();
|
|
$titles = $docModel->AllTitle();
|
|
foreach ($fisrtpage as $key => $value) {
|
|
$obj['title'] = $value['title'];
|
|
$obj['id'] = $value['id'];
|
|
$obj['content'] = $value['content'];
|
|
$obj['type'] = $value['type'];
|
|
//数据加工
|
|
// $markdown = new Parsedown;
|
|
// $content = $markdown->text($value['content']);
|
|
|
|
$Parsedown = new \ParsedownToC();
|
|
$content = $Parsedown->body($value['content']);
|
|
// $content = $Parsedown->contentsList();
|
|
|
|
$obj['content'] = $content;
|
|
array_push($firstpagedocs,$obj);
|
|
}
|
|
if(\App\Config::$DEBUG)
|
|
View::renderTemplate("/blog/basic.html",[
|
|
"url"=>\App\Config::Url(),
|
|
'route'=>'article',
|
|
'docs'=>$firstpagedocs,
|
|
'index'=>true,
|
|
'debug'=>true,
|
|
"typedocs" => $typedocs,
|
|
"alltitle" => $titles,
|
|
]);
|
|
else{
|
|
View::renderTemplate("/blog/basic.html",[
|
|
"url"=>\App\Config::Url(),
|
|
'route'=>'article',
|
|
'docs'=>$firstpagedocs,
|
|
'index'=>true,
|
|
'debug'=>false,
|
|
"typedocs" => $typedocs,
|
|
"alltitle" => $titles,
|
|
]);
|
|
}
|
|
}
|
|
|
|
function articleAction() {
|
|
if(sizeof($this->querys) != 0){
|
|
$docModel = new Models\Doc();
|
|
$commentModel = new Models\DocComment();
|
|
$doc = $docModel->titleDoc(rawurldecode( $this->querys['title']));
|
|
$id = $doc[0]["id"];
|
|
$Parsedown = new \ParsedownToC();
|
|
$content = $Parsedown->body($doc[0]['content']);
|
|
$toc = $Parsedown->contentsList();
|
|
|
|
$typedocs = $docModel->getAllTypeDocs();
|
|
$doccoment = $commentModel->DocComments($id);
|
|
$titles = $docModel->AllTitle();
|
|
|
|
if(\App\Config::$DEBUG)
|
|
View::renderTemplate("/blog/basic.html",
|
|
[
|
|
"url"=>\App\Config::Url(),
|
|
'route'=>'article',
|
|
'title'=>rawurldecode($this->querys['title']),
|
|
'index'=>false,
|
|
'content'=>$content,
|
|
'toc'=>$toc,
|
|
'type' => $this->querys['type'],
|
|
'debug' => true,
|
|
'article'=>true,
|
|
"typedocs" => $typedocs,
|
|
"comments" => $doccoment,
|
|
"comment_count" => count($doccoment),
|
|
"docid"=>$id,
|
|
"alltitle" => $titles,
|
|
]);
|
|
else
|
|
View::renderTemplate("/blog/basic.html",[
|
|
"url"=>\App\Config::Url(),
|
|
'route'=>'article',
|
|
'title'=>rawurldecode($this->querys['title']),
|
|
'article'=>true,
|
|
'content'=>$content,
|
|
'toc'=>$toc,
|
|
'type' => $this->querys['type'],
|
|
"typedocs" => $typedocs,
|
|
"comments" => $doccoment,
|
|
"comment_count" => count($doccoment),
|
|
"docid"=>$id,
|
|
"alltitle" => $titles,
|
|
]);
|
|
}else{
|
|
View::renderTemplate("/blog/basic.html",['title'=>'test','index'=>false]);
|
|
}
|
|
}
|
|
|
|
function donateAction(){
|
|
View::renderTemplate("/blog/basic.html",
|
|
[
|
|
"url"=>\App\Config::Url(),
|
|
'route'=>"donate",
|
|
"url"=>\App\Config::Url()
|
|
]);
|
|
}
|
|
function dataAction(){
|
|
View::renderTemplate("/blog/basic.html",
|
|
[
|
|
"url"=>\App\Config::Url(),
|
|
'route'=>"data",
|
|
]);
|
|
}
|
|
function guideAction(){
|
|
View::renderTemplate("/blog/basic.html",
|
|
[
|
|
"url"=>\App\Config::Url(),
|
|
'route'=>"guide",
|
|
]);
|
|
}
|
|
function jsAction(){
|
|
//print_r($_SERVER);
|
|
}
|
|
function projectAction(){
|
|
View::renderTemplate("/blog/basic.html",
|
|
[
|
|
"url"=>\App\Config::Url(),
|
|
'route'=>"project",
|
|
]);
|
|
}
|
|
} |