/[LeafOK_CVS]/fenglin/bbs/section_list.inc.php
ViewVC logotype

Annotation of /fenglin/bbs/section_list.inc.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Apr 10 12:23:25 2025 UTC (11 months ago) by sysadm
Branch: MAIN
Refact load_section_list

1 sysadm 1.1 <?
2     function load_section_list(array & $result, callable $filter, mysqli $db_conn) : bool
3     {
4     $sql = "SELECT SID, section_config.CID, section_config.title AS s_title, section_class.title AS c_title
5     FROM section_config INNER JOIN section_class ON section_config.CID = section_class.CID
6     WHERE section_class.enable AND section_config.enable
7     ORDER BY section_class.sort_order, section_config.sort_order";
8    
9     $rs = mysqli_query($db_conn, $sql);
10     if ($rs == false)
11     {
12     return false;
13     }
14    
15     $last_cid = -1;
16     $last_c_title = "";
17     $section_list = array();
18     while ($row = mysqli_fetch_array($rs))
19     {
20     if ($row["CID"] != $last_cid)
21     {
22     if (count($section_list) > 0)
23     {
24     array_push($result, array(
25     "cid" => $last_cid,
26     "title" => $last_c_title,
27     "sections" => $section_list,
28     ));
29    
30     $section_list = array();
31     }
32    
33     $last_cid = $row["CID"];
34     $last_c_title = $row["c_title"];
35     }
36    
37     if (call_user_func($filter, $row["SID"]))
38     {
39     array_push($section_list, array(
40     "sid" => $row["SID"],
41     "title" => $row["s_title"],
42     ));
43     }
44     }
45    
46     if (count($section_list) > 0)
47     {
48     array_push($result, array(
49     "cid" => $last_cid,
50     "title" => $last_c_title,
51     "sections" => $section_list,
52     ));
53     }
54    
55     mysqli_free_result($rs);
56    
57     return true;
58     }
59     ?>

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1