Issues (1014)

Themes/default/Printpage.template.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines https://www.simplemachines.org
7
 * @copyright 2022 Simple Machines and individual contributors
8
 * @license https://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1.0
11
 */
12
13
/**
14
 * The header. Defines the look and layout of the page as well as a form for choosing print options.
15
 */
16
function template_print_above()
17
{
18
	global $context, $txt, $modSettings;
19
20
	echo '<!DOCTYPE html>
21
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
22
	<head>
23
		<meta charset="', $context['character_set'], '">
24
		<meta name="robots" content="noindex">
25
		<link rel="canonical" href="', $context['canonical_url'], '">
26
		<title>', $txt['print_page'], ' - ', $context['topic_subject'], '</title>
27
		<style>
28
			body, a {
29
				color: #000;
30
				background: #fff;
31
			}
32
			body, td, .normaltext {
33
				font-family: Verdana, arial, helvetica, serif;
34
				font-size: small;
35
			}
36
			h1#title {
37
				font-size: large;
38
				font-weight: bold;
39
			}
40
			h2#linktree {
41
				margin: 1em 0 2.5em 0;
42
				font-size: small;
43
				font-weight: bold;
44
			}
45
			dl#posts {
46
				width: 90%;
47
				margin: 0;
48
				padding: 0;
49
				list-style: none;
50
			}
51
			div.postheader, #poll_data {
52
				border: solid #000;
53
				border-width: 1px 0;
54
				padding: 4px 0;
55
			}
56
			div.postbody {
57
				margin: 1em 0 2em 2em;
58
			}
59
			table {
60
				empty-cells: show;
61
			}
62
			blockquote {
63
				margin: 0 0 8px 0;
64
				padding: 6px 10px;
65
				font-size: small;
66
				border: 1px solid #d6dfe2;
67
				border-left: 2px solid #aaa;
68
				border-right: 2px solid #aaa;
69
			}
70
			blockquote cite {
71
				display: block;
72
				border-bottom: 1px solid #aaa;
73
				font-size: 0.9em;
74
			}
75
			blockquote cite:before {
76
				color: #aaa;
77
				font-size: 22px;
78
				font-style: normal;
79
				margin-right: 5px;
80
			}
81
			code {
82
				border: 1px solid #000;
83
				margin: 3px;
84
				padding: 1px;
85
				display: block;
86
			}
87
			code {
88
				font: x-small monospace;
89
			}
90
			.smalltext, .codeheader {
91
				font-size: x-small;
92
			}
93
			.largetext {
94
				font-size: large;
95
			}
96
			.centertext {
97
				text-align: center;
98
			}
99
			hr {
100
				height: 1px;
101
				border: 0;
102
				color: black;
103
				background-color: black;
104
			}
105
			.voted {
106
				font-weight: bold;
107
			}
108
			#footer {
109
				font-family: Verdana, sans-serif;
110
			}
111
			@media print {
112
				.print_options {
113
					display: none;
114
				}
115
			}
116
			@media screen {
117
				.print_options {
118
					margin: 1em 0;
119
				}
120
			}';
121
122
	if (!empty($modSettings['max_image_width']))
123
		echo '
124
			.bbc_img {
125
				max-width: ' . $modSettings['max_image_width'] . 'px;
126
			}';
127
128
	if (!empty($modSettings['max_image_height']))
129
		echo '
130
			.bbc_img {
131
				max-height: ' . $modSettings['max_image_height'] . 'px;
132
			}';
133
134
	echo '
135
		</style>
136
	</head>
137
	<body>';
138
139
	template_print_options();
140
141
	echo '
142
		<h1 id="title">', $context['forum_name_html_safe'], '</h1>
143
		<h2 id="linktree">', $context['category_name'], ' => ', (!empty($context['parent_boards']) ? implode(' => ', $context['parent_boards']) . ' => ' : ''), $context['board_name'], ' => ', $txt['topic_started'], ': ', $context['poster_name'], ' ', $txt['search_on'], ' ', $context['post_time'], '</h2>
144
		<div id="posts">';
145
}
146
147
/**
148
 * The main page. This shows the relevant info in a printer-friendly format
149
 */
150
function template_main()
151
{
152
	global $context, $options, $txt, $scripturl, $topic;
153
154
	if (!empty($context['poll']))
155
	{
156
		echo '
157
			<div id="poll_data">', $txt['poll'], '
158
				<div class="question">', $txt['poll_question'], ': <strong>', $context['poll']['question'], '</strong>';
159
160
		$options = 1;
161
		foreach ($context['poll']['options'] as $option)
162
			echo '
163
					<div class="', $option['voted_this'] ? 'voted' : '', '">', $txt['option'], ' ', $options++, ': <strong>', $option['option'], '</strong>
164
						', $context['allow_poll_view'] ? $txt['votes'] . ': ' . $option['votes'] . '' : '', '
165
					</div>';
166
167
		echo '
168
			</div>';
169
	}
170
171
	foreach ($context['posts'] as $post)
172
	{
173
		echo '
174
			<div class="postheader">
175
				', $txt['title'], ': <strong>', $post['subject'], '</strong><br>
176
				', $txt['post_by'], ': <strong>', $post['member'], '</strong> ', $txt['search_on'], ' <strong>', $post['time'], '</strong>
177
			</div>
178
			<div class="postbody">
179
				', $post['body'];
180
181
		// Show attachment images
182
		if (isset($_GET['images']) && !empty($context['printattach'][$post['id_msg']]))
183
		{
184
			echo '
185
				<hr>';
186
187
			foreach ($context['printattach'][$post['id_msg']] as $attach)
188
				echo '
189
					<img width="' . $attach['width'] . '" height="' . $attach['height'] . '" src="', $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attach['id_attach'] . '" alt="">';
190
		}
191
192
		echo '
193
			</div><!-- .postbody -->';
194
	}
195
}
196
197
/**
198
 * The footer.
199
 */
200
function template_print_below()
201
{
202
	echo '
203
		</div><!-- #posts -->';
204
205
	template_print_options();
206
207
	echo '
208
		<div id="footer" class="smalltext">', theme_copyright(), '</div>
0 ignored issues
show
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...
209
	</body>
210
</html>';
211
}
212
213
/**
214
 * Displays the print page options
215
 */
216
function template_print_options()
217
{
218
	global $scripturl, $topic, $txt;
219
220
	$url_text = $scripturl . '?action=printpage;topic=' . $topic . '.0';
221
	$url_images = $url_text . ';images';
222
223
	echo '
224
		<div class="print_options">';
225
226
	// Which option is set, text or text&images
227
	if (isset($_REQUEST['images']))
228
		echo '
229
			<a href="', $url_text, '">', $txt['print_page_text'], '</a> | <strong><a href="', $url_images, '">', $txt['print_page_images'], '</a></strong>';
230
	else
231
		echo '
232
			<strong><a href="', $url_text, '">', $txt['print_page_text'], '</a></strong> | <a href="', $url_images, '">', $txt['print_page_images'], '</a>';
233
234
	echo '
235
		</div><!-- .print_options -->';
236
}
237
238
?>