|
|
@ -74,39 +74,13 @@ Class ListController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
$scanResults = array($cateId => $currentDir); //重新组装数据 |
|
|
|
$scanResults = array($cateId => $currentDir); //重新组装数据 |
|
|
|
|
|
|
|
|
|
|
|
//header('Content-Type: text/html; charset=utf-8'); |
|
|
|
|
|
|
|
//print_r($currentDir); |
|
|
|
|
|
|
|
//print_r($scanResults); |
|
|
|
|
|
|
|
//exit; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//非首页统一从缓存获取目录数据,有效期 1 小时 |
|
|
|
//获取目录 |
|
|
|
$cacheKey = $this->getCacheKey('all', 'menu', 2); |
|
|
|
$menus = $scanner->getMenus(); |
|
|
|
$menus = Common::getCacheFromFile($cacheKey, 3600); |
|
|
|
|
|
|
|
|
|
|
|
$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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//排序 |
|
|
|
|
|
|
|
$sortedTree = $this->sortMenusAndDirTree($menus_sorted, $menus, $dirTree); |
|
|
|
|
|
|
|
if (!empty($sortedTree)) { |
|
|
|
|
|
|
|
$menus = $sortedTree['menus']; |
|
|
|
|
|
|
|
$dirTree = $sortedTree['dirTree']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取目录面包屑 |
|
|
|
//获取目录面包屑 |
|
|
|
//TODO: 重写此方法,根据scanner->getId()方法来逐级目录生成 |
|
|
|
|
|
|
|
$subcate = $scanResults[$cateId]; |
|
|
|
$subcate = $scanResults[$cateId]; |
|
|
|
$breadcrumbs = $this->getBreadcrumbs($currentDir, $cachedParentData, $scanner); |
|
|
|
$breadcrumbs = $this->getBreadcrumbs($currentDir, $cachedParentData, $scanner); |
|
|
|
|
|
|
|
|
|
|
@ -189,7 +163,7 @@ Class ListController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据目录结构以及当前目录获取面包屑 |
|
|
|
//根据目录结构以及当前目录获取面包屑 |
|
|
|
//TODO: 改善每一级目录的链接地址中的cid,利用缓存数据把每一级的缓存cid参数记录下来 |
|
|
|
//缓存key统一生成,方便按规则获取上一级目录的缓存cid |
|
|
|
protected function getBreadcrumbs($currentDir, $scanResults, $scanner) { |
|
|
|
protected function getBreadcrumbs($currentDir, $scanResults, $scanner) { |
|
|
|
$webroot = FSC::$app['config']['content_directory']; |
|
|
|
$webroot = FSC::$app['config']['content_directory']; |
|
|
|
$arr = explode($webroot, $currentDir['realpath']); |
|
|
|
$arr = explode($webroot, $currentDir['realpath']); |
|
|
|