1
|
|
|
<?php |
2
|
|
|
namespace Gilbertsoft\Lib\Utility; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the "GS Library" Extension for TYPO3 CMS. |
6
|
|
|
* |
7
|
|
|
* Copyright (C) 2017 by Gilbertsoft (gilbertsoft.org) |
8
|
|
|
* |
9
|
|
|
* This program is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU General Public License as published by |
11
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
12
|
|
|
* (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* For the full license information, please read the LICENSE file that |
20
|
|
|
* was distributed with this source code. |
21
|
|
|
* |
22
|
|
|
* The TYPO3 project - inspiring people to share! |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Typo3Mode class. |
27
|
|
|
* |
28
|
|
|
* USE: |
29
|
|
|
* The class is intended to be used without creating an instance of it. |
30
|
|
|
* So: Do not instantiate - call functions with "\Gilbertsoft\TYPO3\Warranty\Utility\Provider::" prefixed the function name. |
31
|
|
|
* So use \Gilbertsoft\TYPO3\Warranty\Utility\Provider::[method-name] to refer to the functions, eg. '\Gilbertsoft\TYPO3\Warranty\Utility\Provider::getName()' |
32
|
|
|
*/ |
33
|
|
|
class Typo3Mode |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* Returns TRUE if mode is set. |
37
|
|
|
* |
38
|
|
|
* @return bool |
39
|
|
|
* @api |
40
|
|
|
*/ |
41
|
|
|
public static function checkMode() |
42
|
|
|
{ |
43
|
|
|
return defined('TYPO3_MODE'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Returns TRUE if request type is set. |
48
|
|
|
* |
49
|
|
|
* @return bool |
50
|
|
|
* @api |
51
|
|
|
*/ |
52
|
|
|
public static function checkRequestType() |
53
|
|
|
{ |
54
|
|
|
return defined('TYPO3_REQUESTTYPE'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns TRUE if called in frontend mode. |
59
|
|
|
* |
60
|
|
|
* @return bool |
61
|
|
|
* @api |
62
|
|
|
*/ |
63
|
|
|
public static function isFrontend() |
64
|
|
|
{ |
65
|
|
|
return (self::checkMode() && (TYPO3_MODE == 'FE')) || (self::checkRequestType() && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_FE)); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Returns TRUE if called in backend mode. |
70
|
|
|
* |
71
|
|
|
* @return bool |
72
|
|
|
* @api |
73
|
|
|
*/ |
74
|
|
|
public static function isBackend() |
75
|
|
|
{ |
76
|
|
|
return (self::checkMode() && (TYPO3_MODE == 'BE')) || (self::checkRequestType() && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_BE)); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Returns TRUE if called in CLI mode. |
81
|
|
|
* |
82
|
|
|
* @return bool |
83
|
|
|
* @api |
84
|
|
|
*/ |
85
|
|
|
public static function isCli() |
86
|
|
|
{ |
87
|
|
|
return (defined('TYPO3_cliMode') && TYPO3_cliMode === true) || (self::checkRequestType() && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Returns TRUE if called in ajax mode. |
92
|
|
|
* |
93
|
|
|
* @return bool |
94
|
|
|
* @api |
95
|
|
|
*/ |
96
|
|
|
public static function isAjax() |
97
|
|
|
{ |
98
|
|
|
return ($GLOBALS['TYPO3_AJAX']) || (self::checkRequestType() && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Returns TRUE if called in install mode. |
103
|
|
|
* |
104
|
|
|
* @return bool |
105
|
|
|
* @api |
106
|
|
|
*/ |
107
|
|
|
public static function isInstall() |
108
|
|
|
{ |
109
|
|
|
return (defined('TYPO3_enterInstallScript') && TYPO3_enterInstallScript) || (self::checkRequestType() && (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Returns TRUE if called in composer mode. |
114
|
|
|
* |
115
|
|
|
* @return bool |
116
|
|
|
* @api |
117
|
|
|
*/ |
118
|
|
|
public static function isComposerMode() |
119
|
|
|
{ |
120
|
|
|
return (defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|