2024.8.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

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

Member Function Documentation

◆ getActionChangeXlightPort()

static TplAppXlight::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.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated action string for changing the Xlight port.

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

235 {
236 global $bearsamppBins;
237
238 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getXlight()->getName())) . PHP_EOL .
240 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

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

◆ getActionEnableXlight()

static TplAppXlight::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.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Parameters
int$enableThe enable flag (1 to enable, 0 to disable).
Returns
string The generated action string for enabling or disabling Xlight.

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

140 {
141 global $bearsamppBins;
142
143 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getXlight()->getName(), $enable)) . PHP_EOL .
145 }
const ENABLE

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

◆ getActionInstallXlightService()

static TplAppXlight::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 249 of file class.tpl.app.xlight.php.

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

◆ getActionRemoveXlightService()

static TplAppXlight::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 262 of file class.tpl.app.xlight.php.

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

◆ getActionSwitchXlightVersion()

static TplAppXlight::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.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Parameters
string$versionThe version to switch to.
Returns
string The generated action string for switching the Xlight version.

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

158 {
159 global $bearsamppBins;
160
161 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getXlight()->getName(), $version)) . PHP_EOL .
163 }
const SWITCH_VERSION

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

◆ getMenuXlight()

static TplAppXlight::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.

@global object $bearsamppRoot Provides access to the root path of the application. @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.

Returns
string The generated Xlight menu items and actions.

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

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

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

◆ getMenuXlightService()

static TplAppXlight::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.

@global object $bearsamppRoot Provides access to the root path of the application. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated Xlight service menu items and actions.

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

178 {
180
181 $tplChangePort = TplApp::getActionMulti(
182 self::ACTION_CHANGE_PORT, null,
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 .
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), $bearsamppRoot->getRootPath() . '/nssmEnvPaths.dat') . PHP_EOL;
199
200 if (!$isInstalled) {
201 $tplInstallService = TplApp::getActionMulti(
202 self::ACTION_INSTALL_SERVICE, null,
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,
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 }
$result
const CHECK_PORT
const MENU_INSTALL_SERVICE
const MENU_UPDATE_ENV_PATH
const MENU_REMOVE_SERVICE
const MENU_CHECK_PORT
const MENU_CHANGE_PORT
const GLYPH_SERVICE_REMOVE
static getItemActionServiceStop($service)
static getItemActionServiceStart($service)
static getItemActionServiceRestart($service)
const GLYPH_SERVICE_INSTALL

References $bearsamppBins, $bearsamppLang, $bearsamppRoot, $result, Action\CHECK_PORT, TplApp\getActionMulti(), TplApp\getActionRun(), TplAestan\getItemActionServiceRestart(), TplAestan\getItemActionServiceStart(), TplAestan\getItemActionServiceStop(), TplAestan\getItemNotepad(), TplAestan\getItemSeparator(), 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.

◆ getMenuXlightVersions()

static TplAppXlight::getMenuXlightVersions ( )
static

Generates the Xlight versions menu.

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

@global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated Xlight versions menu items and actions.

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

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 }

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

◆ process()

static TplAppXlight::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.

@global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
array The generated menu for enabling or disabling Xlight.

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

34 {
36
37 return TplApp::getMenuEnable($bearsamppLang->getValue(Lang::XLIGHT), self::MENU, get_called_class(), $bearsamppBins->getXlight()->isEnable());
38 }
const XLIGHT
static getMenuEnable($caption, $menu, $class, $enabled=true)

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

Referenced by TplApp\getSectionMenuLeft().

+ Here is the caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const TplAppXlight::ACTION_CHANGE_PORT = 'changeXlightPort'

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

◆ ACTION_ENABLE

const TplAppXlight::ACTION_ENABLE = 'enableXlight'

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

◆ ACTION_INSTALL_SERVICE

const TplAppXlight::ACTION_INSTALL_SERVICE = 'installXlightService'

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

◆ ACTION_REMOVE_SERVICE

const TplAppXlight::ACTION_REMOVE_SERVICE = 'removeXlightService'

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

◆ ACTION_SWITCH_VERSION

const TplAppXlight::ACTION_SWITCH_VERSION = 'switchXlightVersion'

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

◆ MENU

const TplAppXlight::MENU = 'xlight'

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

◆ MENU_SERVICE

const TplAppXlight::MENU_SERVICE = 'xlightService'

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

◆ MENU_VERSIONS

const TplAppXlight::MENU_VERSIONS = 'xlightVersions'

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


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