Completed
Pull Request — release-2.1 (#5080)
by
unknown
12:56
created
Themes/default/Post.template.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
 										<div class="bar"></div>
402 402
 									</div>
403 403
 									<div class="attach-ui">
404
-										<a data-dz-remove class="button cancel">', $txt['modify_cancel'] ,'</a>
405
-										<a class="button upload">', $txt['upload'] ,'</a>
404
+										<a data-dz-remove class="button cancel">', $txt['modify_cancel'], '</a>
405
+										<a class="button upload">', $txt['upload'], '</a>
406 406
 									</div>
407 407
 								</div><!-- .attach-info -->
408 408
 							</div><!-- #au-template -->
@@ -419,10 +419,10 @@  discard block
 block discarded – undo
419 419
 							</dt>
420 420
 							<dd class="smalltext fallback">
421 421
 								<div id="attachUpload" class="descbox">
422
-									<h5>', $txt['attach_drop_zone'] ,'</h5>
423
-									<a class="button" id="attach-cancelAll">', $txt['attached_cancelAll'] ,'</a>
424
-									<a class="button" id="attach-uploadAll">', $txt['attached_uploadAll'] ,'</a>
425
-									<a class="button fileinput-button">', $txt['attach_add'] ,'</a>
422
+									<h5>', $txt['attach_drop_zone'], '</h5>
423
+									<a class="button" id="attach-cancelAll">', $txt['attached_cancelAll'], '</a>
424
+									<a class="button" id="attach-uploadAll">', $txt['attached_uploadAll'], '</a>
425
+									<a class="button fileinput-button">', $txt['attach_add'], '</a>
426 426
 									<div id="total-progress" class="progress_bar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
427 427
 										<div class="bar"></div>
428 428
 									</div>
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	// Option to delete an event if user is editing one.
533 533
 	if ($context['make_event'] && !$context['event']['new'])
534 534
 		echo '
535
-						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
535
+						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'], '" class="button you_sure">';
536 536
 
537 537
 	echo '
538 538
 					</span>
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 
575 575
 	$newPostsHTML .= '
576 576
 			<br class="clear">
577
-			<div id="msg_%PostID%_ignored_prompt" class="smalltext" style="display: none;">' . $txt['ignoring_user'] .  '<a href="#" id="msg_%PostID%_ignored_link" style="%IgnoredStyle%">' . $txt['show_ignore_user_post'] . '</a></div>
577
+			<div id="msg_%PostID%_ignored_prompt" class="smalltext" style="display: none;">' . $txt['ignoring_user'] . '<a href="#" id="msg_%PostID%_ignored_link" style="%IgnoredStyle%">' . $txt['show_ignore_user_post'] . '</a></div>
578 578
 			<div class="list_posts smalltext" id="msg_%PostID%_body">%PostBody%</div>
579 579
 		</div>';
580 580
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 			});';
661 661
 
662 662
 	echo '
663
-			var oEditorID = "', $context['post_box_name'] ,'";
663
+			var oEditorID = "', $context['post_box_name'], '";
664 664
 			var oEditorObject = oEditorHandle_', $context['post_box_name'], ';
665 665
 		</script>';
666 666
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 			if ($context['can_quote'])
693 693
 				echo '
694 694
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
695
-						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
695
+						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>
696 696
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
697 697
 					</ul>';
698 698
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	<head>
778 778
 		<meta charset="', $context['character_set'], '">
779 779
 		<title>', $txt['spell_check'], '</title>
780
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
780
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
781 781
 		<style>
782 782
 			body, td {
783 783
 				font-size: small;
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 			var spell_formname = window.opener.spell_formname;
808 808
 			var spell_fieldname = window.opener.spell_fieldname;
809 809
 		</script>
810
-		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'] ,'"></script>
811
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
810
+		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'], '"></script>
811
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
812 812
 		<script>
813 813
 			', $context['spell_js'], '
814 814
 		</script>
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 	<head>
853 853
 		<meta charset="', $context['character_set'], '">
854 854
 		<title>', $txt['retrieving_quote'], '</title>
855
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
855
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
856 856
 	</head>
857 857
 	<body>
858 858
 		', $txt['retrieving_quote'], '
Please login to merge, or discard this patch.
Braces   +184 added lines, -131 removed lines patch added patch discarded remove patch
@@ -22,24 +22,26 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32 33
 
33
-	foreach ($context['icons'] as $icon)
34
-		echo '
34
+	foreach ($context['icons'] as $icon) {
35
+			echo '
35 36
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
37
+	}
36 38
 
37 39
 	echo '
38 40
 			};';
39 41
 
40 42
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
41
-	if ($context['make_poll'])
42
-		echo '
43
+	if ($context['make_poll']) {
44
+			echo '
43 45
 			var pollOptionNum = 0, pollTabIndex;
44 46
 			var pollOptionId = ', $context['last_choice_id'], ';
45 47
 			function addPollOption()
@@ -58,11 +60,13 @@  discard block
 block discarded – undo
58 60
 
59 61
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), ');
60 62
 			}';
63
+	}
61 64
 
62 65
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
63
-	if ($context['make_event'])
64
-		echo '
66
+	if ($context['make_event']) {
67
+			echo '
65 68
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
69
+	}
66 70
 
67 71
 	// End of the javascript, start the form and display the link tree.
68 72
 	echo '
@@ -83,9 +87,10 @@  discard block
 block discarded – undo
83 87
 			</div>
84 88
 			<br>';
85 89
 
86
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
87
-		echo '
90
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
91
+			echo '
88 92
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
93
+	}
89 94
 
90 95
 	// Start the main table.
91 96
 	echo '
@@ -110,26 +115,29 @@  discard block
 block discarded – undo
110 115
 					</div>';
111 116
 
112 117
 	// If this won't be approved let them know!
113
-	if (!$context['becomes_approved'])
114
-		echo '
118
+	if (!$context['becomes_approved']) {
119
+			echo '
115 120
 					<div class="noticebox">
116 121
 						<em>', $txt['wait_for_approval'], '</em>
117 122
 						<input type="hidden" name="not_approved" value="1">
118 123
 					</div>';
124
+	}
119 125
 
120 126
 	// If it's locked, show a message to warn the replier.
121
-	if (!empty($context['locked']))
122
-	echo '
127
+	if (!empty($context['locked'])) {
128
+		echo '
123 129
 					<div class="errorbox">
124 130
 						', $txt['topic_locked_no_reply'], '
125 131
 					</div>';
132
+	}
126 133
 
127
-	if (!empty($modSettings['drafts_post_enabled']))
128
-		echo '
134
+	if (!empty($modSettings['drafts_post_enabled'])) {
135
+			echo '
129 136
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
130 137
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
131 138
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
132 139
 					</div>';
140
+	}
133 141
 
134 142
 	// The post header... important stuff
135 143
 	template_post_header();
@@ -162,9 +170,10 @@  discard block
 block discarded – undo
162 170
 				echo '
163 171
 										<optgroup label="', $category['name'], '">';
164 172
 
165
-				foreach ($category['boards'] as $board)
166
-					echo '
173
+				foreach ($category['boards'] as $board) {
174
+									echo '
167 175
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
176
+				}
168 177
 				echo '
169 178
 										</optgroup>';
170 179
 			}
@@ -200,9 +209,10 @@  discard block
 block discarded – undo
200 209
 									<span class="label">', $txt['calendar_timezone'], '</span>
201 210
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
202 211
 
203
-		foreach ($context['all_timezones'] as $tz => $tzname)
204
-			echo '
212
+		foreach ($context['all_timezones'] as $tz => $tzname) {
213
+					echo '
205 214
 										<option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
215
+		}
206 216
 
207 217
 		echo '
208 218
 									</select>
@@ -231,14 +241,15 @@  discard block
 block discarded – undo
231 241
 								</dd>';
232 242
 
233 243
 		// Loop through all the choices and print them out.
234
-		foreach ($context['choices'] as $choice)
235
-			echo '
244
+		foreach ($context['choices'] as $choice) {
245
+					echo '
236 246
 								<dt>
237 247
 									<label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>:
238 248
 								</dt>
239 249
 								<dd>
240 250
 									<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255">
241 251
 								</dd>';
252
+		}
242 253
 
243 254
 		echo '
244 255
 								<p id="pollMoreOptions"></p>
@@ -268,14 +279,15 @@  discard block
 block discarded – undo
268 279
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '>
269 280
 								</dd>';
270 281
 
271
-		if ($context['poll_options']['guest_vote_enabled'])
272
-			echo '
282
+		if ($context['poll_options']['guest_vote_enabled']) {
283
+					echo '
273 284
 								<dt>
274 285
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
275 286
 								</dt>
276 287
 								<dd>
277 288
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '>
278 289
 								</dd>';
290
+		}
279 291
 
280 292
 		echo '
281 293
 								<dt>
@@ -296,8 +308,8 @@  discard block
 block discarded – undo
296 308
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
297 309
 
298 310
 	// If we're editing and displaying edit details, show a box where they can say why
299
-	if (isset($context['editing']) && $modSettings['show_modify'])
300
-		echo '
311
+	if (isset($context['editing']) && $modSettings['show_modify']) {
312
+			echo '
301 313
 					<dl>
302 314
 						<dt class="clear">
303 315
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -306,20 +318,23 @@  discard block
 block discarded – undo
306 318
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80">
307 319
 						</dd>
308 320
 					</dl>';
321
+	}
309 322
 
310 323
 	// If this message has been edited in the past - display when it was.
311
-	if (isset($context['last_modified']))
312
-		echo '
324
+	if (isset($context['last_modified'])) {
325
+			echo '
313 326
 					<div class="padding smalltext">
314 327
 						', $context['last_modified_text'], '
315 328
 					</div>';
329
+	}
316 330
 
317 331
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
318
-	if (!empty($modSettings['additional_options_collapsable']))
319
-		echo '
332
+	if (!empty($modSettings['additional_options_collapsable'])) {
333
+			echo '
320 334
 					<div id="postAdditionalOptionsHeader">
321 335
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
322 336
 					</div>';
337
+	}
323 338
 
324 339
 	echo '
325 340
 					<div id="postAdditionalOptions">';
@@ -352,19 +367,21 @@  discard block
 block discarded – undo
352 367
 								', $txt['uncheck_unwatchd_attach'], ':
353 368
 							</dd>';
354 369
 
355
-		foreach ($context['current_attachments'] as $attachment)
356
-			echo '
370
+		foreach ($context['current_attachments'] as $attachment) {
371
+					echo '
357 372
 							<dd class="smalltext">
358 373
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
359 374
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label>
360 375
 							</dd>';
376
+		}
361 377
 
362 378
 		echo '
363 379
 						</dl>';
364 380
 
365
-		if (!empty($context['files_in_session_warning']))
366
-			echo '
381
+		if (!empty($context['files_in_session_warning'])) {
382
+					echo '
367 383
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
384
+		}
368 385
 	}
369 386
 
370 387
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -429,13 +446,14 @@  discard block
 block discarded – undo
429 446
 									<div class="fallback">
430 447
 										<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
431 448
 
432
-		if (!empty($modSettings['attachmentSizeLimit']))
433
-			echo '
449
+		if (!empty($modSettings['attachmentSizeLimit'])) {
450
+					echo '
434 451
 										<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">';
452
+		}
435 453
 
436 454
 		// Show more boxes if they aren't approaching that limit.
437
-		if ($context['num_allowed_attachments'] > 1)
438
-			echo '
455
+		if ($context['num_allowed_attachments'] > 1) {
456
+					echo '
439 457
 										<script>
440 458
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
441 459
 											var current_attachment = 1;
@@ -455,6 +473,7 @@  discard block
 block discarded – undo
455 473
 										<a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a>
456 474
 									</div><!-- .fallback -->
457 475
 								</div><!-- #attachUpload -->';
476
+		}
458 477
 
459 478
 		echo '
460 479
 							</dd>';
@@ -466,21 +485,25 @@  discard block
 block discarded – undo
466 485
 							<dd class="smalltext">';
467 486
 
468 487
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
469
-		if (!empty($modSettings['attachmentCheckExtensions']))
470
-			echo '
488
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
489
+					echo '
471 490
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
491
+		}
472 492
 
473
-		if (!empty($context['attachment_restrictions']))
474
-			echo '
493
+		if (!empty($context['attachment_restrictions'])) {
494
+					echo '
475 495
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
496
+		}
476 497
 
477
-		if ($context['num_allowed_attachments'] == 0)
478
-			echo '
498
+		if ($context['num_allowed_attachments'] == 0) {
499
+					echo '
479 500
 								', $txt['attach_limit_nag'], '<br>';
501
+		}
480 502
 
481
-		if (!$context['can_post_attachment_unapproved'])
482
-			echo '
503
+		if (!$context['can_post_attachment_unapproved']) {
504
+					echo '
483 505
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
506
+		}
484 507
 
485 508
 		echo '
486 509
 							</dd>
@@ -504,24 +527,26 @@  discard block
 block discarded – undo
504 527
 							<dt><strong>', $txt['subject'], '</strong></dt>
505 528
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
506 529
 
507
-		foreach ($context['drafts'] as $draft)
508
-			echo '
530
+		foreach ($context['drafts'] as $draft) {
531
+					echo '
509 532
 							<dt>', $draft['link'], '</dt>
510 533
 							<dd>', $draft['poster_time'], '</dd>';
534
+		}
511 535
 		echo '
512 536
 						</dl>
513 537
 					</div>';
514 538
 	}
515 539
 
516 540
 	// Is visual verification enabled?
517
-	if ($context['require_verification'])
518
-		echo '
541
+	if ($context['require_verification']) {
542
+			echo '
519 543
 					<div class="post_verification">
520 544
 						<span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
521 545
 							<strong>', $txt['verification'], ':</strong>
522 546
 						</span>
523 547
 						', template_control_verification($context['visual_verification_id'], 'all'), '
524 548
 					</div>';
549
+	}
525 550
 
526 551
 	// Finally, the submit buttons.
527 552
 	echo '
@@ -530,9 +555,10 @@  discard block
 block discarded – undo
530 555
 						', template_control_richedit_buttons($context['post_box_name']);
531 556
 
532 557
 	// Option to delete an event if user is editing one.
533
-	if ($context['make_event'] && !$context['event']['new'])
534
-		echo '
558
+	if ($context['make_event'] && !$context['event']['new']) {
559
+			echo '
535 560
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
561
+	}
536 562
 
537 563
 	echo '
538 564
 					</span>
@@ -541,9 +567,10 @@  discard block
 block discarded – undo
541 567
 			<br class="clear">';
542 568
 
543 569
 	// Assuming this isn't a new topic pass across the last message id.
544
-	if (isset($context['topic_last_message']))
545
-		echo '
570
+	if (isset($context['topic_last_message'])) {
571
+			echo '
546 572
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
573
+	}
547 574
 
548 575
 	echo '
549 576
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -564,13 +591,14 @@  discard block
 block discarded – undo
564 591
 			</h5>
565 592
 			&nbsp;-&nbsp;%PostTime%&nbsp;&#187; <span class="new_posts" id="image_new_%PostID%">' . $txt['new'] . '</span>';
566 593
 
567
-	if ($context['can_quote'])
568
-		$newPostsHTML .= '
594
+	if ($context['can_quote']) {
595
+			$newPostsHTML .= '
569 596
 			<ul class="quickbuttons sf-js-enabled sf-arrows" id="msg_%PostID%_quote" style="touch-action: pan-y;">
570 597
 				<li id="post_modify">
571 598
 					<a href="#postmodify" onclick="return insertQuoteFast(%PostID%);" class="quote_button"><span class="generic_icons quote"></span>' . $txt['quote'] . '</a>
572 599
 				</li>
573 600
 			</ul>';
601
+	}
574 602
 
575 603
 	$newPostsHTML .= '
576 604
 			<br class="clear">
@@ -596,16 +624,17 @@  discard block
 block discarded – undo
596 624
 				sSessionVar: ', JavaScriptEscape($context['session_var']), ',
597 625
 				newPostsTemplate:', JavaScriptEscape($newPostsHTML);
598 626
 
599
-	if (!empty($context['current_board']))
600
-		echo ',
627
+	if (!empty($context['current_board'])) {
628
+			echo ',
601 629
 				iCurrentBoard: ', $context['current_board'], '';
630
+	}
602 631
 
603 632
 	echo '
604 633
 			});';
605 634
 
606 635
 	// Code for showing and hiding additional options.
607
-	if (!empty($modSettings['additional_options_collapsable']))
608
-		echo '
636
+	if (!empty($modSettings['additional_options_collapsable'])) {
637
+			echo '
609 638
 			var oSwapAdditionalOptions = new smc_Toggle({
610 639
 				bToggleEnabled: true,
611 640
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -633,10 +662,11 @@  discard block
 block discarded – undo
633 662
 					}
634 663
 				]
635 664
 			});';
665
+	}
636 666
 
637 667
 	// Code for showing and hiding drafts
638
-	if (!empty($context['drafts']))
639
-		echo '
668
+	if (!empty($context['drafts'])) {
669
+			echo '
640 670
 			var oSwapDraftOptions = new smc_Toggle({
641 671
 				bToggleEnabled: true,
642 672
 				bCurrentlyCollapsed: true,
@@ -658,6 +688,7 @@  discard block
 block discarded – undo
658 688
 					}
659 689
 				]
660 690
 			});';
691
+	}
661 692
 
662 693
 	echo '
663 694
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -678,8 +709,9 @@  discard block
 block discarded – undo
678 709
 		foreach ($context['previous_posts'] as $post)
