|
|
@ -9,6 +9,11 @@ Class SiteController extends Controller { |
|
|
|
|
|
|
|
|
|
|
|
public function actionIndex() { |
|
|
|
public function actionIndex() { |
|
|
|
//获取数据 |
|
|
|
//获取数据 |
|
|
|
|
|
|
|
$menus = []; //菜单,一级目录 |
|
|
|
|
|
|
|
$htmlReadme = ''; //Readme.md 内容,底部网站详细介绍 |
|
|
|
|
|
|
|
$htmlCateReadme = ''; //当前目录下的Readme.md 内容 |
|
|
|
|
|
|
|
$menus_sorted = []; //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 |
|
|
|
|
|
|
|
|
|
|
|
$scanner = new DirScanner(); |
|
|
|
$scanner = new DirScanner(); |
|
|
|
$scanner->setWebRoot(FSC::$app['config']['content_directory']); |
|
|
|
$scanner->setWebRoot(FSC::$app['config']['content_directory']); |
|
|
|
$dirTree = $scanner->scan(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'], 4); |
|
|
|
$dirTree = $scanner->scan(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'], 4); |
|
|
@ -16,12 +21,15 @@ Class SiteController extends Controller { |
|
|
|
|
|
|
|
|
|
|
|
//获取目录 |
|
|
|
//获取目录 |
|
|
|
$menus = $scanner->getMenus(); |
|
|
|
$menus = $scanner->getMenus(); |
|
|
|
$cateId = $this->get('id', $menus[0]['id']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$titles = []; |
|
|
|
$titles = []; |
|
|
|
$htmlReadme = ''; |
|
|
|
$htmlReadme = ''; |
|
|
|
$readmeFile = $scanner->getDefaultReadme(); |
|
|
|
$readmeFile = $scanner->getDefaultReadme(); |
|
|
|
if (!empty($readmeFile)) { |
|
|
|
if (!empty($readmeFile)) { |
|
|
|
|
|
|
|
if (!empty($readmeFile['sort'])) { |
|
|
|
|
|
|
|
$menus_sorted = explode("\n", $readmeFile['sort']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$titles = $scanner->getMDTitles($readmeFile['id']); |
|
|
|
$titles = $scanner->getMDTitles($readmeFile['id']); |
|
|
|
|
|
|
|
|
|
|
|
$Parsedown = new Parsedown(); |
|
|
|
$Parsedown = new Parsedown(); |
|
|
@ -30,10 +38,18 @@ Class SiteController extends Controller { |
|
|
|
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); |
|
|
|
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//排序 |
|
|
|
|
|
|
|
$sortedTree = $this->sortMenusAndDirTree($menus_sorted, $menus, $dirTree); |
|
|
|
|
|
|
|
if (!empty($sortedTree)) { |
|
|
|
|
|
|
|
$menus = $sortedTree['menus']; |
|
|
|
|
|
|
|
$dirTree = $sortedTree['dirTree']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//默认显示的目录 |
|
|
|
|
|
|
|
$cateId = $this->get('id', $menus[0]['id']); |
|
|
|
$subcate = $scanResults[$cateId]; |
|
|
|
$subcate = $scanResults[$cateId]; |
|
|
|
|
|
|
|
|
|
|
|
//获取当前目录下的readme |
|
|
|
//获取当前目录下的readme |
|
|
|
$htmlCateReadme = ''; |
|
|
|
|
|
|
|
$cateReadmeFile = $scanner->getDefaultReadme($cateId); |
|
|
|
$cateReadmeFile = $scanner->getDefaultReadme($cateId); |
|
|
|
if (!empty($cateReadmeFile)) { |
|
|
|
if (!empty($cateReadmeFile)) { |
|
|
|
$Parsedown = new Parsedown(); |
|
|
|
$Parsedown = new Parsedown(); |
|
|
@ -42,6 +58,10 @@ Class SiteController extends Controller { |
|
|
|
$htmlCateReadme = $scanner->fixMDUrls($cateReadmeFile['realpath'], $htmlCateReadme); |
|
|
|
$htmlCateReadme = $scanner->fixMDUrls($cateReadmeFile['realpath'], $htmlCateReadme); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; |
|
|
|
$pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; |
|
|
|
if (!empty($readmeFile['title'])) { |
|
|
|
if (!empty($readmeFile['title'])) { |
|
|
|
$pageTitle = $readmeFile['title']; |
|
|
|
$pageTitle = $readmeFile['title']; |
|
|
|