Bearsampp
2026.7.11
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-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
TplAppXlight
11
{
12
const
MENU
=
'xlight'
;
13
const
MENU_VERSIONS
=
'xlightVersions'
;
14
const
MENU_SERVICE
=
'xlightService'
;
15
16
const
ACTION_ENABLE
=
'enableXlight'
;
17
const
ACTION_SWITCH_VERSION
=
'switchXlightVersion'
;
18
const
ACTION_CHANGE_PORT
=
'changeXlightPort'
;
19
const
ACTION_INSTALL_SERVICE
=
'installXlightService'
;
20
const
ACTION_REMOVE_SERVICE
=
'removeXlightService'
;
21
33
public
static
function
process
()
34
{
35
global
$bearsamppLang
,
$bearsamppBins
;
36
37
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::XLIGHT
), self::MENU, get_called_class(),
$bearsamppBins
->getXlight()->isEnable());
38
}
39
53
public
static
function
getMenuXlight
()
54
{
55
global
$bearsamppRoot
,
$bearsamppConfig
,
$bearsamppBins
,
$bearsamppLang
;
56
$resultItems = $resultActions =
''
;
57
58
$isEnabled =
$bearsamppBins
->getXlight()->isEnable();
59
60
// Download
61
$resultItems .=
TplAestan::getItemLink
(
62
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
63
HttpClient::getWebsiteUrl
(
'module/xlight'
,
'#releases'
),
64
false
,
65
TplAestan::GLYPH_BROWSER
66
) . PHP_EOL;
67
68
// Enable
69
$tplEnable =
TplApp::getActionMulti
(
70
self::ACTION_ENABLE, array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
71
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
72
false
, get_called_class()
73
);
74
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
75
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
76
77
if
($isEnabled) {
78
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
79
80
// Versions
81
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
82
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
83
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
84
85
// Service
86
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
87
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
88
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
89
90
// Log
91
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_LOGS
),
$bearsamppBins
->getXlight()->getLog()) . PHP_EOL;
92
}
93
94
return
$resultItems . PHP_EOL . $resultActions;
95
}
96
106
public
static
function
getMenuXlightVersions
()
107
{
108
global
$bearsamppBins
;
109
$items =
''
;
110
$actions =
''
;
111
112
foreach
(
$bearsamppBins
->getXlight()->getVersionList() as $version) {
113
$tplSwitchXlightVersion =
TplApp::getActionMulti
(
114
self::ACTION_SWITCH_VERSION, array($version),
115
array($version, $version ==
$bearsamppBins
->getXlight()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
116
false
, get_called_class()
117
);
118
119
// Item
120
$items .= $tplSwitchXlightVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
121
122
// Action
123
$actions .= PHP_EOL . $tplSwitchXlightVersion[
TplApp::SECTION_CONTENT
];
124
}
125
126
return
$items . $actions;
127
}
128
139
public
static
function
getActionEnableXlight
($enable)
140
{
141
global
$bearsamppBins
;
142
143
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getXlight()->getName(), $enable)) . PHP_EOL .
144
TplAppReload::getActionReload
();
145
}
146
157
public
static
function
getActionSwitchXlightVersion
($version)
158
{
159
global
$bearsamppBins
;
160
161
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getXlight()->getName(), $version)) . PHP_EOL .
162
TplAppReload::getActionReload
() . PHP_EOL;
163
}
164
177
public
static
function
getMenuXlightService
()
178
{
179
global
$bearsamppRoot
,
$bearsamppLang
,
$bearsamppBins
;
180
181
$tplChangePort =
TplApp::getActionMulti
(
182
self::ACTION_CHANGE_PORT,
null
,
183
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
184
false
, get_called_class()
185
);
186
187
$isInstalled =
$bearsamppBins
->getXlight()->getService()->isInstalled();
188
189
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getXlight()->getService()->getName()) . PHP_EOL .
190
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getXlight()->getService()->getName()) . PHP_EOL .
191
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getXlight()->getService()->getName()) . PHP_EOL .
192
TplAestan::getItemSeparator
() . PHP_EOL .
193
TplApp::getActionRun
(
194
Action::CHECK_PORT
, array(
$bearsamppBins
->getXlight()->getName(),
$bearsamppBins
->getXlight()->getPort()),
195
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getXlight()->getPort()),
TplAestan::GLYPH_LIGHT
)
196
) . PHP_EOL .
197
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL .
198
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_UPDATE_ENV_PATH
),
Path::getRootPath
() .
'/nssmEnvPaths.dat'
) . PHP_EOL;
199
200
if
(!$isInstalled) {
201
$tplInstallService =
TplApp::getActionMulti
(
202
self::ACTION_INSTALL_SERVICE,
null
,
203
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
204
$isInstalled, get_called_class()
205
);
206
207
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
208
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
209
}
else
{
210
$tplRemoveService =
TplApp::getActionMulti
(
211
self::ACTION_REMOVE_SERVICE,
null
,
212
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
213
!$isInstalled, get_called_class()
214
);
215
216
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
217
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
218
}
219
220
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL;
221
222
return
$result
;
223
}
224
234
public
static
function
getActionChangeXlightPort
()
235
{
236
global
$bearsamppBins
;
237
238
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getXlight()->getName())) . PHP_EOL .
239
TplAppReload::getActionReload
();
240
}
241
249
public
static
function
getActionInstallXlightService
()
250
{
251
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinXlight::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
252
TplAppReload::getActionReload
();
253
}
254
262
public
static
function
getActionRemoveXlightService
()
263
{
264
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinXlight::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
265
TplAppReload::getActionReload
();
266
}
267
}
268
$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: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\SERVICE
const SERVICE
Definition
class.lang.php:67
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:41
Lang\MENU_CHANGE_PORT
const MENU_CHANGE_PORT
Definition
class.lang.php:90
Lang\MENU_INSTALL_SERVICE
const MENU_INSTALL_SERVICE
Definition
class.lang.php:102
Lang\MENU_UPDATE_ENV_PATH
const MENU_UPDATE_ENV_PATH
Definition
class.lang.php:122
Lang\MENU_LOGS
const MENU_LOGS
Definition
class.lang.php:105
Lang\XLIGHT
const XLIGHT
Definition
class.lang.php:135
Lang\MENU_REMOVE_SERVICE
const MENU_REMOVE_SERVICE
Definition
class.lang.php:110
Lang\MENU_CHECK_PORT
const MENU_CHECK_PORT
Definition
class.lang.php:92
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:80
Path\getRootPath
static getRootPath($aetrayPath=false)
Definition
class.path.php:309
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:335
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:188
TplAestan\getItemNotepad
static getItemNotepad($caption, $path)
Definition
class.tpl.aestan.php:211
TplAestan\getItemActionServiceStart
static getItemActionServiceStart($service)
Definition
class.tpl.aestan.php:313
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:125
TplAestan\getItemActionServiceRestart
static getItemActionServiceRestart($service)
Definition
class.tpl.aestan.php:357
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
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:44
TplAppXlight
Definition
class.tpl.app.xlight.php:11
TplAppXlight\getMenuXlight
static getMenuXlight()
Definition
class.tpl.app.xlight.php:53
TplAppXlight\getMenuXlightVersions
static getMenuXlightVersions()
Definition
class.tpl.app.xlight.php:106
TplAppXlight\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.xlight.php:16
TplAppXlight\MENU
const MENU
Definition
class.tpl.app.xlight.php:12
TplAppXlight\process
static process()
Definition
class.tpl.app.xlight.php:33
TplAppXlight\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.xlight.php:17
TplAppXlight\getActionChangeXlightPort
static getActionChangeXlightPort()
Definition
class.tpl.app.xlight.php:234
TplAppXlight\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.xlight.php:13
TplAppXlight\getActionEnableXlight
static getActionEnableXlight($enable)
Definition
class.tpl.app.xlight.php:139
TplAppXlight\getMenuXlightService
static getMenuXlightService()
Definition
class.tpl.app.xlight.php:177
TplAppXlight\MENU_SERVICE
const MENU_SERVICE
Definition
class.tpl.app.xlight.php:14
TplAppXlight\getActionRemoveXlightService
static getActionRemoveXlightService()
Definition
class.tpl.app.xlight.php:262
TplAppXlight\getActionSwitchXlightVersion
static getActionSwitchXlightVersion($version)
Definition
class.tpl.app.xlight.php:157
TplAppXlight\ACTION_INSTALL_SERVICE
const ACTION_INSTALL_SERVICE
Definition
class.tpl.app.xlight.php:19
TplAppXlight\ACTION_REMOVE_SERVICE
const ACTION_REMOVE_SERVICE
Definition
class.tpl.app.xlight.php:20
TplAppXlight\getActionInstallXlightService
static getActionInstallXlightService()
Definition
class.tpl.app.xlight.php:249
TplAppXlight\ACTION_CHANGE_PORT
const ACTION_CHANGE_PORT
Definition
class.tpl.app.xlight.php:18
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:41
sandbox
core
classes
tpls
app
class.tpl.app.xlight.php
Generated by
1.17.0