2020-07-09 16:04:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Models;
|
|
|
|
use Core\Controller;
|
|
|
|
use Core\View;
|
|
|
|
use Parsedown;
|
|
|
|
use App\Config;
|
|
|
|
|
|
|
|
|
|
|
|
class NewUi extends Controller
|
|
|
|
{
|
2020-08-06 12:27:47 +00:00
|
|
|
function indexAction() {
|
2020-07-09 16:04:53 +00:00
|
|
|
$docModel = new Models\Doc();
|
2020-07-12 07:59:34 +00:00
|
|
|
$limit = 5;
|
|
|
|
$offset = 0;
|
2020-07-09 16:04:53 +00:00
|
|
|
$firstpagedocs = [];
|
|
|
|
$typedocs = $docModel->getAllTypeDocs();
|
|
|
|
$titles = $docModel->AllTitle();
|
2020-07-11 16:51:00 +00:00
|
|
|
$groups = $docModel->getGroups();
|
|
|
|
$groupstype = $docModel->GetAllGroupType();
|
2020-07-12 07:59:34 +00:00
|
|
|
if(sizeof($this->params) == 2){
|
|
|
|
$limit = $this->params[0];
|
|
|
|
$offset = $this->params[1];
|
|
|
|
}
|
2020-08-01 09:02:05 +00:00
|
|
|
$fisrtpage = $docModel->pageDoc($limit,$offset,55);
|
2020-07-28 14:19:23 +00:00
|
|
|
$top5 = $docModel->top5Doc();
|
2020-07-09 16:04:53 +00:00
|
|
|
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']);
|
|
|
|
$obj['content'] = $content;
|
|
|
|
array_push($firstpagedocs,$obj);
|
|
|
|
}
|
|
|
|
if(\App\Config::$DEBUG)
|
|
|
|
View::renderTemplate("/blog/index.html",[
|
2020-07-31 16:56:57 +00:00
|
|
|
"url"=>\App\Config::Url(),
|
2020-07-09 16:04:53 +00:00
|
|
|
'route'=>'article',
|
|
|
|
'docs'=>$firstpagedocs,
|
|
|
|
'index'=>true,
|
|
|
|
'debug'=>true,
|
|
|
|
"typedocs" => $typedocs,
|
|
|
|
"alltitle" => $titles,
|
2020-07-11 16:51:00 +00:00
|
|
|
"groups" => $groups,
|
2020-07-28 14:19:23 +00:00
|
|
|
"group_types"=>$groupstype,
|
|
|
|
"topdoc"=>$top5,
|
2020-07-28 14:39:14 +00:00
|
|
|
"title"=>"一个博客",
|
2020-07-09 16:04:53 +00:00
|
|
|
]);
|
|
|
|
else{
|
|
|
|
View::renderTemplate("/blog/index.html",[
|
2020-07-31 16:56:57 +00:00
|
|
|
"url"=>\App\Config::Url(),
|
2020-07-09 16:04:53 +00:00
|
|
|
'route'=>'article',
|
|
|
|
'docs'=>$firstpagedocs,
|
|
|
|
'index'=>true,
|
|
|
|
'debug'=>false,
|
|
|
|
"typedocs" => $typedocs,
|
|
|
|
"alltitle" => $titles,
|
2020-07-11 16:51:00 +00:00
|
|
|
"groups" => $groups,
|
2020-07-28 14:19:23 +00:00
|
|
|
"group_types"=>$groupstype,
|
|
|
|
"topdoc"=>$top5,
|
2020-07-28 14:39:14 +00:00
|
|
|
"title"=>"一个博客",
|
2020-07-09 16:04:53 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 18:16:35 +00:00
|
|
|
function articleAction(){
|
2020-07-16 16:30:40 +00:00
|
|
|
$commentModel = new Models\DocComment();
|
|
|
|
$doccoment = $commentModel->DocComments((int)$this->params[0]);
|
2020-07-14 16:27:25 +00:00
|
|
|
if(sizeof($this->params) > 0){
|
2020-07-28 14:19:23 +00:00
|
|
|
|
2020-07-14 16:27:25 +00:00
|
|
|
}
|
|
|
|
$docModel = new Models\Doc();
|
|
|
|
$firstpagedocs = [];
|
|
|
|
$typedocs = $docModel->getAllTypeDocs();
|
2020-07-15 15:01:22 +00:00
|
|
|
$doc = $docModel->doc((int)$this->params[0]);
|
2020-07-14 16:27:25 +00:00
|
|
|
$titles = $docModel->AllTitle();
|
|
|
|
$groups = $docModel->getGroups();
|
|
|
|
$groupstype = $docModel->GetAllGroupType();
|
2020-08-01 09:02:05 +00:00
|
|
|
|
2020-08-06 12:27:47 +00:00
|
|
|
$fisrtpage = $docModel->pageDoc(5,0,55);
|
2021-01-13 13:13:27 +00:00
|
|
|
$markdown = new \ParsedownToC();
|
|
|
|
$doc[0]['content'] = $markdown->body($doc[0]['content']);
|
|
|
|
$doc[0]['toc'] = $markdown->contentsList();
|
2020-07-28 14:19:23 +00:00
|
|
|
$top5 = $docModel->top5Doc();
|
2020-07-12 07:59:34 +00:00
|
|
|
|
2020-07-14 16:27:25 +00:00
|
|
|
foreach ($fisrtpage as $key => $value) {
|
|
|
|
$obj['title'] = $value['title'];
|
|
|
|
$obj['id'] = $value['id'];
|
|
|
|
$obj['content'] = $value['content'];
|
|
|
|
$obj['type'] = $value['type'];
|
|
|
|
//数据加工
|
2021-01-13 13:13:27 +00:00
|
|
|
$content = $markdown->body($value['content']);
|
2020-07-14 16:27:25 +00:00
|
|
|
$obj['content'] = $content;
|
|
|
|
array_push($firstpagedocs,$obj);
|
|
|
|
}
|
|
|
|
if(\App\Config::$DEBUG)
|
2020-07-15 15:01:22 +00:00
|
|
|
View::renderTemplate("/blog/article.html",[
|
2020-07-19 16:54:28 +00:00
|
|
|
"url"=>\App\Config::ServerUrl(),
|
2020-07-14 16:27:25 +00:00
|
|
|
'route'=>'article',
|
|
|
|
'index'=>true,
|
|
|
|
'debug'=>true,
|
|
|
|
"typedocs" => $typedocs,
|
|
|
|
"alltitle" => $titles,
|
|
|
|
"groups" => $groups,
|
|
|
|
"group_types"=>$groupstype,
|
|
|
|
"title"=>urldecode ($this->params[1]),
|
2020-07-15 15:01:22 +00:00
|
|
|
"doc"=>$doc[0],
|
2020-07-16 16:30:40 +00:00
|
|
|
"comments" => $doccoment,
|
|
|
|
"comment_count" => count($doccoment),
|
2020-07-19 16:54:28 +00:00
|
|
|
"doc_type"=>$doc[0]["type"],
|
2020-07-19 17:06:07 +00:00
|
|
|
"group_type"=>$docModel->TypeGroup($doc[0]["type"])[0][0],
|
2020-07-28 14:19:23 +00:00
|
|
|
"topdoc"=>$top5,
|
2020-07-14 16:27:25 +00:00
|
|
|
]);
|
|
|
|
else{
|
2020-07-15 15:01:22 +00:00
|
|
|
View::renderTemplate("/blog/article.html",[
|
2020-07-19 16:54:28 +00:00
|
|
|
"url"=>\App\Config::ServerUrl(),
|
2020-07-14 16:27:25 +00:00
|
|
|
'route'=>'article',
|
|
|
|
'index'=>true,
|
|
|
|
'debug'=>false,
|
|
|
|
"typedocs" => $typedocs,
|
|
|
|
"alltitle" => $titles,
|
|
|
|
"groups" => $groups,
|
|
|
|
"group_types"=>$groupstype,
|
|
|
|
"title"=>urldecode ($this->params[1]),
|
2020-07-15 15:01:22 +00:00
|
|
|
"doc"=>$doc[0],
|
2020-07-16 16:30:40 +00:00
|
|
|
"comments" => $doccoment,
|
|
|
|
"comment_count" => count($doccoment),
|
2020-07-19 16:54:28 +00:00
|
|
|
"doc_type"=>$doc[0]["type"],
|
2020-07-19 17:06:07 +00:00
|
|
|
"group_type"=>$docModel->TypeGroup($doc[0]["type"])[0][0],
|
2020-07-28 14:19:23 +00:00
|
|
|
"topdoc"=>$top5,
|
2020-07-14 16:27:25 +00:00
|
|
|
]);
|
2020-07-11 18:16:35 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-01 09:02:05 +00:00
|
|
|
function searchAction()
|
|
|
|
{
|
|
|
|
if (sizeof($this->querys) != 0) {
|
|
|
|
$docModel = new Models\Doc();
|
|
|
|
$commentModel = new Models\DocComment();
|
|
|
|
$doc = $docModel->titleDoc(rawurldecode($this->querys['title']));
|
|
|
|
$id = $doc[0]["id"];
|
2021-01-13 13:13:27 +00:00
|
|
|
$markdown = new \ParsedownToC();
|
|
|
|
$doc[0]['content'] = $markdown->body($doc[0]['content']);
|
|
|
|
|
2020-08-01 09:02:05 +00:00
|
|
|
$typedocs = $docModel->getAllTypeDocs();
|
|
|
|
$doccoment = $commentModel->DocComments($id);
|
|
|
|
$titles = $docModel->AllTitle();
|
|
|
|
$top5 = $docModel->top5Doc();
|
|
|
|
$groups = $docModel->getGroups();
|
|
|
|
$groupstype = $docModel->GetAllGroupType();
|
|
|
|
|
|
|
|
if (\App\Config::$DEBUG)
|
|
|
|
View::renderTemplate("/blog/article.html",
|
|
|
|
[
|
|
|
|
"url"=>\App\Config::ServerUrl(),
|
|
|
|
'route'=>'article',
|
|
|
|
'index'=>true,
|
|
|
|
'debug'=>true,
|
|
|
|
"typedocs" => $typedocs,
|
|
|
|
"alltitle" => $titles,
|
|
|
|
"groups" => $groups,
|
|
|
|
"group_types"=>$groupstype,
|
|
|
|
"title"=>urldecode ($this->querys['title']),
|
|
|
|
"doc"=>$doc[0],
|
|
|
|
"comments" => $doccoment,
|
|
|
|
"comment_count" => count($doccoment),
|
|
|
|
"doc_type"=>$doc[0]["type"],
|
|
|
|
"group_type"=>$docModel->TypeGroup($doc[0]["type"])[0][0],
|
|
|
|
"topdoc"=>$top5,
|
|
|
|
]);
|
|
|
|
else
|
|
|
|
View::renderTemplate("/blog/article.html", [
|
|
|
|
"url"=>\App\Config::ServerUrl(),
|
|
|
|
'route'=>'article',
|
|
|
|
'index'=>true,
|
|
|
|
'debug'=>true,
|
|
|
|
"typedocs" => $typedocs,
|
|
|
|
"alltitle" => $titles,
|
|
|
|
"groups" => $groups,
|
|
|
|
"group_types"=>$groupstype,
|
|
|
|
"title"=>urldecode ($this->querys['title']),
|
|
|
|
"doc"=>$doc[0],
|
|
|
|
"comments" => $doccoment,
|
|
|
|
"comment_count" => count($doccoment),
|
|
|
|
"doc_type"=>$doc[0]["type"],
|
|
|
|
"group_type"=>$docModel->TypeGroup($doc[0]["type"])[0][0],
|
|
|
|
"topdoc"=>$top5,
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
View::renderTemplate("/blog/article.html", ['title' => 'test', 'index' => false]);
|
|
|
|
}
|
|
|
|
}
|
2020-07-09 16:04:53 +00:00
|
|
|
}
|