diff --git a/themes/beauty/controller/CommandController.php b/themes/beauty/controller/CommandController.php index 950af57..4e1fac8 100644 --- a/themes/beauty/controller/CommandController.php +++ b/themes/beauty/controller/CommandController.php @@ -155,12 +155,12 @@ eof; protected function scanMediaFiles($dirpath = '') { $rootDir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory']; if (empty($dirpath)) { - $dirpath = $rootDir; + $dirpath = realpath($rootDir); } echo "\n\n== Scanning directory {$dirpath} ...\n"; $scanner = new DirScanner(); - $scanner->setWebRoot(FSC::$app['config']['content_directory']); + $scanner->setWebRoot($this->getCurrentWebroot($dirpath)); $scanner->setRootDir($dirpath); //尝试使用exiftool来获取视频的拍摄时间 diff --git a/themes/beauty/controller/ListController.php b/themes/beauty/controller/ListController.php index ae66e87..0bc231a 100644 --- a/themes/beauty/controller/ListController.php +++ b/themes/beauty/controller/ListController.php @@ -405,7 +405,7 @@ Class ListController extends Controller { //先获取keys文件,以快速检查年份和月份数据是否存在,并用于展示月份导航栏 $cacheKey = $this->dateIndexCacheKey . "_keys"; - $expireSeconds = 86400 * 30; //缓存 30 天 + $expireSeconds = 86400 * 365; //缓存 365 天 $cacheSubDir = 'index'; $cacheData_keys = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); if (empty($cacheData_keys)) { @@ -427,8 +427,9 @@ Class ListController extends Controller { //优先从缓存获取目录数据 $maxScanDeep = 0; //最大扫描目录级数 + $expireSeconds = 86400; $cacheKey = $this->getCacheKey('all', 'menu', $maxScanDeep); - $menus = Common::getCacheFromFile($cacheKey); + $menus = Common::getCacheFromFile($cacheKey, $expireSeconds); //获取目录面包屑 $breadcrumbs = [ @@ -454,7 +455,6 @@ Class ListController extends Controller { $htmlCateReadme = ''; //当前目录下的Readme.md 内容 $copyright = ''; - $expireSeconds = 86400; $cacheKey = $this->getCacheKey('root', 'readme', $maxScanDeep); $readmeFile = Common::getCacheFromFile($cacheKey, $expireSeconds); @@ -468,9 +468,11 @@ Class ListController extends Controller { $pageSize = (int)$pageSize; //支持图片、视频、音乐类型筛选 + $pageTitleSuffix = '照片和视频'; $showType = $this->get('show', 'all'); $filtExts = []; if ($showType == 'image') { + $pageTitleSuffix = '照片'; foreach($cacheData as $month => $arr) { $cacheData[$month] = array_filter($arr, function($item) { $filtExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif'); @@ -478,6 +480,7 @@ Class ListController extends Controller { }); } }else if ($showType == 'video') { + $pageTitleSuffix = '视频'; foreach($cacheData as $month => $arr) { $cacheData[$month] = array_filter($arr, function($item) { $filtExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8'); @@ -485,6 +488,7 @@ Class ListController extends Controller { }); } }else if ($showType == 'audio') { + $pageTitleSuffix = '音乐'; foreach($cacheData as $month => $arr) { $cacheData[$month] = array_filter($arr, function($item) { $filtExts = !empty(FSC::$app['config']['supportedAudioExts']) ? FSC::$app['config']['supportedAudioExts'] : array('mp3'); @@ -494,10 +498,11 @@ Class ListController extends Controller { } - $pageTitle = "{$para_year}年的照片和视频"; + $pageTitlePrefix = "{$intYear}年的"; if (!empty($para_month)) { - $pageTitle = "{$intYear}年{$intMonth}月的照片和视频"; + $pageTitlePrefix = "{$intYear}年{$intMonth}月的"; } + $pageTitle = "{$pageTitlePrefix}{$pageTitleSuffix}"; $viewName = 'bydate'; @@ -506,7 +511,8 @@ Class ListController extends Controller { 'htmlReadme', 'htmlCateReadme', 'copyright', 'mp3File', 'isAdminIp', 'page', 'pageSize', 'showType', 'cacheData', - 'cacheData_keys' + 'cacheData_keys', + 'para_year', 'para_month' ); return $this->render($viewName, $params, $pageTitle); } diff --git a/themes/beauty/views/list/bydate.php b/themes/beauty/views/list/bydate.php index 3cfcf84..e24ff17 100644 --- a/themes/beauty/views/list/bydate.php +++ b/themes/beauty/views/list/bydate.php @@ -1,3 +1,315 @@ + + + +
+ $files) { + $total += Html::getDataTotal($files, $supportedExts); //翻页支持 + } +} + + +$totalNum = ''; +if ($total > 0) { + $totalNum = <<总数 {$total} +eof; +} + + +if (!empty($viewData['alertWarning'])) { + echo <<{$viewData['alertWarning']}
+eof; +} + +echo << + {$totalNum} + 当前位置: + 首页 +eof; + +$breadcrumbs = !empty($viewData['breadcrumbs']) ? $viewData['breadcrumbs'] : []; +if (!empty($breadcrumbs)) { + foreach ($breadcrumbs as $bread) { + if ($bread['id'] != $selectedId) { + echo <<{$bread['name']} +eof; + } else { + echo <<{$bread['name']} +eof; + } + } +} + +echo << +eof; +?> + +
+ '所有', + 'image' => '照片', + 'video' => '视频', + 'audio' => '音乐', + ); + + echo ''; + + + //显示图片、视频、音乐 + foreach($cacheData as $month => $files) { //按月份输出 + $pageStartIndex = ($viewData['page']-1) * $viewData['pageSize']; + $index = 0; + + foreach ($files as $file) { + if (empty($file['extension']) || !in_array($file['extension'], $supportedExts)) { + continue; + } + + //翻页支持 + if ($index < $pageStartIndex) { + $index ++; + continue; + }else if ($index >= $pageStartIndex + $viewData['pageSize']) { + break; + } + + //图片、视频显示文件修改日期 + if (!empty($file['original_ctime'])) { //优先使用照片的拍摄日期 + $title = '摄于' . date('Y-m-d H:i', $file['original_ctime']); + }else { + $title = Common::getDateFromString($file['filename']); //根据文件名获取拍摄日期 + if (empty($title) && !empty($file['fstat']['mtime']) && !empty($file['fstat']['ctime'])) { + $title = date('Y-m-d', Common::getFileCreateTime($file)); + } + } + + if (in_array($file['extension'], $imgExts)) { + //缩略图 + $imgUrl = urlencode($file['path']); + $smallUrl = "/site/smallimg/?id={$file['id']}&url={$imgUrl}"; + if (empty(FSC::$app['config']['enableSmallImage']) || FSC::$app['config']['enableSmallImage'] === 'false') { + $smallUrl = $file['path']; + } + + //大图(支持中尺寸的缩略图) + $bigUrl = "/site/smallimg/?id={$file['id']}&url={$imgUrl}&size=middle"; + if (empty(FSC::$app['config']['enableSmallImageForWan']) || FSC::$app['config']['enableSmallImageForWan'] === 'false') { + $bigUrl = $file['path']; + } + + echo << + + {$file['filename']} +
+ + {$title} + +
+ {$btnSetSnap} +
+
+eof; + }else if (in_array($file['extension'], $videoExts)) { //输出视频 + //m3u8支持 + if ($file['extension'] == 'm3u8') { + $videoUrl = urlencode("{$file['path']}&cid={$viewData['cacheDataId']}"); + }else { + $videoUrl = urlencode($file['path']); + } + + $linkUrl = "/site/player?id={$file['id']}&pid={$file['pid']}&cid={$viewData['cacheDataId']}&url={$videoUrl}"; + if ($viewData['showType'] == 'video') { + $linkUrl .= "&page={$viewData['page']}&limit={$viewData['pageSize']}"; + } + + echo << + + {$file['filename']} +
+ + {$title} + +
+ video play button + 00:00:00 +
+ +eof; + }else if (in_array($file['extension'], $audioExts)) { //输出音乐 + $title = !empty($file['title']) ? $file['title'] : $file['filename']; + $videoUrl = urlencode($file['path']); + $linkUrl = "/site/audioplayer?id={$file['id']}&pid={$file['pid']}&cid={$viewData['cacheDataId']}&url={$videoUrl}"; + if ($viewData['showType'] == 'audio') { + $linkUrl .= "&page={$viewData['page']}&limit={$viewData['pageSize']}"; + } + + $snapshot = '/img/beauty/audio_icon.jpeg'; + if (!empty($file['snapshot'])) { + $snapshot = $file['snapshot']; + }else { //尝试找出同名的图片文件 + $matchedImage = Html::searchImageByFilename($file['filename'], $viewData['allFiles'], $imgExts); + if (!empty($matchedImage)) { + $snapshot = $matchedImage['path']; + } + } + + echo << + + {$file['filename']} + {$title} + video play button + 00:00:00 + + +eof; + } + + + $index++; + } + } +?> + + + + \ No newline at end of file diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index f5f9b13..fa6a752 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -6,6 +6,13 @@ $imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config $videoExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8'); $audioExts = !empty(FSC::$app['config']['supportedAudioExts']) ? FSC::$app['config']['supportedAudioExts'] : array('mp3'); $supportedExts = array_merge($imgExts, $videoExts, $audioExts); +if ($viewData['showType'] == 'image') { + $supportedExts = $imgExts; +}else if ($viewData['showType'] == 'video') { + $supportedExts = $videoExts; +}else if ($viewData['showType'] == 'audio') { + $supportedExts = $audioExts; +} //需密码授权的目录显示lock图标 $authConfig = !empty(FSC::$app['config']['password_auth']) ? FSC::$app['config']['password_auth'] : array();