679 710
 		{
680 711
 			$ignoring = false;
681
-			if (!empty($post['is_ignored']))
682
-				$ignored_posts[] = $ignoring = $post['id'];
712
+			if (!empty($post['is_ignored'])) {
713
+							$ignored_posts[] = $ignoring = $post['id'];
714
+			}
683 715
 
684 716
 			echo '
685 717
 			<div class="windowbg">
@@ -689,22 +721,24 @@  discard block
 block discarded – undo
689 721
 					</h5>
690 722
 					&nbsp;-&nbsp;', $post['time'];
691 723
 
692
-			if ($context['can_quote'])
693
-				echo '
724
+			if ($context['can_quote']) {
725
+							echo '
694 726
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
695 727
 						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
696 728
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
697 729
 					</ul>';
730
+			}
698 731
 
699 732
 			echo '
700 733
 					<br class="clear">';
701 734
 
702
-			if ($ignoring)
703
-				echo '
735
+			if ($ignoring) {
736
+							echo '
704 737
 					<div id="msg_', $post['id'], '_ignored_prompt" class="smalltext">
705 738
 						', $txt['ignoring_user'], '
706 739
 						<a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
707 740
 					</div>';
741
+			}
708 742
 
709 743
 			echo '
710 744
 					<div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div>
@@ -859,10 +893,10 @@  discard block
 block discarded – undo
859 893
 		<div id="temporary_posting_area" style="display: none;"></div>
860 894
 		<script>';
861 895
 
862
-	if ($context['close_window'])
863
-		echo '
896
+	if ($context['close_window']) {
897
+			echo '
864 898
 			window.close();';
865
-	else
899
+	} else
866 900
 	{
867 901
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;)
868 902
 		echo '
@@ -916,11 +950,12 @@  discard block
 block discarded – undo
916 950
 				</p>
917 951
 				<ul>';
918 952
 
919
-	foreach ($context['groups'] as $group)
920
-		echo '
953
+	foreach ($context['groups'] as $group) {
954
+			echo '
921 955
 					<li>
922 956
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
923 957
 					</li>';
958
+	}
924 959
 
925 960
 	echo '
926 961
 					<li>
@@ -1027,28 +1062,32 @@  discard block
 block discarded – undo
1027 1062
 	foreach ($context['posting_fields'] as $pfid => $pf)
1028 1063
 	{
1029 1064
 		// We need both a label and an input
1030
-		if (empty($pf['label']) || empty($pf['input']))
1031
-			continue;
1065
+		if (empty($pf['label']) || empty($pf['input'])) {
1066
+					continue;
1067
+		}
1032 1068
 
1033 1069
 		// The labels are pretty simple...
1034 1070
 		echo '
1035 1071
 						<dt class="clear pf_', $pfid, '">';
1036 1072
 
1037 1073
 		// Any leading HTML before the label
1038
-		if (!empty($pf['label']['before']))
1039
-			echo '
1074
+		if (!empty($pf['label']['before'])) {
1075
+					echo '
1040 1076
 							', $pf['label']['before'];
1077
+		}
1041 1078
 
1042
-		if (!empty($pf['label']['html']))
1043
-			echo $pf['label']['html'];
1044
-		else
1045
-			echo '
1079
+		if (!empty($pf['label']['html'])) {
1080
+					echo $pf['label']['html'];
1081
+		} else {
1082
+					echo '
1046 1083
 							<label for="', !empty($pf['input']['attributes']['name']) ? $pf['input']['attributes']['name'] : $pfid, '" id="caption_', $pfid, '"', !empty($pf['label']['class']) ? ' class="' . $pf['label']['class'] . '"' : '', '>', $pf['label']['text'], '</label>';
1084
+		}
1047 1085
 
1048 1086
 		// Any trailing HTML after the label
1049
-		if (!empty($pf['label']['after']))
1050
-			echo '
1087
+		if (!empty($pf['label']['after'])) {
1088
+					echo '
1051 1089
 							', $pf['label']['after'];
1090
+		}
1052 1091
 
1053 1092
 		echo '
1054 1093
 						</dt>';
@@ -1058,9 +1097,10 @@  discard block
 block discarded – undo
1058 1097
 						<dd class="pf_', $pfid, '">';
1059 1098
 
1060 1099
 		// Any leading HTML before the main input
1061
-		if (!empty($pf['input']['before']))
1062
-			echo '
1100
+		if (!empty($pf['input']['before'])) {
1101
+					echo '
1063 1102
 							', $pf['input']['before'];
1103
+		}
1064 1104
 
1065 1105
 		// If there is a literal HTML string already defined, just print it.
1066 1106
 		if (!empty($pf['input']['html']))
@@ -1073,17 +1113,19 @@  discard block
 block discarded – undo
1073 1113
 			echo '
1074 1114
 							<input type="', $pf['input']['type'], '"';
1075 1115
 
1076
-			if (empty($pf['input']['attributes']['name']))
1077
-				echo ' name="', $pfid, '"';
1116
+			if (empty($pf['input']['attributes']['name'])) {
1117
+							echo ' name="', $pfid, '"';
1118
+			}
1078 1119
 
1079 1120
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1080 1121
 			{
1081 1122
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1082 1123
 				{
1083
-					if (is_bool($value))
1084
-						echo $value ? ' ' . $attribute : '';
1085
-					else
1086
-						echo ' ', $attribute, '="', $value, '"';
1124
+					if (is_bool($value)) {
1125
+											echo $value ? ' ' . $attribute : '';
1126
+					} else {
1127
+											echo ' ', $attribute, '="', $value, '"';
1128
+					}
1087 1129
 				}
1088 1130
 			}
1089 1131
 
@@ -1095,19 +1137,21 @@  discard block
 block discarded – undo
1095 1137
 			echo '
1096 1138
 							<textarea';
1097 1139
 
1098
-			if (empty($pf['input']['attributes']['name']))
1099
-				echo ' name="', $pfid, '"';
1140
+			if (empty($pf['input']['attributes']['name'])) {
1141
+							echo ' name="', $pfid, '"';
1142
+			}
1100 1143
 
1101 1144
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1102 1145
 			{
1103 1146
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1104 1147
 				{
1105
-					if ($attribute === 'value')
1106
-						continue;
1107
-					elseif (is_bool($value))
1108
-						echo $value ? ' ' . $attribute : '';
1109
-					else
1110
-						echo ' ', $attribute, '="', $value, '"';
1148
+					if ($attribute === 'value') {
1149
+											continue;
1150
+					} elseif (is_bool($value)) {
1151
+											echo $value ? ' ' . $attribute : '';
1152
+					} else {
1153
+											echo ' ', $attribute, '="', $value, '"';
1154
+					}
1111 1155
 				}
1112 1156
 			}
1113 1157
 
@@ -1120,17 +1164,19 @@  discard block
 block discarded – undo
1120 1164
 			echo '
1121 1165
 							<select';
1122 1166
 
1123
-			if (empty($pf['input']['attributes']['name']))
1124
-				echo ' name="', $pfid, '"';
1167
+			if (empty($pf['input']['attributes']['name'])) {
1168
+							echo ' name="', $pfid, '"';
1169
+			}
1125 1170
 
1126 1171
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1127 1172
 			{
1128 1173
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1129 1174
 				{
1130
-					if (is_bool($value))
1131
-						echo $value ? ' ' . $attribute : '';
1132
-					else
1133
-						echo ' ', $attribute, '="', $value, '"';
1175
+					if (is_bool($value)) {
1176
+											echo $value ? ' ' . $attribute : '';
1177
+					} else {
1178
+											echo ' ', $attribute, '="', $value, '"';
1179
+					}
1134 1180
 				}
1135 1181
 			}
1136 1182
 
@@ -1145,17 +1191,19 @@  discard block
 block discarded – undo
1145 1191
 					echo '
1146 1192
 								<optgroup';
1147 1193
 
1148
-					if (empty($option['attributes']['label']))
1149
-						echo ' label="', $optlabel, '"';
1194
+					if (empty($option['attributes']['label'])) {
1195
+											echo ' label="', $optlabel, '"';
1196
+					}
1150 1197
 
1151 1198
 					if (!empty($option['attributes']) && is_array($option['attributes']))
1152 1199
 					{
1153 1200
 						foreach ($option['attributes'] as $attribute => $value)
1154 1201
 						{
1155
-							if (is_bool($value))
1156
-								echo $value ? ' ' . $attribute : '';
1157
-							else
1158
-								echo ' ', $attribute, '="', $value, '"';
1202
+							if (is_bool($value)) {
1203
+															echo $value ? ' ' . $attribute : '';
1204
+							} else {
1205
+															echo ' ', $attribute, '="', $value, '"';
1206
+							}
1159 1207
 						}
1160 1208
 					}
1161 1209
 
@@ -1168,10 +1216,11 @@  discard block
 block discarded – undo
1168 1216
 
1169 1217
 						foreach ($grouped_option['attributes'] as $attribute => $value)
1170 1218
 						{
1171
-							if (is_bool($value))
1172
-								echo $value ? ' ' . $attribute : '';
1173
-							else
1174
-								echo ' ', $attribute, '="', $value, '"';
1219
+							if (is_bool($value)) {
1220
+															echo $value ? ' ' . $attribute : '';
1221
+							} else {
1222
+															echo ' ', $attribute, '="', $value, '"';
1223
+							}
1175 1224
 						}
1176 1225
 
1177 1226
 						echo '>', $grouped_optlabel, '</option>';
@@ -1189,10 +1238,11 @@  discard block
 block discarded – undo
1189 1238
 
1190 1239
 					foreach ($option['attributes'] as $attribute => $value)
1191 1240
 					{
1192
-						if (is_bool($value))
1193
-							echo $value ? ' ' . $attribute : '';
1194
-						else
1195
-							echo ' ', $attribute, '="', $value, '"';
1241
+						if (is_bool($value)) {
1242
+													echo $value ? ' ' . $attribute : '';
1243
+						} else {
1244
+													echo ' ', $attribute, '="', $value, '"';
1245
+						}
1196 1246
 					}
1197 1247
 
1198 1248
 					echo '>', $optlabel, '</option>';
@@ -1213,12 +1263,13 @@  discard block
 block discarded – undo
1213 1263
 			{
1214 1264
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1215 1265
 				{
1216
-					if ($attribute === 'name')
1217
-						continue;
1218
-					elseif (is_bool($value))
1219
-						echo $value ? ' ' . $attribute : '';
1220
-					else
1221
-						echo ' ', $attribute, '="', $value, '"';
1266
+					if ($attribute === 'name') {
1267
+											continue;
1268
+					} elseif (is_bool($value)) {
1269
+											echo $value ? ' ' . $attribute : '';
1270
+					} else {
1271
+											echo ' ', $attribute, '="', $value, '"';
1272
+					}
1222 1273
 				}
1223 1274
 			}
1224 1275
 
@@ -1231,10 +1282,11 @@  discard block
 block discarded – undo
1231 1282
 
1232 1283
 				foreach ($option['attributes'] as $attribute => $value)
1233 1284
 				{
1234
-					if (is_bool($value))
1235
-						echo $value ? ' ' . $attribute : '';
1236
-					else
1237
-						echo ' ', $attribute, '="', $value, '"';
1285
+					if (is_bool($value)) {
1286
+											echo $value ? ' ' . $attribute : '';
1287
+					} else {
1288
+											echo ' ', $attribute, '="', $value, '"';
1289
+					}
1238 1290
 				}
1239 1291
 
1240 1292
 				echo ' tabindex="', $context['tabindex']++, '">', $optlabel, '</input>';
@@ -1245,9 +1297,10 @@  discard block
 block discarded – undo
1245 1297
 		}
1246 1298
 
1247 1299
 		// Any trailing HTML after the main input
1248
-		if (!empty($pf['input']['after']))
1249
-			echo '
1300
+		if (!empty($pf['input']['after'])) {
1301
+					echo '
1250 1302
 							', $pf['input']['after'];
1303
+		}
1251 1304
 
1252 1305
 		echo '
1253 1306
 						</dd>';
Please login to merge, or discard this patch.
Sources/Themes.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1744,9 +1744,9 @@
 block discarded – undo
1744 1744
 			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1745
 		
1746 1746
 		// Do not list minified_ files
1747
-		foreach($context['theme_files'] as $key=>$file)
1747
+		foreach ($context['theme_files'] as $key=>$file)
1748 1748
 		{
1749
-			if(strpos($file['filename'], 'minified_') !== FALSE)
1749
+			if (strpos($file['filename'], 'minified_') !== FALSE)
1750 1750
 				unset($context['theme_files'][$key]);
1751 1751
 		}
1752 1752
 
Please login to merge, or discard this patch.
Braces   +348 added lines, -271 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
  * @version 2.1 Beta 4
31 31
  */
32 32
 
33
-if (!defined('SMF'))
33
+if (!defined('SMF')) {
34 34
 	die('No direct access...');
35
+}
35 36
 
36 37
 /**
37 38
  * Subaction handler - manages the action and delegates control to the proper
@@ -103,12 +104,12 @@  discard block
 block discarded – undo
103 104
 	cache_put_data('minimized_css', null);
104 105
 
105 106
 	// Follow the sa or just go to administration.
106
-	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']]))
107
-		call_helper($subActions[$_GET['sa']]);
108
-
109
-	else
110
-		call_helper($subActions['admin']);
111
-}
107
+	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) {
108
+			call_helper($subActions[$_GET['sa']]);
109
+	} else {
110
+			call_helper($subActions['admin']);
111
+	}
112
+	}
112 113
 
113 114
 /**
114 115
  * This function allows administration of themes and their settings,
@@ -130,15 +131,16 @@  discard block
 block discarded – undo
130 131
 		checkSession();
131 132
 		validateToken('admin-tm');
132 133
 
133
-		if (isset($_POST['options']['known_themes']))
134
-			foreach ($_POST['options']['known_themes'] as $key => $id)
134
+		if (isset($_POST['options']['known_themes'])) {
135
+					foreach ($_POST['options']['known_themes'] as $key => $id)
135 136
 				$_POST['options']['known_themes'][$key] = (int) $id;
137
+		} else {
138
+					fatal_lang_error('themes_none_selectable', false);
139
+		}
136 140
 
137
-		else
138
-			fatal_lang_error('themes_none_selectable', false);
139
-
140
-		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes']))
141
-			fatal_lang_error('themes_default_selectable', false);
141
+		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) {
142
+					fatal_lang_error('themes_default_selectable', false);
143
+		}
142 144
 
143 145
 		// Commit the new settings.
144 146
 		updateSettings(array(
@@ -146,8 +148,9 @@  discard block
 block discarded – undo
146 148
 			'theme_guests' => $_POST['options']['theme_guests'],
147 149
 			'knownThemes' => implode(',', $_POST['options']['known_themes']),
148 150
 		));
149
-		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes']))
150
-			updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
151
+		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) {
152
+					updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
153
+		}
151 154
 
152 155
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin');
153 156
 	}
@@ -166,8 +169,9 @@  discard block
 block discarded – undo
166 169
 	// Look for a non existent theme directory. (ie theme87.)
167 170
 	$theme_dir = $boarddir . '/Themes/theme';
168 171
 	$i = 1;
169
-	while (file_exists($theme_dir . $i))
170
-		$i++;
172
+	while (file_exists($theme_dir . $i)) {
173
+			$i++;
174
+	}
171 175
 
172 176
 	$context['new_theme_name'] = 'theme' . $i;
173 177
 
@@ -189,8 +193,9 @@  discard block
 block discarded – undo
189 193
 	loadLanguage('Admin');
190 194
 	isAllowedTo('admin_forum');
191 195
 
192
-	if (isset($_REQUEST['th']))
193
-		return SetThemeSettings();
196
+	if (isset($_REQUEST['th'])) {
197
+			return SetThemeSettings();
198
+	}
194 199
 
195 200
 	if (isset($_POST['save']))
196 201
 	{
@@ -274,12 +279,13 @@  discard block
 block discarded – undo
274 279
 		$context['themes'] = array();
275 280
 		while ($row = $smcFunc['db_fetch_assoc']($request))
276 281
 		{
277
-			if (!isset($context['themes'][$row['id_theme']]))
278
-				$context['themes'][$row['id_theme']] = array(
282
+			if (!isset($context['themes'][$row['id_theme']])) {
283
+							$context['themes'][$row['id_theme']] = array(
279 284
 					'id' => $row['id_theme'],
280 285
 					'num_default_options' => 0,
281 286
 					'num_members' => 0,
282 287
 				);
288
+			}
283 289
 			$context['themes'][$row['id_theme']][$row['variable']] = $row['value'];
284 290
 		}
285 291
 		$smcFunc['db_free_result']($request);
@@ -293,8 +299,9 @@  discard block
 block discarded – undo
293 299
 				'guest_member' => -1,
294 300
 			)
295 301
 		);
296
-		while ($row = $smcFunc['db_fetch_assoc']($request))
297
-			$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
302
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
303
+					$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
304
+		}
298 305
 		$smcFunc['db_free_result']($request);
299 306
 
300 307
 		// Need to make sure we don't do custom fields.
@@ -305,8 +312,9 @@  discard block
 block discarded – undo
305 312
 			)
306 313
 		);
307 314
 		$customFields = array();
308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
309
-			$customFields[] = $row['col_name'];
315
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
316
+					$customFields[] = $row['col_name'];
317
+		}
310 318
 		$smcFunc['db_free_result']($request);
311 319
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
312 320
 
@@ -321,14 +329,16 @@  discard block
 block discarded – undo
321 329
 				'custom_fields' => empty($customFields) ? array() : $customFields,
322 330
 			)
323 331
 		);
324
-		while ($row = $smcFunc['db_fetch_assoc']($request))
325
-			$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
332
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
333
+					$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
334
+		}
326 335
 		$smcFunc['db_free_result']($request);
327 336
 
328 337
 		// There has to be a Settings template!
329
-		foreach ($context['themes'] as $k => $v)
330
-			if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
338
+		foreach ($context['themes'] as $k => $v) {
339
+					if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
331 340
 				unset($context['themes'][$k]);
341
+		}
332 342
 
333 343
 		loadTemplate('Themes');
334 344
 		$context['sub_template'] = 'reset_list';
@@ -343,16 +353,19 @@  discard block
 block discarded – undo
343 353
 		checkSession();
344 354
 		validateToken('admin-sto');
345 355
 
346
-		if (empty($_POST['options']))
347
-			$_POST['options'] = array();
348
-		if (empty($_POST['default_options']))
349
-			$_POST['default_options'] = array();
356
+		if (empty($_POST['options'])) {
357
+					$_POST['options'] = array();
358
+		}
359
+		if (empty($_POST['default_options'])) {
360
+					$_POST['default_options'] = array();
361
+		}
350 362
 
351 363
 		// Set up the sql query.
352 364
 		$setValues = array();
353 365
 
354
-		foreach ($_POST['options'] as $opt => $val)
355
-			$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
366
+		foreach ($_POST['options'] as $opt => $val) {
367
+					$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
368
+		}
356 369
 
357 370
 		$old_settings = array();
358 371
 		foreach ($_POST['default_options'] as $opt => $val)
@@ -366,8 +379,8 @@  discard block
 block discarded – undo
366 379
 		if (!empty($setValues))
367 380
 		{
368 381
 			// Are there options in non-default themes set that should be cleared?
369
-			if (!empty($old_settings))
370
-				$smcFunc['db_query']('', '
382
+			if (!empty($old_settings)) {
383
+							$smcFunc['db_query']('', '
371 384
 					DELETE FROM {db_prefix}themes
372 385
 					WHERE id_theme != {int:default_theme}
373 386
 						AND id_member = {int:guest_member}
@@ -378,6 +391,7 @@  discard block
 block discarded – undo
378 391
 						'old_settings' => $old_settings,
379 392
 					)
380 393
 				);
394
+			}
381 395
 
382 396
 			$smcFunc['db_insert']('replace',
383 397
 				'{db_prefix}themes',
@@ -391,8 +405,7 @@  discard block
 block discarded – undo
391 405
 		cache_put_data('theme_settings-1', null, 90);
392 406
 
393 407
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
394
-	}
395
-	elseif (isset($_POST['submit']) && $_POST['who'] == 1)
408
+	} elseif (isset($_POST['submit']) && $_POST['who'] == 1)
396 409
 	{
397 410
 		checkSession();
398 411
 		validateToken('admin-sto');
@@ -405,9 +418,9 @@  discard block
 block discarded – undo
405 418
 		$old_settings = array();
406 419
 		foreach ($_POST['default_options'] as $opt => $val)
407 420
 		{
408
-			if ($_POST['default_options_master'][$opt] == 0)
409
-				continue;
410
-			elseif ($_POST['default_options_master'][$opt] == 1)
421
+			if ($_POST['default_options_master'][$opt] == 0) {
422
+							continue;
423
+			} elseif ($_POST['default_options_master'][$opt] == 1)
411 424
 			{
412 425
 				// Delete then insert for ease of database compatibility!
413 426
 				$smcFunc['db_query']('substring', '
@@ -433,8 +446,7 @@  discard block
 block discarded – undo
433 446
 				);
434 447
 
435 448
 				$old_settings[] = $opt;
436
-			}
437
-			elseif ($_POST['default_options_master'][$opt] == 2)
449
+			} elseif ($_POST['default_options_master'][$opt] == 2)
438 450
 			{
439 451
 				$smcFunc['db_query']('', '
440 452
 					DELETE FROM {db_prefix}themes
@@ -449,8 +461,8 @@  discard block
 block discarded – undo
449 461
 		}
450 462
 
451 463
 		// Delete options from other themes.
452
-		if (!empty($old_settings))
453
-			$smcFunc['db_query']('', '
464
+		if (!empty($old_settings)) {
465
+					$smcFunc['db_query']('', '
454 466
 				DELETE FROM {db_prefix}themes
455 467
 				WHERE id_theme != {int:default_theme}
456 468
 					AND id_member > {int:no_member}
@@ -461,12 +473,13 @@  discard block
 block discarded – undo
461 473
 					'old_settings' => $old_settings,
462 474
 				)
463 475
 			);
476
+		}
464 477
 
465 478
 		foreach ($_POST['options'] as $opt => $val)
466 479
 		{
467
-			if ($_POST['options_master'][$opt] == 0)
468
-				continue;
469
-			elseif ($_POST['options_master'][$opt] == 1)
480
+			if ($_POST['options_master'][$opt] == 0) {
481
+							continue;
482
+			} elseif ($_POST['options_master'][$opt] == 1)
470 483
 			{
471 484
 				// Delete then insert for ease of database compatibility - again!
472 485
 				$smcFunc['db_query']('substring', '
@@ -491,8 +504,7 @@  discard block
 block discarded – undo
491 504
 						'value' => (is_array($val) ? implode(',', $val) : $val),
492 505
 					)
493 506
 				);
494
-			}
495
-			elseif ($_POST['options_master'][$opt] == 2)
507
+			} elseif ($_POST['options_master'][$opt] == 2)
496 508
 			{
497 509
 				$smcFunc['db_query']('', '
498 510
 					DELETE FROM {db_prefix}themes
@@ -509,8 +521,7 @@  discard block
 block discarded – undo
509 521
 		}
510 522
 
511 523
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
512
-	}
513
-	elseif (!empty($_GET['who']) && $_GET['who'] == 2)
524
+	} elseif (!empty($_GET['who']) && $_GET['who'] == 2)
514 525
 	{
515 526
 		checkSession('get');
516 527
 		validateToken('admin-stor', 'request');
@@ -525,8 +536,9 @@  discard block
 block discarded – undo
525 536
 				)
526 537
 			);
527 538
 			$customFields = array();
528
-			while ($row = $smcFunc['db_fetch_assoc']($request))
529
-				$customFields[] = $row['col_name'];
539
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
540
+							$customFields[] = $row['col_name'];
541
+			}
530 542
 			$smcFunc['db_free_result']($request);
531 543
 		}
532 544
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
@@ -581,13 +593,13 @@  discard block
 block discarded – undo
581 593
 			)
582 594
 		);
583 595
 		$context['theme_options'] = array();
584
-		while ($row = $smcFunc['db_fetch_assoc']($request))
585
-			$context['theme_options'][$row['variable']] = $row['value'];
596
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
597
+					$context['theme_options'][$row['variable']] = $row['value'];
598
+		}
586 599
 		$smcFunc['db_free_result']($request);
587 600
 
588 601
 		$context['theme_options_reset'] = false;
589
-	}
590
-	else
602
+	} else
591 603
 	{
592 604
 		$context['theme_options'] = array();
593 605
 		$context['theme_options_reset'] = true;
@@ -596,8 +608,9 @@  discard block
 block discarded – undo
596 608
 	foreach ($context['options'] as $i => $setting)
597 609
 	{
598 610
 		// Just skip separators
599
-		if (!is_array($setting))
600
-			continue;
611
+		if (!is_array($setting)) {
612
+					continue;
613
+		}
601 614
 
602 615
 		// Is this disabled?
603 616
 		if (isset($setting['enabled']) && $setting['enabled'] === false)
@@ -606,15 +619,17 @@  discard block
 block discarded – undo
606 619
 			continue;
607 620
 		}
608 621
 
609
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
610
-			$context['options'][$i]['type'] = 'checkbox';
611
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
612
-			$context['options'][$i]['type'] = 'number';
613
-		elseif ($setting['type'] == 'string')
614
-			$context['options'][$i]['type'] = 'text';
622
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
623
+					$context['options'][$i]['type'] = 'checkbox';
624
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
625
+					$context['options'][$i]['type'] = 'number';
626
+		} elseif ($setting['type'] == 'string') {
627
+					$context['options'][$i]['type'] = 'text';
628
+		}
615 629
 
616
-		if (isset($setting['options']))
617
-			$context['options'][$i]['type'] = 'list';
630
+		if (isset($setting['options'])) {
631
+					$context['options'][$i]['type'] = 'list';
632
+		}
618 633
 
619 634
 		$context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']];
620 635
 	}
@@ -639,8 +654,9 @@  discard block
 block discarded – undo
639 654
 {
640 655
 	global $txt, $context, $settings, $modSettings, $smcFunc;
641 656
 
642
-	if (empty($_GET['th']) && empty($_GET['id']))
643
-		return ThemeAdmin();
657
+	if (empty($_GET['th']) && empty($_GET['id'])) {
658
+			return ThemeAdmin();
659
+	}
644 660
 
645 661
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
646 662
 
@@ -651,8 +667,9 @@  discard block
 block discarded – undo
651 667
 	isAllowedTo('admin_forum');
652 668
 
653 669
 	// Validate inputs/user.
654
-	if (empty($_GET['th']))
655
-		fatal_lang_error('no_theme', false);
670
+	if (empty($_GET['th'])) {
671
+			fatal_lang_error('no_theme', false);
672
+	}
656 673
 
657 674
 	// Fetch the smiley sets...
658 675
 	$sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
@@ -660,8 +677,9 @@  discard block
 block discarded – undo
660 677
 	$context['smiley_sets'] = array(
661 678
 		'' => $txt['smileys_no_default']
662 679
 	);
663
-	foreach ($sets as $i => $set)
664
-		$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
680
+	foreach ($sets as $i => $set) {
681
+			$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
682
+	}
665 683
 
666 684
 	$old_id = $settings['theme_id'];
667 685
 	$old_settings = $settings;
@@ -686,8 +704,9 @@  discard block
 block discarded – undo
686 704
 	if (file_exists($settings['theme_dir'] . '/index.template.php'))
687 705
 	{
688 706
 		$file_contents = implode('', file($settings['theme_dir'] . '/index.template.php'));
689
-		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches))
690
-				eval('global $settings;' . $matches[0]);
707
+		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) {
708
+						eval('global $settings;' . $matches[0]);
709
+		}
691 710
 	}
692 711
 
693 712
 	// Let mods hook into the theme settings.
@@ -699,37 +718,45 @@  discard block
 block discarded – undo
699 718
 		checkSession();
700 719
 		validateToken('admin-sts');
701 720
 
702
-		if (empty($_POST['options']))
703
-			$_POST['options'] = array();
704
-		if (empty($_POST['default_options']))
705
-			$_POST['default_options'] = array();
721
+		if (empty($_POST['options'])) {
722
+					$_POST['options'] = array();
723
+		}
724
+		if (empty($_POST['default_options'])) {
725
+					$_POST['default_options'] = array();
726
+		}
706 727
 
707 728
 		// Make sure items are cast correctly.
708 729
 		foreach ($context['theme_settings'] as $item)
709 730
 		{
710 731
 			// Disregard this item if this is just a separator.
711
-			if (!is_array($item))
712
-				continue;
732
+			if (!is_array($item)) {
733
+							continue;
734
+			}
713 735
 
714 736
 			foreach (array('options', 'default_options') as $option)
715 737
 			{
716
-				if (!isset($_POST[$option][$item['id']]))
717
-					continue;
738
+				if (!isset($_POST[$option][$item['id']])) {
739
+									continue;
740
+				}
718 741
 				// Checkbox.
719
-				elseif (empty($item['type']))
720
-					$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
742
+				elseif (empty($item['type'])) {
743
+									$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
744
+				}
721 745
 				// Number
722
-				elseif ($item['type'] == 'number')
723
-					$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
746
+				elseif ($item['type'] == 'number') {
747
+									$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
748
+				}
724 749
 			}
725 750
 		}
726 751
 
727 752
 		// Set up the sql query.
728 753
 		$inserts = array();
729
-		foreach ($_POST['options'] as $opt => $val)
730
-			$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
731
-		foreach ($_POST['default_options'] as $opt => $val)
732
-			$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
754
+		foreach ($_POST['options'] as $opt => $val) {
755
+					$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
756
+		}
757
+		foreach ($_POST['default_options'] as $opt => $val) {
758
+					$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
759
+		}
733 760
 		// If we're actually inserting something..
734 761
 		if (!empty($inserts))
735 762
 		{
@@ -755,8 +782,9 @@  discard block
 block discarded – undo
755 782
 
756 783
 	foreach ($settings as $setting => $dummy)
757 784
 	{
758
-		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs')))
759
-			$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
785
+		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
786
+					$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
787
+		}
760 788
 	}
761 789
 
762 790
 	$context['settings'] = $context['theme_settings'];
@@ -765,18 +793,21 @@  discard block
 block discarded – undo
765 793
 	foreach ($context['settings'] as $i => $setting)
766 794
 	{
767 795
 		// Separators are dummies, so leave them alone.
768
-		if (!is_array($setting))
769
-			continue;
796
+		if (!is_array($setting)) {
797
+					continue;
798
+		}
770 799
 
771
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
772
-			$context['settings'][$i]['type'] = 'checkbox';
773
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
774
-			$context['settings'][$i]['type'] = 'number';
775
-		elseif ($setting['type'] == 'string')
776
-			$context['settings'][$i]['type'] = 'text';
800
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
801
+					$context['settings'][$i]['type'] = 'checkbox';
802
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
803
+					$context['settings'][$i]['type'] = 'number';
804
+		} elseif ($setting['type'] == 'string') {
805
+					$context['settings'][$i]['type'] = 'text';
806
+		}
777 807
 
778
-		if (isset($setting['options']))
779
-			$context['settings'][$i]['type'] = 'list';
808
+		if (isset($setting['options'])) {
809
+					$context['settings'][$i]['type'] = 'list';
810
+		}
780 811
 
781 812
 		$context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
782 813
 	}
@@ -829,8 +860,9 @@  discard block
 block discarded – undo
829 860
 	$themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
830 861
 
831 862
 	// You can't delete the default theme!
832
-	if ($themeID == 1)
833
-		fatal_lang_error('no_access', false);
863
+	if ($themeID == 1) {
864
+			fatal_lang_error('no_access', false);
865
+	}
834 866
 
835 867
 	$theme_info = get_single_theme($themeID);
836 868
 
@@ -838,8 +870,9 @@  discard block
 block discarded – undo
838 870
 	remove_theme($themeID);
839 871
 
840 872
 	// And remove all its files and folders too.
841
-	if (!empty($theme_info) && !empty($theme_info['theme_dir']))
842
-		remove_dir($theme_info['theme_dir']);
873
+	if (!empty($theme_info) && !empty($theme_info['theme_dir'])) {
874
+			remove_dir($theme_info['theme_dir']);
875
+	}
843 876
 
844 877
 	// Go back to the list page.
845 878
 	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing');
@@ -864,12 +897,14 @@  discard block
 block discarded – undo
864 897
 	$enableThemes = explode(',', $modSettings['enableThemes']);
865 898
 
866 899
 	// Are we disabling it?
867
-	if (isset($_GET['disabled']))
868
-		$enableThemes = array_diff($enableThemes, array($themeID));
900
+	if (isset($_GET['disabled'])) {
901
+			$enableThemes = array_diff($enableThemes, array($themeID));
902
+	}
869 903
 
870 904
 	// Nope? then enable it!
871
-	else
872
-		$enableThemes[] = (string) $themeID;
905
+	else {
906
+			$enableThemes[] = (string) $themeID;
907
+	}
873 908
 
874 909
 	// Update the setting.
875 910
 	$enableThemes = strtr(implode(',', $enableThemes), array(',,' => ','));
@@ -904,18 +939,21 @@  discard block
 block discarded – undo
904 939
 
905 940
 	$_SESSION['id_theme'] = 0;
906 941
 
907
-	if (isset($_GET['id']))
908
-		$_GET['th'] = $_GET['id'];
942
+	if (isset($_GET['id'])) {
943
+			$_GET['th'] = $_GET['id'];
944
+	}
909 945
 
910 946
 	// Saving a variant cause JS doesn't work - pretend it did ;)
911 947
 	if (isset($_POST['save']))
912 948
 	{
913 949
 		// Which theme?
914
-		foreach ($_POST['save'] as $k => $v)
915
-			$_GET['th'] = (int) $k;
950
+		foreach ($_POST['save'] as $k => $v) {
951
+					$_GET['th'] = (int) $k;
952
+		}
916 953
 
917
-		if (isset($_POST['vrt'][$k]))
918
-			$_GET['vrt'] = $_POST['vrt'][$k];
954
+		if (isset($_POST['vrt'][$k])) {
955
+					$_GET['vrt'] = $_POST['vrt'][$k];
956
+		}
919 957
 	}
920 958
 
921 959
 	// Have we made a decision, or are we just browsing?
@@ -1004,10 +1042,10 @@  discard block
 block discarded – undo
1004 1042
 				);
1005 1043
 				cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90);
1006 1044
 
1007
-				if ($user_info['id'] == $_REQUEST['u'])
1008
-					$_SESSION['id_variant'] = 0;
1009
-			}
1010
-			elseif ($_GET['th'] == 0)
1045
+				if ($user_info['id'] == $_REQUEST['u']) {
1046
+									$_SESSION['id_variant'] = 0;
1047
+				}
1048
+			} elseif ($_GET['th'] == 0)
1011 1049
 			{
1012 1050
 				// Remove any custom variants.
1013 1051
 				$smcFunc['db_query']('', '
@@ -1088,12 +1126,13 @@  discard block
 block discarded – undo
1088 1126
 		);
1089 1127
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1090 1128
 		{
1091
-			if (!isset($context['available_themes'][$row['id_theme']]))
1092
-				$context['available_themes'][$row['id_theme']] = array(
1129
+			if (!isset($context['available_themes'][$row['id_theme']])) {
1130
+							$context['available_themes'][$row['id_theme']] = array(
1093 1131
 					'id' => $row['id_theme'],
1094 1132
 					'selected' => $context['current_theme'] == $row['id_theme'],
1095 1133
 					'num_users' => 0
1096 1134
 				);
1135
+			}
1097 1136
 			$context['available_themes'][$row['id_theme']][$row['variable']] = $row['value'];
1098 1137
 		}
1099 1138
 		$smcFunc['db_free_result']($request);
@@ -1106,9 +1145,9 @@  discard block
 block discarded – undo
1106 1145
 			'num_users' => 0
1107 1146
 		);
1108 1147
 		$guest_theme = 0;
1148
+	} else {
1149
+			$guest_theme = $modSettings['theme_guests'];
1109 1150
 	}
1110
-	else
1111
-		$guest_theme = $modSettings['theme_guests'];
1112 1151
 
1113 1152
 	$request = $smcFunc['db_query']('', '
1114 1153
 		SELECT id_theme, COUNT(*) AS the_count
@@ -1121,15 +1160,17 @@  discard block
 block discarded – undo
1121 1160
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1122 1161
 	{
1123 1162
 		// Figure out which theme it is they are REALLY using.
1124
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes'])))
1125
-			$row['id_theme'] = $guest_theme;
1126
-		elseif (empty($modSettings['theme_allow']))
1127
-			$row['id_theme'] = $guest_theme;
1163
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) {
1164
+					$row['id_theme'] = $guest_theme;
1165
+		} elseif (empty($modSettings['theme_allow'])) {
1166
+					$row['id_theme'] = $guest_theme;
1167
+		}
1128 1168
 
1129
-		if (isset($context['available_themes'][$row['id_theme']]))
1130
-			$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1131
-		else
1132
-			$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1169
+		if (isset($context['available_themes'][$row['id_theme']])) {
1170
+					$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1171
+		} else {
1172
+					$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1173
+		}
1133 1174
 	}
1134 1175
 	$smcFunc['db_free_result']($request);
1135 1176
 
@@ -1148,8 +1189,9 @@  discard block
 block discarded – undo
1148 1189
 				'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
1149 1190
 			)
1150 1191
 		);
1151
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1152
-			$variant_preferences[$row['id_theme']] = $row['value'];
1192
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1193
+					$variant_preferences[$row['id_theme']] = $row['value'];
1194
+		}
1153 1195
 		$smcFunc['db_free_result']($request);
1154 1196
 	}
1155 1197
 
@@ -1160,17 +1202,18 @@  discard block
 block discarded – undo
1160 1202
 	foreach ($context['available_themes'] as $id_theme => $theme_data)
1161 1203
 	{
1162 1204
 		// Don't try to load the forum or board default theme's data... it doesn't have any!
1163
-		if ($id_theme == 0)
1164
-			continue;
1205
+		if ($id_theme == 0) {
1206
+					continue;
1207
+		}
1165 1208
 
1166 1209
 		// The thumbnail needs the correct path.
1167 1210
 		$settings['images_url'] = &$theme_data['images_url'];
1168 1211
 
1169
-		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
1170
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1171
-		elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
1172
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1173
-		else
1212
+		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) {
1213
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1214
+		} elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) {
1215
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1216
+		} else
1174 1217
 		{
1175 1218
 			$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png';
1176 1219
 			$txt['theme_description'] = '';
@@ -1195,15 +1238,17 @@  discard block
 block discarded – undo
1195 1238
 					loadLanguage('Settings');
1196 1239
 
1197 1240
 					$context['available_themes'][$id_theme]['variants'] = array();
1198
-					foreach ($settings['theme_variants'] as $variant)
1199
-						$context['available_themes'][$id_theme]['variants'][$variant] = array(
1241
+					foreach ($settings['theme_variants'] as $variant) {
1242
+											$context['available_themes'][$id_theme]['variants'][$variant] = array(
1200 1243
 							'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant,
1201 1244
 							'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'),
1202 1245
 						);
1246
+					}
1203 1247
 
1204 1248
 					$context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0]));
1205
-					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']))
1206
-						$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1249
+					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) {
1250
+											$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1251
+					}
1207 1252
 
1208 1253
 					$context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'];
1209 1254
 					// Allow themes to override the text.
@@ -1219,8 +1264,9 @@  discard block
 block discarded – undo
1219 1264
 	// As long as we're not doing the default theme...
1220 1265
 	if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
1221 1266
 	{
1222
-		if ($guest_theme != 0)
1223
-			$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1267
+		if ($guest_theme != 0) {
1268
+					$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1269
+		}
1224 1270
 
1225 1271
 		$context['available_themes'][0]['id'] = 0;
1226 1272
 		$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
@@ -1269,14 +1315,16 @@  discard block
 block discarded – undo
1269 1315
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1270 1316
 
1271 1317
 		// Got any info from the specific form?
1272
-		if (!isset($_POST['save_' . $action]))
1273
-			fatal_lang_error('theme_install_no_action', false);
1318
+		if (!isset($_POST['save_' . $action])) {
1319
+					fatal_lang_error('theme_install_no_action', false);
1320
+		}
1274 1321
 
1275 1322
 		validateToken('admin-t-' . $action);
1276 1323
 
1277 1324
 		// Hopefully the themes directory is writable, or we might have a problem.
1278
-		if (!is_writable($themedir))
1279
-			fatal_lang_error('theme_install_write_error', 'critical');
1325
+		if (!is_writable($themedir)) {
1326
+					fatal_lang_error('theme_install_write_error', 'critical');
1327
+		}
1280 1328
 
1281 1329
 		// Call the function and handle the result.
1282 1330
 		$result = $subActions[$action]();
@@ -1291,9 +1339,10 @@  discard block
 block discarded – undo
1291 1339
 	}
1292 1340
 
1293 1341
 	// Nope, show a nice error.
1294
-	else
1295
-		fatal_lang_error('theme_install_no_action', false);
1296
-}
1342
+	else {
1343
+			fatal_lang_error('theme_install_no_action', false);
1344
+	}
1345
+	}
1297 1346
 
1298 1347
 /**
1299 1348
  * Installs a theme from a theme package.
@@ -1309,8 +1358,9 @@  discard block
 block discarded – undo
1309 1358
 	$dirtemp = $themedir . '/temp';
1310 1359
 
1311 1360
 	// Make sure the temp dir doesn't already exist
1312
-	if (file_exists($dirtemp))
1313
-		remove_dir($dirtemp);
1361
+	if (file_exists($dirtemp)) {
1362
+			remove_dir($dirtemp);
1363
+	}
1314 1364
 
1315 1365
 	// Create the temp dir.
1316 1366
 	mkdir($dirtemp, 0777);
@@ -1322,17 +1372,20 @@  discard block
 block discarded – undo
1322 1372
 		smf_chmod($dirtemp, '0755');
1323 1373
 
1324 1374
 		// How about now?
1325
-		if (!is_writable($dirtemp))
1326
-			fatal_lang_error('theme_install_write_error', 'critical');
1375
+		if (!is_writable($dirtemp)) {
1376
+					fatal_lang_error('theme_install_write_error', 'critical');
1377
+		}
1327 1378
 	}
1328 1379
 
1329 1380
 	// This happens when the admin session is gone and the user has to login again.
1330
-	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz']))
1331
-		redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1381
+	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) {
1382
+			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1383
+	}
1332 1384
 
1333 1385
 	// Another error check layer, something went wrong with the upload.
1334
-	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1335
-		fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1386
+	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) {
1387
+			fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1388
+	}
1336 1389
 
1337 1390
 	// Get the theme's name.
1338 1391
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1363,11 +1416,10 @@  discard block
 block discarded – undo
1363 1416
 
1364 1417
 		// return all the info.
1365 1418
 		return $context['to_install'];
1419
+	} else {
1420
+			fatal_lang_error('theme_install_error_title', false);
1421
+	}
1366 1422
 	}
1367
-
1368
-	else
1369
-		fatal_lang_error('theme_install_error_title', false);
1370
-}
1371 1423
 
1372 1424
 /**
1373 1425
  * Makes a copy from the default theme, assigns a name for it and installs it.
@@ -1381,15 +1433,17 @@  discard block
 block discarded – undo
1381 1433
 	global $forum_version;
1382 1434
 
1383 1435
 	// There's gotta be something to work with.
1384
-	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy']))
1385
-		fatal_lang_error('theme_install_error_title', false);
1436
+	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) {
1437
+			fatal_lang_error('theme_install_error_title', false);
1438
+	}
1386 1439
 
1387 1440
 	// Get a cleaner version.
1388 1441
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1389 1442
 
1390 1443
 	// Is there a theme already named like this?
1391
-	if (file_exists($themedir . '/' . $name))
1392
-		fatal_lang_error('theme_install_already_dir', false);
1444
+	if (file_exists($themedir . '/' . $name)) {
1445
+			fatal_lang_error('theme_install_already_dir', false);
1446
+	}
1393 1447
 
1394 1448
 	// This is a brand new theme so set all possible values.
1395 1449
 	$context['to_install'] = array(
@@ -1409,8 +1463,9 @@  discard block
 block discarded – undo
1409 1463
 
1410 1464
 	// Buy some time.
1411 1465
 	@set_time_limit(600);
1412
-	if (function_exists('apache_reset_timeout'))
1413
-		@apache_reset_timeout();
1466
+	if (function_exists('apache_reset_timeout')) {
1467
+			@apache_reset_timeout();
1468
+	}
1414 1469
 
1415 1470
 	// Create subdirectories for css and javascript files.
1416 1471
 	mkdir($context['to_install']['theme_dir'] . '/css', 0777);
@@ -1446,12 +1501,13 @@  discard block
 block discarded – undo
1446 1501
 
1447 1502
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1448 1503
 	{
1449
-		if ($row['variable'] == 'theme_templates')
1450
-			$theme_templates = $row['value'];
1451
-		elseif ($row['variable'] == 'theme_layers')
1452
-			$theme_layers = $row['value'];
1453
-		else
1454
-			continue;
1504
+		if ($row['variable'] == 'theme_templates') {
1505
+					$theme_templates = $row['value'];
1506
+		} elseif ($row['variable'] == 'theme_layers') {
1507
+					$theme_layers = $row['value'];
1508
+		} else {
1509
+					continue;
1510
+		}
1455 1511
 	}
1456 1512
 
1457 1513
 	$smcFunc['db_free_result']($request);
@@ -1510,12 +1566,14 @@  discard block
 block discarded – undo
1510 1566
 	global $themedir, $themeurl, $context;
1511 1567
 
1512 1568
 	// Cannot use the theme dir as a theme dir.
1513
-	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
1514
-		fatal_lang_error('theme_install_invalid_dir', false);
1569
+	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) {
1570
+			fatal_lang_error('theme_install_invalid_dir', false);
1571
+	}
1515 1572
 
1516 1573
 	// Check is there is "something" on the dir.
1517
-	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
1518
-		fatal_lang_error('theme_install_error', false);
1574
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
1575
+			fatal_lang_error('theme_install_error', false);
1576
+	}
1519 1577
 
1520 1578
 	$name = basename($_REQUEST['theme_dir']);
1521 1579
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
@@ -1559,24 +1617,27 @@  discard block
 block discarded – undo
1559 1617
 	}
1560 1618
 
1561 1619
 	// Any special layers?
1562
-	if (isset($settings['catch_action']['layers']))
1563
-		$context['template_layers'] = $settings['catch_action']['layers'];
1620
+	if (isset($settings['catch_action']['layers'])) {
1621
+			$context['template_layers'] = $settings['catch_action']['layers'];
1622
+	}
1564 1623
 
1565 1624
 	// Any function to call?
1566 1625
 	if (isset($settings['catch_action']['function']))
1567 1626
 	{
1568 1627
 		$hook = $settings['catch_action']['function'];
1569 1628
 
1570
-		if (!isset($settings['catch_action']['filename']))
1571
-			$settings['catch_action']['filename'] = '';
1629
+		if (!isset($settings['catch_action']['filename'])) {
1630
+					$settings['catch_action']['filename'] = '';
1631
+		}
1572 1632
 
1573 1633
 		add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false);
1574 1634
 		call_integration_hook('integrate_wrap_action');
1575 1635
 	}
1576 1636
 	// And finally, the main sub template ;).
1577
-	if (isset($settings['catch_action']['sub_template']))
1578
-		$context['sub_template'] = $settings['catch_action']['sub_template'];
1579
-}
1637
+	if (isset($settings['catch_action']['sub_template'])) {
1638
+			$context['sub_template'] = $settings['catch_action']['sub_template'];
1639
+	}
1640
+	}
1580 1641
 
1581 1642
 /**
1582 1643
  * Set an option via javascript.
@@ -1595,12 +1656,14 @@  discard block
 block discarded – undo
1595 1656
 	checkSession('get');
1596 1657
 
1597 1658
 	// This good-for-nothing pixel is being used to keep the session alive.
1598
-	if (empty($_GET['var']) || !isset($_GET['val']))
1599
-		redirectexit($settings['images_url'] . '/blank.png');
1659
+	if (empty($_GET['var']) || !isset($_GET['val'])) {
1660
+			redirectexit($settings['images_url'] . '/blank.png');
1661
+	}
1600 1662
 
1601 1663
 	// Sorry, guests can't go any further than this.
1602
-	if ($user_info['is_guest'] || $user_info['id'] == 0)
1603
-		obExit(false);
1664
+	if ($user_info['is_guest'] || $user_info['id'] == 0) {
1665
+			obExit(false);
1666
+	}
1604 1667
 
1605 1668
 	$reservedVars = array(
1606 1669
 		'actual_theme_url',
@@ -1623,8 +1686,9 @@  discard block
 block discarded – undo
1623 1686
 	);
1624 1687
 
1625 1688
 	// Can't change reserved vars.
1626
-	if (in_array(strtolower($_GET['var']), $reservedVars))
1627
-		redirectexit($settings['images_url'] . '/blank.png');
1689
+	if (in_array(strtolower($_GET['var']), $reservedVars)) {
1690
+			redirectexit($settings['images_url'] . '/blank.png');
1691
+	}
1628 1692
 
1629 1693
 	// Use a specific theme?
1630 1694
 	if (isset($_GET['th']) || isset($_GET['id']))
@@ -1640,8 +1704,9 @@  discard block
 block discarded – undo
1640 1704
 	{
1641 1705
 		$options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array();
1642 1706
 		// New thingy...
1643
-		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5)
1644
-			$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1707
+		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
1708
+					$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1709
+		}
1645 1710
 
1646 1711
 		// Change the value to be something nice,
1647 1712
 		$_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']);
@@ -1671,8 +1736,9 @@  discard block
 block discarded – undo
1671 1736
 	global $context, $scripturl, $boarddir, $smcFunc, $txt;
1672 1737
 
1673 1738
 	// @todo Should this be removed?
1674
-	if (isset($_REQUEST['preview']))
1675
-		die('die() with fire');
1739
+	if (isset($_REQUEST['preview'])) {
1740
+			die('die() with fire');
1741
+	}
1676 1742
 
1677 1743
 	isAllowedTo('admin_forum');
1678 1744
 	loadTemplate('Themes');
@@ -1686,11 +1752,11 @@  discard block
 block discarded – undo
1686 1752
 		foreach ($context['themes'] as $key => $theme)
1687 1753
 		{
1688 1754
 			// There has to be a Settings template!
1689
-			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css'))
1690
-				unset($context['themes'][$key]);
1691
-
1692
-			else
1693
-				$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1755
+			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) {
1756
+							unset($context['themes'][$key]);
1757
+			} else {
1758
+							$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1759
+			}
1694 1760
 		}
1695 1761
 
1696 1762
 		$context['sub_template'] = 'edit_list';
@@ -1705,22 +1771,24 @@  discard block
 block discarded – undo
1705 1771
 	$context['theme_id'] = $currentTheme['id'];
1706 1772
 	$context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']);
1707 1773
 
1708
-	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css'))
1709
-		fatal_lang_error('theme_edit_missing', false);
1774
+	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) {
1775
+			fatal_lang_error('theme_edit_missing', false);
1776
+	}
1710 1777
 
1711 1778
 	if (!isset($_REQUEST['filename']))
1712 1779
 	{
1713 1780
 		if (isset($_GET['directory']))
1714 1781
 		{
1715
-			if (substr($_GET['directory'], 0, 1) == '.')
1716
-				$_GET['directory'] = '';
1717
-			else
1782
+			if (substr($_GET['directory'], 0, 1) == '.') {
1783
+							$_GET['directory'] = '';
1784
+			} else
1718 1785
 			{
1719 1786
 				$_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']);
1720 1787
 
1721 1788
 				$temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']);
1722
-				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1723
-					$_GET['directory'] = '';
1789
+				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1790
+									$_GET['directory'] = '';
1791
+				}
1724 1792
 			}
1725 1793
 		}
1726 1794
 
@@ -1739,44 +1807,47 @@  discard block
 block discarded – undo
1739 1807
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp,
1740 1808
 				'size' => '',
1741 1809
 			));
1810
+		} else {
1811
+					$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1742 1812
 		}
1743
-		else
1744
-			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1813
 		
1746 1814
 		// Do not list minified_ files
1747 1815
 		foreach($context['theme_files'] as $key=>$file)
1748 1816
 		{
1749
-			if(strpos($file['filename'], 'minified_') !== FALSE)
1750
-				unset($context['theme_files'][$key]);
1817
+			if(strpos($file['filename'], 'minified_') !== FALSE) {
1818
+							unset($context['theme_files'][$key]);
1819
+			}
1751 1820
 		}
1752 1821
 
1753 1822
 		$context['sub_template'] = 'edit_browse';
1754 1823
 
1755 1824
 		return;
1756
-	}
1757
-	else
1825
+	} else
1758 1826
 	{
1759
-		if (substr($_REQUEST['filename'], 0, 1) == '.')
1760
-			$_REQUEST['filename'] = '';
1761
-		else
1827
+		if (substr($_REQUEST['filename'], 0, 1) == '.') {
1828
+					$_REQUEST['filename'] = '';
1829
+		} else
1762 1830
 		{
1763 1831
 			$_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']);
1764 1832
 
1765 1833
 			$temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1766
-			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1767
-				$_REQUEST['filename'] = '';
1834
+			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1835
+							$_REQUEST['filename'] = '';
1836
+			}
1768 1837
 		}
1769 1838
 
1770
-		if (empty($_REQUEST['filename']))
1771
-			fatal_lang_error('theme_edit_missing', false);
1839
+		if (empty($_REQUEST['filename'])) {
1840
+					fatal_lang_error('theme_edit_missing', false);
1841
+		}
1772 1842
 	}
1773 1843
 
1774 1844
 	if (isset($_POST['save']))
1775 1845
 	{
1776 1846
 		if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true)
1777 1847
 		{
1778
-			if (is_array($_POST['entire_file']))
1779
-				$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1848
+			if (is_array($_POST['entire_file'])) {
1849
+							$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1850
+			}
1780 1851
 
1781 1852
 			$_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', '   ' => "\t")));
1782 1853
 
@@ -1788,10 +1859,11 @@  discard block
 block discarded – undo
1788 1859
 				fclose($fp);
1789 1860
 
1790 1861
 				$error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php');
1791
-				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0)
1792
-					$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1793
-				else
1794
-					unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1862
+				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) {
1863
+									$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1864
+				} else {
1865
+									unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1866
+				}
1795 1867
 			}
1796 1868
 
1797 1869
 			if (!isset($error_file))
@@ -1812,10 +1884,11 @@  discard block
 block discarded – undo
1812 1884
 			$context['sub_template'] = 'edit_file';
1813 1885
 
1814 1886
 			// Recycle the submitted data.
1815
-			if (is_array($_POST['entire_file']))
1816
-				$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1817
-			else
1818
-				$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1887
+			if (is_array($_POST['entire_file'])) {
1888
+							$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1889
+			} else {
1890
+							$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1891
+			}
1819 1892
 
1820 1893
 			$context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']);
1821 1894
 
@@ -1838,17 +1911,17 @@  discard block
 block discarded – undo
1838 1911
 		$context['sub_template'] = 'edit_style';
1839 1912
 
1840 1913
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => '   ')));
1841
-	}
1842
-	elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1914
+	} elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1843 1915
 	{
1844 1916
 		$context['sub_template'] = 'edit_template';
1845 1917
 
1846
-		if (!isset($error_file))
1847
-			$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1848
-		else
1918
+		if (!isset($error_file)) {
1919
+					$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1920
+		} else
1849 1921
 		{
1850
-			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0)
1851
-				$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1922
+			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) {
1923
+							$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1924
+			}
1852 1925
 			$file_data = file($error_file);
1853 1926
 			unlink($error_file);
1854 1927
 		}
@@ -1862,8 +1935,9 @@  discard block
 block discarded – undo
1862 1935
 				// Try to format the functions a little nicer...
1863 1936
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
1864 1937
 
1865
-				if (empty($context['file_parts'][$j]['lines']))
1866
-					unset($context['file_parts'][$j]);
1938
+				if (empty($context['file_parts'][$j]['lines'])) {
1939
+									unset($context['file_parts'][$j]);
1940
+				}
1867 1941
 				$context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => '');
1868 1942
 			}
1869 1943
 
@@ -1872,8 +1946,7 @@  discard block
 block discarded – undo
1872 1946
 		}
1873 1947
 
1874 1948
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => '   ')));
1875
-	}
1876
-	else
1949
+	} else
1877 1950
 	{
1878 1951
 		$context['sub_template'] = 'edit_file';
1879 1952
 
@@ -1899,8 +1972,9 @@  discard block
 block discarded – undo
1899 1972
 
1900 1973
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
1901 1974
 
1902
-	if (empty($_GET['th']))
1903
-		fatal_lang_error('theme_install_invalid_id');
1975
+	if (empty($_GET['th'])) {
1976
+			fatal_lang_error('theme_install_invalid_id');
1977
+	}
1904 1978
 
1905 1979
 	// Get the theme info.
1906 1980
 	$theme = get_single_theme($_GET['th']);
@@ -1908,25 +1982,24 @@  discard block
 block discarded – undo
1908 1982
 
1909 1983
 	if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0)
1910 1984
 	{
1911
-		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'))
1912
-			$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1913
-
1914
-		else
1915
-			fatal_lang_error('no_access', false);
1985
+		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) {
1986
+					$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1987
+		} else {
1988
+					fatal_lang_error('no_access', false);
1989
+		}
1916 1990
 
1917 1991
 		$fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w');
1918 1992
 		fwrite($fp, file_get_contents($filename));
1919 1993
 		fclose($fp);
1920 1994
 
1921 1995
 		redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy');
1922
-	}
1923
-	elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1996
+	} elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1924 1997
 	{
1925
-		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'))
1926
-			$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1927
-
1928
-		else
1929
-			fatal_lang_error('no_access', false);
1998
+		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) {
1999
+					$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
2000
+		} else {
2001
+					fatal_lang_error('no_access', false);
2002
+		}
1930 2003
 
1931 2004
 		$fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w');
1932 2005
 		fwrite($fp, file_get_contents($filename));
@@ -1941,16 +2014,18 @@  discard block
 block discarded – undo
1941 2014
 	$dir = dir($settings['default_theme_dir']);
1942 2015
 	while ($entry = $dir->read())
1943 2016
 	{
1944
-		if (substr($entry, -13) == '.template.php')
1945
-			$templates[] = substr($entry, 0, -13);
2017
+		if (substr($entry, -13) == '.template.php') {
2018
+					$templates[] = substr($entry, 0, -13);
2019
+		}
1946 2020
 	}
1947 2021
 	$dir->close();
1948 2022
 
1949 2023
 	$dir = dir($settings['default_theme_dir'] . '/languages');
1950 2024
 	while ($entry = $dir->read())
1951 2025
 	{
1952
-		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches))
1953
-			$lang_files[] = $matches[1];
2026
+		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) {
2027
+					$lang_files[] = $matches[1];
2028
+		}
1954 2029
 	}
1955 2030
 	$dir->close();
1956 2031
 
@@ -1958,21 +2033,23 @@  discard block
 block discarded – undo
1958 2033
 	natcasesort($lang_files);
1959 2034
 
1960 2035
 	$context['available_templates'] = array();
1961
-	foreach ($templates as $template)
1962
-		$context['available_templates'][$template] = array(
2036
+	foreach ($templates as $template) {
2037
+			$context['available_templates'][$template] = array(
1963 2038
 			'filename' => $template . '.template.php',
1964 2039
 			'value' => $template,
1965 2040
 			'already_exists' => false,
1966 2041
 			'can_copy' => is_writable($theme['theme_dir']),
1967 2042
 		);
2043
+	}
1968 2044
 	$context['available_language_files'] = array();
1969
-	foreach ($lang_files as $file)
1970
-		$context['available_language_files'][$file] = array(
2045
+	foreach ($lang_files as $file) {
2046
+			$context['available_language_files'][$file] = array(
1971 2047
 			'filename' => $file . '.php',
1972 2048
 			'value' => $file,
1973 2049
 			'already_exists' => false,
1974 2050
 			'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']),
1975 2051
 		);
2052
+	}
1976 2053
 
1977 2054
 	$dir = dir($theme['theme_dir']);
1978 2055
 	while ($entry = $dir->read())
Please login to merge, or discard this patch.
Sources/Subs-Boards.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	if (!empty($boardUpdateParameters['deny_groups']))
661 661
 	{
662 662
 		$insert = array();
663
-		foreach($boardOptions['deny_groups'] as $value)
663
+		foreach ($boardOptions['deny_groups'] as $value)
664 664
 			$insert[] = array($value, $board_id, 1);
665 665
 
666 666
 		$smcFunc['db_query']('', '
@@ -674,14 +674,14 @@  discard block
 block discarded – undo
674 674
 				'{db_prefix}board_permissions_view',
675 675
 				array('id_group' => 'int', 'id_board' => 'int', 'deny' => 'int'),
676 676
 				$insert,
677
-				array('id_group','id_board','deny')
677
+				array('id_group', 'id_board', 'deny')
678 678
 				);
679 679
 	}
680 680
 
681 681
 	if (!empty($boardUpdateParameters['member_groups']))
682 682
 	{
683 683
 		$insert = array();
684
-		foreach($boardOptions['access_groups'] as $value)
684
+		foreach ($boardOptions['access_groups'] as $value)
685 685
 			$insert[] = array($value, $board_id, 0);
686 686
 		$smcFunc['db_query']('', '
687 687
 			DELETE FROM {db_prefix}board_permissions_view
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 				'{db_prefix}board_permissions_view',
695 695
 				array('id_group' => 'int', 'id_board' => 'int', 'deny' => 'int'),
696 696
 				$insert,
697
-				array('id_group','id_board','deny')
697
+				array('id_group', 'id_board', 'deny')
698 698
 				);
699 699
 	}
700 700
 
@@ -901,14 +901,14 @@  discard block
 block discarded – undo
901 901
 
902 902
 	$insert = array();
903 903
 
904
-	foreach(explode(',', $default_memgrps) as $value)
904
+	foreach (explode(',', $default_memgrps) as $value)
905 905
 			$insert[] = array($value, $board_id, 0);
906 906
 
907 907
 	$smcFunc['db_insert']('',
908 908
 		'{db_prefix}board_permissions_view',
909 909
 		array('id_group' => 'int', 'id_board' => 'int', 'deny' => 'int'),
910 910
 		$insert,
911
-		array('id_group','id_board','deny'),
911
+		array('id_group', 'id_board', 'deny'),
912 912
 		1
913 913
 	);
914 914
 
Please login to merge, or discard this patch.
Braces   +256 added lines, -181 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Mark a board or multiple boards read.
@@ -28,14 +29,16 @@  discard block
 block discarded – undo
28 29
 	global $user_info, $modSettings, $smcFunc;
29 30
 
30 31
 	// Force $boards to be an array.
31
-	if (!is_array($boards))
32
-		$boards = array($boards);
33
-	else
34
-		$boards = array_unique($boards);
32
+	if (!is_array($boards)) {
33
+			$boards = array($boards);
34
+	} else {
35
+			$boards = array_unique($boards);
36
+	}
35 37
 
36 38
 	// No boards, nothing to mark as read.
37
-	if (empty($boards))
38
-		return;
39
+	if (empty($boards)) {
40
+			return;
41
+	}
39 42
 
40 43
 	// Allow the user to mark a board as unread.
41 44
 	if ($unread)
@@ -65,8 +68,9 @@  discard block
 block discarded – undo
65 68
 	else
66 69
 	{
67 70
 		$markRead = array();
68
-		foreach ($boards as $board)
69
-			$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board);
71
+		foreach ($boards as $board) {
72
+					$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board);
73
+		}
70 74
 
71 75
 		// Update log_mark_read and log_boards.
72 76
 		$smcFunc['db_insert']('replace',
@@ -99,8 +103,9 @@  discard block
 block discarded – undo
99 103
 	list ($lowest_topic) = $smcFunc['db_fetch_row']($result);
100 104
 	$smcFunc['db_free_result']($result);
101 105
 
102
-	if (empty($lowest_topic))
103
-		return;
106
+	if (empty($lowest_topic)) {
107
+			return;
108
+	}
104 109
 
105 110
 	// @todo SLOW This query seems to eat it sometimes.
106 111
 	$result = $smcFunc['db_query']('', '
@@ -118,12 +123,13 @@  discard block
 block discarded – undo
118 123
 		)
119 124
 	);
120 125
 	$topics = array();
121
-	while ($row = $smcFunc['db_fetch_assoc']($result))
122
-		$topics[] = $row['id_topic'];
126
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
127
+			$topics[] = $row['id_topic'];
128
+	}
123 129
 	$smcFunc['db_free_result']($result);
124 130
 
125
-	if (!empty($topics))
126
-		$smcFunc['db_query']('', '
131
+	if (!empty($topics)) {
132
+			$smcFunc['db_query']('', '
127 133
 			DELETE FROM {db_prefix}log_topics
128 134
 			WHERE id_member = {int:current_member}
129 135
 				AND id_topic IN ({array_int:topic_list})',
@@ -132,7 +138,8 @@  discard block
 block discarded – undo
132 138
 				'topic_list' => $topics,
133 139
 			)
134 140
 		);
135
-}
141
+	}
142
+	}
136 143
 
137 144
 /**
138 145
  * Mark one or more boards as read.
@@ -157,23 +164,26 @@  discard block
 block discarded – undo
157 164
 			)
158 165
 		);
159 166
 		$boards = array();
160
-		while ($row = $smcFunc['db_fetch_assoc']($result))
161
-			$boards[] = $row['id_board'];
167
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
168
+					$boards[] = $row['id_board'];
169
+		}
162 170
 		$smcFunc['db_free_result']($result);
163 171
 
164
-		if (!empty($boards))
165
-			markBoardsRead($boards, isset($_REQUEST['unread']));
172
+		if (!empty($boards)) {
173
+					markBoardsRead($boards, isset($_REQUEST['unread']));
174
+		}
166 175
 
167 176
 		$_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID'];
168
-		if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false)
169
-			redirectexit('action=unread');
177
+		if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) {
178
+					redirectexit('action=unread');
179
+		}
170 180
 
171
-		if (isset($_SESSION['topicseen_cache']))
172
-			$_SESSION['topicseen_cache'] = array();
181
+		if (isset($_SESSION['topicseen_cache'])) {
182
+					$_SESSION['topicseen_cache'] = array();
183
+		}
173 184
 
174 185
 		redirectexit();
175
-	}
176
-	elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies')
186
+	} elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies')
177 187
 	{
178 188
 		// Make sure all the topics are integers!
179 189
 		$topics = array_map('intval', explode('-', $_REQUEST['topics']));
@@ -189,13 +199,15 @@  discard block
 block discarded – undo
189 199
 			)
190 200
 		);
191 201
 		$logged_topics = array();
192
-		while ($row = $smcFunc['db_fetch_assoc']($request))
193
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
202
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
203
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
204
+		}
194 205
 		$smcFunc['db_free_result']($request);
195 206
 
196 207
 		$markRead = array();
197
-		foreach ($topics as $id_topic)
198
-			$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
208
+		foreach ($topics as $id_topic) {
209
+					$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
210
+		}
199 211
 
200 212
 		$smcFunc['db_insert']('replace',
201 213
 			'{db_prefix}log_topics',
@@ -204,8 +216,9 @@  discard block
 block discarded – undo
204 216
 			array('id_member', 'id_topic')
205 217
 		);
206 218
 
207
-		if (isset($_SESSION['topicseen_cache']))
208
-			$_SESSION['topicseen_cache'] = array();
219
+		if (isset($_SESSION['topicseen_cache'])) {
220
+					$_SESSION['topicseen_cache'] = array();
221
+		}
209 222
 
210 223
 		redirectexit('action=unreadreplies');
211 224
 	}
@@ -230,11 +243,13 @@  discard block
 block discarded – undo
230 243
 		if (!empty($_GET['t']))
231 244
 		{
232 245
 			// If they read the whole topic, go back to the beginning.
233
-			if ($_GET['t'] >= $topicinfo['id_last_msg'])
234
-				$earlyMsg = 0;
246
+			if ($_GET['t'] >= $topicinfo['id_last_msg']) {
247
+							$earlyMsg = 0;
248
+			}
235 249
 			// If they want to mark the whole thing read, same.
236
-			elseif ($_GET['t'] <= $topicinfo['id_first_msg'])
237
-				$earlyMsg = 0;
250
+			elseif ($_GET['t'] <= $topicinfo['id_first_msg']) {
251
+							$earlyMsg = 0;
252
+			}
238 253
 			// Otherwise, get the latest message before the named one.
239 254
 			else
240 255
 			{
@@ -255,9 +270,9 @@  discard block
 block discarded – undo
255 270
 			}
256 271
 		}
257 272
 		// Marking read from first page?  That's the whole topic.
258
-		elseif ($_REQUEST['start'] == 0)
259
-			$earlyMsg = 0;
260
-		else
273
+		elseif ($_REQUEST['start'] == 0) {
274
+					$earlyMsg = 0;
275
+		} else
261 276
 		{
262 277
 			$result = $smcFunc['db_query']('', '
263 278
 				SELECT id_msg
@@ -285,8 +300,7 @@  discard block
 block discarded – undo
285 300
 		);
286 301
 
287 302
 		redirectexit('board=' . $board . '.0');
288
-	}
289
-	else
303
+	} else
290 304
 	{
291 305
 		$categories = array();
292 306
 		$boards = array();
@@ -294,17 +308,20 @@  discard block
 block discarded – undo
294 308
 		if (isset($_REQUEST['c']))
295 309
 		{
296 310
 			$_REQUEST['c'] = explode(',', $_REQUEST['c']);
297
-			foreach ($_REQUEST['c'] as $c)
298
-				$categories[] = (int) $c;
311
+			foreach ($_REQUEST['c'] as $c) {
312
+							$categories[] = (int) $c;
313
+			}
299 314
 		}
300 315
 		if (isset($_REQUEST['boards']))
301 316
 		{
302 317
 			$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
303
-			foreach ($_REQUEST['boards'] as $b)
304
-				$boards[] = (int) $b;
318
+			foreach ($_REQUEST['boards'] as $b) {
319
+							$boards[] = (int) $b;
320
+			}
321
+		}
322
+		if (!empty($board)) {
323
+					$boards[] = (int) $board;
305 324
 		}
306
-		if (!empty($board))
307
-			$boards[] = (int) $board;
308 325
 
309 326
 		if (isset($_REQUEST['children']) && !empty($boards))
310 327
 		{
@@ -324,9 +341,10 @@  discard block
 block discarded – undo
324 341
 					'board_list' => $boards,
325 342
 				)
326 343
 			);
327
-			while ($row = $smcFunc['db_fetch_assoc']($request))
328
-				if (in_array($row['id_parent'], $boards))
344
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
345
+							if (in_array($row['id_parent'], $boards))
329 346
 					$boards[] = $row['id_board'];
347
+			}
330 348
 			$smcFunc['db_free_result']($request);
331 349
 		}
332 350
 
@@ -343,8 +361,9 @@  discard block
 block discarded – undo
343 361
 			$clauseParameters['board_list'] = $boards;
344 362
 		}
345 363
 
346
-		if (empty($clauses))
347
-			redirectexit();
364
+		if (empty($clauses)) {
365
+					redirectexit();
366
+		}
348 367
 
349 368
 		$request = $smcFunc['db_query']('', '
350 369
 			SELECT b.id_board
@@ -355,19 +374,22 @@  discard block
 block discarded – undo
355 374
 			))
356 375
 		);
357 376
 		$boards = array();
358
-		while ($row = $smcFunc['db_fetch_assoc']($request))
359
-			$boards[] = $row['id_board'];
377
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
378
+					$boards[] = $row['id_board'];
379
+		}
360 380
 		$smcFunc['db_free_result']($request);
361 381
 
362
-		if (empty($boards))
363
-			redirectexit();
382
+		if (empty($boards)) {
383
+					redirectexit();
384
+		}
364 385
 
365 386
 		markBoardsRead($boards, isset($_REQUEST['unread']));
366 387
 
367 388
 		foreach ($boards as $b)
368 389
 		{
369
-			if (isset($_SESSION['topicseen_cache'][$b]))
370
-				$_SESSION['topicseen_cache'][$b] = array();
390
+			if (isset($_SESSION['topicseen_cache'][$b])) {
391
+							$_SESSION['topicseen_cache'][$b] = array();
392
+			}
371 393
 		}
372 394
 
373 395
 		if (!isset($_REQUEST['unread']))
@@ -385,8 +407,9 @@  discard block
 block discarded – undo
385 407
 			if ($smcFunc['db_num_rows']($result) > 0)
386 408
 			{
387 409
 				$logBoardInserts = array();
388
-				while ($row = $smcFunc['db_fetch_assoc']($result))
389
-					$logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']);
410
+				while ($row = $smcFunc['db_fetch_assoc']($result)) {
411
+									$logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']);
412
+				}
390 413
 
391 414
 				$smcFunc['db_insert']('replace',
392 415
 					'{db_prefix}log_boards',
@@ -397,17 +420,18 @@  discard block
 block discarded – undo
397 420
 			}
398 421
 			$smcFunc['db_free_result']($result);
399 422
 
400
-			if (empty($board))
401
-				redirectexit();
402
-			else
403
-				redirectexit('board=' . $board . '.0');
404
-		}
405
-		else
423
+			if (empty($board)) {
424
+							redirectexit();
425
+			} else {
426
+							redirectexit('board=' . $board . '.0');
427
+			}
428
+		} else
406 429
 		{
407
-			if (empty($board_info['parent']))
408
-				redirectexit();
409
-			else
410
-				redirectexit('board=' . $board_info['parent'] . '.0');
430
+			if (empty($board_info['parent'])) {
431
+							redirectexit();
432
+			} else {
433
+							redirectexit('board=' . $board_info['parent'] . '.0');
434
+			}
411 435
 		}
412 436
 	}
413 437
 }
@@ -432,11 +456,13 @@  discard block
 block discarded – undo
432 456
 			'selected_message' => (int) $messageID,
433 457
 		)
434 458
 	);
435
-	if ($smcFunc['db_num_rows']($result) > 0)
436
-		list ($memberID) = $smcFunc['db_fetch_row']($result);
459
+	if ($smcFunc['db_num_rows']($result) > 0) {
460
+			list ($memberID) = $smcFunc['db_fetch_row']($result);
461
+	}
437 462
 	// The message doesn't even exist.
438
-	else
439
-		$memberID = 0;
463
+	else {
464
+			$memberID = 0;
465
+	}
440 466
 	$smcFunc['db_free_result']($result);
441 467
 
442 468
 	return (int) $memberID;
@@ -457,8 +483,9 @@  discard block
 block discarded – undo
457 483
 	getBoardTree();
458 484
 
459 485
 	// Make sure given boards and categories exist.
460
-	if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']])))
461
-		fatal_lang_error('no_board');
486
+	if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) {
487
+			fatal_lang_error('no_board');
488
+	}
462 489
 
463 490
 	$id = $board_id;
464 491
 	call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions));
@@ -486,8 +513,9 @@  discard block
 block discarded – undo
486 513
 			$child_level = 0;
487 514
 			$id_parent = 0;
488 515
 			$after = 0;
489
-			foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy)
490
-				$after = max($after, $boards[$id_board]['order']);
516
+			foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) {
517
+							$after = max($after, $boards[$id_board]['order']);
518
+			}
491 519
 		}
492 520
 
493 521
 		// Make the board a child of a given board.
@@ -498,17 +526,19 @@  discard block
 block discarded – undo
498 526
 			$id_parent = $boardOptions['target_board'];
499 527
 
500 528
 			// People can be creative, in many ways...
501
-			if (isChildOf($id_parent, $board_id))
502
-				fatal_lang_error('mboards_parent_own_child_error', false);
503
-			elseif ($id_parent == $board_id)
504
-				fatal_lang_error('mboards_board_own_child_error', false);
529
+			if (isChildOf($id_parent, $board_id)) {
530
+							fatal_lang_error('mboards_parent_own_child_error', false);
531
+			} elseif ($id_parent == $board_id) {
532
+							fatal_lang_error('mboards_board_own_child_error', false);
533
+			}
505 534
 
506 535
 			$after = $boards[$boardOptions['target_board']]['order'];
507 536
 
508 537
 			// Check if there are already children and (if so) get the max board order.
509
-			if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child']))
510
-				foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy)
538
+			if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) {
539
+							foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy)
511 540
 					$after = max($after, $boards[$childBoard_id]['order']);
541
+			}
512 542
 		}
513 543
 
514 544
 		// Place a board before or after another board, on the same child level.
@@ -521,8 +551,9 @@  discard block
 block discarded – undo
521 551
 		}
522 552
 
523 553
 		// Oops...?
524
-		else
525
-			trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR);
554
+		else {
555
+					trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR);
556
+		}
526 557
 
527 558
 		// Get a list of children of this board.
528 559
 		$childList = array();
@@ -531,14 +562,16 @@  discard block
 block discarded – undo
531 562
 		// See if there are changes that affect children.
532 563
 		$childUpdates = array();
533 564
 		$levelDiff = $child_level - $boards[$board_id]['level'];
534
-		if ($levelDiff != 0)
535
-			$childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}';
536
-		if ($id_cat != $boards[$board_id]['category'])
537
-			$childUpdates[] = 'id_cat = {int:category}';
565
+		if ($levelDiff != 0) {
566
+					$childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}';
567
+		}
568
+		if ($id_cat != $boards[$board_id]['category']) {
569
+					$childUpdates[] = 'id_cat = {int:category}';
570
+		}
538 571
 
539 572
 		// Fix the children of this board.
540
-		if (!empty($childList) && !empty($childUpdates))
541
-			$smcFunc['db_query']('', '
573
+		if (!empty($childList) && !empty($childUpdates)) {
574
+					$smcFunc['db_query']('', '
542 575
 				UPDATE {db_prefix}boards
543 576
 				SET ' . implode(',
544 577
 					', $childUpdates) . '
@@ -549,6 +582,7 @@  discard block
 block discarded – undo
549 582
 					'level_diff' => $levelDiff,
550 583
 				)
551 584
 			);
585
+		}
552 586
 
553 587
 		// Make some room for this spot.
554 588
 		$smcFunc['db_query']('', '
@@ -644,8 +678,8 @@  discard block
 block discarded – undo
644 678
 	call_integration_hook('integrate_modify_board', array($id, $boardOptions, &$boardUpdates, &$boardUpdateParameters));
645 679
 
646 680
 	// Do the updates (if any).
647
-	if (!empty($boardUpdates))
648
-		$smcFunc['db_query']('', '
681
+	if (!empty($boardUpdates)) {
682
+			$smcFunc['db_query']('', '
649 683
 			UPDATE {db_prefix}boards
650 684
 			SET
651 685
 				' . implode(',
@@ -655,13 +689,15 @@  discard block
 block discarded – undo
655 689
 				'selected_board' => $board_id,
656 690
 			))
657 691
 		);
692
+	}
658 693
 	
659 694
 	// Do permission sync
660 695
 	if (!empty($boardUpdateParameters['deny_groups']))
661 696
 	{
662 697
 		$insert = array();
663
-		foreach($boardOptions['deny_groups'] as $value)
664
-			$insert[] = array($value, $board_id, 1);
698
+		foreach($boardOptions['deny_groups'] as $value) {
699
+					$insert[] = array($value, $board_id, 1);
700
+		}
665 701
 
666 702
 		$smcFunc['db_query']('', '
667 703
 			DELETE FROM {db_prefix}board_permissions_view
@@ -681,8 +717,9 @@  discard block
 block discarded – undo
681 717
 	if (!empty($boardUpdateParameters['member_groups']))
682 718
 	{
683 719
 		$insert = array();
684
-		foreach($boardOptions['access_groups'] as $value)
685
-			$insert[] = array($value, $board_id, 0);
720
+		foreach($boardOptions['access_groups'] as $value) {
721
+					$insert[] = array($value, $board_id, 0);
722
+		}
686 723
 		$smcFunc['db_query']('', '
687 724
 			DELETE FROM {db_prefix}board_permissions_view
688 725
 			WHERE id_board = {int:selected_board} AND deny = 0',
@@ -722,13 +759,15 @@  discard block
 block discarded – undo
722 759
 			{
723 760
 				$moderators[$k] = trim($moderators[$k]);
724 761
 
725
-				if (strlen($moderators[$k]) == 0)
726
-					unset($moderators[$k]);
762
+				if (strlen($moderators[$k]) == 0) {
763
+									unset($moderators[$k]);
764
+				}
727 765
 			}
728 766
 
729 767
 			// Find all the id_member's for the member_name's in the list.
730
-			if (empty($boardOptions['moderators']))
731
-				$boardOptions['moderators'] = array();
768
+			if (empty($boardOptions['moderators'])) {
769
+							$boardOptions['moderators'] = array();
770
+			}
732 771
 			if (!empty($moderators))
733 772
 			{
734 773
 				$request = $smcFunc['db_query']('', '
@@ -741,8 +780,9 @@  discard block
 block discarded – undo
741 780
 						'limit' => count($moderators),
742 781
 					)
743 782
 				);
744
-				while ($row = $smcFunc['db_fetch_assoc']($request))
745
-					$boardOptions['moderators'][] = $row['id_member'];
783
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
784
+									$boardOptions['moderators'][] = $row['id_member'];
785
+				}
746 786
 				$smcFunc['db_free_result']($request);
747 787
 			}
748 788
 		}
@@ -751,8 +791,9 @@  discard block
 block discarded – undo
751 791
 		if (!empty($boardOptions['moderators']))
752 792
 		{
753 793
 			$inserts = array();
754
-			foreach ($boardOptions['moderators'] as $moderator)
755
-				$inserts[] = array($board_id, $moderator);
794
+			foreach ($boardOptions['moderators'] as $moderator) {
795
+							$inserts[] = array($board_id, $moderator);
796
+			}
756 797
 
757 798
 			$smcFunc['db_insert']('insert',
758 799
 				'{db_prefix}moderators',
@@ -782,14 +823,16 @@  discard block
 block discarded – undo
782 823
 			{
783 824
 				$moderator_groups[$k] = trim($moderator_groups[$k]);
784 825
 
785
-				if (strlen($moderator_groups[$k]) == 0)
786
-					unset($moderator_groups[$k]);
826
+				if (strlen($moderator_groups[$k]) == 0) {
827
+									unset($moderator_groups[$k]);
828
+				}
787 829
 			}
788 830
 
789 831
 			/* 	Find all the id_group's for all the group names in the list
790 832
 				But skip any invalid ones (invisible/post groups/Administrator/Moderator) */
791
-			if (empty($boardOptions['moderator_groups']))
792
-				$boardOptions['moderator_groups'] = array();
833
+			if (empty($boardOptions['moderator_groups'])) {
834
+							$boardOptions['moderator_groups'] = array();
835
+			}
793 836
 			if (!empty($moderator_groups))
794 837
 			{
795 838
 				$request = $smcFunc['db_query']('', '
@@ -820,8 +863,9 @@  discard block
 block discarded – undo
820 863
 		if (!empty($boardOptions['moderator_groups']))
821 864
 		{
822 865
 			$inserts = array();
823
-			foreach ($boardOptions['moderator_groups'] as $moderator_group)
824
-				$inserts[] = array($board_id, $moderator_group);
866
+			foreach ($boardOptions['moderator_groups'] as $moderator_group) {
867
+							$inserts[] = array($board_id, $moderator_group);
868
+			}
825 869
 
826 870
 			$smcFunc['db_insert']('insert',
827 871
 				'{db_prefix}moderator_groups',
@@ -835,14 +879,16 @@  discard block
 block discarded – undo
835 879
 		updateSettings(array('settings_updated' => time()));
836 880
 	}
837 881
 
838
-	if (isset($boardOptions['move_to']))
839
-		reorderBoards();
882
+	if (isset($boardOptions['move_to'])) {
883
+			reorderBoards();
884
+	}
840 885
 
841 886
 	clean_cache('data');
842 887
 
843
-	if (empty($boardOptions['dont_log']))
844
-		logAction('edit_board', array('board' => $board_id), 'admin');
845
-}
888
+	if (empty($boardOptions['dont_log'])) {
889
+			logAction('edit_board', array('board' => $board_id), 'admin');
890
+	}
891
+	}
846 892
 
847 893
 /**
848 894
  * Create a new board and set its properties and position.
@@ -858,11 +904,13 @@  discard block
 block discarded – undo
858 904
 	global $boards, $smcFunc;
859 905
 
860 906
 	// Trigger an error if one of the required values is not set.
861
-	if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category']))
862
-		trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR);
907
+	if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) {
908
+			trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR);
909
+	}
863 910
 
864
-	if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board']))
865
-		trigger_error('createBoard(): Target board is not set', E_USER_ERROR);
911
+	if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) {
912
+			trigger_error('createBoard(): Target board is not set', E_USER_ERROR);
913
+	}
866 914
 
867 915
 	// Set every optional value to its default value.
868 916
 	$boardOptions += array(
@@ -901,8 +949,9 @@  discard block
 block discarded – undo
901 949
 
902 950
 	$insert = array();
903 951
 
904
-	foreach(explode(',', $default_memgrps) as $value)
905
-			$insert[] = array($value, $board_id, 0);
952
+	foreach(explode(',', $default_memgrps) as $value) {
953
+				$insert[] = array($value, $board_id, 0);
954
+	}
906 955
 
907 956
 	$smcFunc['db_insert']('',
908 957
 		'{db_prefix}board_permissions_view',
@@ -912,8 +961,9 @@  discard block
 block discarded – undo
912 961
 		1
913 962
 	);
914 963
 
915
-	if (empty($board_id))
916
-		return 0;
964
+	if (empty($board_id)) {
965
+			return 0;
966
+	}
917 967
 
918 968
 	// Change the board according to the given specifications.
919 969
 	modifyBoard($board_id, $boardOptions);
@@ -976,8 +1026,9 @@  discard block
 block discarded – undo
976 1026
 	global $sourcedir, $boards, $smcFunc;
977 1027
 
978 1028
 	// No boards to delete? Return!
979
-	if (empty($boards_to_remove))
980
-		return;
1029
+	if (empty($boards_to_remove)) {
1030
+			return;
1031
+	}
981 1032
 
982 1033
 	getBoardTree();
983 1034
 
@@ -988,12 +1039,14 @@  discard block
 block discarded – undo
988 1039
 	{
989 1040
 		// Get a list of the child boards that will also be removed.
990 1041
 		$child_boards_to_remove = array();
991
-		foreach ($boards_to_remove as $board_to_remove)
992
-			recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']);
1042
+		foreach ($boards_to_remove as $board_to_remove) {
1043
+					recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']);
1044
+		}
993 1045
 
994 1046
 		// Merge the children with their parents.
995
-		if (!empty($child_boards_to_remove))
996
-			$boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove));
1047
+		if (!empty($child_boards_to_remove)) {
1048
+					$boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove));
1049
+		}
997 1050
 	}
998 1051
 	// Move the children to a safe home.
999 1052
 	else
@@ -1001,10 +1054,11 @@  discard block
 block discarded – undo
1001 1054
 		foreach ($boards_to_remove as $id_board)
1002 1055
 		{
1003 1056
 			// @todo Separate category?
1004
-			if ($moveChildrenTo === 0)
1005
-				fixChildren($id_board, 0, 0);
1006
-			else
1007
-				fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo);
1057
+			if ($moveChildrenTo === 0) {
1058
+							fixChildren($id_board, 0, 0);
1059
+			} else {
1060
+							fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo);
1061
+			}
1008 1062
 		}
1009 1063
 	}
1010 1064
 
@@ -1018,8 +1072,9 @@  discard block
 block discarded – undo
1018 1072
 		)
1019 1073
 	);
1020 1074
 	$topics = array();
1021
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1022
-		$topics[] = $row['id_topic'];
1075
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1076
+			$topics[] = $row['id_topic'];
1077
+	}
1023 1078
 	$smcFunc['db_free_result']($request);
1024 1079
 
1025 1080
 	require_once($sourcedir . '/RemoveTopic.php');
@@ -1116,8 +1171,9 @@  discard block
 block discarded – undo
1116 1171
 	clean_cache('data');
1117 1172
 
1118 1173
 	// Let's do some serious logging.
1119
-	foreach ($boards_to_remove as $id_board)
1120
-		logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin');
1174
+	foreach ($boards_to_remove as $id_board) {
1175
+			logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin');
1176
+	}
1121 1177
 
1122 1178
 	reorderBoards();
1123 1179
 }
@@ -1136,8 +1192,8 @@  discard block
 block discarded – undo
1136 1192
 	$board_order = 0;
1137 1193
 	foreach ($cat_tree as $catID => $dummy)
1138 1194
 	{
1139
-		foreach ($boardList[$catID] as $boardID)
1140
-			if ($boards[$boardID]['order'] != ++$board_order)
1195
+		foreach ($boardList[$catID] as $boardID) {
1196
+					if ($boards[$boardID]['order'] != ++$board_order)
1141 1197
 				$smcFunc['db_query']('', '
1142 1198
 					UPDATE {db_prefix}boards
1143 1199
 					SET board_order = {int:new_order}
@@ -1147,6 +1203,7 @@  discard block
 block discarded – undo
1147 1203
 						'selected_board' => $boardID,
1148 1204
 					)
1149 1205
 				);
1206
+		}
1150 1207
 	}
1151 1208
 
1152 1209
 	// Empty the board order cache
@@ -1175,8 +1232,9 @@  discard block
 block discarded – undo
1175 1232
 		)
1176 1233
 	);
1177 1234
 	$children = array();
1178
-	while ($row = $smcFunc['db_fetch_assoc']($result))
1179
-		$children[] = $row['id_board'];
1235
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
1236
+			$children[] = $row['id_board'];
1237
+	}
1180 1238
 	$smcFunc['db_free_result']($result);
1181 1239
 
1182 1240
 	// ...and set it to a new parent and child_level.
@@ -1192,9 +1250,10 @@  discard block
 block discarded – undo
1192 1250
 	);
1193 1251
 
1194 1252
 	// Recursively fix the children of the children.
1195
-	foreach ($children as $child)
1196
-		fixChildren($child, $newLevel + 1, $child);
1197
-}
1253
+	foreach ($children as $child) {
1254
+			fixChildren($child, $newLevel + 1, $child);
1255
+	}
1256
+	}
1198 1257
 
1199 1258
 /**
1200 1259
  * Tries to load up the entire board order and category very very quickly
@@ -1211,8 +1270,9 @@  discard block
 block discarded – undo
1211 1270
 		'boards' => array(),
1212 1271
 	);
1213 1272
 
1214
-	if (!empty($tree_order['boards']))
1215
-		return $tree_order;
1273
+	if (!empty($tree_order['boards'])) {
1274
+			return $tree_order;
1275
+	}
1216 1276
 
1217 1277
 	if (($cached = cache_get_data('board_order', 86400)) !== null)
1218 1278
 	{
@@ -1228,8 +1288,9 @@  discard block
 block discarded – undo
1228 1288
 	);
1229 1289
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1230 1290
 	{
1231
-		if (!in_array($row['id_cat'], $tree_order['cats']))
1232
-			$tree_order['cats'][] = $row['id_cat'];
1291
+		if (!in_array($row['id_cat'], $tree_order['cats'])) {
1292
+					$tree_order['cats'][] = $row['id_cat'];
1293
+		}
1233 1294
 		$tree_order['boards'][] = $row['id_board'];
1234 1295
 	}
1235 1296
 	$smcFunc['db_free_result']($request);
@@ -1249,16 +1310,19 @@  discard block
 block discarded – undo
1249 1310
 	$tree = getTreeOrder();
1250 1311
 
1251 1312
 	$ordered = array();
1252
-	foreach ($tree['boards'] as $board)
1253
-		if (!empty($boards[$board]))
1313
+	foreach ($tree['boards'] as $board) {
1314
+			if (!empty($boards[$board]))
1254 1315
 		{
1255 1316
 			$ordered[$board] = $boards[$board];
1317
+	}
1256 1318
 
1257
-			if (is_array($ordered[$board]) && !empty($ordered[$board]['boards']))
1258
-				sortBoards($ordered[$board]['boards']);
1319
+			if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) {
1320
+							sortBoards($ordered[$board]['boards']);
1321
+			}
1259 1322
 
1260
-			if (is_array($ordered[$board]) && !empty($ordered[$board]['children']))
1261
-				sortBoards($ordered[$board]['children']);
1323
+			if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) {
1324
+							sortBoards($ordered[$board]['children']);
1325
+			}
1262 1326
 		}
1263 1327
 
1264 1328
 	$boards = $ordered;
@@ -1274,12 +1338,14 @@  discard block
 block discarded – undo
1274 1338
 	$tree = getTreeOrder();
1275 1339
 
1276 1340
 	$ordered = array();
1277
-	foreach ($tree['cats'] as $cat)
1278
-		if (!empty($categories[$cat]))
1341
+	foreach ($tree['cats'] as $cat) {
1342
+			if (!empty($categories[$cat]))
1279 1343
 		{
1280 1344
 			$ordered[$cat] = $categories[$cat];
1281
-			if (!empty($ordered[$cat]['boards']))
1282
-				sortBoards($ordered[$cat]['boards']);
1345
+	}
1346
+			if (!empty($ordered[$cat]['boards'])) {
1347
+							sortBoards($ordered[$cat]['boards']);
1348
+			}
1283 1349
 		}
1284 1350
 
1285 1351
 	$categories = $ordered;
@@ -1295,8 +1361,9 @@  discard block
 block discarded – undo
1295 1361
 {
1296 1362
 	global $smcFunc, $scripturl, $txt;
1297 1363
 
1298
-	if (empty($boards))
1299
-		return array();
1364
+	if (empty($boards)) {
1365
+			return array();
1366
+	}
1300 1367
 
1301 1368
 	$request = $smcFunc['db_query']('', '
1302 1369
 		SELECT mem.id_member, mem.real_name, mo.id_board
@@ -1310,8 +1377,9 @@  discard block
 block discarded – undo
1310 1377
 	$moderators = array();
1311 1378
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1312 1379
 	{
1313
-		if (empty($moderators[$row['id_board']]))
1314
-			$moderators[$row['id_board']] = array();
1380
+		if (empty($moderators[$row['id_board']])) {
1381
+					$moderators[$row['id_board']] = array();
1382
+		}
1315 1383
 
1316 1384
 		$moderators[$row['id_board']][] = array(
1317 1385
 			'id' => $row['id_member'],
@@ -1335,8 +1403,9 @@  discard block
 block discarded – undo
1335 1403
 {
1336 1404
 	global $smcFunc, $scripturl, $txt;
1337 1405
 
1338
-	if (empty($boards))
1339
-		return array();
1406
+	if (empty($boards)) {
1407
+			return array();
1408
+	}
1340 1409
 
1341 1410
 	$request = $smcFunc['db_query']('', '
1342 1411
 		SELECT mg.id_group, mg.group_name, bg.id_board
@@ -1350,8 +1419,9 @@  discard block
 block discarded – undo
1350 1419
 	$groups = array();
1351 1420
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1352 1421
 	{
1353
-		if (empty($groups[$row['id_board']]))
1354
-			$groups[$row['id_board']] = array();
1422
+		if (empty($groups[$row['id_board']])) {
1423
+					$groups[$row['id_board']] = array();
1424
+		}
1355 1425
 
1356 1426
 		$groups[$row['id_board']][] = array(
1357 1427
 			'id' => $row['id_group'],
@@ -1426,8 +1496,9 @@  discard block
 block discarded – undo
1426 1496
 
1427 1497
 		if (!empty($row['id_board']))
1428 1498
 		{
1429
-			if ($row['child_level'] != $curLevel)
1430
-				$prevBoard = 0;
1499
+			if ($row['child_level'] != $curLevel) {
1500
+							$prevBoard = 0;
1501
+			}
1431 1502
 
1432 1503
 			$boards[$row['id_board']] = array(
1433 1504
 				'id' => $row['id_board'],
@@ -1459,16 +1530,16 @@  discard block
 block discarded – undo
1459 1530
 					'children' => array()
1460 1531
 				);
1461 1532
 				$boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']];
1462
-			}
1463
-			else
1533
+			} else
1464 1534
 			{
1465 1535
 				// Parent doesn't exist!
1466
-				if (!isset($boards[$row['id_parent']]['tree']))
1467
-					fatal_lang_error('no_valid_parent', false, array($row['board_name']));
1536
+				if (!isset($boards[$row['id_parent']]['tree'])) {
1537
+									fatal_lang_error('no_valid_parent', false, array($row['board_name']));
1538
+				}
1468 1539
 
1469 1540
 				// Wrong childlevel...we can silently fix this...
1470
-				if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1)
1471
-					$smcFunc['db_query']('', '
1541
+				if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) {
1542
+									$smcFunc['db_query']('', '
1472 1543
 						UPDATE {db_prefix}boards
1473 1544
 						SET child_level = {int:new_child_level}
1474 1545
 						WHERE id_board = {int:selected_board}',
@@ -1477,6 +1548,7 @@  discard block
 block discarded – undo
1477 1548
 							'selected_board' => $row['id_board'],
1478 1549
 						)
1479 1550
 					);
1551
+				}
1480 1552
 
1481 1553
 				$boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array(
1482 1554
 					'node' => &$boards[$row['id_board']],
@@ -1510,8 +1582,9 @@  discard block
 block discarded – undo
1510 1582
  */
1511 1583
 function recursiveBoards(&$_boardList, &$_tree)
1512 1584
 {
1513
-	if (empty($_tree['children']))
1514
-		return;
1585
+	if (empty($_tree['children'])) {
1586
+			return;
1587
+	}
1515 1588
 
1516 1589
 	foreach ($_tree['children'] as $id => $node)
1517 1590
 	{
@@ -1530,11 +1603,13 @@  discard block
 block discarded – undo
1530 1603
 {
1531 1604
 	global $boards;
1532 1605
 
1533
-	if (empty($boards[$child]['parent']))
1534
-		return false;
1606
+	if (empty($boards[$child]['parent'])) {
1607
+			return false;
1608
+	}
1535 1609
 
1536
-	if ($boards[$child]['parent'] == $parent)
1537
-		return true;
1610
+	if ($boards[$child]['parent'] == $parent) {
1611
+			return true;
1612
+	}
1538 1613
 
1539 1614
 	return isChildOf($boards[$child]['parent'], $parent);
1540 1615
 }
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Braces   +54 added lines, -39 removed lines patch added patch discarded remove patch
@@ -83,16 +83,18 @@  discard block
 block discarded – undo
83 83
 		foreach ($section['areas'] as $i => $area)
84 84
 		{
85 85
 			// Not supposed to be printed?
86
-			if (empty($area['label']))
87
-				continue;
86
+			if (empty($area['label'])) {
87
+							continue;
88
+			}
88 89
 
89 90
 			echo '
90 91
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>
91 92
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>';
92 93
 
93 94
 			// Is this the current area, or just some area?
94
-			if (!empty($area['selected']) && empty($context['tabs']))
95
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
95
+			if (!empty($area['selected']) && empty($context['tabs'])) {
96
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
97
+			}
96 98
 
97 99
 			// Are there any subsections?
98 100
 			if (!empty($area['subsections']))
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 
103 105
 				foreach ($area['subsections'] as $sa => $sub)
104 106
 				{
105
-					if (!empty($sub['disabled']))
106
-						continue;
107
+					if (!empty($sub['disabled'])) {
108
+											continue;
109
+					}
107 110
 
108 111
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
109 112
 
@@ -150,8 +153,9 @@  discard block
 block discarded – undo
150 153
 							<h3 class="catbg">';
151 154
 
152 155
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
153
-		if (function_exists('template_admin_quick_search'))
154
-			template_admin_quick_search();
156
+		if (function_exists('template_admin_quick_search')) {
157
+					template_admin_quick_search();
158
+		}
155 159
 
156 160
 		// Exactly how many tabs do we have?
157 161
 		if (!empty($context['tabs']))
@@ -166,30 +170,36 @@  discard block
 block discarded – undo
166 170
 				}
167 171
 
168 172
 				// Did this not even exist - or do we not have a label?
169
-				if (!isset($tab_context['tabs'][$id]))
170
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
171
-				elseif (!isset($tab_context['tabs'][$id]['label']))
172
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
173
+				if (!isset($tab_context['tabs'][$id])) {
174
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
175
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
176
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
177
+				}
173 178
 
174 179
 				// Has a custom URL defined in the main admin structure?
175
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
176
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
180
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
181
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
182
+				}
177 183
 
178 184
 				// Any additional paramaters for the url?
179
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
180
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
185
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
186
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
187
+				}
181 188
 
182 189
 				// Has it been deemed selected?
183
-				if (!empty($tab['is_selected']))
184
-					$tab_context['tabs'][$id]['is_selected'] = true;
190
+				if (!empty($tab['is_selected'])) {
191
+									$tab_context['tabs'][$id]['is_selected'] = true;
192
+				}
185 193
 
186 194
 				// Does it have its own help?
187
-				if (!empty($tab['help']))
188
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
195
+				if (!empty($tab['help'])) {
196
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
197
+				}
189 198
 
190 199
 				// Is this the last one?
191
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
192
-					$tab_context['tabs'][$id]['is_last'] = true;
200
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
201
+									$tab_context['tabs'][$id]['is_last'] = true;
202
+				}
193 203
 			}
194 204
 
195 205
 			// Find the selected tab
@@ -206,22 +216,24 @@  discard block
 block discarded – undo
206 216
 		// Show an icon and/or a help item?
207 217
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
208 218
 		{
209
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
210
-				echo '
219
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
220
+							echo '
211 221
 								<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
212
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
213
-				echo '
222
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
223
+							echo '
214 224
 								<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
225
+			}
215 226
 
216
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
217
-				echo '
227
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
228
+							echo '
218 229
 								<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
230
+			}
219 231
 
