Error404Page::setCustomHeader()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright (c) 2018 Justin Kuenzel (jukusoft.com)
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
20
/**
21
 * Project: RocketCMS
22
 * License: Apache 2.0 license
23
 * User: Justin
24
 * Date: 20.03.2018
25
 * Time: 14:13
26
 */
27
28
class Error404Page extends HTMLPage {
29
30
	public function setCustomHeader () {
31
		//set error 404 not found header
32
		header("HTTP/1.0 404 Not Found");
33
	}
34
35
	public function getContent(): string {
36
		//first check, if specific template exists
37
		$current_style = Registry::singleton()->getSetting("current_style_name");
38
		if (file_exists(STYLE_PATH . $current_style . "/pages/error404.tpl")) {
39
			$template = new Template($this->getPage()->hasCustomTemplate() ? $this->getPage()->getCustomTemplate() : "pages/error404");
40
41
			$template->assign("TITLE", $this->getPage()->getTitle());
42
			$template->assign("CONTENT", parent::getContent());
43
44
			$template->parse("main");
45
			return $template->getCode();
46
		} else {
47
			return parent::getContent();
48
		}
49
	}
50
51
}
52
53
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
54