/[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.7 - (hide annotations)
Tue Apr 29 11:55:32 2025 UTC (10 months, 2 weeks ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +0 -1 lines
Remove redundant PHP closing tag

1 sysadm 1.6 <?php
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 sysadm 1.5 section_class.title AS c_title, section_config.recommend
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     }

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