220 232
 			echo $tab_context['title'];
221
-		}
222
-		else
223
-			echo '
233
+		} else {
234
+					echo '
224 235
 								', $tab_context['title'];
236
+		}
225 237
 
226 238
 		echo '
227 239
 							</h3>', (function_exists('template_admin_quick_search') ? '
@@ -230,11 +242,12 @@  discard block
 block discarded – undo
230 242
 	}
231 243
 
232 244
 	// Shall we use the tabs? Yes, it's the only known way!
233
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
234
-		echo '
245
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
246
+			echo '
235 247
 					<p class="information">
236 248
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
237 249
 					</p>';
250
+	}
238 251
 
239 252
 	// Print out all the items in this tab (if any).
240 253
 	if (!empty($context['tabs']))
@@ -246,19 +259,21 @@  discard block
 block discarded – undo
246 259
 
247 260
 		foreach ($tab_context['tabs'] as $sa => $tab)
248 261
 		{
249
-			if (!empty($tab['disabled']))
250
-				continue;
262
+			if (!empty($tab['disabled'])) {
263
+							continue;
264
+			}
251 265
 
252
-			if (!empty($tab['is_selected']))
253
-				echo '
266
+			if (!empty($tab['is_selected'])) {
267
+							echo '
254 268
 							<li>
255 269
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
256 270
 							</li>';
257
-			else
258
-				echo '
271
+			} else {
272
+							echo '
259 273
 							<li>
260 274
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
261 275
 							</li>';
276
+			}
262 277
 		}
