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

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

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

Returns
string The generated action string for enabling or disabling Node.js.

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

160 {
161 global $bearsamppBins;
162
165 array($bearsamppBins->getNodejs()->getName(), $enable)
166 ) . PHP_EOL . TplAppReload::getActionReload();
167 }
global $bearsamppBins
const ENABLE
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

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

◆ getActionSwitchNodejsVersion()

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

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

Returns
string The generated action string for switching Node.js versions.

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

181 {
182 global $bearsamppBins;
183
186 array($bearsamppBins->getNodejs()->getName(), $version)
187 ) . PHP_EOL . TplAppReload::getActionReload() . PHP_EOL;
188 }
const SWITCH_VERSION

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

◆ getMenuNodejs()

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

@global object $bearsamppBins Provides access to system binaries and their configurations. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppTools Provides access to various tools used in the application.

Returns
string The generated menu items and actions for Node.js.

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

60 {
61 global $bearsamppBins, $bearsamppLang, $bearsamppTools;
62 $resultItems = $resultActions = '';
63
64 $isEnabled = $bearsamppBins->getNodejs()->isEnable();
65
66 // Download
67 $resultItems .= TplAestan::getItemLink(
69 Util::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::getItemConsoleZ(
101 $bearsamppTools->getConsoleZ()->getTabTitleNodejs()
102 ) . PHP_EOL;
103
104 // Conf
105 $resultItems .= TplAestan::getItemNotepad(
106 basename($bearsamppBins->getNodejs()->getConf()),
107 $bearsamppBins->getNodejs()->getConf()
108 ) . PHP_EOL;
109 }
110
111 return $resultItems . PHP_EOL . $resultActions;
112 }
global $bearsamppLang
const DISABLED
const VERSIONS
const DOWNLOAD_MORE
const CONSOLE
static getItemSeparator()
static getItemConsoleZ($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 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)

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

◆ getMenuNodejsVersions()

static TplAppNodejs::getMenuNodejsVersions ( )
static

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

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

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

Returns
string The generated menu items and actions for Node.js versions.

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

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

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

◆ process()

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

@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 Node.js.

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 caller graph for this function:

Field Documentation

◆ ACTION_ENABLE

const TplAppNodejs::ACTION_ENABLE = 'enableNodejs'

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

◆ ACTION_SWITCH_VERSION

const TplAppNodejs::ACTION_SWITCH_VERSION = 'switchNodejsVersion'

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

◆ MENU

const TplAppNodejs::MENU = 'nodejs'

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

◆ MENU_VERSIONS

const TplAppNodejs::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: