/[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.4 - (hide annotations)
Sat Apr 12 05:04:39 2025 UTC (11 months ago) by sysadm
Branch: MAIN
Changes since 1.3: +3 -3 lines
Refact

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

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