263 278
 
264 279
 		// The end of tabs
Please login to merge, or discard this patch.
Themes/default/ReportToMod.template.php 1 patch
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,16 +62,17 @@
 block discarded – undo
62 62
 				<div id="error_box" class="errorbox">
63 63
 					<ul id="error_list">';
64 64
 
65
-		foreach ($context['post_errors'] as $key => $error)
66
-			echo '
65
+		foreach ($context['post_errors'] as $key => $error) {
66
+					echo '
67 67
 						<li id="error_', $key, '" class="error">', $error, '</li>';
68
+		}
68 69
 
69 70
 		echo '
70 71
 					</ul>';
71
-	}
72
-	else
73
-		echo '
72
+	} else {
73
+			echo '
74 74
 				<div id="error_box" class="errorbox hidden">';
75
+	}
75 76
 
76 77
 	echo '
77 78
 				</div>';
Please login to merge, or discard this patch.
Themes/default/ManageMembergroups.template.php 1 patch
Braces   +104 added lines, -74 removed lines patch added patch discarded remove patch
@@ -54,9 +54,10 @@  discard block
 block discarded – undo
54 54
 							<legend>', $txt['membergroups_edit_select_group_type'], '</legend>
55 55
 							<label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0" checked onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>';
56 56
 
57
-		if ($context['allow_protected'])
58
-			echo '
57
+		if ($context['allow_protected']) {
58
+					echo '
59 59
 							<label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>';
60
+		}
60 61
 
