|
|
|
@ -10,6 +10,7 @@ Class SiteController extends Controller {
@@ -10,6 +10,7 @@ Class SiteController extends Controller {
|
|
|
|
|
public function actionIndex() { |
|
|
|
|
//获取数据 |
|
|
|
|
$menus = []; |
|
|
|
|
$menus_sorted = []; |
|
|
|
|
$htmlReadme = ''; |
|
|
|
|
|
|
|
|
|
$titles = []; |
|
|
|
@ -23,6 +24,10 @@ Class SiteController extends Controller {
@@ -23,6 +24,10 @@ Class SiteController extends Controller {
|
|
|
|
|
$menus = $scanner->getMenus(); |
|
|
|
|
|
|
|
|
|
if (!empty($readmeFile)) { |
|
|
|
|
if (!empty($readmeFile['sort'])) { |
|
|
|
|
$menus_sorted = explode("\n", $readmeFile['sort']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$titles = $scanner->getMDTitles($readmeFile['id']); |
|
|
|
|
$content = file_get_contents($readmeFile['realpath']); |
|
|
|
|
|
|
|
|
@ -31,6 +36,42 @@ Class SiteController extends Controller {
@@ -31,6 +36,42 @@ Class SiteController extends Controller {
|
|
|
|
|
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//排序 |
|
|
|
|
if (!empty($menus_sorted) && !empty($menus)) { |
|
|
|
|
$menu_dirs = array_column($menus, 'directory'); |
|
|
|
|
$names = array_replace(array_flip($menus_sorted), array_flip($menu_dirs)); |
|
|
|
|
if (!empty($names)) { |
|
|
|
|
$menus_sorted = array_keys($names); |
|
|
|
|
|
|
|
|
|
$arr = []; |
|
|
|
|
foreach($menus_sorted as $name) { |
|
|
|
|
$index = array_search($name, $menu_dirs); |
|
|
|
|
array_push($arr, $menus[$index]); |
|
|
|
|
} |
|
|
|
|
$menus = $arr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//dirTree排序 |
|
|
|
|
$sorted_dirs = array_column($menus, 'directory'); |
|
|
|
|
$tree_dirs = array_column($dirTree, 'directory'); |
|
|
|
|
$names = array_replace(array_flip($sorted_dirs), array_flip($tree_dirs)); |
|
|
|
|
if (!empty($names)) { |
|
|
|
|
$sorted_dirs = array_keys($names); |
|
|
|
|
|
|
|
|
|
$arr = []; |
|
|
|
|
foreach($sorted_dirs as $name) { |
|
|
|
|
foreach($dirTree as $index => $item) { |
|
|
|
|
if ($item['directory'] == $name) { |
|
|
|
|
array_push($arr, $item); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$dirTree = $arr; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; |
|
|
|
|
$viewName = 'index'; |
|
|
|
|
$params = compact('dirTree', 'menus', 'htmlReadme'); |
|
|
|
|