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

Static Public Member Functions

static getActionEnableNodejs ($enable)
static getActionSwitchNodejsVersion ($version)
static getMenuNodejs ()
static getMenuNodejsVersions ()
static process ()

Data Fields

const ACTION_ENABLE = 'enableNodejs'
const ACTION_SWITCH_VERSION = 'switchNodejsVersion'
const MENU = 'nodejs'
const MENU_VERSIONS = 'nodejsVersions'

Detailed Description

Class TplAppNodejs

This class provides methods to generate and manage menu items and actions related to Node.js within the Bearsampp application. It includes functionalities for enabling/disabling Node.js, switching Node.js versions, and generating menus for Node.js actions.

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

Member Function Documentation

◆ getActionEnableNodejs()

getActionEnableNodejs ( $enable)
static

Generates the action to enable or disable Node.js.

This method creates the action string for enabling or disabling Node.js. It includes commands to reload the application.

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

Definition at line 162 of file class.tpl.app.nodejs.php.

163 {
164 global $bearsamppBins;
165
168 array($bearsamppBins->getNodejs()->getName(), $enable)
169 ) . PHP_EOL . TplAppReload::getActionReload();
170 }
global $bearsamppBins
const ENABLE
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

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

Here is the call graph for this function:

◆ getActionSwitchNodejsVersion()

getActionSwitchNodejsVersion ( $version)
static

Generates the action to switch Node.js versions.

This method creates the action string for switching Node.js versions. It includes commands to reload the application.

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

Definition at line 183 of file class.tpl.app.nodejs.php.

184 {
185 global $bearsamppBins;
186
189 array($bearsamppBins->getNodejs()->getName(), $version)
190 ) . PHP_EOL . TplAppReload::getActionReload() . PHP_EOL;
191 }
const SWITCH_VERSION

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

Here is the call graph for this function:

◆ getMenuNodejs()

getMenuNodejs ( )
static

Generates the Node.js menu items and associated actions.

This method creates menu items for Node.js, including options to download more versions, enable/disable Node.js, switch versions, open a console, and edit the configuration file.

Returns
string The generated menu items and actions for Node.js. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppTools Provides access to various tools used in the application.

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

Definition at line 59 of file class.tpl.app.nodejs.php.

60 {
61 global $bearsamppBins, $bearsamppLang, $bearsamppTools, $bearsamppRoot;
62 $resultItems = $resultActions = '';
63
64 $isEnabled = $bearsamppBins->getNodejs()->isEnable();
65
66 // Download
67 $resultItems .= TplAestan::getItemLink(
69 HttpClient::getWebsiteUrl('module/nodejs', '#releases'),
70 false,
72 ) . PHP_EOL;
73
74 // Enable
75 $tplEnable = TplApp::getActionMulti(
76 self::ACTION_ENABLE,
77 array($isEnabled ? Config::DISABLED : Config::ENABLED),
78 array($bearsamppLang->getValue(Lang::MENU_ENABLE), $isEnabled ? TplAestan::GLYPH_CHECK : ''),
79 false,
80 get_called_class()
81 );
82 $resultItems .= $tplEnable[TplApp::SECTION_CALL] . PHP_EOL;
83 $resultActions .= $tplEnable[TplApp::SECTION_CONTENT] . PHP_EOL;
84
85 if ($isEnabled) {
86 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
87
88 // Versions
89 $tplVersions = TplApp::getMenu(
91 self::MENU_VERSIONS,
92 get_called_class()
93 );
94 $resultItems .= $tplVersions[TplApp::SECTION_CALL] . PHP_EOL;
95 $resultActions .= $tplVersions[TplApp::SECTION_CONTENT];
96
97 // Console
98 $resultItems .= TplAestan::getItemPowerShell(
101 null,
102 $bearsamppTools->getPowerShell()->getTabTitleNodejs(),
104 null
105 ) . PHP_EOL;
106
107 // Conf
108 $resultItems .= TplAestan::getItemNotepad(
109 basename($bearsamppBins->getNodejs()->getConf()),
110 $bearsamppBins->getNodejs()->getConf()
111 ) . PHP_EOL;
112 }
113
114 return $resultItems . PHP_EOL . $resultActions;
115 }
global $bearsamppLang
global $bearsamppRoot
const DISABLED
const ENABLED
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
const MENU_ENABLE
const DOWNLOAD_MORE
const CONSOLE
const VERSIONS
static getWwwPath($aetrayPath=false)
static getItemPowerShell($caption, $glyph, $id=null, $title=null, $initDir=null, $command=null)
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

References $bearsamppBins, $bearsamppLang, $bearsamppRoot, Lang\CONSOLE, Config\DISABLED, Lang\DOWNLOAD_MORE, Config\ENABLED, TplApp\getActionMulti(), TplAestan\getItemLink(), TplAestan\getItemNotepad(), TplAestan\getItemPowerShell(), TplAestan\getItemSeparator(), TplApp\getMenu(), HttpClient\getWebsiteUrl(), Path\getWwwPath(), TplAestan\GLYPH_BROWSER, TplAestan\GLYPH_CHECK, TplAestan\GLYPH_NODEJS, Lang\MENU_ENABLE, TplApp\SECTION_CALL, TplApp\SECTION_CONTENT, and Lang\VERSIONS.

Here is the call graph for this function:

◆ getMenuNodejsVersions()

getMenuNodejsVersions ( )
static

Generates the Node.js versions menu items and associated actions.

This method creates menu items for switching between different Node.js versions.

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

Definition at line 126 of file class.tpl.app.nodejs.php.

127 {
128 global $bearsamppBins;
129 $items = '';
130 $actions = '';
131
132 foreach ($bearsamppBins->getNodejs()->getVersionList() as $version) {
133 $tplSwitchNodejsVersion = TplApp::getActionMulti(
134 self::ACTION_SWITCH_VERSION,
135 array($version),
136 array($version, $version == $bearsamppBins->getNodejs()->getVersion() ? TplAestan::GLYPH_CHECK : ''),
137 false,
138 get_called_class()
139 );
140
141 // Item
142 $items .= $tplSwitchNodejsVersion[TplApp::SECTION_CALL] . PHP_EOL;
143
144 // Action
145 $actions .= PHP_EOL . $tplSwitchNodejsVersion[TplApp::SECTION_CONTENT];
146 }
147
148 return $items . $actions;
149 }

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 and generates the Node.js menu.

This method generates the menu for Node.js, including options to enable/disable Node.js and switch versions.

Returns
array The generated menu for Node.js. @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 35 of file class.tpl.app.nodejs.php.

36 {
38
41 self::MENU,
42 get_called_class(),
43 $bearsamppBins->getNodejs()->isEnable()
44 );
45 }
const NODEJS
static getMenuEnable($caption, $menu, $class, $enabled=true)

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

Referenced by TplApp\getSectionMenuLeft().

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

Field Documentation

◆ ACTION_ENABLE

const ACTION_ENABLE = 'enableNodejs'

Definition at line 22 of file class.tpl.app.nodejs.php.

◆ ACTION_SWITCH_VERSION

const ACTION_SWITCH_VERSION = 'switchNodejsVersion'

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

◆ MENU

const MENU = 'nodejs'

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

◆ MENU_VERSIONS

const MENU_VERSIONS = 'nodejsVersions'

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


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