|
|
@ -45,31 +45,27 @@ Class ListController extends SiteController { |
|
|
|
$dirTree = $sortedTree['dirTree']; |
|
|
|
$dirTree = $sortedTree['dirTree']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取目录面包屑 |
|
|
|
|
|
|
|
$cateId = $this->get('id', $menus[0]['id']); |
|
|
|
|
|
|
|
$subcate = $scanResults[$cateId]; |
|
|
|
|
|
|
|
$breadcrumbs = $this->getBreadcrumbs($scanResults, $subcate); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取当前目录下的readme |
|
|
|
|
|
|
|
$cateReadmeFile = $scanner->getDefaultReadme($cateId); |
|
|
|
|
|
|
|
if (!empty($cateReadmeFile)) { |
|
|
|
|
|
|
|
$Parsedown = new Parsedown(); |
|
|
|
|
|
|
|
$content = file_get_contents($cateReadmeFile['realpath']); |
|
|
|
|
|
|
|
$htmlCateReadme = $Parsedown->text($content); |
|
|
|
|
|
|
|
$htmlCateReadme = $scanner->fixMDUrls($cateReadmeFile['realpath'], $htmlCateReadme); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取tags分类 |
|
|
|
//获取tags分类 |
|
|
|
$tags = $this->getTags($dirTree); |
|
|
|
$tags = $this->getTags($dirTree); |
|
|
|
|
|
|
|
|
|
|
|
//TODO: 根据tag获取相关数据,并传给视图;调整视图兼容tag的数据结构 |
|
|
|
//获取目录面包屑 |
|
|
|
|
|
|
|
$tagId = $cateId = $this->get('id', ''); |
|
|
|
|
|
|
|
$tagItem = $tags[$tagId]; |
|
|
|
|
|
|
|
$breadcrumbs = $this->getBreadcrumbs($scanResults, $tagItem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据tag获取相关数据,并传给视图;调整视图兼容tag的数据结构 |
|
|
|
|
|
|
|
if (!empty($tags)) { |
|
|
|
|
|
|
|
foreach($tags as $id => $tag) { |
|
|
|
|
|
|
|
$scanResults[$id]['files'] = $this->getTagFiles($tag, $scanResults); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pageTitle = $defaultTitle = !empty($titles) ? $titles[0]['name'] : FSC::$app['config']['site_name']; |
|
|
|
$pageTitle = $defaultTitle = !empty($titles) ? $titles[0]['name'] : FSC::$app['config']['site_name']; |
|
|
|
if (!empty($subcate)) { |
|
|
|
if (!empty($tagItem)) { |
|
|
|
$pageTitle = "{$subcate['directory']}相关视频,来自{$defaultTitle}"; |
|
|
|
$pageTitle = "{$tagItem['name']}相关视频,来自{$defaultTitle}"; |
|
|
|
if (!empty($subcate['title'])) { |
|
|
|
if (!empty($tagItem['title'])) { |
|
|
|
$pageTitle = "{$subcate['title']},来自{$defaultTitle}"; |
|
|
|
$pageTitle = "{$tagItem['title']},来自{$defaultTitle}"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$viewName = '//site/index'; //共享视图 |
|
|
|
$viewName = '//site/index'; //共享视图 |
|
|
@ -78,36 +74,32 @@ Class ListController extends SiteController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据目录结构以及当前目录获取面包屑 |
|
|
|
//根据目录结构以及当前目录获取面包屑 |
|
|
|
protected function getBreadcrumbs($menus, $subcate) { |
|
|
|
protected function getBreadcrumbs($menus, $tag) { |
|
|
|
$breads = array(); |
|
|
|
$breads = array(); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($subcate['directory'])) { |
|
|
|
|
|
|
|
array_push($breads, [ |
|
|
|
array_push($breads, [ |
|
|
|
'id' => $subcate['id'], |
|
|
|
'id' => $tag['id'], |
|
|
|
'name' => $subcate['directory'], |
|
|
|
'name' => $tag['name'], |
|
|
|
'url' => $subcate['path'], |
|
|
|
'url' => "/list/?id={$tag['id']}", |
|
|
|
]); |
|
|
|
]); |
|
|
|
}else { //如果是文件 |
|
|
|
|
|
|
|
array_push($breads, [ |
|
|
|
|
|
|
|
'id' => $subcate['id'], |
|
|
|
|
|
|
|
'name' => $subcate['filename'], |
|
|
|
|
|
|
|
'url' => $subcate['path'], |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $breads; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$parent = !empty($menus[$subcate['pid']]) ? $menus[$subcate['pid']] : null; |
|
|
|
//根据tag的filenames获取它们的files数据,数据结构保持跟原file一致 |
|
|
|
while($parent) { |
|
|
|
protected function getTagFiles($tag, $scanResults) { |
|
|
|
array_unshift($breads, [ |
|
|
|
$files = array(); |
|
|
|
'id' => $parent['id'], |
|
|
|
if (empty($tag['files'])) {return $files;} |
|
|
|
'name' => $parent['directory'], |
|
|
|
|
|
|
|
'url' => $parent['path'], |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$parent = !empty($parent['pid']) && !empty($menus[$parent['pid']]) ? $menus[$parent['pid']] : null; |
|
|
|
foreach($tag['files'] as $filename) { |
|
|
|
|
|
|
|
foreach($scanResults as $id => $item) { |
|
|
|
|
|
|
|
if (!empty($item['filename']) && $item['filename'] == $filename && $item['extension'] == 'url') { |
|
|
|
|
|
|
|
$files[$id] = $item; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $breads; |
|
|
|
return $files; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|