Bearsampp 2026.9.23
Loading...
Searching...
No Matches
TplAppXlight Class Reference

Static Public Member Functions

static getActionChangeXlightPort ()
static getActionEnableXlight ($enable)
static getActionInstallXlightService ()
static getActionRemoveXlightService ()
static getActionSwitchXlightVersion ($version)
static getMenuXlight ()
static getMenuXlightService ()
static getMenuXlightVersions ()
static process ()

Data Fields

const ACTION_CHANGE_PORT = 'changeXlightPort'
const ACTION_ENABLE = 'enableXlight'
const ACTION_INSTALL_SERVICE = 'installXlightService'
const ACTION_REMOVE_SERVICE = 'removeXlightService'
const ACTION_SWITCH_VERSION = 'switchXlightVersion'
const MENU = 'xlight'
const MENU_SERVICE = 'xlightService'
const MENU_VERSIONS = 'xlightVersions'

Detailed Description

Class TplAppXlight

This class provides methods to generate menu items and actions for managing Xlight within the Bearsampp application. It includes functionalities for enabling/disabling Xlight, switching versions, changing ports, and managing the Xlight service.

Definition at line 17 of file class.tpl.app.xlight.php.

Member Function Documentation

◆ getActionChangeXlightPort()

getActionChangeXlightPort ( )
static

Generates the action to change the Xlight port.

This method creates the action string for changing the Xlight port and includes a command to reload the application.

Returns
string The generated action string for changing the Xlight port. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 254 of file class.tpl.app.xlight.php.

255 {
256 global $bearsamppBins;
257
258 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getXlight()->getName())) . PHP_EOL .
260 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

References $bearsamppBins, Action\CHANGE_PORT, TplAppReload\getActionReload(), and TplApp\getActionRun().

Here is the call graph for this function:

◆ getActionEnableXlight()

getActionEnableXlight ( $enable)
static

Generates the action to enable or disable Xlight.

This method creates the action string for enabling or disabling Xlight and includes a command to reload the application.

Parameters
int$enableThe enable flag (1 to enable, 0 to disable).
Returns
string The generated action string for enabling or disabling Xlight. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 151 of file class.tpl.app.xlight.php.

152 {
153 global $bearsamppBins;
154
155 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getXlight()->getName(), $enable)) . PHP_EOL .
157 }
const ENABLE

References $bearsamppBins, Action\ENABLE, TplAppReload\getActionReload(), and TplApp\getActionRun().

Here is the call graph for this function:

◆ getActionInstallXlightService()

getActionInstallXlightService ( )
static

Generates the action to install the Xlight service.

This method creates the action string for installing the Xlight service and includes a command to reload the application.

Returns
string The generated action string for installing the Xlight service.

Definition at line 269 of file class.tpl.app.xlight.php.

References TplAppReload\getActionReload(), TplApp\getActionRun(), ActionService\INSTALL, Action\SERVICE, and BinXlight\SERVICE_NAME.

Here is the call graph for this function:

◆ getActionRemoveXlightService()

getActionRemoveXlightService ( )
static

Generates the action to remove the Xlight service.

This method creates the action string for removing the Xlight service and includes a command to reload the application.

Returns
string The generated action string for removing the Xlight service.

Definition at line 282 of file class.tpl.app.xlight.php.

References TplAppReload\getActionReload(), TplApp\getActionRun(), ActionService\REMOVE, Action\SERVICE, and BinXlight\SERVICE_NAME.

Here is the call graph for this function:

◆ getActionSwitchXlightVersion()

getActionSwitchXlightVersion ( $version)
static

Generates the action to switch the Xlight version.

This method creates the action string for switching the Xlight version and includes a command to reload the application.

Parameters
string$versionThe version to switch to.
Returns
string The generated action string for switching the Xlight version. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 170 of file class.tpl.app.xlight.php.

171 {
172 global $bearsamppBins;
173
174 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getXlight()->getName(), $version)) . PHP_EOL .
176 }
const SWITCH_VERSION

References $bearsamppBins, TplAppReload\getActionReload(), TplApp\getActionRun(), and Action\SWITCH_VERSION.

Here is the call graph for this function:

◆ getMenuXlight()

getMenuXlight ( )
static

Generates the Xlight menu.

This method creates the menu items and associated actions for Xlight, including options for downloading, enabling, switching versions, managing the service, and viewing logs.

Returns
string The generated Xlight menu items and actions. @global object $bearsamppConfig Provides access to the application configuration. @global object $bearsamppBins Provides access to system binaries and their configurations. @global object $bearsamppLang Provides language support for retrieving language-specific values.

@global object $bearsamppRoot Provides access to the root path of the application.

Definition at line 60 of file class.tpl.app.xlight.php.

