Mercurial > hg > vamp-website
comparison forum/Themes/default/GenericList.template.php @ 76:e3e11437ecea website
Add forum code
author | Chris Cannam |
---|---|
date | Sun, 07 Jul 2013 11:25:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:72f59aa7e503 | 76:e3e11437ecea |
---|---|
1 <?php | |
2 /** | |
3 * Simple Machines Forum (SMF) | |
4 * | |
5 * @package SMF | |
6 * @author Simple Machines | |
7 * @copyright 2011 Simple Machines | |
8 * @license http://www.simplemachines.org/about/smf/license.php BSD | |
9 * | |
10 * @version 2.0 | |
11 */ | |
12 | |
13 function template_show_list($list_id = null) | |
14 { | |
15 global $context, $settings, $options, $scripturl, $txt, $modSettings; | |
16 | |
17 // Get a shortcut to the current list. | |
18 $list_id = $list_id === null ? $context['default_list'] : $list_id; | |
19 $cur_list = &$context[$list_id]; | |
20 | |
21 // These are the main tabs that is used all around the template. | |
22 if (!empty($settings['use_tabs']) && isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) | |
23 template_create_list_menu($cur_list['list_menu'], 'top'); | |
24 | |
25 if (isset($cur_list['form'])) | |
26 echo ' | |
27 <form action="', $cur_list['form']['href'], '" method="post"', empty($cur_list['form']['name']) ? '' : ' name="' . $cur_list['form']['name'] . '" id="' . $cur_list['form']['name'] . '"', ' accept-charset="', $context['character_set'], '"> | |
28 <div class="generic_list">'; | |
29 | |
30 // Show the title of the table (if any). | |
31 if (!empty($cur_list['title'])) | |
32 echo ' | |
33 <div class="title_bar clear_right"> | |
34 <h3 class="titlebg"> | |
35 ', $cur_list['title'], ' | |
36 </h3> | |
37 </div>'; | |
38 // This is for the old style menu with the arrows "> Test | Test 1" | |
39 if (empty($settings['use_tabs']) && isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) | |
40 template_create_list_menu($cur_list['list_menu'], 'top'); | |
41 | |
42 if (isset($cur_list['additional_rows']['top_of_list'])) | |
43 template_additional_rows('top_of_list', $cur_list); | |
44 | |
45 if (isset($cur_list['additional_rows']['after_title'])) | |
46 { | |
47 echo ' | |
48 <div class="information flow_hidden">'; | |
49 template_additional_rows('after_title', $cur_list); | |
50 echo ' | |
51 </div>'; | |
52 } | |
53 | |
54 if (!empty($cur_list['items_per_page']) || isset($cur_list['additional_rows']['bottom_of_list'])) | |
55 { | |
56 echo ' | |
57 <div class="flow_auto">'; | |
58 | |
59 // Show the page index (if this list doesn't intend to show all items). | |
60 if (!empty($cur_list['items_per_page'])) | |
61 echo ' | |
62 <div class="floatleft"> | |
63 <div class="pagesection">', $txt['pages'], ': ', $cur_list['page_index'], '</div> | |
64 </div>'; | |
65 | |
66 if (isset($cur_list['additional_rows']['above_column_headers'])) | |
67 { | |
68 echo ' | |
69 <div class="floatright">'; | |
70 | |
71 template_additional_rows('above_column_headers', $cur_list); | |
72 | |
73 echo ' | |
74 </div>'; | |
75 } | |
76 | |
77 echo ' | |
78 </div>'; | |
79 } | |
80 | |
81 echo ' | |
82 <table class="table_grid" cellspacing="0" width="', !empty($cur_list['width']) ? $cur_list['width'] : '100%', '">'; | |
83 | |
84 // Show the column headers. | |
85 $header_count = count($cur_list['headers']); | |
86 if (!($header_count < 2 && empty($cur_list['headers'][0]['label']))) | |
87 { | |
88 echo ' | |
89 <thead> | |
90 <tr class="catbg">'; | |
91 | |
92 // Loop through each column and add a table header. | |
93 $i = 0; | |
94 foreach ($cur_list['headers'] as $col_header) | |
95 { | |
96 $i ++; | |
97 if (empty($col_header['class']) && $i == 1) | |
98 $col_header['class'] = 'first_th'; | |
99 elseif (empty($col_header['class']) && $i == $header_count) | |
100 $col_header['class'] = 'last_th'; | |
101 | |
102 echo ' | |
103 <th scope="col"', empty($col_header['class']) ? '' : ' class="' . $col_header['class'] . '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '>', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? ' ' : $col_header['label'], empty($col_header['href']) ? '' : '</a>', empty($col_header['sort_image']) ? '' : ' <img src="' . $settings['images_url'] . '/sort_' . $col_header['sort_image'] . '.gif" alt="" />', '</th>'; | |
104 } | |
105 | |
106 echo ' | |
107 </tr> | |
108 </thead> | |
109 <tbody>'; | |
110 } | |
111 | |
112 // Show a nice message informing there are no items in this list. | |
113 if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) | |
114 echo ' | |
115 <tr> | |
116 <td class="windowbg" colspan="', $cur_list['num_columns'], '" align="', !empty($cur_list['no_items_align']) ? $cur_list['no_items_align'] : 'center', '"><div class="padding">', $cur_list['no_items_label'], '</div></td> | |
117 </tr>'; | |
118 | |
119 // Show the list rows. | |
120 elseif (!empty($cur_list['rows'])) | |
121 { | |
122 $alternate = false; | |
123 foreach ($cur_list['rows'] as $id => $row) | |
124 { | |
125 echo ' | |
126 <tr class="windowbg', $alternate ? '2' : '', '" id="list_', $list_id, '_', $id, '">'; | |
127 | |
128 foreach ($row as $row_data) | |
129 echo ' | |
130 <td', empty($row_data['class']) ? '' : ' class="' . $row_data['class'] . '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '>', $row_data['value'], '</td>'; | |
131 | |
132 echo ' | |
133 </tr>'; | |
134 | |
135 $alternate = !$alternate; | |
136 } | |
137 } | |
138 | |
139 echo ' | |
140 </tbody> | |
141 </table>'; | |
142 | |
143 if (!empty($cur_list['items_per_page']) || isset($cur_list['additional_rows']['below_table_data']) || isset($cur_list['additional_rows']['bottom_of_list'])) | |
144 { | |
145 echo ' | |
146 <div class="flow_auto">'; | |
147 | |
148 // Show the page index (if this list doesn't intend to show all items). | |
149 if (!empty($cur_list['items_per_page'])) | |
150 echo ' | |
151 <div class="floatleft"> | |
152 <div class="pagesection">', $txt['pages'], ': ', $cur_list['page_index'], '</div> | |
153 </div>'; | |
154 | |
155 if (isset($cur_list['additional_rows']['below_table_data'])) | |
156 { | |
157 echo ' | |
158 <div class="floatright">'; | |
159 | |
160 template_additional_rows('below_table_data', $cur_list); | |
161 | |
162 echo ' | |
163 </div>'; | |
164 } | |
165 | |
166 if (isset($cur_list['additional_rows']['bottom_of_list'])) | |
167 { | |
168 echo ' | |
169 <div class="floatright">'; | |
170 | |
171 template_additional_rows('bottom_of_list', $cur_list); | |
172 | |
173 echo ' | |
174 </div>'; | |
175 } | |
176 | |
177 echo ' | |
178 </div>'; | |
179 } | |
180 | |
181 if (isset($cur_list['form'])) | |
182 { | |
183 foreach ($cur_list['form']['hidden_fields'] as $name => $value) | |
184 echo ' | |
185 <input type="hidden" name="', $name, '" value="', $value, '" />'; | |
186 | |
187 echo ' | |
188 </div> | |
189 </form>'; | |
190 } | |
191 | |
192 // Tabs at the bottom. Usually bottom alligned. | |
193 if (!empty($settings['use_tabs']) && isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom')) | |
194 template_create_list_menu($cur_list['list_menu'], 'bottom'); | |
195 | |
196 if (isset($cur_list['javascript'])) | |
197 echo ' | |
198 <script type="text/javascript"><!-- // --><![CDATA[ | |
199 ', $cur_list['javascript'], ' | |
200 // ]]></script>'; | |
201 } | |
202 | |
203 function template_additional_rows($row_position, $cur_list) | |
204 { | |
205 global $context, $settings, $options; | |
206 | |
207 foreach ($cur_list['additional_rows'][$row_position] as $row) | |
208 echo ' | |
209 <div class="additional_row', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '>', $row['value'], '</div>'; | |
210 } | |
211 | |
212 function template_create_list_menu($list_menu, $direction = 'top') | |
213 { | |
214 global $context, $settings; | |
215 | |
216 /** | |
217 // This is use if you want your generic lists to have tabs. | |
218 $cur_list['list_menu'] = array( | |
219 // This is the style to use. Tabs or Buttons (Text 1 | Text 2). | |
220 // By default tabs are selected if not set. | |
221 // The main difference between tabs and buttons is that tabs get highlighted if selected. | |
222 // If style is set to buttons and use tabs is diabled then we change the style to old styled tabs. | |
223 'style' => 'tabs', | |
224 // The posisiton of the tabs/buttons. Left or Right. By default is set to left. | |
225 'position' => 'left', | |
226 // This is used by the old styled menu. We *need* to know the total number of columns to span. | |
227 'columns' => 0, | |
228 // This gives you the option to show tabs only at the top, bottom or both. | |
229 // By default they are just shown at the top. | |
230 'show_on' => 'top', | |
231 // Links. This is the core of the array. It has all the info that we need. | |
232 'links' => array( | |
233 'name' => array( | |
234 // This will tell use were to go when they click it. | |
235 'href' => $scripturl . '?action=theaction', | |
236 // The name that you want to appear for the link. | |
237 'label' => $txt['name'], | |
238 // If we use tabs instead of buttons we highlight the current tab. | |
239 // Must use conditions to determine if its selected or not. | |
240 'is_selected' => isset($_REQUEST['name']), | |
241 ), | |
242 ), | |
243 ); | |
244 */ | |
245 | |
246 // Are we using right-to-left orientation? | |
247 $first = $context['right_to_left'] ? 'last' : 'first'; | |
248 $last = $context['right_to_left'] ? 'first' : 'last'; | |
249 | |
250 // Tabs take preference over buttons in certain cases. | |
251 if (empty($settings['use_tabs']) && $list_menu['style'] == 'button') | |
252 $list_menu['style'] = 'tabs'; | |
253 | |
254 if (!isset($list_menu['style']) || isset($list_menu['style']) && $list_menu['style'] == 'tabs') | |
255 { | |
256 if (!empty($settings['use_tabs'])) | |
257 { | |
258 echo ' | |
259 <table cellpadding="0" cellspacing="0" style="margin-', $list_menu['position'], ': 10px; width: 100%;"> | |
260 <tr>', $list_menu['position'] == 'right' ? ' | |
261 <td> </td>' : '', ' | |
262 <td align="', $list_menu['position'], '"> | |
263 <table cellspacing="0" cellpadding="0"> | |
264 <tr> | |
265 <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $first, '"> </td>'; | |
266 | |
267 foreach ($list_menu['links'] as $link) | |
268 { | |
269 if ($link['is_selected']) | |
270 echo ' | |
271 <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $first, '"> </td> | |
272 <td valign="top" class="', $direction == 'top' ? 'mirrortab' : 'maintab', '_active_back"> | |
273 <a href="', $link['href'], '">', $link['label'], '</a> | |
274 </td> | |
275 <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $last, '"> </td>'; | |
276 else | |
277 echo ' | |
278 <td valign="top" class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back"> | |
279 <a href="', $link['href'], '">', $link['label'], '</a> | |
280 </td>'; | |
281 } | |
282 | |
283 echo ' | |
284 <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $last, '"> </td> | |
285 </tr> | |
286 </table> | |
287 </td>', $list_menu['position'] == 'left' ? ' | |
288 <td> </td>' : '', ' | |
289 </tr> | |
290 </table>'; | |
291 } | |
292 else | |
293 { | |
294 echo ' | |
295 <tr class="titlebg"> | |
296 <td colspan="', $context['colspan'], '">'; | |
297 | |
298 $links = array(); | |
299 foreach ($list_menu['links'] as $link) | |
300 $links[] = ($link['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.gif" alt=">" /> ' : '') . '<a href="' . $link['href'] . '">' . $link['label'] . '</a>'; | |
301 | |
302 echo ' | |
303 ', implode(' | ', $links), ' | |
304 </td> | |
305 </tr>'; | |
306 } | |
307 } | |
308 elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons') | |
309 { | |
310 $links = array(); | |
311 foreach ($list_menu['links'] as $link) | |
312 $links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>'; | |
313 | |
314 echo ' | |
315 <table cellpadding="0" cellspacing="0" style="margin-', $list_menu['position'], ': 10px; width: 100%;"> | |
316 <tr>', $list_menu['position'] == 'right' ? ' | |
317 <td> </td>' : '', ' | |
318 <td align="', $list_menu['position'], '"> | |
319 <table cellspacing="0" cellpadding="0"> | |
320 <tr> | |
321 <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $first, '"> </td> | |
322 <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back">', implode(' | ', $links), '</td> | |
323 <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $last, '"> </td> | |
324 </tr> | |
325 </table> | |
326 </td>', $list_menu['position'] == 'left' ? ' | |
327 <td> </td>' : '', ' | |
328 </tr> | |
329 </table>'; | |
330 } | |
331 } | |
332 | |
333 ?> |