61 62
 		echo '
62 63
 							<label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br>
@@ -66,14 +67,15 @@  discard block
 block discarded – undo
66 67
 					</dd>';
67 68
 	}
68 69
 
69
-	if ($context['post_group'] || $context['undefined_group'])
70
-		echo '
70
+	if ($context['post_group'] || $context['undefined_group']) {
71
+			echo '
71 72
 					<dt id="min_posts_text">
72 73
 						<strong>', $txt['membergroups_min_posts'], ':</strong>
73 74
 					</dt>
74 75
 					<dd>
75 76
 						<input type="number" name="min_posts" id="min_posts_input" size="5">
76 77
 					</dd>';
78
+	}
77 79
 
78 80
 	if (!$context['post_group'] || !empty($modSettings['permission_enable_postgroups']))
79 81
 	{
@@ -91,9 +93,10 @@  discard block
 block discarded – undo
91 93
 								<option value="-1">', $txt['membergroups_guests'], '</option>
92 94
 								<option value="0" selected>', $txt['membergroups_members'], '</option>';
93 95
 
94
-		foreach ($context['groups'] as $group)
95
-			echo '
96
+		foreach ($context['groups'] as $group) {
97
+					echo '
96 98
 								<option value="', $group['id'], '">', $group['name'], '</option>';
99
+		}
97 100
 
98 101
 		echo '
99 102
 							</select>
@@ -104,9 +107,10 @@  discard block
 block discarded – undo
104 107
 								<option value="-1">', $txt['membergroups_guests'], '</option>
105 108
 								<option value="0" selected>', $txt['membergroups_members'], '</option>';
106 109
 
107
-		foreach ($context['groups'] as $group)
108
-			echo '
110
+		foreach ($context['groups'] as $group) {
111
+					echo '
109 112
 								<option value="', $group['id'], '">', $group['name'], '</option>';
113
+		}
110 114
 
111 115
 		echo '
112 116
 							</select>
@@ -138,8 +142,8 @@  discard block
 block discarded – undo
138 142
 				<input type="submit" value="', $txt['membergroups_add_group'], '" class="button">
139 143
 			</div><!-- .windowbg -->';
140 144
 
141
-	if ($context['undefined_group'])
142
-		echo '
145
+	if ($context['undefined_group']) {
146
+			echo '
143 147
 			<script>
144 148
 				function swapPostGroup(isChecked)
145 149
 				{
@@ -149,6 +153,7 @@  discard block
 block discarded – undo
149 153
 				}
150 154
 				swapPostGroup(', $context['post_group'] ? 'true' : 'false', ');
151 155
 			</script>';
156
+	}
152 157
 
153 158
 	echo '
154 159
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -178,14 +183,15 @@  discard block
 block discarded – undo
178 183
 						<input type="text" name="group_name" id="group_name_input" value="', $context['group']['editable_name'], '" size="30">
179 184
 					</dd>';
180 185
 
181
-	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
182
-		echo '
186
+	if ($context['group']['id'] != 3 && $context['group']['id'] != 4) {
187
+			echo '
183 188
 					<dt id="group_desc_text">
184 189
 						<label for="group_desc_input"><strong>', $txt['membergroups_edit_desc'], ':</strong></label>
185 190
 					</dt>
186 191
 					<dd>
187 192
 						<textarea name="group_desc" id="group_desc_input" rows="4" cols="40">', $context['group']['description'], '</textarea>
188 193
 					</dd>';
194
+	}
189 195
 
190 196
 	// Group type...
191 197
 	if ($context['group']['allow_post_group'])
@@ -199,9 +205,10 @@  discard block
 block discarded – undo
199 205
 							<legend>', $txt['membergroups_edit_select_group_type'], '</legend>
200 206
 							<label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0"', !$context['group']['is_post_group'] && $context['group']['type'] == 0 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>';
201 207
 
202
-		if ($context['group']['allow_protected'])
203
-			echo '
208
+		if ($context['group']['allow_protected']) {
209
+					echo '
204 210
 							<label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1"', $context['group']['type'] == 1 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>';
211
+		}
205 212
 
206 213
 		echo '
207 214
 							<label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2"', $context['group']['type'] == 2 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br>
@@ -211,8 +218,8 @@  discard block
 block discarded – undo
211 218
 					</dd>';
212 219
 	}
213 220
 
214
-	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
215
-		echo '
221
+	if ($context['group']['id'] != 3 && $context['group']['id'] != 4) {
222
+			echo '
216 223
 					<dt id="group_moderators_text">
217 224
 						<label for="group_moderators"><strong>', $txt['moderators'], ':</strong></label>
218 225
 					</dt>
@@ -230,6 +237,7 @@  discard block
 block discarded – undo
230 237
 							<option value="2"', $context['group']['hidden'] == 2 ? ' selected' : '', '>', $txt['membergroups_edit_hidden_all'], '</option>
231 238
 						</select>
232 239
 					</dd>';
240
+	}
233 241
 
234 242
 	// Can they inherit permissions?
235 243
 	if ($context['group']['id'] > 1 && $context['group']['id'] != 3)
@@ -246,9 +254,10 @@  discard block
 block discarded – undo
246 254
 							<option value="0"', $context['group']['inherited_from'] == 0 ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_members'], '</option>';
247 255
 
248 256
 		// For all the inheritable groups show an option.
249
-		foreach ($context['inheritable_groups'] as $id => $group)
250
-			echo '
257
+		foreach ($context['inheritable_groups'] as $id => $group) {
258
+					echo '
251 259
 							<option value="', $id, '"', $context['group']['inherited_from'] == $id ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $group, '</option>';
260
+		}
252 261
 
253 262
 		echo '
254 263
 						</select>
@@ -256,8 +265,8 @@  discard block
 block discarded – undo
256 265
 					</dd>';
257 266
 	}
258 267
 
259
-	if ($context['group']['allow_post_group'])
260
-		echo '
268
+	if ($context['group']['allow_post_group']) {
269
+			echo '
261 270
 
262 271
 					<dt id="min_posts_text">
263 272
 						<label for="min_posts_input"><strong>', $txt['membergroups_min_posts'], ':</strong></label>
@@ -265,6 +274,7 @@  discard block
 block discarded – undo
265 274
 					<dd>
266 275
 						<input type="number" name="min_posts" id="min_posts_input"', $context['group']['is_post_group'] ? ' value="' . $context['group']['min_posts'] . '"' : '', ' size="6">
267 276
 					</dd>';
277
+	}
268 278
 
269 279
 	echo '
270 280
 					<dt>
@@ -294,9 +304,10 @@  discard block
 block discarded – undo
294 304
 						<select name="icon_image" id="icon_image_input">';
295 305
 
296 306
 		// For every possible icon, create an option.
297
-		foreach ($context['possible_icons'] as $icon)
298
-			echo '
307
+		foreach ($context['possible_icons'] as $icon) {
308
+					echo '
299 309
 							<option value="', $icon, '"', $context['group']['icon_image'] == $icon ? ' selected' : '', '>', $icon, '</option>';
310
+		}
300 311
 
301 312
 		echo '
302 313
 						</select>
@@ -305,9 +316,10 @@  discard block
 block discarded – undo
305 316
 	}
306 317
 
307 318
 	// No? Hide the entire control.
308
-	else
309
-		echo '
319
+	else {
320
+			echo '
310 321
 					<input type="hidden" name="icon_image" value="">';
322
+	}
311 323
 
312 324
 	echo '
313 325
 					<dt>
@@ -319,8 +331,8 @@  discard block
 block discarded – undo
319 331
 					</dd>';
320 332
 
321 333
 	// Force 2FA for this membergroup?
