/[LeafOK_CVS]/lbbs/utils/bin/gen_section_menu.php
ViewVC logotype

Diff of /lbbs/utils/bin/gen_section_menu.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Mon May 19 01:50:56 2025 UTC Revision 1.7 by sysadm, Fri May 30 03:00:26 2025 UTC
# Line 31  Line 31 
31                  },                  },
32                  function (array $section, array $filter_param) : mixed                  function (array $section, array $filter_param) : mixed
33                  {                  {
34                          return null;                          $db_conn = $filter_param["db"];
35                            $result = array(
36                                    "article_count" => 0,
37                                    "section_master" => "",
38                            );
39    
40                            // Query article count
41                            $sql = "SELECT COUNT(*) AS article_count FROM bbs WHERE SID = " .
42                                            $section["SID"] . " AND visible";
43                            
44                            $rs = mysqli_query($db_conn, $sql);
45                            if ($rs == false)
46                            {
47                                    echo mysqli_error($db_conn);
48                                    return $result;
49                            }
50    
51                            if ($row = mysqli_fetch_array($rs))
52                            {
53                                    $result["article_count"] = $row["article_count"];
54                            }
55                            mysqli_free_result($rs);
56    
57                            // Query section master
58                            $sql = "SELECT user_list.UID, user_list.username, section_master.major FROM section_master
59                                            INNER JOIN user_list ON section_master.UID = user_list.UID WHERE SID = " .
60                                            $section["SID"] . " AND section_master.enable AND (NOW() BETWEEN begin_dt AND end_dt)
61                                            ORDER BY major DESC LIMIT 1";
62    
63                            $rs = mysqli_query($db_conn, $sql);
64                            if ($rs == false)
65                            {
66                                    echo mysqli_error($db_conn);
67                                    return $result;
68                            }
69    
70                            if ($row = mysqli_fetch_array($rs))
71                            {
72                                    $result["section_master"] = $row["username"];
73                            }
74                            mysqli_free_result($rs);
75    
76                            return $result;
77                  },                  },
78                  $db_conn);                  $db_conn,
79                    array(
80                            "db" => $db_conn
81                    )
82            );
83    
84          if ($ret == false)          if ($ret == false)
85          {          {
# Line 41  Line 87 
87                  exit();                  exit();
88          }          }
89    
90            // Generate menu of section class
91          $buffer .= <<<MENU          $buffer .= <<<MENU
92  #---------------------------------------------------------------------  #---------------------------------------------------------------------
 %S_EGROUP  
   ·µ»Ø[¡û] ½øÈë[¡ú] Ñ¡Ôñ[¡ü,¡ý]  
     ÏÂÊô°æ¿é  À¸Ä¿Ãû³Æ                    ÖÐ  ÎÄ  Ðð  Êö                          
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
 %  
 #---------------------------------------------------------------------  
