Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.tpl.app.nodejs.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
16
class
TplAppNodejs
17
{
18
// Constants for menu and action identifiers
19
const
MENU
=
'nodejs'
;
20
const
MENU_VERSIONS
=
'nodejsVersions'
;
21
22
const
ACTION_ENABLE
=
'enableNodejs'
;
23
const
ACTION_SWITCH_VERSION
=
'switchNodejsVersion'
;
24
35
public
static
function
process
()
36
{
37
global
$bearsamppLang
,
$bearsamppBins
;
38
39
return
TplApp::getMenuEnable
(
40
$bearsamppLang
->getValue(
Lang::NODEJS
),
41
self::MENU,
42
get_called_class(),
43
$bearsamppBins
->getNodejs()->isEnable()
44
);
45
}
46
59
public
static
function
getMenuNodejs
()
60
{
61
global
$bearsamppBins
,
$bearsamppLang
, $bearsamppTools,
$bearsamppRoot
;
62
$resultItems = $resultActions =
''
;
63
64
$isEnabled =
$bearsamppBins
->getNodejs()->isEnable();
65
66
// Download
67
$resultItems .=
TplAestan::getItemLink
(
68
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
69
HttpClient::getWebsiteUrl
(
'module/nodejs'
,
'#releases'
),
70
false
,
71
TplAestan::GLYPH_BROWSER
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
(
90
$bearsamppLang
->getValue(
Lang::VERSIONS
),
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
(
99
$bearsamppLang
->getValue(
Lang::CONSOLE
),
100
TplAestan::GLYPH_NODEJS
,
101
null
,
102
$bearsamppTools->getPowerShell()->getTabTitleNodejs(),
103
Path::getWwwPath
(),
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
}
116
126
public
static
function
getMenuNodejsVersions
()
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
}
150
162
public
static
function
getActionEnableNodejs
($enable)
163
{
164
global
$bearsamppBins
;
165
166
return
TplApp::getActionRun
(
167
Action::ENABLE
,
168
array(
$bearsamppBins
->getNodejs()->getName(), $enable)
169
) . PHP_EOL .
TplAppReload::getActionReload
();
170
}
171
183
public
static
function
getActionSwitchNodejsVersion
($version)
184
{
185
global
$bearsamppBins
;
186
187
return
TplApp::getActionRun
(
188
Action::SWITCH_VERSION
,
189
array(
$bearsamppBins
->getNodejs()->getName(), $version)
190
) . PHP_EOL .
TplAppReload::getActionReload
() . PHP_EOL;
191
}
192
}
193
$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\ENABLE
const ENABLE
Definition
class.action.php:31
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\NODEJS
const NODEJS
Definition
class.lang.php:133
Lang\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:98
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:41
Lang\CONSOLE
const CONSOLE
Definition
class.lang.php:34
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:80
Path\getWwwPath
static getWwwPath($aetrayPath=false)
Definition
class.path.php:1078
TplAestan\getItemPowerShell
static getItemPowerShell($caption, $glyph, $id=null, $title=null, $initDir=null, $command=null)
Definition
class.tpl.aestan.php:141
TplAestan\GLYPH_CHECK
const GLYPH_CHECK
Definition
class.tpl.aestan.php:61
TplAestan\GLYPH_NODEJS
const GLYPH_NODEJS
Definition
class.tpl.aestan.php:73
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\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:125
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
TplAppNodejs
Definition
class.tpl.app.nodejs.php:17
TplAppNodejs\getMenuNodejs
static getMenuNodejs()
Definition
class.tpl.app.nodejs.php:59
TplAppNodejs\getActionSwitchNodejsVersion
static getActionSwitchNodejsVersion($version)
Definition
class.tpl.app.nodejs.php:183
TplAppNodejs\getMenuNodejsVersions
static getMenuNodejsVersions()
Definition
class.tpl.app.nodejs.php:126
TplAppNodejs\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.nodejs.php:22
TplAppNodejs\MENU
const MENU
Definition
class.tpl.app.nodejs.php:19
TplAppNodejs\process
static process()
Definition
class.tpl.app.nodejs.php:35
TplAppNodejs\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.nodejs.php:23
TplAppNodejs\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.nodejs.php:20
TplAppNodejs\getActionEnableNodejs
static getActionEnableNodejs($enable)
Definition
class.tpl.app.nodejs.php:162
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:44
sandbox
core
classes
tpls
app
class.tpl.app.nodejs.php
Generated by
1.17.0