61 {
63 $resultItems = $resultActions = '';
64
65 $isEnabled = $bearsamppBins->getXlight()->isEnable();
66
67 // Download
68 $resultItems .= TplAestan::getItemLink(
70 HttpClient::getWebsiteUrl('module/xlight', '#releases'),
71 false,
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 }
global $bearsamppLang
global $bearsamppRoot
const DISABLED
const ENABLED
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
const MENU_ENABLE
const SERVICE
const DOWNLOAD_MORE
const MENU_LOGS
const VERSIONS
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemNotepad($caption, $path)
static getItemSeparator()
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
static getMenu($caption, $menu, $class)
const SECTION_CALL
const SECTION_CONTENT
global $bearsamppConfig
Definition homepage.php:46

References $bearsamppBins, $bearsamppConfig, $bearsamppLang, $bearsamppRoot, Config\DISABLED, Lang\DOWNLOAD_MORE, Config\ENABLED, TplApp\getActionMulti(), TplAestan\getItemLink(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), TplApp\getMenu(), HttpClient\getWebsiteUrl(), TplAestan\GLYPH_BROWSER, TplAestan\GLYPH_CHECK, Lang\MENU_ENABLE, Lang\MENU_LOGS, TplApp\SECTION_CALL, TplApp\SECTION_CONTENT, Lang\SERVICE, and Lang\VERSIONS.

Here is the call graph for this function:

◆ getMenuXlightService()

getMenuXlightService ( )
static

Generates the Xlight service menu.

This method creates the menu items and associated actions for managing the Xlight service, including starting, stopping, restarting, changing ports, and installing or removing the service.

Returns
string The generated Xlight service menu items and actions. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppRoot Provides access to the root path of the application.

Definition at line 190 of file class.tpl.app.xlight.php.

191 {
193
194 $tplChangePort = TplApp::getActionMulti(
195 self::ACTION_CHANGE_PORT,
196 null,
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 .
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,
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,
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 }
$result
const CHECK_PORT
const MENU_CHANGE_PORT
const MENU_INSTALL_SERVICE
const MENU_UPDATE_ENV_PATH
const MENU_REMOVE_SERVICE
const MENU_CHECK_PORT
static getRootPath($aetrayPath=false)
const GLYPH_SERVICE_REMOVE
static getItemActionServiceStop($service)
const GLYPH_SERVICE_INSTALL
static getItemActionServiceStart($service)
static getItemActionServiceRestart($service)

References $bearsamppBins, $bearsamppLang, $bearsamppRoot, $result, Action\CHECK_PORT, TplApp\getActionMulti(), TplApp\getActionRun(), TplAestan\getItemActionServiceRestart(), TplAestan\getItemActionServiceStart(), TplAestan\getItemActionServiceStop(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), Path\getRootPath(), TplAestan\GLYPH_LIGHT, TplAestan\GLYPH_NETWORK, TplAestan\GLYPH_SERVICE_INSTALL, TplAestan\GLYPH_SERVICE_REMOVE, Lang\MENU_CHANGE_PORT, Lang\MENU_CHECK_PORT, Lang\MENU_INSTALL_SERVICE, Lang\MENU_REMOVE_SERVICE, Lang\MENU_UPDATE_ENV_PATH, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Here is the call graph for this function:

◆ getMenuXlightVersions()

getMenuXlightVersions ( )
static

Generates the Xlight versions menu.

This method creates the menu items and associated actions for switching between different versions of Xlight.

Returns
string The generated Xlight versions menu items and actions. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 115 of file class.tpl.app.xlight.php.

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 }

References $bearsamppBins, TplApp\getActionMulti(), TplAestan\GLYPH_CHECK, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Here is the call graph for this function:

◆ process()

process ( )
static

Processes the Xlight menu.

This method generates the menu for enabling or disabling Xlight. It uses the global language object to retrieve the localized string for Xlight.

Returns
array The generated menu for enabling or disabling Xlight. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppLang Provides language support for retrieving language-specific values.

Definition at line 40 of file class.tpl.app.xlight.php.

41 {
43
44 return TplApp::getMenuEnable($bearsamppLang->getValue(Lang::XLIGHT), self::MENU, get_called_class(), $bearsamppBins->getXlight()->isEnable());
45 }
const XLIGHT
static getMenuEnable($caption, $menu, $class, $enabled=true)

References $bearsamppBins, $bearsamppLang, TplApp\getMenuEnable(), and Lang\XLIGHT.

Referenced by TplApp\getSectionMenuLeft().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const ACTION_CHANGE_PORT = 'changeXlightPort'

Definition at line 25 of file class.tpl.app.xlight.php.

◆ ACTION_ENABLE

const ACTION_ENABLE = 'enableXlight'

Definition at line 23 of file class.tpl.app.xlight.php.

◆ ACTION_INSTALL_SERVICE

const ACTION_INSTALL_SERVICE = 'installXlightService'

Definition at line 26 of file class.tpl.app.xlight.php.

◆ ACTION_REMOVE_SERVICE

const ACTION_REMOVE_SERVICE = 'removeXlightService'

Definition at line 27 of file class.tpl.app.xlight.php.

◆ ACTION_SWITCH_VERSION

const ACTION_SWITCH_VERSION = 'switchXlightVersion'

Definition at line 24 of file class.tpl.app.xlight.php.

◆ MENU

const MENU = 'xlight'

Definition at line 19 of file class.tpl.app.xlight.php.

◆ MENU_SERVICE

const MENU_SERVICE = 'xlightService'

Definition at line 21 of file class.tpl.app.xlight.php.

◆ MENU_VERSIONS

const MENU_VERSIONS = 'xlightVersions'

Definition at line 20 of file class.tpl.app.xlight.php.


The documentation for this class was generated from the following file: