1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Simple Machines Forum (SMF) |
4
|
|
|
* |
5
|
|
|
* @package SMF |
6
|
|
|
* @author Simple Machines https://www.simplemachines.org |
7
|
|
|
* @copyright 2020 Simple Machines and individual contributors |
8
|
|
|
* @license https://www.simplemachines.org/about/smf/license.php BSD |
9
|
|
|
* |
10
|
|
|
* @version 2.1 RC3 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This template handles displaying a list |
15
|
|
|
* |
16
|
|
|
* @param string $list_id The list ID. If null, uses $context['default_list']. |
17
|
|
|
*/ |
18
|
|
|
function template_show_list($list_id = null) |
19
|
|
|
{ |
20
|
|
|
global $context; |
21
|
|
|
|
22
|
|
|
// Get a shortcut to the current list. |
23
|
|
|
$list_id = $list_id === null ? (!empty($context['default_list']) ? $context['default_list'] : '') : $list_id; |
24
|
|
|
|
25
|
|
|
if (empty($list_id) || empty($context[$list_id])) |
26
|
|
|
return; |
27
|
|
|
|
28
|
|
|
$cur_list = &$context[$list_id]; |
29
|
|
|
|
30
|
|
|
if (isset($cur_list['form'])) |
31
|
|
|
echo ' |
32
|
|
|
<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'], '">'; |
33
|
|
|
|
34
|
|
|
// Show the title of the table (if any). |
35
|
|
|
if (!empty($cur_list['title'])) |
36
|
|
|
echo ' |
37
|
|
|
<div class="cat_bar"> |
38
|
|
|
<h3 class="catbg"> |
39
|
|
|
', $cur_list['title'], ' |
40
|
|
|
</h3> |
41
|
|
|
</div>'; |
42
|
|
|
|
43
|
|
|
if (isset($cur_list['additional_rows']['after_title'])) |
44
|
|
|
{ |
45
|
|
|
echo ' |
46
|
|
|
<div class="information flow_hidden">'; |
47
|
|
|
|
48
|
|
|
template_additional_rows('after_title', $cur_list); |
49
|
|
|
|
50
|
|
|
echo ' |
51
|
|
|
</div>'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
if (isset($cur_list['additional_rows']['top_of_list'])) |
55
|
|
|
template_additional_rows('top_of_list', $cur_list); |
56
|
|
|
|
57
|
|
|
if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['above_column_headers'])) |
58
|
|
|
{ |
59
|
|
|
// Show the page index (if this list doesn't intend to show all items). |
60
|
|
|
if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) |
61
|
|
|
echo ' |
62
|
|
|
<div class="floatleft"> |
63
|
|
|
<div class="pagesection">', $cur_list['page_index'], '</div> |
64
|
|
|
</div>'; |
65
|
|
|
|
66
|
|
|
if (isset($cur_list['additional_rows']['above_column_headers'])) |
67
|
|
|
template_additional_rows('above_column_headers', $cur_list); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
echo ' |
71
|
|
|
<table class="table_grid" ', !empty($list_id) ? 'id="' . $list_id . '"' : '', ' ', !empty($cur_list['width']) ? ' style="width:' . $cur_list['width'] . '"' : '', '>'; |
72
|
|
|
|
73
|
|
|
// Show the column headers. |
74
|
|
|
$header_count = count($cur_list['headers']); |
75
|
|
|
if (!($header_count < 2 && empty($cur_list['headers'][0]['label']))) |
76
|
|
|
{ |
77
|
|
|
echo ' |
78
|
|
|
<thead> |
79
|
|
|
<tr class="title_bar">'; |
80
|
|
|
|
81
|
|
|
// Loop through each column and add a table header. |
82
|
|
|
foreach ($cur_list['headers'] as $col_header) |
83
|
|
|
echo ' |
84
|
|
|
<th scope="col" id="header_', $list_id, '_', $col_header['id'], '" class="', $col_header['id'], empty($col_header['class']) ? '' : ' ' . $col_header['class'], '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '> |
85
|
|
|
', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? '' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <span class="main_icons sort_' . $col_header['sort_image'] . '"></span></a>'), ' |
86
|
|
|
</th>'; |
87
|
|
|
|
88
|
|
|
echo ' |
89
|
|
|
</tr> |
90
|
|
|
</thead>'; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
echo ' |
94
|
|
|
<tbody>'; |
95
|
|
|
|
96
|
|
|
// Show a nice message informing there are no items in this list. |
97
|
|
|
if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) |
98
|
|
|
echo ' |
99
|
|
|
<tr class="windowbg"> |
100
|
|
|
<td colspan="', $cur_list['num_columns'], '" class="', !empty($cur_list['no_items_align']) ? $cur_list['no_items_align'] : 'centertext', '"> |
101
|
|
|
', $cur_list['no_items_label'], ' |
102
|
|
|
</td> |
103
|
|
|
</tr>'; |
104
|
|
|
|
105
|
|
|
// Show the list rows. |
106
|
|
|
elseif (!empty($cur_list['rows'])) |
107
|
|
|
{ |
108
|
|
|
foreach ($cur_list['rows'] as $id => $row) |
109
|
|
|
{ |
110
|
|
|
echo ' |
111
|
|
|
<tr class="windowbg', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', ' id="list_', $list_id, '_', $id, '">'; |
112
|
|
|
|
113
|
|
|
if (!empty($row['data'])) |
114
|
|
|
foreach ($row['data'] as $row_id => $row_data) |
115
|
|
|
echo ' |
116
|
|
|
<td class="', $row_id, empty($row_data['class']) ? '' : ' ' . $row_data['class'] . '', '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '> |
117
|
|
|
', $row_data['value'], ' |
118
|
|
|
</td>'; |
119
|
|
|
|
120
|
|
|
echo ' |
121
|
|
|
</tr>'; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
echo ' |
126
|
|
|
</tbody> |
127
|
|
|
</table>'; |
128
|
|
|
|
129
|
|
|
if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['below_table_data'])) |
130
|
|
|
{ |
131
|
|
|
echo ' |
132
|
|
|
<div class="flow_auto">'; |
133
|
|
|
|
134
|
|
|
// Show the page index (if this list doesn't intend to show all items). |
135
|
|
|
if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) |
136
|
|
|
echo ' |
137
|
|
|
<div class="floatleft"> |
138
|
|
|
<div class="pagesection">', $cur_list['page_index'], '</div> |
139
|
|
|
</div>'; |
140
|
|
|
|
141
|
|
|
if (isset($cur_list['additional_rows']['below_table_data'])) |
142
|
|
|
template_additional_rows('below_table_data', $cur_list); |
143
|
|
|
|
144
|
|
|
echo ' |
145
|
|
|
</div>'; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
if (isset($cur_list['additional_rows']['bottom_of_list'])) |
149
|
|
|
template_additional_rows('bottom_of_list', $cur_list); |
150
|
|
|
|
151
|
|
|
if (isset($cur_list['form'])) |
152
|
|
|
{ |
153
|
|
|
foreach ($cur_list['form']['hidden_fields'] as $name => $value) |
154
|
|
|
echo ' |
155
|
|
|
<input type="hidden" name="', $name, '" value="', $value, '">'; |
156
|
|
|
|
157
|
|
|
if (isset($cur_list['form']['token'])) |
158
|
|
|
echo ' |
159
|
|
|
<input type="hidden" name="', $context[$cur_list['form']['token'] . '_token_var'], '" value="', $context[$cur_list['form']['token'] . '_token'], '">'; |
160
|
|
|
|
161
|
|
|
echo ' |
162
|
|
|
</form>'; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
if (isset($cur_list['javascript'])) |
166
|
|
|
echo ' |
167
|
|
|
<script> |
168
|
|
|
', $cur_list['javascript'], ' |
169
|
|
|
</script>'; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* This template displays additional rows above or below the list. |
174
|
|
|
* |
175
|
|
|
* @param string $row_position The position ('top', 'bottom', etc.) |
176
|
|
|
* @param array $cur_list An array with the data for the current list |
177
|
|
|
*/ |
178
|
|
|
function template_additional_rows($row_position, $cur_list) |
179
|
|
|
{ |
180
|
|
|
foreach ($cur_list['additional_rows'][$row_position] as $row) |
181
|
|
|
echo ' |
182
|
|
|
<div class="additional_row', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '> |
183
|
|
|
', $row['value'], ' |
184
|
|
|
</div>'; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
?> |