Browse Source

tajian list/ done

master
filesite 1 year ago
parent
commit
6c223a5d42
  1. 72
      themes/tajian/controller/ListController.php
  2. 3
      themes/tajian/views/site/index.php

72
themes/tajian/controller/ListController.php

@ -45,31 +45,27 @@ Class ListController extends SiteController { @@ -45,31 +45,27 @@ Class ListController extends SiteController {
$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 = $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'];
if (!empty($subcate)) {
$pageTitle = "{$subcate['directory']}相关视频,来自{$defaultTitle}";
if (!empty($subcate['title'])) {
$pageTitle = "{$subcate['title']},来自{$defaultTitle}";
if (!empty($tagItem)) {
$pageTitle = "{$tagItem['name']}相关视频,来自{$defaultTitle}";
if (!empty($tagItem['title'])) {
$pageTitle = "{$tagItem['title']},来自{$defaultTitle}";
}
}
$viewName = '//site/index'; //共享视图
@ -78,36 +74,32 @@ Class ListController extends SiteController { @@ -78,36 +74,32 @@ Class ListController extends SiteController {
}
//根据目录结构以及当前目录获取面包屑
protected function getBreadcrumbs($menus, $subcate) {
protected function getBreadcrumbs($menus, $tag) {
$breads = array();
if (!empty($subcate['directory'])) {
array_push($breads, [
'id' => $subcate['id'],
'name' => $subcate['directory'],
'url' => $subcate['path'],
'id' => $tag['id'],
'name' => $tag['name'],
'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;
while($parent) {
array_unshift($breads, [
'id' => $parent['id'],
'name' => $parent['directory'],
'url' => $parent['path'],
]);
//根据tag的filenames获取它们的files数据,数据结构保持跟原file一致
protected function getTagFiles($tag, $scanResults) {
$files = array();
if (empty($tag['files'])) {return $files;}
$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;
}
}

3
themes/tajian/views/site/index.php

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<?php
//常用方法
require_once __DIR__ . '/../../../../plugins/Html.php';
$imgPreffix = FSC::$app['config']['content_directory'] . FSC::$app['config']['tajian']['data_dir'];
$imgPreffix = '/' . FSC::$app['config']['content_directory'] . FSC::$app['config']['tajian']['data_dir'];
?><div class="menu">
<?php
@ -50,7 +50,6 @@ eof; @@ -50,7 +50,6 @@ eof;
$imgExts = array('jpg', 'jpeg', 'png', 'gif');
$videoExts = array('url');
$category = $viewData['scanResults'][$selectedId];
//TODO: 兼容按tag分类显示数据
//当前目录的描述介绍
if (!empty($category['description'])) {

Loading…
Cancel
Save