Passed
Pull Request — release-2.1 (#7165)
by John
06:10
created

template_main22()   A

Complexity

Conditions 5
Paths 8

Size

Total Lines 50
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 18
c 1
b 0
f 0
nc 8
nop 0
dl 0
loc 50
rs 9.3554
1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines https://www.simplemachines.org
7
 * @copyright 2021 Simple Machines and individual contributors
8
 * @license https://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 RC4
11
 */
12
13
/**
14
 * Choose which type of report to run?
15
 */
16
function template_report_type()
17
{
18
	global $context, $scripturl, $txt;
19
20
	echo '
21
		<form action="', $scripturl, '?action=admin;area=reports" method="post" accept-charset="', $context['character_set'], '">
22
			<div class="cat_bar">
23
				<h3 class="catbg">', $txt['generate_reports_type'], '</h3>
24
			</div>
25
			<div class="windowbg">
26
				<dl class="settings">';
27
28
	// Go through each type of report they can run.
29
	foreach ($context['report_types'] as $type)
30
	{
31
		if (isset($type['description']))
32
			echo '
33
					<dt>', $type['description'], '</dt>';
34
35
		echo '
36
					<dd>
37
						<input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', '>
38
						<strong><label for="rt_', $type['id'], '">', $type['title'], '</label></strong>
39
					</dd>';
40
	}
41
	echo '
42
				</dl>
43
				<input type="submit" name="continue" value="', $txt['generate_reports_continue'], '" class="button">
44
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
45
			</div><!-- .windowbg -->
46
		</form>';
47
}
48
49
/**
50
 * This is the standard template for showing reports.
51
 */
52
function template_main()
53
{
54
	global $context, $txt;
55
56
	echo '
57
		<div class="cat_bar">
58
			<h3 class="catbg">', $txt['results'], '</h3>
59
		</div>
60
		<div id="report_buttons">';
61
62
	if (!empty($context['report_buttons']))
63
		template_button_strip($context['report_buttons'], 'right');
64
65
	echo '
66
		</div>';
67
68
	// Go through each table!
69
	foreach ($context['tables'] as $table)
70
	{
71
		echo '
72
		<table class="table_grid report_results">';
73
74
		if (!empty($table['title']))
75
			echo '
76
			<thead>
77
				<tr class="title_bar">
78
					<th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th>
79
				</tr>
80
			</thead>
81
			<tbody>';
82
83
		// Now do each row!
84
		$row_number = 0;
85
		foreach ($table['data'] as $row)
86
		{
87
			if ($row_number == 0 && !empty($table['shading']['top']))
88
				echo '
89
				<tr class="windowbg table_caption">';
90
			else
91
				echo '
92
				<tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">';
93
94
			// Now do each column.
95
			$column_number = 0;
96
97
			foreach ($row as $data)
98
			{
99
				// If this is a special separator, skip over!
100
				if (!empty($data['separator']) && $column_number == 0)
101
				{
102
					echo '
103
					<td colspan="', $table['column_count'], '" class="smalltext">
104
						', $data['v'], ':
105
					</td>';
106
					break;
107
				}
108
109
				// Shaded?
110
				if ($column_number == 0 && !empty($table['shading']['left']))
111
					echo '
112
					<td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '>
113
						', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), '
114
					</td>';
115
				else
116
					echo '
117
					<td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '>
118
						', $data['v'], '
119
					</td>';
120
121
				$column_number++;
122
			}
123
124
			echo '
125
				</tr>';
126
127
			$row_number++;
128
		}
129
		echo '
130
			</tbody>
131
		</table>';
132
	}
133
}
134
135
/**
136
 * This is the standard template for showing reports.
137
 */
138
function template_main22()
139
{
140
	global $context, $txt;
141
142
	echo '
143
		<div id="report_buttons">';
144
145
	if (!empty($context['report_buttons']))
146
		template_button_strip($context['report_buttons'], 'right');
147
148
	echo '
149
		</div>';
150
151
	// Go through each table!
152
	foreach ($context['table'] as $id => $title)
153
	{
154
		echo '
155
		<table class="table_grid">
156
			<thead>
157
				<tr>
158
					<th class="lefttext" scope="col" colspan="', $context['num_cols'], '">
159
						<div class="cat_bar">
160
							<h3 class="catbg">', $title, '</h3>
161
						</div>
162
					</th>
163
				</tr>
164
				<tr class="title_bar">
165
					<th scope="col">', implode('</th>
166
					<th scope="col">', $context['cols']), '</th>
167
				</tr>
168
			</thead>
169
			<tbody>';
170
171
		// Now do each row!
172
		foreach ($context['rows'][$context['table_pointers'][$id] ?? $id] as $row)
173
		{
174
			echo '
175
				<tr class="smalltext centertext windowbg">';
176
177
			foreach ($context['cols'] as $colId => $col)
178
				echo '
179
					<td>
180
						', $row[$colId] ?? $context['default_value'], '
181
					</td>';
182
183
			echo '
184
				</tr>';
185
		}
186
187
		echo '
188
			</tbody>
189
		</table>';
190
	}
191
}
192
193
/**
194
 * This is the standard template for showing reports.
195
 */
196
function template_main2()
197
{
198
	global $context, $txt;
199
200
	$fp = fopen('php://output', 'W');
201
	fwrite($fp, '
202
		<table class="table_grid">');
203
	foreach ($context['table'] as $id => $title)
204
	{
205
		fwrite($fp, '
206
			<thead>
207
				<tr>
208
					<th class="lefttext" scope="col" colspan="');
209
		fwrite($fp, $context['num_cols']);
210
		fwrite($fp, '">
211
						<div class="cat_bar">
212
							<h3 class="catbg">');
213
		fwrite($fp, $title);
214
		fwrite($fp, '</h3>
215
						</div>
216
					</th>
217
				</tr>
218
				<tr class="title_bar">
219
					<th scope="col">');
220
		fwrite($fp, implode('</th>
221
					<th scope="col">', $context['cols']));
222
		fwrite($fp, '</th>
223
				</tr>
224
			</thead>
225
			<tbody>');
226
227
		foreach ($context['rows'][$context['table_pointers'][$id] ?? $id] as $row)
228
		{
229
			fwrite($fp, '
230
				<tr class="smalltext centertext windowbg">');
231
232
			foreach ($context['cols'] as $colId => $col)
233
			{
234
				fwrite($fp, '
235
					<td>');
236
				fwrite($fp, $row[$colId] ?? $context['default_value']);
237
				fwrite($fp, '
238
					</td>');
239
			}
240
241
			fwrite($fp, '
242
				</tr>');
243
		}
244
245
		fwrite($fp, '
246
			</tbody>');
247
	}
248
	fwrite($fp, '
249
		</table>');
250
	fclose($fp);
251
}
252
253
/**
254
 * Header of the print page!
255
 */
256
function template_print_above()
257
{
258
	global $context, $settings, $modSettings;
259
260
	echo '<!DOCTYPE html>
261
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
262
	<head>
263
		<meta charset="', $context['character_set'], '">
264
		<title>', $context['page_title'], '</title>
265
		<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/report.css', $context['browser_cache'], '">
266
	</head>
267
	<body>';
268
}
269
270
/**
271
 * The main print page
272
 */
273
function template_print()
274
{
275
	global $context;
276
277
	// Go through each table!
278
	foreach ($context['tables'] as $table)
279
	{
280
		echo '
281
		<div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '">
282
			<table class="bordercolor">';
283
284
		if (!empty($table['title']))
285
			echo '
286
				<tr class="title_bar">
287
					<td colspan="', $table['column_count'], '">
288
						', $table['title'], '
289
					</td>
290
				</tr>';
291
292
		// Now do each row!
293
		$row_number = 0;
294
		foreach ($table['data'] as $row)
295
		{
296
			if ($row_number == 0 && !empty($table['shading']['top']))
297
				echo '
298
				<tr class="titlebg">';
299
			else
300
				echo '
301
				<tr class="windowbg">';
302
303
			// Now do each column!!
304
			$column_number = 0;
305
			foreach ($row as $data)
306
			{
307
				// If this is a special separator, skip over!
308
				if (!empty($data['separator']) && $column_number == 0)
309
				{
310
					echo '
311
					<td colspan="', $table['column_count'], '" class="smalltext">
312
						<strong>', $data['v'], ':</strong>
313
					</td>';
314
					break;
315
				}
316
317
				// Shaded?
318
				if ($column_number == 0 && !empty($table['shading']['left']))
319
					echo '
320
					<td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '>
321
						', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), '
322
					</td>';
323
				else
324
					echo '
325
					<td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '>
326
						', $data['v'], '
327
					</td>';
328
329
				$column_number++;
330
			}
331
332
			echo '
333
				</tr>';
334
335
			$row_number++;
336
		}
337
		echo '
338
			</table>
339
		</div>
340
		<br>';
341
	}
342
}
343
344
/**
345
 * Footer of the print page.
346
 */
347
function template_print_below()
348
{
349
	echo '
350
		<div class="copyright">', theme_copyright(), '</div>
0 ignored issues
show
Bug introduced by
Are you sure the usage of theme_copyright() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
351
	</body>
352
</html>';
353
}
354
355
?>