Browse Source

pagination improved

master
filesite 5 months ago
parent
commit
ae1a78c697
  1. 9
      plugins/Html.php
  2. 4
      themes/beauty/controller/ListController.php
  3. 16
      themes/beauty/views/site/index.php
  4. 1
      www/css/beauty.css

9
plugins/Html.php

@ -216,10 +216,10 @@ eof; @@ -216,10 +216,10 @@ eof;
eof;
}
//中间显示 10 页
//包括当前页一共显示 10 页
$otherLinks = '';
$startPage = $page > 5 ? $page - 5 : 1;
$endPage = $startPage + 10 < $maxPage ? $startPage + 10 : $maxPage;
$startPage = floor(($page-1) / 10)*10 + 1;
$endPage = $startPage + 9 < $maxPage ? $startPage + 9 : $maxPage;
for ($i = $startPage; $i <= $endPage; $i ++) {
$url = self::getPaginationLink($currentUrl, $i, $limit);
if ($i != $page) {
@ -241,9 +241,6 @@ eof; @@ -241,9 +241,6 @@ eof;
{$previousLink}
{$otherLinks}
{$nextLink}
<li class="page-item disabled">
<span class="page-link">总数 <strong>{$total}</strong></span>
</li>
</ul>
</nav>
eof;

4
themes/beauty/controller/ListController.php

@ -24,11 +24,11 @@ Class ListController extends Controller { @@ -24,11 +24,11 @@ Class ListController extends Controller {
$scanner = new DirScanner();
//TODO: 根据参数cid获取id对应的目录realpath,从而只扫描这个目录
//根据参数cid获取id对应的目录realpath,从而只扫描这个目录
$cacheSeconds = 3600;
$cachedParentData = Common::getCacheFromFile($cacheParentDataId, $cacheSeconds);
if (empty($cachedParentData)) {
throw new Exception("缓存已过期,请返回上一页重新进入!", 404);
return $this->redirect('/');
}
$currentDir = $cachedParentData[$cateId];

16
themes/beauty/views/site/index.php

@ -54,9 +54,19 @@ eof; @@ -54,9 +54,19 @@ eof;
<div class="img_main">
<?php
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif');
$category = !empty($viewData['scanResults'][$selectedId]) ? $viewData['scanResults'][$selectedId] : [];
$total = 0; //翻页支持
if (!empty($category['files'])) {
$total = Html::getDataTotal($category['files'], $imgExts); //翻页支持
}
if (!empty($breadcrumbs)) {
echo <<<eof
<div class="breadcrumbs text_dark">
<span class="pull-right total">总数 <strong>{$total}</strong></span>
<small>当前位置:</small>
<a href="/">首页</a> /
eof;
@ -81,11 +91,6 @@ eof; @@ -81,11 +91,6 @@ eof;
<div class="im_mainl row">
<?php
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif');
$category = !empty($viewData['scanResults'][$selectedId]) ? $viewData['scanResults'][$selectedId] : [];
$total = 0; //翻页支持
//如果没有选中任何目录,则把所有目录显示出来
if (empty($selectedId) && !empty($viewData['menus'])) {
$category = array(
@ -182,7 +187,6 @@ eof; @@ -182,7 +187,6 @@ eof;
}
if (!empty($category['files'])) { //一级目录支持
$total = Html::getDataTotal($category['files'], $imgExts); //翻页支持
$pageStartIndex = ($viewData['page']-1) * $viewData['pageSize'];
$index = 0;
foreach ($category['files'] as $file) {

1
www/css/beauty.css

@ -109,6 +109,7 @@ a:link{text-decoration:none} @@ -109,6 +109,7 @@ a:link{text-decoration:none}
.page_meta .breadcrumb{background:none;display: inline-block;padding:8px 0 8px 0;margin:0}
.breadcrumbs{padding-left:1.5em;padding-bottom:10px;font-size:13px}
.breadcrumbs small{font-size:13px}
.breadcrumbs .total{padding-right:10px}
/* 主题切换 */
.lampshow .web_info{border-color:#363636}

Loading…
Cancel
Save