Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
class.tpl.app.xlight.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
TplAppXlight
18
{
19
const
MENU
=
'xlight'
;
20
const
MENU_VERSIONS
=
'xlightVersions'
;
21
const
MENU_SERVICE
=
'xlightService'
;
22
23
const
ACTION_ENABLE
=
'enableXlight'
;
24
const
ACTION_SWITCH_VERSION
=
'switchXlightVersion'
;
25
const
ACTION_CHANGE_PORT
=
'changeXlightPort'
;
26
const
ACTION_INSTALL_SERVICE
=
'installXlightService'
;
27
const
ACTION_REMOVE_SERVICE
=
'removeXlightService'
;
28
40
public
static
function
process
()
41
{
42
global
$bearsamppLang
,
$bearsamppBins
;
43
44
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::XLIGHT
), self::MENU, get_called_class(),
$bearsamppBins
->getXlight()->isEnable());
45
}
46
60
public
static
function
getMenuXlight
()
61
{
62
global
$bearsamppRoot
,
$bearsamppConfig
,
$bearsamppBins
,
$bearsamppLang
;
63
$resultItems = $resultActions =
''
;
64
65
$isEnabled =
$bearsamppBins
->getXlight()->isEnable();
66
67
// Download
68
$resultItems .=
TplAestan::getItemLink
(
69
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
70
HttpClient::getWebsiteUrl
(
'module/xlight'
,
'#releases'
),
71
false
,
72
TplAestan::GLYPH_BROWSER
73
) . PHP_EOL;
74
75
// Enable
76
$tplEnable =
TplApp::getActionMulti
(
77
self::ACTION_ENABLE,
78
array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
79
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
80
false
,
81
get_called_class()
82
);
83
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
84
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
85
86
if
($isEnabled) {
87
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
88
89
// Versions
90
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
91
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
92
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
93
94
// Service
95
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
96
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
97
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
98
99
// Log
100
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_LOGS
),
$bearsamppBins
->getXlight()->getLog()) . PHP_EOL;
101
}
102
103
return
$resultItems . PHP_EOL . $resultActions;
104
}
105
115
public
static
function
getMenuXlightVersions
()
116
{
117
global
$bearsamppBins
;
118
$items =
''
;
119
$actions =
''
;
120
121
foreach
(
$bearsamppBins
->getXlight()->getVersionList() as $version) {
122
$tplSwitchXlightVersion =
TplApp::getActionMulti
(
123
self::ACTION_SWITCH_VERSION,
124
array($version),
125
array($version, $version ==
$bearsamppBins
->getXlight()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
126
false
,
127
get_called_class()
128
);
129
130
// Item
131
$items .= $tplSwitchXlightVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
132
133
// Action
134
$actions .= PHP_EOL . $tplSwitchXlightVersion[
TplApp::SECTION_CONTENT
];
135
}
136
137
return
$items . $actions;
138
}
139
151
public
static
function
getActionEnableXlight
($enable)
152
{
153
global
$bearsamppBins
;
154
155
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getXlight()->getName(), $enable)) . PHP_EOL .
156
TplAppReload::getActionReload
();
157
}
158
170
public
static
function
getActionSwitchXlightVersion
($version)
171
{
172
global
$bearsamppBins
;
173
174
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getXlight()->getName(), $version)) . PHP_EOL .
175
TplAppReload::getActionReload
() . PHP_EOL;
176
}
177
190
public
static
function
getMenuXlightService
()
191
{
192
global
$bearsamppRoot
,
$bearsamppLang
,
$bearsamppBins
;
193
194
$tplChangePort =
TplApp::getActionMulti
(
195
self::ACTION_CHANGE_PORT,
196
null
,
197
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
198
false
,
199
get_called_class()
200
);
201
202
$isInstalled =
$bearsamppBins
->getXlight()->getService()->isInstalled();
203
204
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getXlight()->getService()->getName()) . PHP_EOL .
205
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getXlight()->getService()->getName()) . PHP_EOL .
206
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getXlight()->getService()->getName()) . PHP_EOL .
207
TplAestan::getItemSeparator
() . PHP_EOL .
208
TplApp::getActionRun
(
209
Action::CHECK_PORT
,
210
array(
$bearsamppBins
->getXlight()->getName(),
$bearsamppBins
->getXlight()->getPort()),
211
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getXlight()->getPort()),
TplAestan::GLYPH_LIGHT
)
212
) . PHP_EOL .
213
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL .
214
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_UPDATE_ENV_PATH
),
Path::getRootPath
() .
'/nssmEnvPaths.dat'
) . PHP_EOL;
215
216
if
(!$isInstalled) {
217
$tplInstallService =
TplApp::getActionMulti
(
218
self::ACTION_INSTALL_SERVICE,
219
null
,
220
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
221
$isInstalled,
222
get_called_class()
223
);
224
225
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
226
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
227
}
else
{
228
$tplRemoveService =
TplApp::getActionMulti
(
229
self::ACTION_REMOVE_SERVICE,
230
null
,
231
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
232
!$isInstalled,
233
get_called_class()
234
);
235
236
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
237
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
238
}
239
240
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL;
241
242
return
$result
;
243
}
244
254
public
static
function
getActionChangeXlightPort
()
255
{
256
global
$bearsamppBins
;
257
258
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getXlight()->getName())) . PHP_EOL .
259
TplAppReload::getActionReload
();
260
}
261
269
public
static
function
getActionInstallXlightService
()
270
{
271
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinXlight::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
272
TplAppReload::getActionReload
();
273
}
274
282
public
static
function
getActionRemoveXlightService
()
283
{
284
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinXlight::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
285
TplAppReload::getActionReload
();
286
}
287
}
288
$result
$result
Definition
ajax.apache.php:19
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
Action\SWITCH_VERSION
const SWITCH_VERSION
Definition
class.action.php:56
Action\SERVICE
const SERVICE
Definition
class.action.php:46
Action\CHANGE_PORT
const CHANGE_PORT
Definition
class.action.php:21
Action\CHECK_PORT
const CHECK_PORT
Definition
class.action.php:22
Action\ENABLE
const ENABLE
Definition
class.action.php:31
ActionService\REMOVE
const REMOVE
Definition
class.action.service.php:22
ActionService\INSTALL
const INSTALL
Definition
class.action.service.php:21
BinXlight\SERVICE_NAME
const SERVICE_NAME
Definition
class.bin.xlight.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\SERVICE
const SERVICE
Definition
class.lang.php:66
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:40
Lang\MENU_CHANGE_PORT
const MENU_CHANGE_PORT
Definition
class.lang.php:89
Lang\MENU_INSTALL_SERVICE
const MENU_INSTALL_SERVICE
Definition
class.lang.php:101
Lang\MENU_UPDATE_ENV_PATH
const MENU_UPDATE_ENV_PATH
Definition
class.lang.php:121
Lang\MENU_LOGS
const MENU_LOGS
Definition
class.lang.php:104
Lang\XLIGHT
const XLIGHT
Definition
class.lang.php:136
Lang\MENU_REMOVE_SERVICE
const MENU_REMOVE_SERVICE
Definition
class.lang.php:109
Lang\MENU_CHECK_PORT
const MENU_CHECK_PORT
Definition
class.lang.php:91
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:79
Path\getRootPath
static getRootPath($aetrayPath=false)
Definition
class.path.php:324
TplAestan\GLYPH_LIGHT
const GLYPH_LIGHT
Definition
class.tpl.aestan.php:71
TplAestan\GLYPH_CHECK
const GLYPH_CHECK
Definition
class.tpl.aestan.php:61
TplAestan\GLYPH_NETWORK
const GLYPH_NETWORK
Definition
class.tpl.aestan.php:74
TplAestan\GLYPH_SERVICE_REMOVE
const GLYPH_SERVICE_REMOVE
Definition
class.tpl.aestan.php:55
TplAestan\getItemActionServiceStop
static getItemActionServiceStop($service)
Definition
class.tpl.aestan.php:346
TplAestan\GLYPH_SERVICE_INSTALL
const GLYPH_SERVICE_INSTALL
Definition
class.tpl.aestan.php:56
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\getItemActionServiceStart
static getItemActionServiceStart($service)
Definition
class.tpl.aestan.php:322
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:126
TplAestan\getItemActionServiceRestart
static getItemActionServiceRestart($service)
Definition
class.tpl.aestan.php:370
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
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:47
TplAppXlight
Definition
class.tpl.app.xlight.php:18
TplAppXlight\getMenuXlight
static getMenuXlight()
Definition
class.tpl.app.xlight.php:60
TplAppXlight\getMenuXlightVersions
static getMenuXlightVersions()
Definition
class.tpl.app.xlight.php:115
TplAppXlight\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.xlight.php:23
TplAppXlight\MENU
const MENU
Definition
class.tpl.app.xlight.php:19
TplAppXlight\process
static process()
Definition
class.tpl.app.xlight.php:40
TplAppXlight\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.xlight.php:24
TplAppXlight\getActionChangeXlightPort
static getActionChangeXlightPort()
Definition
class.tpl.app.xlight.php:254
TplAppXlight\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.xlight.php:20
TplAppXlight\getActionEnableXlight
static getActionEnableXlight($enable)
Definition
class.tpl.app.xlight.php:151
TplAppXlight\getMenuXlightService
static getMenuXlightService()
Definition
class.tpl.app.xlight.php:190
TplAppXlight\MENU_SERVICE
const MENU_SERVICE
Definition
class.tpl.app.xlight.php:21
TplAppXlight\getActionRemoveXlightService
static getActionRemoveXlightService()
Definition
class.tpl.app.xlight.php:282
TplAppXlight\getActionSwitchXlightVersion
static getActionSwitchXlightVersion($version)
Definition
class.tpl.app.xlight.php:170
TplAppXlight\ACTION_INSTALL_SERVICE
const ACTION_INSTALL_SERVICE
Definition
class.tpl.app.xlight.php:26
TplAppXlight\ACTION_REMOVE_SERVICE
const ACTION_REMOVE_SERVICE
Definition
class.tpl.app.xlight.php:27
TplAppXlight\getActionInstallXlightService
static getActionInstallXlightService()
Definition
class.tpl.app.xlight.php:269
TplAppXlight\ACTION_CHANGE_PORT
const ACTION_CHANGE_PORT
Definition
class.tpl.app.xlight.php:25
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:46
sandbox
core
classes
tpls
app
class.tpl.app.xlight.php
Generated by
1.17.0