1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Cadmium\System\Frames\Site |
5
|
|
|
* @author Anton Romanov |
6
|
|
|
* @copyright Copyright (c) 2015-2017, Anton Romanov |
7
|
|
|
* @link http://cadmium-cms.com |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Frames\Site { |
11
|
|
|
|
12
|
|
|
use Frames, Frames\Status, Modules\Auth, Modules\Settings, Ajax, Request, Template; |
13
|
|
|
|
14
|
|
|
abstract class Section extends Frames\Section { |
15
|
|
|
|
16
|
|
|
# Define active section |
17
|
|
|
|
18
|
|
|
const SECTION = SECTION_SITE; |
19
|
|
|
|
20
|
|
|
# Define phrases list |
21
|
|
|
|
22
|
|
|
const PHRASES = ['Common', 'Mail', 'Range', 'Site', 'User']; |
23
|
|
|
|
24
|
|
|
# Page settings |
25
|
|
|
|
26
|
|
|
protected $_title = '', $_layout = 'Common'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Handle an auth area request |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
private function handleAuthArea() { |
33
|
|
|
|
34
|
|
|
# Check auth |
35
|
|
|
|
36
|
|
|
if (Auth::check()) Request::redirect(INSTALL_PATH . '/profile'); |
37
|
|
|
|
38
|
|
|
# ------------------------ |
39
|
|
|
|
40
|
|
|
return $this->handleCommonArea(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Handle an authorized area request |
45
|
|
|
*/ |
46
|
|
|
|
47
|
|
|
private function handleAuthorizedArea() { |
48
|
|
|
|
49
|
|
|
# Check auth |
50
|
|
|
|
51
|
|
|
if (!Auth::check() || ((false !== Request::get('logout')) && Auth::logout())) { |
52
|
|
|
|
53
|
|
|
Request::redirect(INSTALL_PATH . '/profile/login'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
# ------------------------ |
57
|
|
|
|
58
|
|
|
return $this->handleCommonArea(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Handle a common area request |
63
|
|
|
*/ |
64
|
|
|
|
65
|
|
|
private function handleCommonArea() { |
66
|
|
|
|
67
|
|
|
# Handle request |
68
|
|
|
|
69
|
|
|
$result = $this->handle(Request::isAjax()); |
|
|
|
|
70
|
|
|
|
71
|
|
|
if (Template::isBlock($result)) return (new View($this->_title, $this->_layout))->display($result); |
|
|
|
|
72
|
|
|
|
73
|
|
|
if (Ajax::isResponse($result)) return Ajax::output($result); |
|
|
|
|
74
|
|
|
|
75
|
|
|
# ------------------------ |
76
|
|
|
|
77
|
|
|
return Status::displayError404(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* The branch method for the site section |
82
|
|
|
*/ |
83
|
|
|
|
84
|
|
|
protected function _section() { |
85
|
|
|
|
86
|
|
|
# Check site status |
87
|
|
|
|
88
|
|
|
if (Settings::get('site_status') === STATUS_MAINTENANCE) return Status::displayMaintenance(); |
89
|
|
|
|
90
|
|
|
if (Settings::get('site_status') === STATUS_UPDATE) return Status::displayUpdate(); |
91
|
|
|
|
92
|
|
|
# Handle request |
93
|
|
|
|
94
|
|
|
if ($this instanceof Area\Auth) return $this->handleAuthArea(); |
95
|
|
|
|
96
|
|
|
if ($this instanceof Area\Authorized) return $this->handleAuthorizedArea(); |
97
|
|
|
|
98
|
|
|
if ($this instanceof Area\Common) return $this->handleCommonArea(); |
99
|
|
|
|
100
|
|
|
# ------------------------ |
101
|
|
|
|
102
|
|
|
return Status::displayError404(); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.