1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xoops\Core\Controller; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* XOOPS AbstractController |
16
|
|
|
* |
17
|
|
|
* See the enclosed file license.txt for licensing information. If you did not |
18
|
|
|
* receive this file, get it at GNU http://www.gnu.org/licenses/gpl-2.0.html |
19
|
|
|
* |
20
|
|
|
* @copyright XOOPS Project (http://xoops.org) |
21
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
22
|
|
|
* @package core |
23
|
|
|
* @since 2.0.0 |
24
|
|
|
* @author Alain091 |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
use Xmf\Request; |
28
|
|
|
use Xoops\Core\FixedGroups; |
29
|
|
|
|
30
|
|
|
abstract class AbstractController |
31
|
|
|
{ |
32
|
|
|
protected $xoops; |
33
|
|
|
protected $xoopsBC; |
34
|
|
|
protected $xoops_url; |
35
|
|
|
|
36
|
|
|
protected $startEvent = ''; |
37
|
|
|
protected $endEvent = ''; |
38
|
|
|
|
39
|
|
|
protected $language = ''; |
40
|
|
|
protected $template = ''; |
41
|
|
|
|
42
|
|
|
public function __construct() |
43
|
|
|
{ |
44
|
|
|
$this->xoops = \Xoops::getInstance(); |
45
|
|
|
$this->xoops_url = \XoopsBaseConfig::get('url'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function run() |
49
|
|
|
{ |
50
|
|
|
if (!empty($this->startEvent)) |
51
|
|
|
$this->xoops->events()->triggerEvent($this->startEvent); |
52
|
|
|
$this->doInit(); |
53
|
|
|
if (!$this->doAuth()) { |
54
|
|
|
//$this->xoops->redirect($this->xoops_url, 1, \XoopsLocale::E_NO_ACCESS_PERMISSION, false); |
55
|
|
|
exit; |
|
|
|
|
56
|
|
|
} |
57
|
|
|
$this->doHeader(); |
58
|
|
|
$this->doContent(); |
59
|
|
|
$this->doFooter(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function doInit() |
63
|
|
|
{ |
64
|
|
|
if (!empty($this->language)) |
65
|
|
|
$this->xoops->loadLanguage($this->language); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function doAuth() |
69
|
|
|
{ |
70
|
|
|
return true; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function doHeader() |
74
|
|
|
{ |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function doContent() |
78
|
|
|
{ |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function doFooter() |
82
|
|
|
{ |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.