Bearsampp
2026.7.11
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-2024 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
10
class
TplAppPhp
11
{
12
const
MENU
=
'php'
;
13
const
MENU_VERSIONS
=
'phpVersions'
;
14
const
MENU_SETTINGS
=
'phpSettings'
;
15
const
MENU_EXTENSIONS
=
'phpExtensions'
;
16
17
const
ACTION_ENABLE
=
'enablePhp'
;
18
const
ACTION_SWITCH_VERSION
=
'switchPhpVersion'
;
19
const
ACTION_SWITCH_SETTING
=
'switchPhpSetting'
;
20
const
ACTION_SWITCH_EXTENSION
=
'switchPhpExtension'
;
21
30
public
static
function
process
()
31
{
32
global
$bearsamppLang
,
$bearsamppBins
;
33
34
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::PHP
), self::MENU, get_called_class(),
$bearsamppBins
->getPhp()->isEnable());
35
}
36
45
public
static
function
getMenuPhp
()
46
{
47
global
$bearsamppBins
,
$bearsamppLang
;
48
$resultItems = $resultActions =
''
;
49
50
$isEnabled =
$bearsamppBins
->getPhp()->isEnable();
51
52
// Download
53
$resultItems .=
TplAestan::getItemLink
(
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
54
HttpClient::getWebsiteUrl
(
'module/php'
,
'#releases'
),
55
false
,
56
TplAestan::GLYPH_BROWSER
57
) . PHP_EOL;
58
59
// Enable
60
$tplEnable =
TplApp::getActionMulti
(
61
self::ACTION_ENABLE, array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
62
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
63
false
, get_called_class()
64
);
65
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
66
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
67
68
if
($isEnabled) {
69
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
70
71
// Versions
72
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
73
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
74
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
75
76
// Settings
77
$tplSettings =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SETTINGS
), self::MENU_SETTINGS, get_called_class());
78
$resultItems .= $tplSettings[
TplApp::SECTION_CALL
] . PHP_EOL;
79
$resultActions .= $tplSettings[
TplApp::SECTION_CONTENT
] . PHP_EOL;
80
81
// Extensions
82
$tplExtensions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::EXTENSIONS
), self::MENU_EXTENSIONS, get_called_class());
83
$resultItems .= $tplExtensions[
TplApp::SECTION_CALL
] . PHP_EOL;
84
$resultActions .= $tplExtensions[
TplApp::SECTION_CONTENT
];
85
86
// Conf
87
$resultItems .=
TplAestan::getItemNotepad
(basename(
$bearsamppBins
->getPhp()->getConf()),
$bearsamppBins
->getPhp()->getConf()) . PHP_EOL;
88
89
// Errors log
90
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_ERROR_LOGS
),
$bearsamppBins
->getPhp()->getErrorLog()) . PHP_EOL;
91
}
92
93
return
$resultItems . PHP_EOL . $resultActions;
94
}
95
103
public
static
function
getMenuPhpVersions
()
104
{
105
global
$bearsamppBins
;
106
$items =
''
;
107
$actions =
''
;
108
109
foreach
(
$bearsamppBins
->getPhp()->getVersionList() as $version) {
110
$glyph =
''
;
111
$apachePhpModule =
$bearsamppBins
->getPhp()->getApacheModule(
$bearsamppBins
->getApache()->getVersion(), $version);
112
if
($apachePhpModule ===
false
) {
113
$glyph =
TplAestan::GLYPH_WARNING
;
114
} elseif ($version ==
$bearsamppBins
->getPhp()->getVersion()) {
115
$glyph =
TplAestan::GLYPH_CHECK
;
116
}
117
118
$tplSwitchPhpVersion =
TplApp::getActionMulti
(
119
self::ACTION_SWITCH_VERSION, array($version),
120
array($version, $glyph),
121
false
, get_called_class()
122
);
123
124
// Item
125
$items .= $tplSwitchPhpVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
126
127
// Action
128
$actions .= PHP_EOL . $tplSwitchPhpVersion[
TplApp::SECTION_CONTENT
];
129
}
130
131
return
$items . $actions;
132
}
133
143
public
static
function
getActionEnablePhp
($enable)
144
{
145
global
$bearsamppBins
;
146
147
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getPhp()->getName(), $enable)) . PHP_EOL .
148
TplAppReload::getActionReload
();
149
}
150
160
public
static
function
getActionSwitchPhpVersion
($version)
161
{
162
global
$bearsamppBins
;
163
164
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getPhp()->getName(), $version)) . PHP_EOL .
165
TplAppReload::getActionReload
() . PHP_EOL;
166
}
167
175
public
static
function
getMenuPhpSettings
()
176
{
177
global
$bearsamppBins
;
178
179
$menuItems =
''
;
180
$menuActions =
''
;
181
foreach
(
$bearsamppBins
->getPhp()->getSettings() as $key => $value) {
182
if
(is_array($value)) {
183
$menuItems .=
'Type: submenu; '
.
184
'Caption: "'
. $key .
'"; '
.
185
'SubMenu: MenuPhpSetting-'
. md5($key) .
'; '
.
186
'Glyph: '
.
TplAestan::GLYPH_FOLDER_CLOSE
. PHP_EOL;
187
}
else
{
188
$glyph =
''
;
189
$settingEnabled =
$bearsamppBins
->getPhp()->isSettingActive($value);
190
if
(!
$bearsamppBins
->getPhp()->isSettingExists($value)) {
191
$glyph =
TplAestan::GLYPH_WARNING
;
192
} elseif ($settingEnabled) {
193
$glyph =
TplAestan::GLYPH_CHECK
;
194
}
195
$tplSwitchPhpSetting =
TplApp::getActionMulti
(
196
self::ACTION_SWITCH_SETTING, array($value, $settingEnabled),
197
array($key, $glyph),
198
false
, get_called_class()
199
);
200
201
$menuItems .= $tplSwitchPhpSetting[
TplApp::SECTION_CALL
] . PHP_EOL;
202
$menuActions .= $tplSwitchPhpSetting[
TplApp::SECTION_CONTENT
];
203
}
204
}
205
206
$submenusItems =
''
;
207
$submenusActions =
''
;
208
$submenuKeys =
self::getSubmenuPhpSettings
();
209
foreach
($submenuKeys as $submenuKey) {
210
$submenusItems .= PHP_EOL .
'[MenuPhpSetting-'
. md5($submenuKey) .
']'
.
211
PHP_EOL .
self::getSubmenuPhpSettings
($submenuKey);
212
213
$submenusActions .=
self::getSubmenuPhpSettings
($submenuKey, array(), array(),
false
);
214
}
215
216
return
$menuItems . $submenusItems . PHP_EOL . $menuActions . $submenusActions;
217
}
218
231
private
static
function
getSubmenuPhpSettings
($passThr = array(),
$result
= array(), $settings = array(), $sectionCall =
true
)
232
{
233
global
$bearsamppBins
;
234
$settings = empty($settings) ?
$bearsamppBins
->getPhp()->getSettings() : $settings;
235
236
foreach
($settings as $key => $value) {
237
if
(is_array($value)) {
238
if
(is_array($passThr)) {
239
array_push(
$result
, $key);
240
$result
=
self::getSubmenuPhpSettings
($passThr,
$result
, $value);
241
}
else
{
242
$result
= is_array(
$result
) ?
''
:
$result
;
243
if
($key == $passThr) {
244
foreach
($value as $key2 => $value2) {
245
if
(is_array($value2) && $sectionCall) {
246
$result
.=
'Type: submenu; '
.
247
'Caption: "'
. $key2 .
'"; '
.
248
'SubMenu: MenuPhpSetting-'
. md5($key2) .
'; '
.
249
'Glyph: '
.
TplAestan::GLYPH_FOLDER_CLOSE
. PHP_EOL;
250
} elseif (!is_array($value2)) {
251
$glyph =
''
;
252
$settingEnabled =
$bearsamppBins
->getPhp()->isSettingActive($value2);
253
if
(!
$bearsamppBins
->getPhp()->isSettingExists($value2)) {
254
$glyph =
TplAestan::GLYPH_WARNING
;
255
} elseif ($settingEnabled) {
256
$glyph =
TplAestan::GLYPH_CHECK
;
257
}
258
$tplSwitchPhpSetting =
TplApp::getActionMulti
(
259
self::ACTION_SWITCH_SETTING, array($value2, $settingEnabled),
260
array($key2, $glyph),
261
false
, get_called_class()
262
);
263
264
if
($sectionCall) {
265
$result
.= $tplSwitchPhpSetting[
TplApp::SECTION_CALL
] . PHP_EOL;
266
}
else
{
267
$result
.= $tplSwitchPhpSetting[
TplApp::SECTION_CONTENT
] . PHP_EOL;
268
}
269
}
270
}
271
}
else
{
272
$result
.=
self::getSubmenuPhpSettings
($passThr,
null
, $value, $sectionCall);
273
}
274
}
275
}
276
}
277
278
return
$result
;
279
}
280
289
public
static
function
getActionSwitchPhpSetting
($setting, $enabled)
290
{
291
$switch = $enabled ?
ActionSwitchPhpParam::SWITCH_OFF
:
ActionSwitchPhpParam::SWITCH_ON
;
292
return
TplApp::getActionRun
(
Action::SWITCH_PHP_PARAM
, array($setting, $switch)) . PHP_EOL .
293
TplService::getActionRestart
(
BinApache::SERVICE_NAME
) . PHP_EOL .
294
TplAppReload::getActionReload
() . PHP_EOL;
295
}
296
304
public
static
function
getMenuPhpExtensions
()
305
{
306
global
$bearsamppBins
;
307
$items =
''
;
308
$actions =
''
;
309
310
foreach
(
$bearsamppBins
->getPhp()->getExtensions() as $extension => $switch) {
311
$tplSwitchPhpExtension =
TplApp::getActionMulti
(
312
self::ACTION_SWITCH_EXTENSION, array($extension, $switch),
313
array($extension, ($switch ==
ActionSwitchPhpExtension::SWITCH_ON
?
TplAestan::GLYPH_CHECK
:
''
)),
314
false
, get_called_class()
315
);
316
317
// Item
318
$items .= $tplSwitchPhpExtension[
TplApp::SECTION_CALL
] . PHP_EOL;
319
320
// Action
321
$actions .= PHP_EOL . $tplSwitchPhpExtension[
TplApp::SECTION_CONTENT
];
322
}
323
324
return
$items . $actions;
325
}
326
335
public
static
function
getActionSwitchPhpExtension
($extension, $switch)
336
{
337
$switch = $switch ==
ActionSwitchPhpExtension::SWITCH_OFF
?
ActionSwitchPhpExtension::SWITCH_ON
:
ActionSwitchPhpExtension::SWITCH_OFF
;
338
return
TplApp::getActionRun
(
Action::SWITCH_PHP_EXTENSION
, array($extension, $switch)) . PHP_EOL .
339
TplService::getActionRestart
(
BinApache::SERVICE_NAME
) . PHP_EOL .
340
TplAppReload::getActionReload
() . PHP_EOL;
341
}
342
}
343
$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:19
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:134
Lang\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:98
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:41
Lang\PHP
const PHP
Definition
class.lang.php:127
Lang\MENU_ERROR_LOGS
const MENU_ERROR_LOGS
Definition
class.lang.php:99
Lang\SETTINGS
const SETTINGS
Definition
class.lang.php:68
Lang\EXTENSIONS
const EXTENSIONS
Definition
class.lang.php:45
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:80
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:188
TplAestan\getItemNotepad
static getItemNotepad($caption, $path)
Definition
class.tpl.aestan.php:211
TplAestan\GLYPH_WARNING
const GLYPH_WARNING
Definition
class.tpl.aestan.php:65
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:125
TplApp\getActionMulti
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
Definition
class.tpl.app.php:152
TplApp\getMenu
static getMenu($caption, $menu, $class)
Definition
class.tpl.app.php:190
TplApp\getActionRun
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
Definition
class.tpl.app.php:115
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:212
TplAppPhp
Definition
class.tpl.app.php.php:11
TplAppPhp\getMenuPhpSettings
static getMenuPhpSettings()
Definition
class.tpl.app.php.php:175
TplAppPhp\ACTION_SWITCH_EXTENSION
const ACTION_SWITCH_EXTENSION
Definition
class.tpl.app.php.php:20
TplAppPhp\getMenuPhpExtensions
static getMenuPhpExtensions()
Definition
class.tpl.app.php.php:304
TplAppPhp\getActionSwitchPhpVersion
static getActionSwitchPhpVersion($version)
Definition
class.tpl.app.php.php:160
TplAppPhp\MENU_EXTENSIONS
const MENU_EXTENSIONS
Definition
class.tpl.app.php.php:15
TplAppPhp\getMenuPhpVersions
static getMenuPhpVersions()
Definition
class.tpl.app.php.php:103
TplAppPhp\getActionSwitchPhpSetting
static getActionSwitchPhpSetting($setting, $enabled)
Definition
class.tpl.app.php.php:289
TplAppPhp\ACTION_SWITCH_SETTING
const ACTION_SWITCH_SETTING
Definition
class.tpl.app.php.php:19
TplAppPhp\getMenuPhp
static getMenuPhp()
Definition
class.tpl.app.php.php:45
TplAppPhp\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.php.php:17
TplAppPhp\MENU
const MENU
Definition
class.tpl.app.php.php:12
TplAppPhp\process
static process()
Definition
class.tpl.app.php.php:30
TplAppPhp\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.php.php:18
TplAppPhp\getSubmenuPhpSettings
static getSubmenuPhpSettings($passThr=array(), $result=array(), $settings=array(), $sectionCall=true)
Definition
class.tpl.app.php.php:231
TplAppPhp\getActionSwitchPhpExtension
static getActionSwitchPhpExtension($extension, $switch)
Definition
class.tpl.app.php.php:335
TplAppPhp\MENU_SETTINGS
const MENU_SETTINGS
Definition
class.tpl.app.php.php:14
TplAppPhp\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.php.php:13
TplAppPhp\getActionEnablePhp
static getActionEnablePhp($enable)
Definition
class.tpl.app.php.php:143
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:44
TplService\getActionRestart
static getActionRestart($sName)
Definition
class.tpl.service.php:51
sandbox
core
classes
tpls
app
class.tpl.app.php.php
Generated by
1.17.0