Browse Source

add video sort by ctime

master
filesite 1 year ago
parent
commit
37683a3c79
  1. 22
      plugins/Html.php
  2. 3
      themes/tajian/views/site/index.php

22
plugins/Html.php

@ -51,4 +51,26 @@ Class Html { @@ -51,4 +51,26 @@ Class Html {
return $platform;
}
//根据ctime进行排序,默认按时间先后倒序排列
public static function sortFilesByCreateTime($files, $way = 'desc') {
$ctimes = array();
foreach($files as $id => $item) {
$ctimes[$id] = $item['fstat']['ctime'];
}
if ($way == 'desc') {
arsort($ctimes, SORT_NUMERIC);
}else {
asort($ctimes, SORT_NUMERIC);
}
$sorted = array();
foreach($ctimes as $id => $ctime) {
array_push($sorted, $files[$id]);
}
return $sorted;
}
}

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

@ -62,7 +62,8 @@ eof; @@ -62,7 +62,8 @@ eof;
if (!empty($category['files'])) { //一级目录支持,目录下直接存放视频文件
foreach($category['files'] as $file) {
$cate_files = Html::sortFilesByCreateTime($category['files'], 'desc'); //按创建时间排序
foreach($cate_files as $file) {
//跳过非.url文件
if (!in_array($file['extension'], $videoExts) || empty($file['shortcut'])) {
continue;

Loading…
Cancel
Save