diff --git a/conf/app.php b/conf/app.php
index a564fb6..1c08862 100644
--- a/conf/app.php
+++ b/conf/app.php
@@ -22,6 +22,6 @@ return array(
//for themes
'googleimage' => [
'imageHeight' => 180, //图片高度,单位:px
-
+ 'contact' => 'FileSite图片网站订制联系:FileSite.io',
],
);
diff --git a/lib/DirScanner.php b/lib/DirScanner.php
index 14de123..1c7bc5f 100644
--- a/lib/DirScanner.php
+++ b/lib/DirScanner.php
@@ -513,12 +513,24 @@ Class DirScanner {
}
$branch = $this->getDirData($realpath, $files);
+
+ //add parent directory's id
+ $pid = $this->getId(realpath($dir));
+ if (!empty($pid)) {
+ $branch = array_merge(['pid' => $pid], $branch);
+ }
}else {
$pathinfo = pathinfo($realpath);
$extension = strtolower($pathinfo['extension']);
if ( in_array($extension, $this->supportFileExtensions) ) {
if ($extension != 'txt') {
$branch = $this->getFileData($realpath);
+
+ //add parent directory's id
+ $pid = $this->getId(realpath($dir));
+ if (!empty($pid)) {
+ $branch = array_merge(['pid' => $pid], $branch);
+ }
}else {
//把描述文件内容合并到被描述的目录或md文件数据中
$branch = $this->mergeDescriptionData($realpath);
@@ -569,10 +581,13 @@ Class DirScanner {
if (!empty($item['description'])) {
$dir['description'] = $item['description'];
}
+ if (!empty($item['pid'])) {
+ $dir['pid'] = $item['pid'];
+ }
}
- if (!empty($item['files'])) {
- $dirs = $this->getMenus($item['files']);
+ if (!empty($item['directories'])) {
+ $dirs = $this->getMenus($item['directories']);
if (!empty($dirs)) {
$dir['directories'] = $dirs;
}
diff --git a/themes/googleimage/controller/ListController.php b/themes/googleimage/controller/ListController.php
index 845f4b6..cbd0850 100644
--- a/themes/googleimage/controller/ListController.php
+++ b/themes/googleimage/controller/ListController.php
@@ -30,13 +30,36 @@ Class ListController extends Controller {
$html = $scanner->fixMDUrls($readmeFile['realpath'], $html);
}
- //TODO: 获取父目录,生成面包屑
-
+ //获取目录面包屑
+ $subcate = $scanResults[$cateId];
+ $breadcrumbs = $this->getBreadcrumbs($menus, $subcate);
$pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统";
$viewName = '//site/index'; //共享视图
- $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'html');
+ $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'html', 'breadcrumbs');
return $this->render($viewName, $params, $pageTitle);
}
+ //根据目录结构以及当前目录获取面包屑
+ protected function getBreadcrumbs($menus, $subcate) {
+ $breads = [];
+
+ array_push($breads, [
+ 'id' => $subcate['id'],
+ 'name' => $subcate['directory'],
+ 'url' => $subcate['path'],
+ ]);
+
+ $foundKey = array_search($subcate['pid'], array_column($menus, 'id'));
+ if ($foundKey !== false) {
+ array_unshift($breads, [
+ 'id' => $menus[$foundKey]['id'],
+ 'name' => $menus[$foundKey]['directory'],
+ 'url' => $menus[$foundKey]['path'],
+ ]);
+ }
+
+ return $breads;
+ }
+
}
diff --git a/themes/googleimage/views/layout/main.php b/themes/googleimage/views/layout/main.php
index ea628be..e7171dd 100644
--- a/themes/googleimage/views/layout/main.php
+++ b/themes/googleimage/views/layout/main.php
@@ -41,6 +41,12 @@ if (!empty($viewFile) && file_exists($viewFile)) {
©FSC 2022 - execute time: {page_time_cost} ms
+ {$contactInfo}