322
-	if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2)
323
-		echo '
334
+	if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2) {
335
+			echo '
324 336
 					<dt>
325 337
 						<label for="group_tfa_force_input"><strong>', $txt['membergroups_tfa_force'], ':</strong></label><br>
326 338
 						<span class="smalltext">', $txt['membergroups_tfa_force_note'], '</span>
@@ -328,6 +340,7 @@  discard block
 block discarded – undo
328 340
 					<dd>
329 341
 						<input type="checkbox" name="group_tfa_force"', $context['group']['tfa_required'] ? ' checked' : '', '>
330 342
 					</dd>';
343
+	}
331 344
 
332 345
 	if (!empty($context['categories']))
333 346
 	{
@@ -338,11 +351,11 @@  discard block
 block discarded – undo
338 351
 					</dt>
339 352
 					<dd>';
340 353
 
341
-		if (!empty($context['can_manage_boards']))
342
-			echo $txt['membergroups_can_manage_access'];
343
-
344
-		else
345
-			template_add_edit_group_boards_list();
354
+		if (!empty($context['can_manage_boards'])) {
355
+					echo $txt['membergroups_can_manage_access'];
356
+		} else {
357
+					template_add_edit_group_boards_list();
358
+		}
346 359
 
347 360
 		echo '
348 361
 					</dd>';
@@ -371,20 +384,21 @@  discard block
 block discarded – undo
371 384
 			sItemListContainerId: \'moderator_container\',
372 385
 			aListItems: [';
373 386
 
374
-	foreach ($context['group']['moderators'] as $id_member => $member_name)
375
-		echo '
387
+	foreach ($context['group']['moderators'] as $id_member => $member_name) {
388
+			echo '
376 389
 				{
377 390
 					sItemId: ', JavaScriptEscape($id_member), ',
378 391
 					sItemName: ', JavaScriptEscape($member_name), '
379 392
 				}', $id_member == $context['group']['last_moderator_id'] ? '' : ',';
393
+	}
380 394
 
381 395
 	echo '
382 396
 			]
383 397
 		});
384 398
 	</script>';
385 399
 
386
-	if ($context['group']['allow_post_group'])
387
-		echo '
400
+	if ($context['group']['allow_post_group']) {
401
+			echo '
388 402
 	<script>
389 403
 		function swapPostGroup(isChecked)
390 404
 		{
@@ -432,7 +446,8 @@  discard block
 block discarded – undo
432 446
 
433 447
 		swapPostGroup(', $context['group']['is_post_group'] ? 'true' : 'false', ');
434 448
 	</script>';
435
-}
449
+	}
450
+	}
436 451
 
