Browse Source

add bydate list page

master
filesite 2 months ago
parent
commit
62057a3f4f
  1. 89
      themes/beauty/controller/ListController.php
  2. 3
      themes/beauty/views/list/bydate.php

89
themes/beauty/controller/ListController.php

@ -422,12 +422,93 @@ Class ListController extends Controller { @@ -422,12 +422,93 @@ Class ListController extends Controller {
throw new Exception("索引数据已失效,请重新扫描所有文件以生成索引数据!", 404);
}
//其它数据获取
//优先从缓存获取目录数据
$maxScanDeep = 0; //最大扫描目录级数
$cacheKey = $this->getCacheKey('all', 'menu', $maxScanDeep);
$menus = Common::getCacheFromFile($cacheKey);
//获取目录面包屑
$breadcrumbs = [
[
'id' => $para_year,
'name' => $intYear,
'url' => "/list/bydate?year={$para_year}",
]
];
if (!empty($para_month)) {
print_r($cacheData[$para_month]);
}else {
print_r($cacheData);
array_push($breadcrumbs,
[
'id' => $para_month,
'name' => $intMonth,
'url' => "/list/bydate?year={$para_year}&month={$para_month}",
]
);
}
$isAdminIp = Common::isAdminIp($this->getUserIp()); //判断是否拥有管理权限
$htmlReadme = array(); //Readme.md 内容,底部网站详细介绍
$htmlCateReadme = ''; //当前目录下的Readme.md 内容
$copyright = '';
$expireSeconds = 86400;
$cacheKey = $this->getCacheKey('root', 'readme', $maxScanDeep);
$readmeFile = Common::getCacheFromFile($cacheKey, $expireSeconds);
$cacheKey = $this->getCacheKey('root', 'mp3', $maxScanDeep);
$mp3File = Common::getCacheFromFile($cacheKey, $expireSeconds);
//翻页支持
$page = $this->get('page', 1);
$pageSize = $this->get('limit', FSC::$app['config']['default_page_size']);
$page = (int)$page;
$pageSize = (int)$pageSize;
//支持图片、视频、音乐类型筛选
$showType = $this->get('show', 'all');
$filtExts = [];
if ($showType == 'image') {
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');
return !empty($item['extension']) && in_array($item['extension'], $filtExts);
});
}
}else if ($showType == 'video') {
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');
return !empty($item['extension']) && in_array($item['extension'], $filtExts);
});
}
}else if ($showType == 'audio') {
foreach($cacheData as $month => $arr) {
$cacheData[$month] = array_filter($arr, function($item) {
$filtExts = !empty(FSC::$app['config']['supportedAudioExts']) ? FSC::$app['config']['supportedAudioExts'] : array('mp3');
return !empty($item['extension']) && in_array($item['extension'], $filtExts);
});
}
}
$pageTitle = "{$para_year}年的照片和视频";
if (!empty($para_month)) {
$pageTitle = "{$intYear}年{$intMonth}月的照片和视频";
}
exit;
$viewName = 'bydate';
$params = compact(
'menus', 'breadcrumbs',
'htmlReadme', 'htmlCateReadme', 'copyright', 'mp3File', 'isAdminIp',
'page', 'pageSize', 'showType',
'cacheData',
'cacheData_keys'
);
return $this->render($viewName, $params, $pageTitle);
}
}

3
themes/beauty/views/list/bydate.php

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
<?php
print_r($viewData['cacheData']);
Loading…
Cancel
Save