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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Thu Apr 10 13:38:44 2025 UTC (11 months ago) by sysadm
Branch: MAIN
Changes since 1.1: +2 -1 lines
Refine

1 <?
2 function load_section_list(array & $result, callable $filter, callable $udf_value_gen, 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 "udf_values" => call_user_func($udf_value_gen, $row["SID"]),
43 ));
44 }
45 }
46
47 if (count($section_list) > 0)
48 {
49 array_push($result, array(
50 "cid" => $last_cid,
51 "title" => $last_c_title,
52 "sections" => $section_list,
53 ));
54 }
55
56 mysqli_free_result($rs);
57
58 return true;
59 }
60 ?>

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