437 452
 /**
438 453
  * The template for determining which boards a group has access to.
@@ -450,13 +465,13 @@  discard block
 block discarded – undo
450 465
 
451 466
 	foreach ($context['categories'] as $category)
452 467
 	{
453
-		if (empty($modSettings['deny_boards_access']))
454
-			echo '
468
+		if (empty($modSettings['deny_boards_access'])) {
469
+					echo '
455 470
 									<li class="category">
456 471
 										<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'new_group\'); return false;"><strong>', $category['name'], '</strong></a>
457 472
 										<ul>';
458
-		else
459
-			echo '
473
+		} else {
474
+					echo '
460 475
 									<li class="category">
461 476
 										<strong>', $category['name'], '</strong>
462 477
 										<span class="select_all_box">
@@ -469,16 +484,17 @@  discard block
 block discarded – undo
469 484
 											</select>
470 485
 										</span>
471 486
 										<ul id="boards_list_', $category['id'], '">';
487
+		}
472 488
 
473 489
 		foreach ($category['boards'] as $board)
474 490
 		{
475
-			if (empty($modSettings['deny_boards_access']))
476
-				echo '
491
+			if (empty($modSettings['deny_boards_access'])) {
492
+							echo '
477 493
 											<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
478 494
 												<input type="checkbox" name="boardaccess[', $board['id'], ']" id="brd', $board['id'], '" value="allow"', $board['allow'] ? ' checked' : '', '> <label for="brd', $board['id'], '">', $board['name'], '</label>
479 495
 											</li>';
480
-			else
481
-				echo '
496
+			} else {
497
+							echo '
482 498
 											<li class="board" style="width:100%">
483 499
 												<span style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">', $board['name'], ': </span>
484 500
 												<span style="width:50%;float:right">
@@ -487,6 +503,7 @@  discard block
 block discarded – undo
487 503
 													<input type="radio" name="boardaccess[', $board['id'], ']" id="deny_brd', $board['id'], '" value="deny"', $board['deny'] ? ' checked' : '', '> <label for="deny_brd', $board['id'], '">', $txt['permissions_option_deny'], '</label>
488 504
 												</span>
489 505
 											</li>';
506
+			}
490 507
 		}
491 508
 
492 509
 		echo '
@@ -497,14 +514,14 @@  discard block
 block discarded – undo
497 514
 	echo '
498 515
 								</ul>';
499 516
 
500
-	if (empty($modSettings['deny_boards_access']))
501
-		echo '
517
+	if (empty($modSettings['deny_boards_access'])) {
518
+			echo '
502 519
 								<br class="clear"><br>
503 520
 								<input type="checkbox" id="checkall_check" onclick="invertAll(this, this.form, \'boardaccess\');">
504 521
 								<label for="checkall_check"><em>', $txt['check_all'], '</em></label>
505 522
 							</fieldset>';
506
-	else
507
-		echo '
523
+	} else {
524
+			echo '
508 525
 								<br class="clear">
509 526
 								<span class="select_all_box">
510 527
 									<em>', $txt['all'], ': </em>
@@ -520,15 +537,17 @@  discard block
 block discarded – undo
520 537
 									});
521 538
 								});
522 539
 							</script>';
540
+	}
523 541
 
524
-	if ($collapse)
525
-		echo '
542
+	if ($collapse) {
543
+			echo '
526 544
 							<a href="javascript:void(0);" onclick="document.getElementById(\'visible_boards\').classList.remove(\'hidden\'); document.getElementById(\'visible_boards_link\').classList.add(\'hidden\'); return false;" id="visible_boards_link" class="hidden">[ ', $txt['membergroups_select_visible_boards'], ' ]</a>
527 545
 							<script>
528 546
 								document.getElementById("visible_boards_link").classList.remove(\'hidden\');
529 547
 								document.getElementById("visible_boards").classList.add(\'hidden\');
530 548
 							</script>';
531
-}
549
+	}
550
+	}
532 551
 
533 552
 /**
534 553
  * Templatine for viewing the members of a group.
@@ -552,14 +571,15 @@  discard block
 block discarded – undo
552 571
 					</dd>';
553 572
 
554 573
 	// Any description to show?
555
-	if (!empty($context['group']['description']))
556
-		echo '
574
+	if (!empty($context['group']['description'])) {
575
+			echo '
557 576
 					<dt>
558 577
 						<strong>' . $txt['membergroups_members_description'] . ':</strong>
559 578
 					</dt>
560 579
 					<dd>
561 580
 						', $context['group']['description'], '
562 581
 					</dd>';
582
+	}
563 583
 
564 584
 	echo '
565 585
 					<dt>
@@ -573,8 +593,9 @@  discard block
 block discarded – undo
573 593
 	if (!empty($context['group']['moderators']))
574 594
 	{
575 595
 		$moderators = array();
576
-		foreach ($context['group']['moderators'] as $moderator)
577
-			$moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>';
596
+		foreach ($context['group']['moderators'] as $moderator) {
597
+					$moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>';
598
+		}
578 599
 
579 600
 		echo '
580 601
 					<dt>
@@ -599,9 +620,10 @@  discard block
 block discarded – undo
599 620
 					<tr class="title_bar">
600 621
 						<th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['name'], $context['sort_by'] == 'name' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>';
601 622
 
602
-	if ($context['can_send_email'])
603
-		echo '
623
+	if ($context['can_send_email']) {
624
+			echo '
604 625
 						<th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=email', $context['sort_by'] == 'email' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['email'], $context['sort_by'] == 'email' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>';
626
+	}
605 627
 
606 628
 	echo '
607 629
 						<th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=active', $context['sort_by'] == 'active' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['membergroups_members_last_active'], $context['sort_by'] == 'active' ? '<span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>
@@ -610,20 +632,22 @@  discard block
 block discarded – undo
610 632
 							<a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=posts', $context['sort_by'] == 'posts' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['posts'], $context['sort_by'] == 'posts' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
611 633
 						</th>';
612 634
 
613
-	if (!empty($context['group']['assignable']))
614
-		echo '
635
+	if (!empty($context['group']['assignable'])) {
636
+			echo '
615 637
 						<th style="width: 4%"><input type="checkbox" onclick="invertAll(this, this.form);"></th>';
638
+	}
616 639
 
617 640
 	echo '
618 641
 					</tr>
619 642
 				</thead>
620 643
 				<tbody>';
621 644
 
622
-	if (empty($context['members']))
623
-		echo '
645
+	if (empty($context['members'])) {
646
+			echo '
624 647
 					<tr class="windowbg">
625 648
 						<td colspan="6">', $txt['membergroups_members_no_members'], '</td>
626 649
 					</tr>';
650
+	}
627 651
 
628 652
 	foreach ($context['members'] as $member)
629 653
 	{
@@ -631,20 +655,22 @@  discard block
 block discarded – undo
631 655
 					<tr class="windowbg">
632 656
 						<td>', $member['name'], '</td>';
633 657
 
634
-		if ($context['can_send_email'])
635
-			echo '
658
+		if ($context['can_send_email']) {
659
+					echo '
636 660
 						<td>
637 661
 								<a href="mailto:', $member['email'], '">', $member['email'], '</a>
638 662
 						</td>';
663
+		}
639 664
 
640 665
 		echo '
641 666
 						<td>', $member['last_online'], '</td>
642 667
 						<td>', $member['registered'], '</td>
643 668
 						<td', empty($context['group']['assignable']) ? ' colspan="2"' : '', '>', $member['posts'], '</td>';
644 669
 
645
-		if (!empty($context['group']['assignable']))
646
-			echo '
670
+		if (!empty($context['group']['assignable'])) {
671
+					echo '
647 672
 						<td style="width: 4%"><input type="checkbox" name="rem[]" value="', $member['id'], '" ', ($context['user']['id'] == $member['id'] && $context['group']['id'] == 1 ? 'onclick="if (this.checked) return confirm(\'' . $txt['membergroups_members_deadmin_confirm'] . '\')" ' : ''), '/></td>';
673
+		}
648 674
 
649 675
 		echo '
650 676
 					</tr>';
@@ -654,11 +680,12 @@  discard block
 block discarded – undo
654 680
 				</tbody>
655 681
 			</table>';
656 682
 
657
-	if (!empty($context['group']['assignable']))
658
-		echo '
683
+	if (!empty($context['group']['assignable'])) {
684
+			echo '
659 685
 			<div class="floatright">
660 686
 				<input type="submit" name="remove" value="', $txt['membergroups_members_remove'], '" class="button ">
661 687
 			</div>';
688
+	}
662 689
 
663 690
 	echo '
664 691
 			<div class="pagesection flow_hidden">
@@ -666,8 +693,8 @@  discard block
 block discarded – undo
666 693
 			</div>
667 694
 			<br>';
668 695
 
669
-	if (!empty($context['group']['assignable']))
670
-		echo '
696
+	if (!empty($context['group']['assignable'])) {
697
+			echo '
671 698
 			<div class="cat_bar">
672 699
 				<h3 class="catbg">', $txt['membergroups_members_add_title'], '</h3>
673 700
 			</div>
@@ -683,14 +710,15 @@  discard block
 block discarded – undo
683 710
 				</dl>
684 711
 				<input type="submit" name="add" value="', $txt['membergroups_members_add'], '" class="button">
685 712
 			</div>';
713
+	}
686 714
 
687 715
 	echo '
688 716
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
689 717
 			<input type="hidden" name="', $context['mod-mgm_token_var'], '" value="', $context['mod-mgm_token'], '">
690 718
 		</form>';
691 719
 
692
-	if (!empty($context['group']['assignable']))
693
-		echo '
720
+	if (!empty($context['group']['assignable'])) {
721
+			echo '
694 722
 	<script>
695 723
 		var oAddMemberSuggest = new smc_AutoSuggest({
696 724
 			sSelf: \'oAddMemberSuggest\',
@@ -706,7 +734,8 @@  discard block
 block discarded – undo
706 734
 			sItemListContainerId: \'toAddItemContainer\'
707 735
 		});
708 736
 	</script>';
709
-}
737
+	}
738
+	}
710 739
 
711 740
 /**
712 741
  * Allow the moderator to enter a reason to each user being rejected.
@@ -726,8 +755,8 @@  discard block
 block discarded – undo
726 755
 				<dl class="settings">';
727 756
 
728 757
 	// Loop through and print out a reason box for each...
729
-	foreach ($context['group_requests'] as $request)
730
-		echo '
758
+	foreach ($context['group_requests'] as $request) {
759
+			echo '
731 760
 					<dt>
732 761
 						<strong>', sprintf($txt['mc_groupr_reason_desc'], $request['member_link'], $request['group_link']), ':</strong>
733 762
 					</dt>
@@ -735,6 +764,7 @@  discard block
 block discarded – undo
735 764
 						<input type="hidden" name="groupr[]" value="', $request['id'], '">
736 765
 						<textarea name="groupreason[', $request['id'], ']" rows="3" cols="40"></textarea>
737 766
 					</dd>';
767
+	}
738 768
 
739 769
 	echo '
740 770
 				</dl>
Please login to merge, or discard this patch.
Themes/default/ManageBoards.template.php 1 patch
Braces   +99 added lines, -68 removed lines patch added patch discarded remove patch
@@ -25,18 +25,20 @@  discard block
 block discarded – undo
25 25
 		</div>
26 26
 		<div class="windowbg">';
27 27
 
28
-	if (!empty($context['move_board']))
29
-		echo '
28
+	if (!empty($context['move_board'])) {
29
+			echo '
30 30
 			<div class="noticebox">
31 31
 				', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', '
32 32
 			</div>';
33
+	}
33 34
 
34 35
 	// No categories so show a label.
35
-	if (empty($context['categories']))
36
-		echo '
36
+	if (empty($context['categories'])) {
37
+			echo '
37 38
 			<div class="windowbg centertext">
38 39
 				', $txt['mboards_no_cats'], '
39 40
 			</div>';
41
+	}
40 42
 
41 43
 	// Loop through every category, listing the boards in each as we go.
42 44
 	foreach ($context['categories'] as $category)
@@ -54,9 +56,10 @@  discard block
 block discarded – undo
54 56
 			<form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '">
55 57
 				<ul id="category_', $category['id'], '" class="nolist">';
56 58
 
57
-		if (!empty($category['move_link']))
58
-			echo '
59
+		if (!empty($category['move_link'])) {
60
+					echo '
59 61
 					<li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>';
62
+		}
60 63
 
61 64
 		$recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>';
62 65
 		$redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">';
@@ -79,9 +82,10 @@  discard block
 block discarded – undo
79 82
 				echo '
80 83
 					<li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">';
81 84
 
82
-				foreach ($board['move_links'] as $link)
83
-					echo '
85
+				foreach ($board['move_links'] as $link) {
86
+									echo '
84 87
 						<a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>';
88
+				}
85 89
 
86 90
 				echo '
87 91
 					</li>';
@@ -130,9 +134,10 @@  discard block
 block discarded – undo
130 134
 						<select name="cat_order">';
131 135
 
132 136
 		// Print every existing category into a select box.
133
-		foreach ($context['category_order'] as $order)
134
-			echo '
137
+		foreach ($context['category_order'] as $order) {
138
+					echo '
135 139
 							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
140
+		}
136 141
 		echo '
137 142
 						</select>
138 143
 					</dd>';
@@ -167,14 +172,15 @@  discard block
 block discarded – undo
167 172
 	{
168 173
 		foreach ($context['custom_category_settings'] as $catset_id => $catset)
169 174
 		{
170
-			if (!empty($catset['dt']) && !empty($catset['dd']))
171
-				echo '
175
+			if (!empty($catset['dt']) && !empty($catset['dd'])) {
176
+							echo '
172 177
 					<dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '">
173 178
 						', $catset['dt'], '
174 179
 					</dt>
175 180
 					<dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '>
176 181
 						', $catset['dd'], '
177 182
 					</dd>';
183
+			}
178 184
 		}
179 185
 	}
180 186
 
@@ -182,21 +188,23 @@  discard block
 block discarded – undo
182 188
 	echo '
183 189
 				</dl>';
184 190
 
185
-	if (isset($context['category']['is_new']))
186
-		echo '
191
+	if (isset($context['category']['is_new'])) {
192
+			echo '
187 193
 				<input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">';
188
-	else
189
-		echo '
194
+	} else {
195
+			echo '
190 196
 				<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">
191 197
 				<input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button you_sure">';
198
+	}
192 199
 	echo '
193 200
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
194 201
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
195 202
 
196 203
 	// If this category is empty we don't bother with the next confirmation screen.
197
-	if ($context['category']['is_empty'])
198
-		echo '
204
+	if ($context['category']['is_empty']) {
205
+			echo '
199 206
 				<input type="hidden" name="empty" value="1">';
207
+	}
200 208
 
201 209
 	echo '
202 210
 			</div><!-- .windowbg -->
@@ -223,9 +231,10 @@  discard block
 block discarded – undo
223 231
 				<p>', $txt['mboards_delete_cat_contains'], ':</p>
224 232
 				<ul>';
225 233
 
226
-	foreach ($context['category']['children'] as $child)
227
-		echo '
234
+	foreach ($context['category']['children'] as $child) {
235
+			echo '
228 236
 					<li>', $child, '</li>';
237
+	}
229 238
 
230 239
 	echo '
231 240
 				</ul>
@@ -239,10 +248,11 @@  discard block
 block discarded – undo
239 248
 					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>:
240 249
 					<select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>';
241 250
 
242
-	foreach ($context['category_order'] as $cat)
243
-		if ($cat['id'] != 0)
251
+	foreach ($context['category_order'] as $cat) {
252
+			if ($cat['id'] != 0)
244 253
 			echo '
245 254
 						<option value="', $cat['id'], '">', $cat['true_name'], '</option>';
255
+	}
246 256
 
247 257
 	echo '
248 258
 					</select>
@@ -285,9 +295,10 @@  discard block
 block discarded – undo
285 295
 					<dd>
286 296
 						<select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">';
287 297
 
288
-	foreach ($context['categories'] as $category)
289
-		echo '
298
+	foreach ($context['categories'] as $category) {
299
+			echo '
290 300
 							<option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>';
301
+	}
291 302
 	echo '
292 303
 						</select>
293 304
 					</dd>';
@@ -315,9 +326,10 @@  discard block
 block discarded – undo
315 326
 						<select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '>
316 327
 							', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '';
317 328
 
318
-		foreach ($context['board_order'] as $order)
319
-			echo '
329
+		foreach ($context['board_order'] as $order) {
330
+					echo '
320 331
 							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
332
+		}
321 333
 		echo '
322 334
 						</select>
323 335
 					</dd>';
@@ -346,13 +358,15 @@  discard block
 block discarded – undo
346 358
 					<dd>
347 359
 						<select name="profile">';
348 360
 
349
-	if (isset($context['board']['is_new']))
350
-		echo '
361
+	if (isset($context['board']['is_new'])) {
362
+			echo '
351 363
 							<option value="-1">[', $txt['permission_profile_inherit'], ']</option>';
364
+	}
352 365
 
353
-	foreach ($context['profiles'] as $id => $profile)
354
-		echo '
366
+	foreach ($context['profiles'] as $id => $profile) {
367
+			echo '
355 368
 							<option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
369
+	}
356 370
 
357 371
 	echo '
358 372
 						</select>
@@ -365,8 +379,8 @@  discard block
 block discarded – undo
365 379
 					</dt>
366 380
 					<dd>';
367 381
 
368
-	if (!empty($modSettings['deny_boards_access']))
369
-		echo '
382
+	if (!empty($modSettings['deny_boards_access'])) {
383
+			echo '
370 384
 						<table>
371 385
 							<tr>
372 386
 								<td></td>
@@ -374,10 +388,11 @@  discard block
 block discarded – undo
374 388
 								<th>', $txt['permissions_option_off'], '</th>
375 389
 								<th>', $txt['permissions_option_deny'], '</th>
376 390
 							</tr>';
391
+	}
377 392
 
378 393
 	// List all the membergroups so the user can choose who may access this board.
379
-	foreach ($context['groups'] as $group)
380
-		if (empty($modSettings['deny_boards_access']))
394
+	foreach ($context['groups'] as $group) {
395
+			if (empty($modSettings['deny_boards_access']))
381 396
 			echo '
382 397
 						<label for="groups_', $group['id'], '">
383 398
 							<input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), '>
@@ -385,8 +400,9 @@  discard block
 block discarded – undo
385 400
 								', $group['name'], '
386 401
 							</span>
387 402
 						</label><br>';
388
-		else
389
-			echo '
403
+	}
404
+		else {
405
+					echo '
390 406
 							<tr>
391 407
 								<td>
392 408
 									<label for="groups_', $group['id'], '_a">
@@ -406,16 +422,17 @@  discard block
 block discarded – undo
406 422
 								</td>
407 423
 								<td></td>
408 424
 							</tr>';
425
+		}
409 426
 
410
-	if (empty($modSettings['deny_boards_access']))
411
-		echo '
427
+	if (empty($modSettings['deny_boards_access'])) {
428
+			echo '
412 429
 						<span class="select_all_box">
413 430
 							<em>', $txt['check_all'], '</em> <input type="checkbox" onclick="invertAll(this, this.form, \'groups[\');">
414 431
 						</span>
415 432
 						<br><br>
416 433
 					</dd>';
417
-	else
418
-		echo '
434
+	} else {
435
+			echo '
419 436
 							<tr class="select_all_box">
420 437
 								<td>
421 438
 								</td>
@@ -434,6 +451,7 @@  discard block
 block discarded – undo
434 451
 							</tr>
435 452
 						</table>
436 453
 					</dd>';
454
+	}
437 455
 
438 456
 	// Options to choose moderators, specify as announcement board and choose whether to count posts here.
439 457
 	echo '
@@ -488,8 +506,8 @@  discard block
 block discarded – undo
488 506
 					</dl>
489 507
 				</div>';
490 508
 
491
-		if ($context['board']['redirect'])
492
-			echo '
509
+		if ($context['board']['redirect']) {
510
+					echo '
493 511
 				<div id="reset_redirect_div">
494 512
 					<dl class="settings">
495 513
 						<dt>
@@ -502,6 +520,7 @@  discard block
 block discarded – undo
502 520
 						</dd>
503 521
 					</dl>
504 522
 				</div>';
523
+		}
505 524
 	}
506 525
 
507 526
 	echo '
@@ -529,9 +548,10 @@  discard block
 block discarded – undo
529 548
 							<select name="boardtheme" id="boardtheme" onchange="refreshOptions();">
530 549
 								<option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>';
531 550
 
532
-	foreach ($context['themes'] as $theme)
533
-		echo '
551
+	foreach ($context['themes'] as $theme) {
552
+			echo '
534 553
 									<option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
554
+	}
535 555
 
536 556
 	echo '
537 557
 							</select>
@@ -560,14 +580,15 @@  discard block
 block discarded – undo
560 580
 
561 581
 		foreach ($context['custom_board_settings'] as $cbs_id => $cbs)
562 582
 		{
563
-			if (!empty($cbs['dt']) && !empty($cbs['dd']))
564
-				echo '
583
+			if (!empty($cbs['dt']) && !empty($cbs['dd'])) {
584
+							echo '
565 585
 						<dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '">
566 586
 							', $cbs['dt'], '
567 587
 						</dt>
568 588
 						<dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '>
569 589
 							', $cbs['dd'], '
570 590
 						</dd>';
591
+			}
571 592
 		}
572 593
 
573 594
 		echo '
@@ -575,9 +596,10 @@  discard block
 block discarded – undo
575 596
 				</div>';
576 597
 	}
577 598
 
578
-	if (!empty($context['board']['is_recycle']))
579
-		echo '
599
+	if (!empty($context['board']['is_recycle'])) {
600
+			echo '
580 601
 				<div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>';
602
+	}
581 603
 
582 604
 	echo '
583 605
 				<input type="hidden" name="rid" value="', $context['redirect_location'], '">
@@ -585,21 +607,24 @@  discard block
 block discarded – undo
585 607
 				<input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">';
586 608
 
587 609
 	// If this board has no children don't bother with the next confirmation screen.
588
-	if ($context['board']['no_children'])
589
-		echo '
610
+	if ($context['board']['no_children']) {
611
+			echo '
590 612
 				<input type="hidden" name="no_children" value="1">';
613
+	}
591 614
 
592
-	if (isset($context['board']['is_new']))
593
-		echo '
615
+	if (isset($context['board']['is_new'])) {
616
+			echo '
594 617
 				<input type="hidden" name="cur_cat" value="', $context['board']['category'], '">
595 618
 				<input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">';
596
-	else
597
-		echo '
619
+	} else {
620
+			echo '
598 621
 				<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">';
622
+	}
599 623
 
600
-	if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle']))
601
-		echo '
624
+	if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) {
625
+			echo '
602 626
 				<input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button you_sure">';
627
+	}
603 628
 	echo '
604 629
 			</div><!-- .windowbg -->
605 630
 		</form>
@@ -620,12 +645,13 @@  discard block
 block discarded – undo
620 645
 			sItemListContainerId: \'moderator_container\',
621 646
 			aListItems: [';
622 647
 
623
-	foreach ($context['board']['moderators'] as $id_member => $member_name)
624
-		echo '
648
+	foreach ($context['board']['moderators'] as $id_member => $member_name) {
649
+			echo '
625 650
 				{
626 651
 					sItemId: ', JavaScriptEscape($id_member), ',
627 652
 					sItemName: ', JavaScriptEscape($member_name), '
628 653
 				}', $id_member == $context['board']['last_moderator_id'] ? '' : ',';
654
+	}
629 655
 
630 656
 	echo '
631 657
 			]
@@ -645,12 +671,13 @@  discard block
 block discarded – undo
645 671
 			sItemListContainerId: \'moderator_group_container\',
646 672
 			aListItems: [';
647 673
 
648
-	foreach ($context['board']['moderator_groups'] as $id_group => $group_name)
649
-		echo '
674
+	foreach ($context['board']['moderator_groups'] as $id_group => $group_name) {
675
+			echo '
650 676
 				{
651 677
 					sItemId: ', JavaScriptEscape($id_group), ',
652 678
 					sItemName: ', JavaScriptEscape($group_name), '
653 679
 				}', $id_group == $context['board']['last_moderator_group_id'] ? '' : ',';
680
+	}
654 681
 
655 682
 		echo '
656 683
 			]
@@ -689,20 +716,22 @@  discard block
 block discarded – undo
689 716
 			else 
690 717
 				document.getElementById("redirect_address_div").classList.add(\'hidden\');';
691 718
 
692
-		if ($context['board']['redirect'])
693
-			echo '
719
+		if ($context['board']['redirect']) {
720
+					echo '
694 721
 			if(redirectEnabled)
695 722
 				document.getElementById("reset_redirect_div").classList.remove(\'hidden\');
696 723
 			else 
697 724
 				document.getElementById("reset_redirect_div").classList.add(\'hidden\');';
725
+		}
698 726
 	}
699 727
 
700 728
 	// Include any JavaScript added by mods using the 'integrate_edit_board' hook.
701 729
 	if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions']))
702 730
 	{
703
-		foreach ($context['custom_refreshOptions'] as $refreshOption)
704
-			echo '
731
+		foreach ($context['custom_refreshOptions'] as $refreshOption) {
732
+					echo '
705 733
 			', $refreshOption;
734
+		}
706 735
 	}
707 736
 
708 737
 	echo '
@@ -731,9 +760,10 @@  discard block
 block discarded – undo
731 760
 				<p>', $txt['mboards_delete_board_contains'], '</p>
732 761
 				<ul>';
733 762
 
734
-	foreach ($context['children'] as $child)
735
-		echo '
763
+	foreach ($context['children'] as $child) {
764
+			echo '
736 765
 					<li>', $child['node']['name'], '</li>';
766
+	}
737 767
 
738 768
 	echo '
739 769
 				</ul>
@@ -747,10 +777,11 @@  discard block
 block discarded – undo
747 777
 					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>:
748 778
 					<select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>';
749 779
 
750
-	foreach ($context['board_order'] as $board)
751
-		if ($board['id'] != $context['board']['id'] && empty($board['is_child']))
780
+	foreach ($context['board_order'] as $board) {
781
+			if ($board['id'] != $context['board']['id'] && empty($board['is_child']))
752 782
 			echo '
753 783
 						<option value="', $board['id'], '">', $board['name'], '</option>';
784
+	}
754 785
 
755 786
 	echo '
756 787
 					</select>
Please login to merge, or discard this patch.
Themes/default/ManageLanguages.template.php 1 patch
Braces   +29 added lines, -20 removed lines patch added patch discarded remove patch
@@ -34,11 +34,12 @@  discard block
 block discarded – undo
34 34
 	}
35 35
 
36 36
 	// An error?
37
-	if (!empty($context['error_message']))
38
-		echo '
37
+	if (!empty($context['error_message'])) {
38
+			echo '
39 39
 	<div class="errorbox">
40 40
 		', $context['error_message'], '
41 41
 	</div>';
42
+	}
42 43
 
43 44
 	// Provide something of an introduction...
44 45
 	echo '
@@ -64,11 +65,12 @@  discard block
 block discarded – undo
64 65
 	// If the files are not writable, we might!
65 66
 	if (!empty($context['still_not_writable']))
66 67
 	{
67
-		if (!empty($context['package_ftp']['error']))
68
-			echo '
68
+		if (!empty($context['package_ftp']['error'])) {
69
+					echo '
69 70
 			<div class="errorbox">
70 71
 				', $context['package_ftp']['error'], '
71 72
 			</div>';
73
+		}
72 74
 
73 75
 		echo '
74 76
 			<div class="cat_bar">
@@ -145,11 +147,12 @@  discard block
 block discarded – undo
145 147
 			</div>';
146 148
 
147 149
 	// Not writable? Oops, show an error for ya.
148
-	if (!empty($context['lang_file_not_writable_message']))
149
-		echo '
150
+	if (!empty($context['lang_file_not_writable_message'])) {
151
+			echo '
150 152
 			<div class="errorbox">
151 153
 				', $context['lang_file_not_writable_message'], '
152 154
 			</div>';
155
+	}
153 156
 
154 157
 	// Show the language entries
155 158
 	echo '
@@ -160,8 +163,8 @@  discard block
 block discarded – undo
160 163
 
161 164
 	foreach ($context['primary_settings'] as $setting => $setting_info)
162 165
 	{
163
-		if ($setting != 'name')
164
-			echo '
166
+		if ($setting != 'name') {
167
+					echo '
165 168
 						<dt>
166 169
 							<a id="settings_', $setting, '_help" href="', $scripturl, '?action=helpadmin;help=languages_', $setting_info['label'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a>
167 170
 							<label for="', $setting, '">', $txt['languages_' . $setting_info['label']], ':</label>
@@ -169,6 +172,7 @@  discard block
 block discarded – undo
169 172
 						<dd>
170 173
 							<input type="', (is_bool($setting_info['value']) ? 'checkbox' : 'text'), '" name="', $setting, '" id="', $setting_info['label'], '" size="20"', (is_bool($setting_info['value']) ? (!empty($setting_info['value']) ? ' checked' : '') : ' value="' . $setting_info['value'] . '"'), (!empty($context['lang_file_not_writable_message']) ? ' disabled' : ''), ' data-orig="' . (is_bool($setting_info['value']) ? (!empty($setting_info['value']) ? 'true' : 'false') : $setting_info['value']) . '">
171 174
 						</dd>';
175
+		}
172 176
 	}
173 177
 
174 178
 	echo '
@@ -180,9 +184,10 @@  discard block
 block discarded – undo
180 184
 				<input type="reset" id="reset_main" value="', $txt['reset'], '" class="button">';
181 185
 
182 186
 	// Allow deleting entries. English can't be deleted though.
183
-	if ($context['lang_id'] != 'english')
184
-		echo '
187
+	if ($context['lang_id'] != 'english') {
188
+			echo '
185 189
 				<input type="submit" name="delete_main" value="', $txt['delete'], '"', !empty($context['lang_file_not_writable_message']) ? ' disabled' : '', ' onclick="confirm(\'', $txt['languages_delete_confirm'], '\');" class="button">';
190
+	}
186 191
 
187 192
 	echo '
188 193
 			</div><!-- .windowbg -->
@@ -209,9 +214,10 @@  discard block
 block discarded – undo
209 214
 		echo '
210 215
 						<optgroup label="', $theme['name'], '">';
211 216
 
212
-		foreach ($theme['files'] as $file)
213
-			echo '
217
+		foreach ($theme['files'] as $file) {
218
+					echo '
214 219
 							<option value="', $id_theme, '+', $file['id'], '"', $file['selected'] ? ' selected' : '', '>', $file['name'], '</option>';
220
+		}
215 221
 
216 222
 		echo '
217 223
 						</optgroup>';
@@ -226,11 +232,12 @@  discard block
 block discarded – undo
226 232
 			</div><!-- .information -->';
227 233
 
228 234
 	// Is it not writable? Show an error.
229
-	if (!empty($context['entries_not_writable_message']))
230
-		echo '
235
+	if (!empty($context['entries_not_writable_message'])) {
236
+			echo '
231 237
 			<div class="errorbox">
232 238
 				', $context['entries_not_writable_message'], '
233 239
 			</div>';
240
+	}
234 241
 
235 242
 	// Already have some file entries?
236 243
 	if (!empty($context['file_entries']))
@@ -259,8 +266,8 @@  discard block
 block discarded – undo
259 266
 						</dt>
260 267
 						<dd id="entry_', $entry_num, '">';
261 268
 
262
-				if ($entry['can_remove'])
263
-					echo '
269
+				if ($entry['can_remove']) {
270
+									echo '
264 271
 							<span style="margin-right: 1ch; white-space: nowrap">
265 272
 								<input id="entry_', $entry_num, '_none" class="entry_toggle" type="radio" name="edit[', $entry['key'], ']', isset($entry['subkey']) ? '[' . $entry['subkey'] . ']' : '', '" value="" data-target="#entry_', $entry_num, '" checked>
266 273
 								<label for="entry_', $entry_num, '_none">', $txt['no_change'], '</label>
@@ -273,10 +280,11 @@  discard block
 block discarded – undo
273 280
 								<input id="entry_', $entry_num, '_remove" class="entry_toggle" type="radio" name="edit[', $entry['key'], ']', isset($entry['subkey']) ? '[' . $entry['subkey'] . ']' : '', '" value="remove" data-target="#entry_', $entry_num, '">
274 281
 								<label for="entry_', $entry_num, '_remove">', $txt['remove'], '</label>
275 282
 							</span>';
276
-				else
277
-					echo '
283
+				} else {
284
+									echo '
278 285
 							<input id="entry_', $entry_num, '_edit" class="entry_toggle" type="checkbox" name="edit[', $entry['key'], ']', isset($entry['subkey']) ? '[' . $entry['subkey'] . ']' : '', '" value="edit" data-target="#entry_', $entry_num, '">
279 286
 							<label for="entry_', $entry_num, '_edit">', $txt['edit'], '</label>';
287
+				}
280 288
 
281 289
 				echo '
282 290
 							</span>
@@ -334,12 +342,13 @@  discard block
 block discarded – undo
334 342
 					<input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '">';
335 343
 
336 344
 	// Do we have some errors? Too bad. Display a little error box.
337
-	if (!empty($context['smf_error']))
338
-		echo '
345
+	if (!empty($context['smf_error'])) {
346
+			echo '
339 347
 					<div>
340 348
 						<br>
341 349
 						<p class="errorbox">', $txt['add_language_error_' . $context['smf_error']], '</p>
342 350
 					</div>';
351
+	}
343 352
 
344 353
 	echo '
345 354
 				</fieldset>
Please login to merge, or discard this patch.
Sources/ManageLanguages.php 2 patches
Braces   +241 added lines, -181 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * This is the main function for the languages area.
@@ -150,11 +151,11 @@  discard block
 block discarded – undo
150 151
 	$language_list = new xmlArray(fetch_web_data($url), true);
151 152
 
152 153
 	// Check that the site responded and that the language exists.
153
-	if (!$language_list->exists('languages'))
154
-		$context['smf_error'] = 'no_response';
155
-	elseif (!$language_list->exists('languages/language'))
156
-		$context['smf_error'] = 'no_files';
157
-	else
154
+	if (!$language_list->exists('languages')) {
155
+			$context['smf_error'] = 'no_response';
156
+	} elseif (!$language_list->exists('languages/language')) {
157
+			$context['smf_error'] = 'no_files';
158
+	} else
158 159
 	{
159 160
 		$language_list = $language_list->path('languages[0]');
160 161
 		$lang_files = $language_list->set('language');
@@ -162,8 +163,9 @@  discard block
 block discarded – undo
162 163
 		foreach ($lang_files as $file)
163 164
 		{
164 165
 			// Were we searching?
165
-			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false)
166
-				continue;
166
+			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) {
167
+							continue;
168
+			}
167 169
 
168 170
 			$smf_languages[] = array(
169 171
 				'id' => $file->fetch('id'),
@@ -174,10 +176,11 @@  discard block
 block discarded – undo
174 176
 				'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>',
175 177
 			);
176 178
 		}
177
-		if (empty($smf_languages))
178
-			$context['smf_error'] = 'no_files';
179
-		else
180
-			return $smf_languages;
179
+		if (empty($smf_languages)) {
180
+					$context['smf_error'] = 'no_files';
181
+		} else {
182
+					return $smf_languages;
183
+		}
181 184
 	}
182 185
 }
183 186
 
@@ -199,8 +202,9 @@  discard block
 block discarded – undo
199 202
 	require_once($sourcedir . '/Subs-Package.php');
200 203
 
201 204
 	// Clearly we need to know what to request.
202
-	if (!isset($_GET['did']))
203
-		fatal_lang_error('no_access', false);
205
+	if (!isset($_GET['did'])) {
206
+			fatal_lang_error('no_access', false);
207
+	}
204 208
 
205 209
 	// Some lovely context.
206 210
 	$context['download_id'] = $_GET['did'];
@@ -220,8 +224,9 @@  discard block
 block discarded – undo
220 224
 		foreach ($_POST['copy_file'] as $file)
221 225
 		{
222 226
 			// Check it's not very bad.
223
-			if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file)))
224
-				fatal_error($txt['languages_download_illegal_paths']);
227
+			if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) {
228
+							fatal_error($txt['languages_download_illegal_paths']);
229
+			}
225 230
 
226 231
 			$chmod_files[] = $boarddir . '/' . $file;
227 232
 			$install_files[] = $file;
@@ -232,8 +237,9 @@  discard block
 block discarded – undo
232 237
 		$files_left = $file_status['files']['notwritable'];
233 238
 
234 239
 		// Something not writable?
235
-		if (!empty($files_left))
236
-			$context['error_message'] = $txt['languages_download_not_chmod'];
240
+		if (!empty($files_left)) {
241
+					$context['error_message'] = $txt['languages_download_not_chmod'];
242
+		}
237 243
 		// Otherwise, go go go!
238 244
 		elseif (!empty($install_files))
239 245
 		{
@@ -248,11 +254,13 @@  discard block
 block discarded – undo
248 254
 	}
249 255
 
250 256
 	// Open up the old china.
251
-	if (!isset($archive_content))
252
-		$archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null);
257
+	if (!isset($archive_content)) {
258
+			$archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null);
259
+	}
253 260
 
254
-	if (empty($archive_content))
255
-		fatal_error($txt['add_language_error_no_response']);
261
+	if (empty($archive_content)) {
262
+			fatal_error($txt['add_language_error_no_response']);
263
+	}
256 264
 
257 265
 	// Now for each of the files, let's do some *stuff*
258 266
 	$context['files'] = array(
@@ -267,8 +275,9 @@  discard block
 block discarded – undo
267 275
 		$extension = substr($filename, strrpos($filename, '.') + 1);
268 276
 
269 277
 		// Don't do anything with files we don't understand.
270
-		if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt')))
271
-			continue;
278
+		if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) {
279
+					continue;
280
+		}
272 281
 
273 282
 		// Basic data.
274 283
 		$context_data = array(
@@ -287,8 +296,9 @@  discard block
 block discarded – undo
287 296
 		// Does the file exist, is it different and can we overwrite?
288 297
 		if (file_exists($boarddir . '/' . $file['filename']))
289 298
 		{
290
-			if (is_writable($boarddir . '/' . $file['filename']))
291
-				$context_data['writable'] = true;
299
+			if (is_writable($boarddir . '/' . $file['filename'])) {
300
+							$context_data['writable'] = true;
301
+			}
292 302
 
293 303
 			// Finally, do we actually think the content has changed?
294 304
 			if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename']))
@@ -301,16 +311,17 @@  discard block
 block discarded – undo
301 311
 			{
302 312
 				$context_data['exists'] = 'same';
303 313
 				$context_data['default_copy'] = false;
314
+			} else {
315
+							$context_data['exists'] = 'different';
304 316
 			}
305
-			else
306
-				$context_data['exists'] = 'different';
307 317
 		}
308 318
 		// No overwrite?
309 319
 		else
310 320
 		{
311 321
 			// Can we at least stick it in the directory...
312
-			if (is_writable($boarddir . '/' . $dirname))
313
-				$context_data['writable'] = true;
322
+			if (is_writable($boarddir . '/' . $dirname)) {
323
+							$context_data['writable'] = true;
324
+			}
314 325
 		}
315 326
 
316 327
 		// I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin...
@@ -325,8 +336,9 @@  discard block
 block discarded – undo
325 336
 			list ($name, $language) = explode('.', $filename);
326 337
 
327 338
 			// Let's get the new version, I like versions, they tell me that I'm up to date.
328
-			if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1)
329
-				$context_data['version'] = $match[1];
339
+			if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) {
340
+							$context_data['version'] = $match[1];
341
+			}
330 342
 
331 343
 			// Now does the old file exist - if so what is it's version?
332 344
 			if (file_exists($boarddir . '/' . $file['filename']))
@@ -342,34 +354,35 @@  discard block
 block discarded – undo
342 354
 					$context_data['cur_version'] = $match[1];
343 355
 
344 356
 					// How does this compare?
345
-					if ($context_data['cur_version'] == $context_data['version'])
346
-						$context_data['version_compare'] = 'same';
347
-					elseif ($context_data['cur_version'] > $context_data['version'])
348
-						$context_data['version_compare'] = 'older';
357
+					if ($context_data['cur_version'] == $context_data['version']) {
358
+											$context_data['version_compare'] = 'same';
359
+					} elseif ($context_data['cur_version'] > $context_data['version']) {
360
+											$context_data['version_compare'] = 'older';
361
+					}
349 362
 
350 363
 					// Don't recommend copying if the version is the same.
351
-					if ($context_data['version_compare'] != 'newer')
352
-						$context_data['default_copy'] = false;
364
+					if ($context_data['version_compare'] != 'newer') {
365
+											$context_data['default_copy'] = false;
366
+					}
353 367
 				}
354 368
 			}
355 369
 
356 370
 			// Add the context data to the main set.
357 371
 			$context['files']['lang'][] = $context_data;
358
-		}
359
-		elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false)
372
+		} elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false)
360 373
 		{
361 374
 			// Registration agreement is a primary file
362 375
 			$context['files']['lang'][] = $context_data;
363
-		}
364
-		else
376
+		} else
365 377
 		{
366 378
 			// There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future
367 379
 			$context['files']['other'][] = $context_data;
368 380
 		}
369 381
 
370 382
 		// Collect together all non-writable areas.
371
-		if (!$context_data['writable'])
372
-			$context['make_writable'][] = $context_data['destination'];
383
+		if (!$context_data['writable']) {
384
+					$context['make_writable'][] = $context_data['destination'];
385
+		}
373 386
 	}
374 387
 
375 388
 	// Before we go to far can we make anything writable, eh, eh?
@@ -384,22 +397,24 @@  discard block
 block discarded – undo
384 397
 		{
385 398
 			if ($type == 'lang')
386 399
 			{
387
-				foreach ($data as $k => $file)
388
-					if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
400
+				foreach ($data as $k => $file) {
401
+									if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
389 402
 						$context['files'][$type][$k]['writable'] = true;
390
-			}
391
-			else
403
+				}
404
+			} else
392 405
 			{
393
-				foreach ($data as $theme => $files)
394
-					foreach ($files as $k => $file)
406
+				foreach ($data as $theme => $files) {
407
+									foreach ($files as $k => $file)
395 408
 						if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
396 409
 							$context['files'][$type][$theme][$k]['writable'] = true;
410
+				}
397 411
 			}
398 412
 		}
399 413
 
400 414
 		// Are we going to need more language stuff?
401
-		if (!empty($context['still_not_writable']))
402
-			loadLanguage('Packages');
415
+		if (!empty($context['still_not_writable'])) {
416
+					loadLanguage('Packages');
417
+		}
403 418
 	}
404 419
 
405 420
 	// This is the list for the main files.
@@ -612,12 +627,13 @@  discard block
 block discarded – undo
612 627
 	highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true);
613 628
 
614 629
 	// Display a warning if we cannot edit the default setting.
615
-	if (!is_writable($boarddir . '/Settings.php'))
616
-		$listOptions['additional_rows'][] = array(
630
+	if (!is_writable($boarddir . '/Settings.php')) {
631
+			$listOptions['additional_rows'][] = array(
617 632
 				'position' => 'after_title',
618 633
 				'value' => $txt['language_settings_writable'],
619 634
 				'class' => 'smalltext alert',
620 635
 			);
636
+	}
621 637
 
622 638
 	require_once($sourcedir . '/Subs-List.php');
623 639
 	createList($listOptions);
@@ -659,10 +675,11 @@  discard block
 block discarded – undo
659 675
 
660 676
 	// Put them back.
661 677
 	$settings['actual_theme_dir'] = $backup_actual_theme_dir;
662
-	if (!empty($backup_base_theme_dir))
663
-		$settings['base_theme_dir'] = $backup_base_theme_dir;
664
-	else
665
-		unset($settings['base_theme_dir']);
678
+	if (!empty($backup_base_theme_dir)) {
679
+			$settings['base_theme_dir'] = $backup_base_theme_dir;
680
+	} else {
681
+			unset($settings['base_theme_dir']);
682
+	}
666 683
 
667 684
 	// Get the language files and data...
668 685
 	foreach ($context['languages'] as $lang)
@@ -691,13 +708,15 @@  discard block
 block discarded – undo
691 708
 	while ($row = $smcFunc['db_fetch_assoc']($request))
692 709
 	{
693 710
 		// Default?
694
-		if (empty($row['lngfile']) || !isset($languages[$row['lngfile']]))
695
-			$row['lngfile'] = $language;
711
+		if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) {
712
+					$row['lngfile'] = $language;
713
+		}
696 714
 
697
-		if (!isset($languages[$row['lngfile']]) && isset($languages['english']))
698
-			$languages['english']['count'] += $row['num_users'];
699
-		elseif (isset($languages[$row['lngfile']]))
700
-			$languages[$row['lngfile']]['count'] += $row['num_users'];
715
+		if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) {
716
+					$languages['english']['count'] += $row['num_users'];
717
+		} elseif (isset($languages[$row['lngfile']])) {
718
+					$languages[$row['lngfile']]['count'] += $row['num_users'];
719
+		}
701 720
 	}
702 721
 	$smcFunc['db_free_result']($request);
703 722
 
@@ -737,13 +756,15 @@  discard block
 block discarded – undo
737 756
 
738 757
 	call_integration_hook('integrate_language_settings', array(&$config_vars));
739 758
 
740
-	if ($return_config)
741
-		return $config_vars;
759
+	if ($return_config) {
760
+			return $config_vars;
761
+	}
742 762
 
743 763
 	// Get our languages. No cache
744 764
 	getLanguages(false);
745
-	foreach ($context['languages'] as $lang)
746
-		$config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);
765
+	foreach ($context['languages'] as $lang) {
766
+			$config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);
767
+	}
747 768
 
748 769
 	// Saving settings?
749 770
 	if (isset($_REQUEST['save']))
@@ -753,8 +774,9 @@  discard block
 block discarded – undo
753 774
 		call_integration_hook('integrate_save_language_settings', array(&$config_vars));
754 775
 
755 776
 		saveSettings($config_vars);
756
-		if (!$settings_not_writable && !$settings_backup_fail)
757
-			$_SESSION['adm-save'] = true;
777
+		if (!$settings_not_writable && !$settings_backup_fail) {
778
+					$_SESSION['adm-save'] = true;
779
+		}
758 780
 		redirectexit('action=admin;area=languages;sa=settings');
759 781
 	}
760 782
 
@@ -763,10 +785,11 @@  discard block
 block discarded – undo
763 785
 	$context['settings_title'] = $txt['language_settings'];
764 786
 	$context['save_disabled'] = $settings_not_writable;
765 787
 
766
-	if ($settings_not_writable)
767
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
768
-	elseif ($settings_backup_fail)
769
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
788
+	if ($settings_not_writable) {
789
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
790
+	} elseif ($settings_backup_fail) {
791
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
792
+	}
770 793
 
771 794
 	// Fill the config array.
772 795
 	prepareServerSettingsContext($config_vars);
@@ -813,8 +836,9 @@  discard block
 block discarded – undo
813 836
 			'theme_dir' => $settings['default_theme_dir'],
814 837
 		),
815 838
 	);
816
-	while ($row = $smcFunc['db_fetch_assoc']($request))
817
-		$themes[$row['id_theme']][$row['variable']] = $row['value'];
839
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
840
+			$themes[$row['id_theme']][$row['variable']] = $row['value'];
841
+	}
818 842
 	$smcFunc['db_free_result']($request);
819 843
 
820 844
 	// This will be where we look
@@ -847,14 +871,16 @@  discard block
 block discarded – undo
847 871
 	// Check we have themes with a path and a name - just in case - and add the path.
848 872
 	foreach ($themes as $id => $data)
849 873
 	{
850
-		if (count($data) != 2)
851
-			unset($themes[$id]);
852
-		elseif (is_dir($data['theme_dir'] . '/languages'))
853
-			$lang_dirs[$id] = $data['theme_dir'] . '/languages';
874
+		if (count($data) != 2) {
875
+					unset($themes[$id]);
876
+		} elseif (is_dir($data['theme_dir'] . '/languages')) {
877
+					$lang_dirs[$id] = $data['theme_dir'] . '/languages';
878
+		}
854 879
 
855 880
 		// How about image directories?
856
-		if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id']))
857
-			$images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
881
+		if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) {
882
+					$images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
883
+		}
858 884
 	}
859 885
 
860 886
 	$current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : '';
@@ -868,15 +894,17 @@  discard block
 block discarded – undo
868 894
 		while ($entry = $dir->read())
869 895
 		{
870 896
 			// We're only after the files for this language.
871
-			if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0)
872
-				continue;
897
+			if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) {
898
+							continue;
899
+			}
873 900
 
874
-			if (!isset($context['possible_files'][$theme]))
875
-				$context['possible_files'][$theme] = array(
901
+			if (!isset($context['possible_files'][$theme])) {
902
+							$context['possible_files'][$theme] = array(
876 903
 					'id' => $theme,
877 904
 					'name' => $themes[$theme]['name'],
878 905
 					'files' => array(),
879 906
 				);
907
+			}
880 908
 
881 909
 			$context['possible_files'][$theme]['files'][] = array(
882 910
 				'id' => $matches[1],
@@ -905,31 +933,36 @@  discard block
 block discarded – undo
905 933
 		{
906 934
 			$_SESSION['last_backup_for'] = $context['lang_id'] . '$$$';
907 935
 			$result = package_create_backup('backup_lang_' . $context['lang_id']);
908
-			if (!$result)
909
-				fatal_lang_error('could_not_language_backup', false);
936
+			if (!$result) {
937
+							fatal_lang_error('could_not_language_backup', false);
938
+			}
910 939
 		}
911 940
 
912 941
 		// Second, loop through the array to remove the files.
913 942
 		foreach ($lang_dirs as $curPath)
914 943
 		{
915
-			foreach ($context['possible_files'][1]['files'] as $lang)
916
-				if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
944
+			foreach ($context['possible_files'][1]['files'] as $lang) {
945
+							if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
917 946
 					unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php');
947
+			}
918 948
 
919 949
 			// Check for the email template.
920
-			if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'))
921
-				unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
950
+			if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) {
951
+							unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
952
+			}
922 953
 		}
923 954
 
924 955
 		// Third, the agreement file.
925
-		if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt'))
926
-			unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
956
+		if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) {
957
+					unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
958
+		}
927 959
 
928 960
 		// Fourth, a related images folder, if it exists...
929
-		if (!empty($images_dirs))
930
-			foreach ($images_dirs as $curPath)
961
+		if (!empty($images_dirs)) {
962
+					foreach ($images_dirs as $curPath)
931 963
 				if (is_dir($curPath))
932 964
 					deltree($curPath);
965
+		}
933 966
 
934 967
 		// Members can no longer use this language.
935 968
 		$smcFunc['db_query']('', '
@@ -973,8 +1006,9 @@  discard block
 block discarded – undo
973 1006
 
974 1007
 		// Build the replacements. old => new
975 1008
 		$replace_array = array();
976
-		foreach ($primary_settings as $setting => $type)
977
-			$replace_array['~\$txt\[\'' . $setting . '\'\]\s*=\s*[^\r\n]+~'] = '$txt[\'' . $setting . '\'] = ' . ($type === 'bool' ? (!empty($_POST[$setting]) ? 'true' : 'false') : '\'' . ($setting = 'native_name' ? htmlentities(un_htmlspecialchars($_POST[$setting]), ENT_QUOTES, $context['character_set']) : preg_replace('~[^\w-]~i', '', $_POST[$setting])) . '\'') . ';';
1009
+		foreach ($primary_settings as $setting => $type) {
1010
+					$replace_array['~\$txt\[\'' . $setting . '\'\]\s*=\s*[^\r\n]+~'] = '$txt[\'' . $setting . '\'] = ' . ($type === 'bool' ? (!empty($_POST[$setting]) ? 'true' : 'false') : '\'' . ($setting = 'native_name' ? htmlentities(un_htmlspecialchars($_POST[$setting]), ENT_QUOTES, $context['character_set']) : preg_replace('~[^\w-]~i', '', $_POST[$setting])) . '\'') . ';';
1011
+		}
978 1012
 
979 1013
 		$current_data = preg_replace(array_keys($replace_array), array_values($replace_array), $current_data);
980 1014
 		$fp = fopen($settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php', 'w+');
@@ -1017,30 +1051,29 @@  discard block
 block discarded – undo
1017 1051
 				if (is_string($v))
1018 1052
 				{
1019 1053
 					// Only try to save if 'edit' was specified and if the string has changed
1020
-					if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k])
1021
-						$save_strings[$k] = cleanLangString($_POST['entry'][$k], false);
1054
+					if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k]) {
1055
+											$save_strings[$k] = cleanLangString($_POST['entry'][$k], false);
1056
+					}
1022 1057
 
1023 1058
 					// Record any add or remove requests. We'll decide on them later.
1024
-					elseif ($v == 'remove')
1025
-						$remove_strings[] = $k;
1026
-					elseif ($v == 'add' && isset($_POST['entry'][$k]))
1059
+					elseif ($v == 'remove') {
1060
+											$remove_strings[] = $k;
1061
+					} elseif ($v == 'add' && isset($_POST['entry'][$k]))
1027 1062
 					{
1028 1063
 						$add_strings[$k] = array(
1029 1064
 							'group' => isset($_POST['grp'][$k]) ? $_POST['grp'][$k] : 'txt',
1030 1065
 							'string' => cleanLangString($_POST['entry'][$k], false),
1031 1066
 						);
1032 1067
 					}
1033
-				}
1034
-				elseif (is_array($v))
1068
+				} elseif (is_array($v))
1035 1069
 				{
1036 1070
 					foreach ($v as $subk => $subv)
1037 1071
 					{
1038
-						if ($subv == 'edit' && isset($_POST['entry'][$k][$subk]) && isset($_POST['comp'][$k][$subk]) && $_POST['entry'][$k][$subk] != $_POST['comp'][$k][$subk])
1039
-							$save_strings[$k][$subk] = cleanLangString($_POST['entry'][$k][$subk], false);
1040
-
1041
-						elseif ($subv == 'remove')
1042
-							$remove_strings[$k][] = $subk;
1043
-						elseif ($subv == 'add' && isset($_POST['entry'][$k][$subk]))
1072
+						if ($subv == 'edit' && isset($_POST['entry'][$k][$subk]) && isset($_POST['comp'][$k][$subk]) && $_POST['entry'][$k][$subk] != $_POST['comp'][$k][$subk]) {
1073
+													$save_strings[$k][$subk] = cleanLangString($_POST['entry'][$k][$subk], false);
1074
+						} elseif ($subv == 'remove') {
1075
+													$remove_strings[$k][] = $subk;
1076
+						} elseif ($subv == 'add' && isset($_POST['entry'][$k][$subk]))
1044 1077
 						{
1045 1078
 							$add_strings[$k][$subk] = array(
1046 1079
 								'group' => isset($_POST['grp'][$k]) ? $_POST['grp'][$k] : 'txt',
@@ -1076,8 +1109,9 @@  discard block
 block discarded – undo
1076 1109
 			foreach ($allows_add_remove[$file_id]['add'] as $var_group)
1077 1110
 			{
1078 1111
 				$group = !empty($special_groups[$file_id][$var_group]) ? $special_groups[$file_id][$var_group] : $var_group;
1079
-				if (in_array($var_group, $allows_add_remove[$file_id]['add']))
1080
-					$context['can_add_lang_entry'][$group] = true;
1112
+				if (in_array($var_group, $allows_add_remove[$file_id]['add'])) {
1113
+									$context['can_add_lang_entry'][$group] = true;
1114
+				}
1081 1115
 			}
1082 1116
 		}
1083 1117
 
@@ -1115,15 +1149,17 @@  discard block
 block discarded – undo
1115 1149
 		foreach ($entries as $entryKey => $entryValue)
1116 1150
 		{
1117 1151
 			// Ignore some things we set separately.
1118
-			if (in_array($entryKey, array_keys($primary_settings)))
1119
-				continue;
1152
+			if (in_array($entryKey, array_keys($primary_settings))) {
1153
+							continue;
1154
+			}
1120 1155
 
1121 1156
 			// These are arrays that need breaking out.
1122 1157
 			if (strpos($entryValue['entry'], 'array(') === 0 && strpos($entryValue['entry'], ')', -1) === strlen($entryValue['entry']) - 1)
1123 1158
 			{
1124 1159
 				// No, you may not use multidimensional arrays of $txt strings. Madness stalks that path.
1125
-				if (isset($entryValue['subkey']))
1126
-					continue;
1160
+				if (isset($entryValue['subkey'])) {
1161
+									continue;
1162
+				}
1127 1163
 
1128 1164
 				// Trim off the array construct bits.
1129 1165
 				$entryValue['entry'] = substr($entryValue['entry'], strpos($entryValue['entry'], 'array(') + 6, -1);
@@ -1166,8 +1202,9 @@  discard block
 block discarded – undo
1166 1202
 
1167 1203
 					/x' . ($context['utf8'] ? 'u' : ''), $entryValue['entry'], $matches);
1168 1204
 
1169
-				if (empty($m))
1170
-					continue;
1205
+				if (empty($m)) {
1206
+									continue;
1207
+				}
1171 1208
 
1172 1209
 				$entryValue['entry'] = $matches[0];
1173 1210
 
@@ -1184,19 +1221,21 @@  discard block
 block discarded – undo
1184 1221
 					{
1185 1222
 						$subKey = trim($matches[1], '\'"');
1186 1223
 
1187
-						if (ctype_digit($subKey))
1188
-							$cur_index = $subKey;
1224
+						if (ctype_digit($subKey)) {
1225
+													$cur_index = $subKey;
1226
+						}
1189 1227
 
1190 1228
 						$subValue = trim(substr($subValue, strpos($subValue, '=>') + 2));
1229
+					} else {
1230
+											$subKey = $cur_index++;
1191 1231
 					}
1192
-					else
1193
-						$subKey = $cur_index++;
1194 1232
 
1195 1233
 					// Clean up some bits.
1196
-					if (strpos($subValue, '\'') === 0)
1197
-						$subValue = trim($subValue, '\'');
1198
-					elseif (strpos($subValue, '"') === 0)
1199
-						$subValue = trim($subValue, '"');
1234
+					if (strpos($subValue, '\'') === 0) {
1235
+											$subValue = trim($subValue, '\'');
1236
+					} elseif (strpos($subValue, '"') === 0) {
1237
+											$subValue = trim($subValue, '"');
1238
+					}
1200 1239
 
1201 1240
 					// Can we save?
1202 1241
 					if (isset($save_strings[$entryKey][$subKey]))
@@ -1205,11 +1244,13 @@  discard block
 block discarded – undo
1205 1244
 						$save_cache['enabled'] = true;
1206 1245
 					}
1207 1246
 					// Should we remove this one?
1208
-					elseif (isset($remove_strings[$entryKey]) && in_array($subKey, $remove_strings[$entryKey]) && $entryValue['can_remove'])
1209
-						$save_cache['enabled'] = true;
1247
+					elseif (isset($remove_strings[$entryKey]) && in_array($subKey, $remove_strings[$entryKey]) && $entryValue['can_remove']) {
1248
+											$save_cache['enabled'] = true;
1249
+					}
1210 1250
 					// Just keep this one as it is
1211
-					else
1212
-						$save_cache['entries'][$subKey] = $subValue;
1251
+					else {
1252
+											$save_cache['entries'][$subKey] = $subValue;
1253
+					}
1213 1254
 
1214 1255
 					$context['file_entries'][$entryValue['group']][] = array(
1215 1256
 						'key' => $entryKey,
@@ -1223,15 +1264,17 @@  discard block
 block discarded – undo
1223 1264
 				// Should we add a new string to this array?
1224 1265
 				if (!empty($context['can_add_lang_entry'][$entryValue['type']]) && isset($add_strings[$entryKey]))
1225 1266
 				{
1226
-					foreach ($add_strings[$entryKey] as $string_key => $string_val)
1227
-						$save_cache['entries'][$string_key] = strtr($string_val['string'], array('\'' => ''));
1267
+					foreach ($add_strings[$entryKey] as $string_key => $string_val) {
1268
+											$save_cache['entries'][$string_key] = strtr($string_val['string'], array('\'' => ''));
1269
+					}
1228 1270
 
1229 1271
 					$save_cache['enabled'] = true;
1230 1272
 
1231 1273
 					// Make sure we don't add this again as an independent line
1232 1274
 					unset($add_strings[$entryKey][$string_key]);
1233
-					if (empty($add_strings[$entryKey]))
1234
-						unset($add_strings[$entryKey]);
1275
+					if (empty($add_strings[$entryKey])) {
1276
+											unset($add_strings[$entryKey]);
1277
+					}
1235 1278
 				}
1236 1279
 
1237 1280
 
@@ -1248,9 +1291,9 @@  discard block
 block discarded – undo
1248 1291
 						{
1249 1292
 							$items[] = $k2 . ' => \'' . $v2 . '\'';
1250 1293
 							$cur_index = $k2;
1294
+						} else {
1295
+													$items[] = '\'' . $v2 . '\'';
1251 1296
 						}
1252
-						else
1253
-							$items[] = '\'' . $v2 . '\'';
1254 1297
 
1255 1298
 						$cur_index++;
1256 1299
 					}
@@ -1267,8 +1310,9 @@  discard block
 block discarded – undo
1267 1310
 				// Saving?
1268 1311
 				if (isset($save_strings[$entryValue['key']][$entryValue['subkey']]) && $save_strings[$entryValue['key']][$entryValue['subkey']] != $entryValue['entry'])
1269 1312
 				{
1270
-					if ($save_strings[$entryValue['key']][$entryValue['subkey']] == '')
1271
-						$save_strings[$entryValue['key']][$entryValue['subkey']] = '\'\'';
1313
+					if ($save_strings[$entryValue['key']][$entryValue['subkey']] == '') {
1314
+											$save_strings[$entryValue['key']][$entryValue['subkey']] = '\'\'';
1315
+					}
1272 1316
 
1273 1317
 					// Preserve subkey as either digit or string
1274 1318
 					$subKey = ctype_digit($entryValue['subkey']) ? $entryValue['subkey'] : '\'' . $entryValue['subkey'] . '\'';
@@ -1309,8 +1353,9 @@  discard block
 block discarded – undo
1309 1353
 				if (isset($save_strings[$entryValue['key']]) && $save_strings[$entryValue['key']] != $entryValue['entry'])
1310 1354
 				{
1311 1355
 					// @todo Fix this properly.
1312
-					if ($save_strings[$entryValue['key']] == '')
1313
-						$save_strings[$entryValue['key']] = '\'\'';
1356
+					if ($save_strings[$entryValue['key']] == '') {
1357
+											$save_strings[$entryValue['key']] = '\'\'';
1358
+					}
1314 1359
 
1315 1360
 					// Set the new value.
1316 1361
 					$entryValue['entry'] = $save_strings[$entryValue['key']];
@@ -1353,8 +1398,9 @@  discard block
 block discarded – undo
1353 1398
 				{
1354 1399
 					$type = isset($special_types[$string_val['group']]) ? $special_types[$string_val['group']] : $string_val['group'];
1355 1400
 
1356
-					if (empty($context['can_add_lang_entry'][$type]))
1357
-						continue;
1401
+					if (empty($context['can_add_lang_entry'][$type])) {
1402
+											continue;
1403
+					}
1358 1404
 
1359 1405
 					$final_saves[$string_key] = array(
1360 1406
 						'find' => "\s*\?".'>$',
@@ -1369,8 +1415,9 @@  discard block
 block discarded – undo
1369 1415
 					{
1370 1416
 						$type = isset($special_types[$substring_val['group']]) ? $special_types[$substring_val['group']] : $substring_val['group'];
1371 1417
 
1372
-						if (empty($context['can_add_lang_entry'][$type]))
1373
-							continue;
1418
+						if (empty($context['can_add_lang_entry'][$type])) {
1419
+													continue;
1420
+						}
1374 1421
 
1375 1422
 						$subKey = ctype_digit(trim($substring_key, '\'')) ? trim($substring_key, '\'') : '\'' . $substring_key . '\'';
1376 1423
 
@@ -1393,10 +1440,11 @@  discard block
 block discarded – undo
1393 1440
 
1394 1441
 			foreach ($final_saves as $save)
1395 1442
 			{
1396
-				if (!empty($save['is_regex']))
1397
-					$file_contents = preg_replace('~' . $save['find'] . '~' . ($context['utf8'] ? 'u' : ''), $save['replace'], $file_contents);
1398
-				else
1399
-					$file_contents = str_replace($save['find'], $save['replace'], $file_contents);
1443
+				if (!empty($save['is_regex'])) {
1444
+									$file_contents = preg_replace('~' . $save['find'] . '~' . ($context['utf8'] ? 'u' : ''), $save['replace'], $file_contents);
1445
+				} else {
1446
+									$file_contents = str_replace($save['find'], $save['replace'], $file_contents);
1447
+				}
1400 1448
 			}
1401 1449
 
1402 1450
 			// Save the actual changes.
@@ -1414,8 +1462,9 @@  discard block
 block discarded – undo
1414 1462
 			// Make sure the Add button has a place to show up.
1415 1463
 			foreach ($context['can_add_lang_entry'] as $group => $value)
1416 1464
 			{
1417
-				if (!isset($context['file_entries'][$group]))
1418
-					$context['file_entries'][$group] = array();
1465
+				if (!isset($context['file_entries'][$group])) {
1466
+									$context['file_entries'][$group] = array();
1467
+				}
1419 1468
 			}
1420 1469
 
1421 1470
 			addInlineJavaScript('
@@ -1507,8 +1556,9 @@  discard block
 block discarded – undo
1507 1556
 	}
1508 1557
 
1509 1558
 	// If we saved, redirect.
1510
-	if ($madeSave)
1511
-		redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id'] . (!empty($file_id) ? ';entries;tfid=' . $theme_id . rawurlencode('+') . $file_id : ''));
1559
+	if ($madeSave) {
1560
+			redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id'] . (!empty($file_id) ? ';entries;tfid=' . $theme_id . rawurlencode('+') . $file_id : ''));
1561
+	}
1512 1562
 
1513 1563
 	createToken('admin-mlang');
1514 1564
 }
@@ -1540,8 +1590,9 @@  discard block
 block discarded – undo
1540 1590
 				// Toggle the escape.
1541 1591
 				$is_escape = !$is_escape;
1542 1592
 				// If we're now escaped don't add this string.
1543
-				if ($is_escape)
1544
-					continue;
1593
+				if ($is_escape) {
1594
+									continue;
1595
+				}
1545 1596
 			}
1546 1597
 			// Special case - parsed string with line break etc?
1547 1598
 			elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape)
@@ -1558,11 +1609,13 @@  discard block
 block discarded – undo
1558 1609
 				if ($in_string != 2 && ($in_string != 1 || !$is_escape))
1559 1610
 				{
1560 1611
 					// Is it the end of a single quote string?
1561
-					if ($in_string == 1)
1562
-						$in_string = 0;
1612
+					if ($in_string == 1) {
1613
+											$in_string = 0;
1614
+					}
1563 1615
 					// Otherwise it's the start!
1564
-					else
1565
-						$in_string = 1;
1616
+					else {
1617
+											$in_string = 1;
1618
+					}
1566 1619
 
1567 1620
 					// Don't actually include this character!
1568 1621
 					continue;
@@ -1575,19 +1628,22 @@  discard block
 block discarded – undo
1575 1628
 				if ($in_string != 1 && ($in_string != 2 || !$is_escape))
1576 1629
 				{
1577 1630
 					// Is it the end of a double quote string?
1578
-					if ($in_string == 2)
1579
-						$in_string = 0;
1631
+					if ($in_string == 2) {
1632
+											$in_string = 0;
1633
+					}
1580 1634
 					// Otherwise it's the start!
1581
-					else
1582
-						$in_string = 2;
1635
+					else {
1636
+											$in_string = 2;
1637
+					}
1583 1638
 
1584 1639
 					// Don't actually include this character!
1585 1640
 					continue;
1586 1641
 				}
1587 1642
 			}
1588 1643
 			// A join/space outside of a string is simply removed.
1589
-			elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.'))
1590
-				continue;
1644
+			elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) {
1645
+							continue;
1646
+			}
1591 1647
 			// Start of a variable?
1592 1648
 			elseif ($in_string == 0 && $string{$i} == '$')
1593 1649
 			{
@@ -1621,8 +1677,7 @@  discard block
 block discarded – undo
1621 1677
 
1622 1678
 		// Unhtml then rehtml the whole thing!
1623 1679
 		$new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string));
1624
-	}
1625
-	else
1680
+	} else
1626 1681
 	{
1627 1682
 		// Keep track of what we're doing...
1628 1683
 		$in_string = 0;
@@ -1651,10 +1706,11 @@  discard block
 block discarded – undo
1651 1706
 				preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches);
1652 1707
 				if (!empty($matches[1]))
1653 1708
 				{
1654
-					if ($in_string == 1)
1655
-						$new_string .= '\' . ';
1656
-					elseif ($new_string)
1657
-						$new_string .= ' . ';
1709
+					if ($in_string == 1) {
1710
+											$new_string .= '\' . ';
1711
+					} elseif ($new_string) {
1712
+											$new_string .= ' . ';
1713
+					}
1658 1714
 
1659 1715
 					$new_string .= $matches[1];
1660 1716
 					$i += strlen($matches[1]) + 3;
@@ -1667,8 +1723,9 @@  discard block
 block discarded – undo
1667 1723
 			elseif ($string{$i} == '<')
1668 1724
 			{
1669 1725
 				// Probably HTML?
1670
-				if ($string{$i + 1} != ' ')
1671
-					$in_html = true;
1726
+				if ($string{$i + 1} != ' ') {
1727
+									$in_html = true;
1728
+				}
1672 1729
 				// Assume we need an entity...
1673 1730
 				else
1674 1731
 				{
@@ -1680,8 +1737,9 @@  discard block
 block discarded – undo
1680 1737
 			elseif ($string{$i} == '>')
1681 1738
 			{
1682 1739
 				// Will it be HTML?
1683
-				if ($in_html)
1684
-					$in_html = false;
1740
+				if ($in_html) {
1741
+									$in_html = false;
1742
+				}
1685 1743
 				// Otherwise we need an entity...
1686 1744
 				else
1687 1745
 				{
@@ -1690,8 +1748,9 @@  discard block
 block discarded – undo
1690 1748
 				}
1691 1749
 			}
1692 1750
 			// Is it a slash? If so escape it...
1693
-			if ($string{$i} == '\\')
1694
-				$new_string .= '\\';
1751
+			if ($string{$i} == '\\') {
1752
+							$new_string .= '\\';
1753
+			}
1695 1754
 			// The infamous double quote?
1696 1755
 			elseif ($string{$i} == '"')
1697 1756
 			{
@@ -1714,10 +1773,11 @@  discard block
 block discarded – undo
1714 1773
 		}
1715 1774
 
1716 1775
 		// If we ended as a string then close it off.
1717
-		if ($in_string == 1)
1718
-			$new_string .= '\'';
1719
-		elseif ($in_string == 2)
1720
-			$new_string .= '"';
1776
+		if ($in_string == 1) {
1777
+					$new_string .= '\'';
1778
+		} elseif ($in_string == 2) {
1779
+					$new_string .= '"';
1780
+		}
1721 1781
 	}
1722 1782
 
1723 1783
 	return $new_string;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 			'editlang' => array(
593 593
 				'header' => array(
594 594
 					'value' => '',
595
-				),'data' => array(
595
+				), 'data' => array(
596 596
 					'function' => function($rowData) use ($scripturl, $txt)
597 597
 					{
598 598
 						return sprintf('<a href="%1$s?action=admin;area=languages;sa=editlang;lid=%2$s" class="button">%3$s</a>', $scripturl, $rowData['id'], $txt['edit']);
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 					// Now create the string!
1270 1270
 					$final_saves[$entryKey] = array(
1271 1271
 						'find' => $entryValue['full'],
1272
-						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n")))  . "\n" . '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');' . $entryValue['cruft'],
1272
+						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n" . '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');' . $entryValue['cruft'],
1273 1273
 					);
1274 1274
 				}
1275 1275
 			}
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 					// And save it
1292 1292
 					$final_saves[$entryKey] = array(
1293 1293
 						'find' => $entryValue['full'],
1294
-						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n")))  . "\n" . '$' . $entryValue['type'] . '[\'' . $entryValue['key'] . '\'][' . $subKey . '] = ' . $save_strings[$entryValue['key']][$entryValue['subkey']] . ';' . $entryValue['cruft'],
1294
+						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n" . '$' . $entryValue['type'] . '[\'' . $entryValue['key'] . '\'][' . $subKey . '] = ' . $save_strings[$entryValue['key']][$entryValue['subkey']] . ';' . $entryValue['cruft'],
1295 1295
 					);
1296 1296
 				}
1297 1297
 
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 					$entryValue['entry'] = '\'\'';
1302 1302
 					$final_saves[$entryKey] = array(
1303 1303
 						'find' => $entryValue['full'],
1304
-						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n")))  . "\n",
1304
+						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n",
1305 1305
 					);
1306 1306
 				}
1307 1307
 
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 					// And we know what to save now!
1330 1330
 					$final_saves[$entryKey] = array(
1331 1331
 						'find' => $entryValue['full'],
1332
-						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n")))  . "\n" . '$' . $entryValue['type'] . '[\'' . $entryValue['key'] . '\'] = ' . $save_strings[$entryValue['key']] . ';' . $entryValue['cruft'],
1332
+						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n" . '$' . $entryValue['type'] . '[\'' . $entryValue['key'] . '\'] = ' . $save_strings[$entryValue['key']] . ';' . $entryValue['cruft'],
1333 1333
 					);
1334 1334
 				}
1335 1335
 				// Remove this entry only if it is allowed
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 					$entryValue['entry'] = '\'\'';
1339 1339
 					$final_saves[$entryKey] = array(
1340 1340
 						'find' => $entryValue['full'],
1341
-						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n")))  . "\n",
1341
+						'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n",
1342 1342
 					);
1343 1343
 				}
1344 1344
 
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
 						continue;
1370 1370
 
1371 1371
 					$final_saves[$string_key] = array(
1372
-						'find' => "\s*\?".'>$',
1373
-						'replace' => "\n\$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?".'>',
1372
+						'find' => "\s*\?" . '>$',
1373
+						'replace' => "\n\$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?" . '>',
1374 1374
 						'is_regex' => true,
1375 1375
 					);
1376 1376
 				}
@@ -1387,8 +1387,8 @@  discard block
 block discarded – undo
1387 1387
 						$subKey = ctype_digit(trim($substring_key, '\'')) ? trim($substring_key, '\'') : '\'' . $substring_key . '\'';
1388 1388
 
1389 1389
 						$final_saves[$string_key . '[' . $substring_key . ']'] = array(
1390
-							'find' => "\s*\?".'>$',
1391
-							'replace' => "\n\$" . $type . '[\'' . $string_key . '\'][' . $subKey . '] = ' . $substring_val['string'] . ';' . "\n\n?".'>',
1390
+							'find' => "\s*\?" . '>$',
1391
+							'replace' => "\n\$" . $type . '[\'' . $string_key . '\'][' . $subKey . '] = ' . $substring_val['string'] . ';' . "\n\n?" . '>',
1392 1392
 							'is_regex' => true,
1393 1393
 						);
1394 1394
 					}
Please login to merge, or discard this patch.