|
|
|
@ -46,31 +46,41 @@ Class SiteController extends Controller {
@@ -46,31 +46,41 @@ Class SiteController extends Controller {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取目录 |
|
|
|
|
$menus = $scanner->getMenus(); |
|
|
|
|
|
|
|
|
|
$titles = array(); |
|
|
|
|
$readmeFile = $scanner->getDefaultReadme(); |
|
|
|
|
if (!empty($readmeFile)) { |
|
|
|
|
if (!empty($readmeFile['sort'])) { |
|
|
|
|
$menus_sorted = explode("\n", $readmeFile['sort']); |
|
|
|
|
//优先从缓存获取目录数据 |
|
|
|
|
$cacheKey = $this->getCacheKey('all', 'menu', $maxScanDeep); |
|
|
|
|
$menus = Common::getCacheFromFile($cacheKey); |
|
|
|
|
|
|
|
|
|
if (empty($menus)) { |
|
|
|
|
//获取目录 |
|
|
|
|
$menus = $scanner->getMenus(); |
|
|
|
|
|
|
|
|
|
$titles = array(); |
|
|
|
|
$readmeFile = $scanner->getDefaultReadme(); |
|
|
|
|
if (!empty($readmeFile)) { |
|
|
|
|
if (!empty($readmeFile['sort'])) { |
|
|
|
|
$menus_sorted = explode("\n", $readmeFile['sort']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$titles = $scanner->getMDTitles($readmeFile['id']); |
|
|
|
|
|
|
|
|
|
$Parsedown = new Parsedown(); |
|
|
|
|
$content = file_get_contents($readmeFile['realpath']); |
|
|
|
|
$htmlReadme = $Parsedown->text($content); |
|
|
|
|
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$titles = $scanner->getMDTitles($readmeFile['id']); |
|
|
|
|
//排序 |
|
|
|
|
$sortedTree = $this->sortMenusAndDirTree($menus_sorted, $menus, $dirTree); |
|
|
|
|
if (!empty($sortedTree)) { |
|
|
|
|
$menus = $sortedTree['menus']; |
|
|
|
|
$dirTree = $sortedTree['dirTree']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$Parsedown = new Parsedown(); |
|
|
|
|
$content = file_get_contents($readmeFile['realpath']); |
|
|
|
|
$htmlReadme = $Parsedown->text($content); |
|
|
|
|
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); |
|
|
|
|
Common::saveCacheToFile($cacheKey, $menus); //保存目录数据 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//排序 |
|
|
|
|
$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]; |
|
|
|
|
|
|
|
|
|