|
|
@ -36,18 +36,12 @@ Class ListController extends Controller { |
|
|
|
throw new Exception("缓存数据中找不到当前目录,请返回上一页重新进入!", 404); |
|
|
|
throw new Exception("缓存数据中找不到当前目录,请返回上一页重新进入!", 404); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//$scanner->setWebRoot(FSC::$app['config']['content_directory']); |
|
|
|
|
|
|
|
$scanner->setWebRoot($this->getCurrentWebroot($currentDir)); |
|
|
|
$scanner->setWebRoot($this->getCurrentWebroot($currentDir)); |
|
|
|
$scanner->setRootDir($currentDir['realpath']); |
|
|
|
$scanner->setRootDir($currentDir['realpath']); |
|
|
|
//header('Content-Type: text/html; charset=utf-8'); |
|
|
|
|
|
|
|
//echo $this->getCurrentWebroot($currentDir) . "\n"; |
|
|
|
|
|
|
|
//echo $currentDir['realpath'] . "\n"; |
|
|
|
|
|
|
|
//exit; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//优先从缓存读取数据 |
|
|
|
//优先从缓存读取数据 |
|
|
|
$prefix = FSC::$app['config']['theme'] . '_v1.0'; |
|
|
|
|
|
|
|
$maxScanDeep = 2; //最大扫描目录级数 |
|
|
|
$maxScanDeep = 2; //最大扫描目录级数 |
|
|
|
$cacheKey = "{$prefix}_ltree_{$maxScanDeep}_{$cateId}"; |
|
|
|
$cacheKey = $this->getCacheKey($cateId, 'tree', $maxScanDeep); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey); |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
|
$dirTree = $cachedData; |
|
|
|
$dirTree = $cachedData; |
|
|
@ -58,7 +52,7 @@ Class ListController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//优先从缓存读取数据 |
|
|
|
//优先从缓存读取数据 |
|
|
|
$cacheKey = $cacheDataId = "{$prefix}_ldata_{$maxScanDeep}_{$cateId}"; |
|
|
|
$cacheKey = $cacheDataId = $this->getCacheKey($cateId, 'data', $maxScanDeep); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey); |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
|
$scanResults = $cachedData; |
|
|
|
$scanResults = $cachedData; |
|
|
@ -146,7 +140,7 @@ Class ListController extends Controller { |
|
|
|
$viewName = '//site/index'; //共享视图 |
|
|
|
$viewName = '//site/index'; //共享视图 |
|
|
|
$params = compact( |
|
|
|
$params = compact( |
|
|
|
'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme', |
|
|
|
'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme', |
|
|
|
'mp3File', 'page', 'pageSize', 'cacheDataId', 'cacheParentDataId' |
|
|
|
'mp3File', 'page', 'pageSize', 'cacheDataId' |
|
|
|
); |
|
|
|
); |
|
|
|
return $this->render($viewName, $params, $pageTitle); |
|
|
|
return $this->render($viewName, $params, $pageTitle); |
|
|
|
} |
|
|
|
} |
|
|
@ -195,6 +189,7 @@ Class ListController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据目录结构以及当前目录获取面包屑 |
|
|
|
//根据目录结构以及当前目录获取面包屑 |
|
|
|
|
|
|
|
//TODO: 改善每一级目录的链接地址中的cid,利用缓存数据把每一级的缓存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']); |
|
|
@ -205,19 +200,24 @@ Class ListController extends Controller { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$cates = explode('/', $arr[1]); |
|
|
|
$cates = explode('/', $arr[1]); |
|
|
|
$parentCate = "{$arr[0]}{$webroot}"; |
|
|
|
$parentCate = preg_replace("/\/$/", '', "{$arr[0]}{$webroot}"); //删除最后一个斜杠 |
|
|
|
foreach ($cates as $cate) { |
|
|
|
foreach ($cates as $index => $cate) { |
|
|
|
if ($cate == $currentDir['directory']) {break;} |
|
|
|
if ($cate == $currentDir['directory']) {break;} |
|
|
|
|
|
|
|
|
|
|
|
$subcate = "{$parentCate}{$cate}"; |
|
|
|
$subcate = "{$parentCate}/{$cate}"; |
|
|
|
$cateId = $scanner->getId($subcate); |
|
|
|
$cateId = $scanner->getId($subcate); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//下一级子目录的id |
|
|
|
|
|
|
|
$parentCateId = $scanner->getId($parentCate); |
|
|
|
|
|
|
|
$cacheKey = $this->getCacheKey($parentCateId, 'data'); |
|
|
|
|
|
|
|
|
|
|
|
array_push($breads, [ |
|
|
|
array_push($breads, [ |
|
|
|
'id' => $cateId, |
|
|
|
'id' => $cateId, |
|
|
|
'name' => $cate, |
|
|
|
'name' => $cate, |
|
|
|
'url' => $scanResults[$cateId]['path'], |
|
|
|
'url' => "/list/?id={$cateId}&cid={$cacheKey}", |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
$parentCate = "{$subcate}/"; //记录上一级目录 |
|
|
|
$parentCate = $subcate; //记录上一级目录 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//最后一级 |
|
|
|
//最后一级 |
|
|
|