From 605b68001ffb31d1c28cabb33fecafdc27809f4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8F=99=E8=BF=B0=E3=80=81=E5=88=AB=E7=A6=BB?=
 <xushubieli@qq.com>
Date: Tue, 24 Dec 2024 20:18:54 +0800
Subject: [PATCH] Update listview.class.php

---
 src/system/archive/listview.class.php | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/system/archive/listview.class.php b/src/system/archive/listview.class.php
index b33bb118..6f821a95 100755
--- a/src/system/archive/listview.class.php
+++ b/src/system/archive/listview.class.php
@@ -417,12 +417,20 @@ class ListView
         }
         //排序方式
         $ordersql = '';
-        if ($orderby == "senddate" || $orderby == "id") {
+        if ($orderby == "senddate") {
+            $ordersql = " ORDER BY arc.senddate $orderWay";
+        } else if ($orderby == "pubdate") {
+            $ordersql = " ORDER BY arc.pubdate $orderWay";
+        } else if ($orderby == "id") {
             $ordersql = " ORDER BY arc.id $orderWay";
         } else if ($orderby == "hot" || $orderby == "click") {
             $ordersql = " ORDER BY arc.click $orderWay";
         } else if ($orderby == "lastpost") {
             $ordersql = " ORDER BY arc.lastpost $orderWay";
+        } else if ($orderby == "scores") {
+            $ordersql = " ORDER BY arc.scores $orderWay";
+        } else if ($orderby == "rand") {
+            $ordersql = " ORDER BY rand() DESC";
         } else {
             $ordersql = " ORDER BY arc.sortrank $orderWay";
         }
@@ -463,7 +471,7 @@ class ListView
             $addJoin = '';
         }
         //如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢
-        if (preg_match('/hot|click|lastpost/', $orderby)) {
+        if (preg_match('/hot|click|lastpost|rand/', $orderby)) {
             $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,mb.uname,mb.face,mb.userid $addField FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb ON arc.mid=mb.mid $addJoin WHERE {$this->addSql} $filtersql $ordersql LIMIT $limitstart,$row";
         }
         //普通情况先从arctiny表查出id,然后按id查询速度非常快
@@ -831,12 +839,20 @@ class ListView
         }
         //排序方式
         $ordersql = '';
-        if ($orderby == "senddate" || $orderby == "id") {
+        if ($orderby == "senddate") {
+            $ordersql = " ORDER BY arc.senddate $orderWay";
+        } else if ($orderby == "pubdate") {
+            $ordersql = " ORDER BY arc.pubdate $orderWay";
+        } else if ($orderby == "id") {
             $ordersql = " ORDER BY arc.id $orderWay";
         } else if ($orderby == "hot" || $orderby == "click") {
             $ordersql = " ORDER BY arc.click $orderWay";
         } else if ($orderby == "lastpost") {
             $ordersql = " ORDER BY arc.lastpost $orderWay";
+        } else if ($orderby == "scores") {
+            $ordersql = " ORDER BY arc.scores $orderWay";
+        } else if ($orderby == "rand") {
+            $ordersql = " ORDER BY rand() DESC";
         } else {
             $ordersql = " ORDER BY arc.sortrank $orderWay";
         }
@@ -877,7 +893,7 @@ class ListView
             $addJoin = '';
         }
         //如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢
-        if (preg_match('/hot|click|lastpost/', $orderby)) {
+        if (preg_match('/hot|click|lastpost|rand/', $orderby)) {
             $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,mb.uname,mb.face,mb.userid $addField FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb ON arc.mid=mb.mid $addJoin WHERE {$this->addSql} $filtersql $ordersql LIMIT $limitstart,$row";
         }
         //普通情况先从arctiny表查出id,然后按di查询速度非常快