Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
class.tpl.app.php.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2026 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
17
class
TplAppPhp
18
{
19
const
MENU
=
'php'
;
20
const
MENU_VERSIONS
=
'phpVersions'
;
21
const
MENU_SETTINGS
=
'phpSettings'
;
22
const
MENU_EXTENSIONS
=
'phpExtensions'
;
23
24
const
ACTION_ENABLE
=
'enablePhp'
;
25
const
ACTION_SWITCH_VERSION
=
'switchPhpVersion'
;
26
const
ACTION_SWITCH_SETTING
=
'switchPhpSetting'
;
27
const
ACTION_SWITCH_EXTENSION
=
'switchPhpExtension'
;
28
37
public
static
function
process
()
38
{
39
global
$bearsamppLang
,
$bearsamppBins
;
40
41
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::PHP
), self::MENU, get_called_class(),
$bearsamppBins
->getPhp()->isEnable());
42
}
43
52
public
static
function
getMenuPhp
()
53
{
54
global
$bearsamppBins
,
$bearsamppLang
;
55
$resultItems = $resultActions =
''
;
56
57
$isEnabled =
$bearsamppBins
->getPhp()->isEnable();
58
59
// Download
60
$resultItems .=
TplAestan::getItemLink
(
61
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
62
HttpClient::getWebsiteUrl
(
'module/php'
,
'#releases'
),
63
false
,
64
TplAestan::GLYPH_BROWSER
65
) . PHP_EOL;
66
67
// Enable
68
$tplEnable =
TplApp::getActionMulti
(
69
self::ACTION_ENABLE,
70
array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
71
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
72
false
,
73
get_called_class()
74
);
75
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
76
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
77
78
if
($isEnabled) {
79
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
80
81
// Versions
82
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
83
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
84
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
85
86
// Settings
87
$tplSettings =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SETTINGS
), self::MENU_SETTINGS, get_called_class());
88
$resultItems .= $tplSettings[
TplApp::SECTION_CALL
] . PHP_EOL;
89
$resultActions .= $tplSettings[
TplApp::SECTION_CONTENT
] . PHP_EOL;
90
91
// Extensions
92
$tplExtensions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::EXTENSIONS
), self::MENU_EXTENSIONS, get_called_class());
93
$resultItems .= $tplExtensions[
TplApp::SECTION_CALL
] . PHP_EOL;
94
$resultActions .= $tplExtensions[
TplApp::SECTION_CONTENT
];
95
96
// Conf
97
$resultItems .=
TplAestan::getItemNotepad
(basename(
$bearsamppBins
->getPhp()->getConf()),
$bearsamppBins
->getPhp()->getConf()) . PHP_EOL;
98
99
// Errors log
100
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_ERROR_LOGS
),
$bearsamppBins
->getPhp()->getErrorLog()) . PHP_EOL;
101
}
102
103
return
$resultItems . PHP_EOL . $resultActions;
104
}
105
113
public
static
function
getMenuPhpVersions
()
114
{
115
global
$bearsamppBins
;
116
$items =
''
;
117
$actions =
''
;
118
119
foreach
(
$bearsamppBins
->getPhp()->getVersionList() as $version) {
120
$glyph =
''
;
121
$apachePhpModule =
$bearsamppBins
->getPhp()->getApacheModule(
$bearsamppBins
->getApache()->getVersion(), $version);
122
if
($apachePhpModule ===
false
) {
123
$glyph =
TplAestan::GLYPH_WARNING
;
124
} elseif ($version ==
$bearsamppBins
->getPhp()->getVersion()) {
125
$glyph =
TplAestan::GLYPH_CHECK
;
126
}
127
128
$tplSwitchPhpVersion =
TplApp::getActionMulti
(
129
self::ACTION_SWITCH_VERSION,
130
array($version),
131
array($version, $glyph),
132
false
,
133
get_called_class()
134
);
135
136
// Item
137
$items .= $tplSwitchPhpVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
138
139
// Action
140
$actions .= PHP_EOL . $tplSwitchPhpVersion[
TplApp::SECTION_CONTENT
];
141
}
142
143
return
$items . $actions;
144
}
145
155
public
static
function
getActionEnablePhp
($enable)
156
{
157
global
$bearsamppBins
;
158
159
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getPhp()->getName(), $enable)) . PHP_EOL .
160
TplAppReload::getActionReload
();
161
}
162
172
public
static
function
getActionSwitchPhpVersion
($version)
173
{
174
global
$bearsamppBins
;
175
176
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getPhp()->getName(), $version)) . PHP_EOL .
177
TplAppReload::getActionReload
() . PHP_EOL;
178
}
179
187
public
static
function
getMenuPhpSettings
()
188
{
189
global
$bearsamppBins
;
190
191
$menuItems =
''
;
192
$menuActions =
''
;
193
foreach
(
$bearsamppBins
->getPhp()->getSettings() as $key => $value) {
194
if
(is_array($value)) {
195
$menuItems .=
'Type: submenu; '
.
196
'Caption: "'
. $key .
'"; '
.
197
'SubMenu: MenuPhpSetting-'
. md5($key) .
'; '
.
198
'Glyph: '
.
TplAestan::GLYPH_FOLDER_CLOSE
. PHP_EOL;
199
}
else
{
200
$glyph =
''
;
201
$settingEnabled =
$bearsamppBins
->getPhp()->isSettingActive($value);
202
if
(!
$bearsamppBins
->getPhp()->isSettingExists($value)) {
203
$glyph =
TplAestan::GLYPH_WARNING
;
204
} elseif ($settingEnabled) {
205
$glyph =
TplAestan::GLYPH_CHECK
;
206
}
207
$tplSwitchPhpSetting =
TplApp::getActionMulti
(
208
self::ACTION_SWITCH_SETTING,
209
array($value, $settingEnabled),
210
array($key, $glyph),
211
false
,
212
get_called_class()
213
);
214
215
$menuItems .= $tplSwitchPhpSetting[
TplApp::SECTION_CALL
] . PHP_EOL;
216
$menuActions .= $tplSwitchPhpSetting[
TplApp::SECTION_CONTENT
];
217
}
218
}
219
220
$submenusItems =
''
;
221
$submenusActions =
''
;
222
$submenuKeys =
self::getSubmenuPhpSettings
();
223
foreach
($submenuKeys as $submenuKey) {
224
$submenusItems .= PHP_EOL .
'[MenuPhpSetting-'
. md5($submenuKey) .
']'
.
225
PHP_EOL .
self::getSubmenuPhpSettings
($submenuKey);
226
227
$submenusActions .=
self::getSubmenuPhpSettings
($submenuKey, array(), array(),
false
);
228
}
229
230
return
$menuItems . $submenusItems . PHP_EOL . $menuActions . $submenusActions;
231
}
232
245
private
static
function
getSubmenuPhpSettings
($passThr = array(),
$result
= array(), $settings = array(), $sectionCall =
true
)
246
{
247
global
$bearsamppBins
;
248
$settings = empty($settings) ?
$bearsamppBins
->getPhp()->getSettings() : $settings;
249
250
foreach
($settings as $key => $value) {
251
if
(is_array($value)) {
252
if
(is_array($passThr)) {
253
array_push(
$result
, $key);
254
$result
=
self::getSubmenuPhpSettings
($passThr,
$result
, $value);
255
}
else
{
256
$result
= is_array(
$result
) ?
''
:
$result
;
257
if
($key == $passThr) {
258
foreach
($value as $key2 => $value2) {
259
if
(is_array($value2) && $sectionCall) {
260
$result
.=
'Type: submenu; '
.
261
'Caption: "'
. $key2 .
'"; '
.
262
'SubMenu: MenuPhpSetting-'
. md5($key2) .
'; '
.
263
'Glyph: '
.
TplAestan::GLYPH_FOLDER_CLOSE
. PHP_EOL;
264
} elseif (!is_array($value2)) {
265
$glyph =
''
;
266
$settingEnabled =
$bearsamppBins
->getPhp()->isSettingActive($value2);
267
if
(!
$bearsamppBins
->getPhp()->isSettingExists($value2)) {
268
$glyph =
TplAestan::GLYPH_WARNING
;
269
} elseif ($settingEnabled) {
270
$glyph =
TplAestan::GLYPH_CHECK
;
271
}
272
$tplSwitchPhpSetting =
TplApp::getActionMulti
(
273
self::ACTION_SWITCH_SETTING,
274
array($value2, $settingEnabled),
275
array($key2, $glyph),
276
false
,
277
get_called_class()
278
);
279
280
if
($sectionCall) {
281
$result
.= $tplSwitchPhpSetting[
TplApp::SECTION_CALL
] . PHP_EOL;
282
}
else
{
283
$result
.= $tplSwitchPhpSetting[
TplApp::SECTION_CONTENT
] . PHP_EOL;
284
}
285
}
286
}
287
}
else
{
288
$result
.=
self::getSubmenuPhpSettings
($passThr,
null
, $value, $sectionCall);
289
}
290
}
291
}
292
}
293
294
return
$result
;
295
}
296
305
public
static
function
getActionSwitchPhpSetting
($setting, $enabled)
306
{
307
$switch = $enabled ?
ActionSwitchPhpParam::SWITCH_OFF
:
ActionSwitchPhpParam::SWITCH_ON
;
308
309
return
TplApp::getActionRun
(
Action::SWITCH_PHP_PARAM
, array($setting, $switch)) . PHP_EOL .
310
TplService::getActionRestart
(
BinApache::SERVICE_NAME
) . PHP_EOL .
311
TplAppReload::getActionReload
() . PHP_EOL;
312
}
313
321
public
static
function
getMenuPhpExtensions
()
322
{
323
global
$bearsamppBins
;
324
$items =
''
;
325
$actions =
''
;
326
327
foreach
(
$bearsamppBins
->getPhp()->getExtensions() as $extension => $switch) {
328
$tplSwitchPhpExtension =
TplApp::getActionMulti
(
329
self::ACTION_SWITCH_EXTENSION,
330
array($extension, $switch),
331
array($extension, ($switch ==
ActionSwitchPhpExtension::SWITCH_ON
?
TplAestan::GLYPH_CHECK
:
''
)),
332
false
,
333
get_called_class()
334
);
335
336
// Item
337
$items .= $tplSwitchPhpExtension[
TplApp::SECTION_CALL
] . PHP_EOL;
338
339
// Action
340
$actions .= PHP_EOL . $tplSwitchPhpExtension[
TplApp::SECTION_CONTENT
];
341
}
342
343
return
$items . $actions;
344
}
345
354
public
static
function
getActionSwitchPhpExtension
($extension, $switch)
355
{
356
$switch = $switch ==
ActionSwitchPhpExtension::SWITCH_OFF
?
ActionSwitchPhpExtension::SWITCH_ON
:
ActionSwitchPhpExtension::SWITCH_OFF
;
357
358
return
TplApp::getActionRun
(
Action::SWITCH_PHP_EXTENSION
, array($extension, $switch)) . PHP_EOL .
359
TplService::getActionRestart
(
BinApache::SERVICE_NAME
) . PHP_EOL .
360
TplAppReload::getActionReload
() . PHP_EOL;
361
}
362
}
363
$result
$result
Definition
ajax.apache.php:19
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Action\SWITCH_VERSION
const SWITCH_VERSION
Definition
class.action.php:56
Action\SWITCH_PHP_EXTENSION
const SWITCH_PHP_EXTENSION
Definition
class.action.php:53
Action\SWITCH_PHP_PARAM
const SWITCH_PHP_PARAM
Definition
class.action.php:54
Action\ENABLE
const ENABLE
Definition
class.action.php:31
ActionSwitchPhpExtension\SWITCH_OFF
const SWITCH_OFF
Definition
class.action.switchPhpExtension.php:18
ActionSwitchPhpExtension\SWITCH_ON
const SWITCH_ON
Definition
class.action.switchPhpExtension.php:17
ActionSwitchPhpParam\SWITCH_OFF
const SWITCH_OFF
Definition
class.action.switchPhpParam.php:19
ActionSwitchPhpParam\SWITCH_ON
const SWITCH_ON
Definition
class.action.switchPhpParam.php:18
BinApache\SERVICE_NAME
const SERVICE_NAME
Definition
class.bin.apache.php:22
Config\DISABLED
const DISABLED
Definition
class.config.php:36
Config\ENABLED
const ENABLED
Definition
class.config.php:35
HttpClient\getWebsiteUrl
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
Definition
class.httpclient.php:131
Lang\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:97
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:40
Lang\PHP
const PHP
Definition
class.lang.php:128
Lang\MENU_ERROR_LOGS
const MENU_ERROR_LOGS
Definition
class.lang.php:98
Lang\SETTINGS
const SETTINGS
Definition
class.lang.php:67
Lang\EXTENSIONS
const EXTENSIONS
Definition
class.lang.php:44
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:79
TplAestan\GLYPH_CHECK
const GLYPH_CHECK
Definition
class.tpl.aestan.php:61
TplAestan\GLYPH_FOLDER_CLOSE
const GLYPH_FOLDER_CLOSE
Definition
class.tpl.aestan.php:52
TplAestan\GLYPH_BROWSER
const GLYPH_BROWSER
Definition
class.tpl.aestan.php:53
TplAestan\getItemLink
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
Definition
class.tpl.aestan.php:191
TplAestan\getItemNotepad
static getItemNotepad($caption, $path)
Definition
class.tpl.aestan.php:215
TplAestan\GLYPH_WARNING
const GLYPH_WARNING
Definition
class.tpl.aestan.php:65
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:126
TplApp\getActionMulti
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
Definition
class.tpl.app.php:153
TplApp\getMenu
static getMenu($caption, $menu, $class)
Definition
class.tpl.app.php:191
TplApp\getActionRun
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
Definition
class.tpl.app.php:116
TplApp\SECTION_CALL
const SECTION_CALL
Definition
class.tpl.app.php:23
TplApp\SECTION_CONTENT
const SECTION_CONTENT
Definition
class.tpl.app.php:24
TplApp\getMenuEnable
static getMenuEnable($caption, $menu, $class, $enabled=true)
Definition
class.tpl.app.php:213
TplAppPhp
Definition
class.tpl.app.php.php:18
TplAppPhp\getMenuPhpSettings
static getMenuPhpSettings()
Definition
class.tpl.app.php.php:187
TplAppPhp\ACTION_SWITCH_EXTENSION
const ACTION_SWITCH_EXTENSION
Definition
class.tpl.app.php.php:27
TplAppPhp\getMenuPhpExtensions
static getMenuPhpExtensions()
Definition
class.tpl.app.php.php:321
TplAppPhp\getActionSwitchPhpVersion
static getActionSwitchPhpVersion($version)
Definition
class.tpl.app.php.php:172
TplAppPhp\MENU_EXTENSIONS
const MENU_EXTENSIONS
Definition
class.tpl.app.php.php:22
TplAppPhp\getMenuPhpVersions
static getMenuPhpVersions()
Definition
class.tpl.app.php.php:113
TplAppPhp\getActionSwitchPhpSetting
static getActionSwitchPhpSetting($setting, $enabled)
Definition
class.tpl.app.php.php:305
TplAppPhp\ACTION_SWITCH_SETTING
const ACTION_SWITCH_SETTING
Definition
class.tpl.app.php.php:26
TplAppPhp\getMenuPhp
static getMenuPhp()
Definition
class.tpl.app.php.php:52
TplAppPhp\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.php.php:24
TplAppPhp\MENU
const MENU
Definition
class.tpl.app.php.php:19
TplAppPhp\process
static process()
Definition
class.tpl.app.php.php:37
TplAppPhp\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.php.php:25
TplAppPhp\getSubmenuPhpSettings
static getSubmenuPhpSettings($passThr=array(), $result=array(), $settings=array(), $sectionCall=true)
Definition
class.tpl.app.php.php:245
TplAppPhp\getActionSwitchPhpExtension
static getActionSwitchPhpExtension($extension, $switch)
Definition
class.tpl.app.php.php:354
TplAppPhp\MENU_SETTINGS
const MENU_SETTINGS
Definition
class.tpl.app.php.php:21
TplAppPhp\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.php.php:20
TplAppPhp\getActionEnablePhp
static getActionEnablePhp($enable)
Definition
class.tpl.app.php.php:155
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:47
TplService\getActionRestart
static getActionRestart($sName)
Definition
class.tpl.service.php:62
sandbox
core
classes
tpls
app
class.tpl.app.php.php
Generated by
1.17.0