93  %menu M_EGROUP  %menu M_EGROUP
94  title       0, 0, "[À¸Ä¿Áбí]"  title       0, 0, "[À¸Ä¿Áбí]"
95  screen      2, 0, S_EGROUP  screen      2, 0, S_EGROUP
# Line 81  MENU; Line 103  MENU;
103                  $section_count = count($section_class["sections"]);                  $section_count = count($section_class["sections"]);
104    
105                  $title_f = str_repeat(" ", 5 - intval(log10($section_count))) . $section_count . " £«  " .                  $title_f = str_repeat(" ", 5 - intval(log10($section_count))) . $section_count . " £«  " .
106                          $section_class['name'] . str_repeat(" ", 28 - strlen($section_class['name'])) .                          $section_class['name'] . str_repeat(" ", 32 - strlen($section_class['name'])) .
107                          "[" . addslashes($section_class['title']) . "]";                          "[" . addslashes($section_class['title']) . "]";
108    
109                  $buffer .= <<<MENU                  $buffer .= <<<MENU
# Line 97  MENU; Line 119  MENU;
119    
120          foreach ($section_hierachy as $c_index => $section_class)          foreach ($section_hierachy as $c_index => $section_class)
121          {          {
122                    // Generate menu of sections in section_class[$c_index]
123                  $buffer .= <<<MENU                  $buffer .= <<<MENU
124  #---------------------------------------------------------------------  #---------------------------------------------------------------------
125  %S__{$section_class["name"]}  %menu M__{$section_class["name"]}
126    ·µ»Ø[¡û] ½øÈë[¡ú] Ñ¡Ôñ[¡ü,¡ý]  title       0, 0, "[{$section_class["title"]}]"
127      Ö÷ÌâÊýÁ¿  °æ¿éÃû³Æ                    ÖÐ  ÎÄ  Ðð  Êö                          screen      2, 0, S_BOARD
128    
129    MENU;
130    
131                    $class_title_f = "[" . addslashes($section_class['title']) . "]" . str_repeat(" ", 10 - str_length($section_class['title']));
132    
133                    foreach ($section_class["sections"] as $s_index => $section)
134                    {
135                            $display_row = ($s_index == 0 ? 4 : 0);
136    
137                            $article_count = $section['udf_values']['article_count'];
138    
139                            $title_f = str_repeat(" ", 5 - intval(log10($article_count))) . $article_count . " £«  " .
140                                    $section['name'] . str_repeat(" ", 20 - strlen($section['name'])) .
141                                    $class_title_f . addslashes($section['title']) . str_repeat(" ", 22 - str_length($section['title'])) .
142                                    $section['udf_values']['section_master'];
143    
144                            $buffer .= <<<MENU
145                            @LIST_SECTION   {$display_row}, 4, 1, {$section['read_user_level']},   "{$section['name']}",    "{$title_f}"
146    
147                            MENU;
148                    }
149    
150                    $buffer .= <<<MENU
151    %
152    
153    MENU;
154    
155            }
156    
157            // Generate menu of all sections
158            $buffer .= <<<MENU
159    #---------------------------------------------------------------------
160    %menu M_BOARD
161    title       0, 0, "[°æ¿éÁбí]"
162    screen      2, 0, S_BOARD
163    page        4, 1, 20
164    
165    MENU;
166    
167            $display_row = 4;
168    
169            foreach ($section_hierachy as $c_index => $section_class)
170            {
171                    $class_title_f = "[" . addslashes($section_class['title']) . "]" . str_repeat(" ", 10 - str_length($section_class['title']));
172    
173                    foreach ($section_class["sections"] as $s_index => $section)
174                    {
175                            $article_count = $section['udf_values']['article_count'];
176    
177                            $title_f = str_repeat(" ", 5 - intval(log10($article_count))) . $article_count . " £«  " .
178                                    $section['name'] . str_repeat(" ", 20 - strlen($section['name'])) .
179                                    $class_title_f . addslashes($section['title']) . str_repeat(" ", 22 - str_length($section['title'])) .
180                                    $section['udf_values']['section_master'];
181    
182                            $buffer .= <<<MENU
183                            @LIST_SECTION   {$display_row}, 4, 1, {$section['read_user_level']},   "{$section['name']}",    "{$title_f}"
184    
185                            MENU;
186    
187                            $display_row = 0;
188                    }
189            }
190    
191            $buffer .= <<<MENU
192  %  %
193    
194    MENU;
195    
196            // Generate menu of favourite sections
197            $buffer .= <<<MENU
198  #---------------------------------------------------------------------  #---------------------------------------------------------------------
199  %menu M__{$section_class["name"]}  %menu M_FAVOUR
200  title       0, 0, "[{$section_class["title"]}]"  title       0, 0, "[°æ¿éÊÕ²Ø]"
201  screen      2, 0, S__{$section_class["name"]}  screen      2, 0, S_BOARD
202    use_filter
203    page        4, 1, 20
204    
205  MENU;  MENU;
206    
207                  $class_title_f = "[" . addslashes($section_class['title']) . "]" . str_repeat(" ", 14 - str_length($section_class['title']));          $display_row = 4;
208    
209            foreach ($section_hierachy as $c_index => $section_class)
210            {
211                    $class_title_f = "[" . addslashes($section_class['title']) . "]" . str_repeat(" ", 10 - str_length($section_class['title']));
212    
213                  foreach ($section_class["sections"] as $s_index => $section)                  foreach ($section_class["sections"] as $s_index => $section)
214                  {                  {
215                          $display_row = ($s_index == 0 ? 4 : 0);                          $article_count = $section['udf_values']['article_count'];
216    
217                          $topic_count = 0; // TODO                          $title_f = str_repeat(" ", 5 - intval(log10($article_count))) . $article_count . " £«  " .
218                                    $section['name'] . str_repeat(" ", 20 - strlen($section['name'])) .
219                          $title_f = str_repeat(" ", 5 - intval(log10($topic_count))) . $topic_count . " £«  " .                                  $class_title_f . addslashes($section['title']) . str_repeat(" ", 22 - str_length($section['title'])) .
220                                  $section['name'] . str_repeat(" ", 22 - strlen($section['name'])) .                                  $section['udf_values']['section_master'];
                                 $class_title_f .  
                                 addslashes($section['title']);  
221    
222                          $buffer .= <<<MENU                          $buffer .= <<<MENU
223                          @LIST_SECTION   {$display_row}, 4, 1, {$section['read_user_level']},   "{$section['name']}",    "{$title_f}"                          @LIST_SECTION   {$display_row}, 4, {$section['sid']}, {$section['read_user_level']},   "{$section['name']}",    "{$title_f}"
224    
225                          MENU;                          MENU;
226    
227                            $display_row = 0;
228                  }                  }
229            }
230    
231                  $buffer .= <<<MENU          $buffer .= <<<MENU
232  %  %
233    
234  MENU;  MENU;
235    
         }  
   
236          unset($section_hierachy);          unset($section_hierachy);
237    
238          mysqli_close($db_conn);          mysqli_close($db_conn);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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