Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
TplPowerShell Class Reference

Static Public Member Functions

static process ()

Private Member Functions

 __construct ()

Static Private Member Functions

static getTab ($title, $icon, $shell, $initDir)
static getTabCmdSection ()
static getTabComposerSection ()
static getTabGhostscriptSection ()
static getTabGitSection ()
static getTabMariadbSection ()
static getTabMysqlSection ()
static getTabNgrokSection ()
static getTabNodejsSection ()
static getTabPearSection ()
static getTabPerlSection ()
static getTabPostgresqlSection ()
static getTabPowerShellSection ()
static getTabPythonSection ()
static getTabRubySection ()
static getTabsSection ()

Detailed Description

Class TplPowerShell

This class is responsible for managing PowerShell configuration. It includes methods to define various sections such as tabs for different tools.

Definition at line 16 of file class.tpl.powershell.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )
private

Private constructor to prevent instantiation.

Definition at line 40 of file class.tpl.powershell.php.

41 {
42 }

Member Function Documentation

◆ getTab()

getTab ( $title,
$icon,
$shell,
$initDir )
staticprivate

Generates the structure for a tab.

This function constructs the structure for a tab, including the title, shell command, and initial directory.

Note: Icon parameter is currently unused as native PowerShell consoles do not support custom icons in tab titles. This was a feature of ConsoleZ which is no longer used. To use icons, consider using a terminal emulator like ConEmu, Cmder, or Windows Terminal.

Parameters
string$titleThe title of the tab.
string | null$iconThe icon for the tab (currently unused).
string$shellThe shell command to be executed in the tab.
string$initDirThe initial directory for the tab.
Returns
string The structure for the tab. @global Core $bearsamppCore The core object of the application.

Definition at line 517 of file class.tpl.powershell.php.

518 {
519 global $bearsamppCore;
520 // Icon parameter is ignored as native PowerShell console does not support custom icons
521 // Return tab information as a formatted string
522 return "Title: $title | Shell: $shell | InitDir: $initDir";
523 }
global $bearsamppCore

References $bearsamppCore.

Referenced by getTabCmdSection(), getTabComposerSection(), getTabGhostscriptSection(), getTabGitSection(), getTabMariadbSection(), getTabMysqlSection(), getTabNgrokSection(), getTabNodejsSection(), getTabPearSection(), getTabPerlSection(), getTabPostgresqlSection(), getTabPowerShellSection(), getTabPythonSection(), and getTabRubySection().

◆ getTabCmdSection()

getTabCmdSection ( )
staticprivate

Generates the structure for the command tab section.

This function creates a structure defining the command tab and its configuration. It retrieves the tab title and shell command from the PowerShell tool and sets the root path.

Returns
string The formatted string for the command tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 95 of file class.tpl.powershell.php.

96 {
97 global $bearsamppRoot, $bearsamppTools;
98
99 return self::getTab(
100 $bearsamppTools->getPowerShell()->getTabTitleDefault(),
101 null, // self::ICON_APP - Icon not supported in native PowerShell console
102 $bearsamppTools->getPowerShell()->getShell(),
103 $bearsamppRoot->getRootPath()
104 ) . PHP_EOL;
105 }
global $bearsamppRoot
static getTab($title, $icon, $shell, $initDir)

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabComposerSection()

getTabComposerSection ( )
staticprivate

Generates the structure for the Composer tab section.

This function creates a structure defining the Composer tab and its configuration. It retrieves the Composer executable path and sets the WWW path.

Returns
string The formatted string for the Composer tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 323 of file class.tpl.powershell.php.

324 {
325 global $bearsamppRoot, $bearsamppTools;
326
327 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getComposer()->getExe() . '"');
328 if (!file_exists($bearsamppTools->getComposer()->getExe())) {
329 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getComposer()->getExe() . ' not found');
330 }
331
332 return self::getTab(
333 $bearsamppTools->getPowerShell()->getTabTitleComposer(),
334 null, // self::ICON_COMPOSER - Icon not supported in native PowerShell console
335 $shell,
336 $bearsamppRoot->getWwwPath()
337 ) . PHP_EOL;
338 }

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabGhostscriptSection()

getTabGhostscriptSection ( )
staticprivate

Generates the tab section for Ghostscript in the console.

This function constructs a shell command to check the version of Ghostscript and verifies if the executable exists. If the executable is not found, it returns a message indicating the absence of the executable. It then creates a tab section with the appropriate title, icon, shell command, and initial directory.

Returns
string The structure for the Ghostscript tab section. @global Tools $bearsamppTools The tools object of the application. @global Root $bearsamppRoot The root object of the application.

Definition at line 453 of file class.tpl.powershell.php.

454 {
455 global $bearsamppRoot, $bearsamppTools;
456
457 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getGhostscript()->getExeConsole() . '"');
458 if (!file_exists($bearsamppTools->getGhostscript()->getExeConsole())) {
459 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getGhostscript()->getExeConsole() . ' not found');
460 }
461
462 return self::getTab(
463 $bearsamppTools->getPowerShell()->getTabTitleGhostscript(),
464 null, // self::ICON_GHOSTSCRIPT - Icon not supported in native PowerShell console
465 $shell,
466 $bearsamppRoot->getWwwPath()
467 ) . PHP_EOL;
468 }

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabGitSection()

getTabGitSection ( )
staticprivate

Generates the structure for the Git tab section.

This function creates a structure defining the Git tab and its configuration. It retrieves the Git executable path and sets the WWW path.

Returns
string The formatted string for the Git tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 266 of file class.tpl.powershell.php.

267 {
268 global $bearsamppRoot, $bearsamppTools;
269
270 $shell = $bearsamppTools->getPowerShell()->getShell();
271 if (!file_exists($bearsamppTools->getGit()->getExe())) {
272 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getGit()->getExe() . ' not found');
273 }
274
275 return self::getTab(
276 $bearsamppTools->getPowerShell()->getTabTitleGit(),
277 null, // self::ICON_GIT - Icon not supported in native PowerShell console
278 $shell,
279 $bearsamppRoot->getWwwPath()
280 ) . PHP_EOL;
281 }

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabMariadbSection()

getTabMariadbSection ( )
staticprivate

Generates the structure for the MariaDB tab section.

This function creates a structure defining the MariaDB tab and its configuration. It retrieves the MariaDB CLI executable path and sets the symlink path.

Returns
string The formatted string for the MariaDB tab section. @global Tools $bearsamppTools The tools object of the application.

@global Bins $bearsamppBins The bins object of the application.

Definition at line 204 of file class.tpl.powershell.php.

205 {
206 global $bearsamppBins, $bearsamppTools;
207
208 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getMariadb()->getCliExe() . '" -u' .
209 $bearsamppBins->getMariadb()->getRootUser() .
210 ($bearsamppBins->getMariadb()->getRootPwd() ? ' -p' : ''));
211 if (!file_exists($bearsamppBins->getMariadb()->getCliExe())) {
212 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getMariadb()->getCliExe() . ' not found');
213 }
214
215 return self::getTab(
216 $bearsamppTools->getPowerShell()->getTabTitleMariadb(),
217 null, // self::ICON_DB - Icon not supported in native PowerShell console
218 $shell,
219 $bearsamppBins->getMariadb()->getSymlinkPath()
220 ) . PHP_EOL;
221 }
global $bearsamppBins

References $bearsamppBins, and getTab().

Referenced by getTabsSection().

◆ getTabMysqlSection()

getTabMysqlSection ( )
staticprivate

Generates the structure for the MySQL tab section.

This function creates a structure defining the MySQL tab and its configuration. It retrieves the MySQL CLI executable path and sets the symlink path.

Returns
string The formatted string for the MySQL tab section. @global Tools $bearsamppTools The tools object of the application.

@global Bins $bearsamppBins The bins object of the application.

Definition at line 174 of file class.tpl.powershell.php.

175 {
176 global $bearsamppBins, $bearsamppTools;
177
178 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getMysql()->getCliExe() . '" -u' .
179 $bearsamppBins->getMysql()->getRootUser() .
180 ($bearsamppBins->getMysql()->getRootPwd() ? ' -p' : ''));
181 if (!file_exists($bearsamppBins->getMysql()->getCliExe())) {
182 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getMysql()->getCliExe() . ' not found');
183 }
184
185 return self::getTab(
186 $bearsamppTools->getPowerShell()->getTabTitleMysql(),
187 null, // self::ICON_DB - Icon not supported in native PowerShell console
188 $shell,
189 $bearsamppBins->getMysql()->getSymlinkPath()
190 ) . PHP_EOL;
191 }

References $bearsamppBins, and getTab().

Referenced by getTabsSection().

◆ getTabNgrokSection()

getTabNgrokSection ( )
staticprivate

Generates the tab section for Ngrok in the console.

This function constructs a shell command to check the version of Ngrok and verifies if the executable exists. If the executable is not found, it returns a message indicating the absence of the executable. It then creates a tab section with the appropriate title, icon, shell command, and initial directory.

Returns
string The structure for the Ngrok tab section. @global Tools $bearsamppTools The tools object of the application. @global Root $bearsamppRoot The root object of the application.

Definition at line 483 of file class.tpl.powershell.php.

484 {
485 global $bearsamppRoot, $bearsamppTools;
486
487 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getNgrok()->getExe() . '"');
488 if (!file_exists($bearsamppTools->getNgrok()->getExe())) {
489 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getNgrok()->getExe() . ' not found');
490 }
491
492 return self::getTab(
493 $bearsamppTools->getPowerShell()->getTabTitleNgrok(),
494 null, // self::ICON_NGROK - Icon not supported in native PowerShell console
495 $shell,
496 $bearsamppRoot->getWwwPath()
497 ) . PHP_EOL;
498 }

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabNodejsSection()

getTabNodejsSection ( )
staticprivate

Generates the structure for the Node.js tab section.

This function creates a structure defining the Node.js tab and its configuration. It retrieves the Node.js launch path and sets the WWW path.

Returns
string The formatted string for the Node.js tab section. @global Bins $bearsamppBins The bins object of the application. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 295 of file class.tpl.powershell.php.

296 {
297 global $bearsamppRoot, $bearsamppBins, $bearsamppTools;
298
299 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getNodejs()->getLaunch() . '"');
300 if (!file_exists($bearsamppBins->getNodejs()->getLaunch())) {
301 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getNodejs()->getLaunch() . ' not found');
302 }
303
304 return self::getTab(
305 $bearsamppTools->getPowerShell()->getTabTitleNodejs(),
306 null, // self::ICON_NODEJS - Icon not supported in native PowerShell console
307 $shell,
308 $bearsamppRoot->getWwwPath()
309 ) . PHP_EOL;
310 }

References $bearsamppBins, $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabPearSection()

getTabPearSection ( )
staticprivate

Generates the structure for the PEAR tab section.

This function creates a structure defining the PEAR tab and its configuration. It retrieves the PEAR executable path and sets the symlink path.

Returns
string The formatted string for the PEAR tab section. @global Tools $bearsamppTools The tools object of the application.

@global Bins $bearsamppBins The bins object of the application.

Definition at line 146 of file class.tpl.powershell.php.

147 {
148 global $bearsamppBins, $bearsamppTools;
149
150 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getPhp()->getPearExe() . '"');
151 if (!file_exists($bearsamppBins->getPhp()->getPearExe())) {
152 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getPhp()->getPearExe() . ' not found');
153 }
154
155 return self::getTab(
156 $bearsamppTools->getPowerShell()->getTabTitlePear(),
157 null, // self::ICON_PEAR - Icon not supported in native PowerShell console
158 $shell,
159 $bearsamppBins->getPhp()->getSymlinkPath() . '/pear'
160 ) . PHP_EOL;
161 }

References $bearsamppBins, and getTab().

Referenced by getTabsSection().

◆ getTabPerlSection()

getTabPerlSection ( )
staticprivate

Generates the structure for the Perl tab section.

This function creates a structure defining the Perl tab and its configuration. It retrieves the Perl executable path and sets the WWW path.

Returns
string The formatted string for the Perl tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 423 of file class.tpl.powershell.php.

424 {
425 global $bearsamppRoot, $bearsamppTools;
426
427 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getPerl()->getExe() . '"');
428 if (!file_exists($bearsamppTools->getPerl()->getExe())) {
429 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getPerl()->getExe() . ' not found');
430 }
431
432 return self::getTab(
433 $bearsamppTools->getPowerShell()->getTabTitlePerl(),
434 null, // self::ICON_PERL - Icon not supported in native PowerShell console
435 $shell,
436 $bearsamppRoot->getWwwPath()
437 ) . PHP_EOL;
438 }

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabPostgresqlSection()

getTabPostgresqlSection ( )
staticprivate

Generates the structure for the PostgreSQL tab section.

This function creates a structure defining the PostgreSQL tab and its configuration. It retrieves the PostgreSQL CLI executable path and sets the symlink path.

Returns
string The formatted string for the PostgreSQL tab section. @global Tools $bearsamppTools The tools object of the application.

@global Bins $bearsamppBins The bins object of the application.

Definition at line 234 of file class.tpl.powershell.php.

235 {
236 global $bearsamppBins, $bearsamppTools;
237
238 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getPostgresql()->getCliExe() . '"' .
239 ' -h 127.0.0.1' .
240 ' -p ' . $bearsamppBins->getPostgresql()->getPort() .
241 ' -U ' . $bearsamppBins->getPostgresql()->getRootUser() .
242 ' -d postgres');
243 if (!file_exists($bearsamppBins->getPostgresql()->getCliExe())) {
244 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getPostgresql()->getCliExe() . ' not found');
245 }
246
247 return self::getTab(
248 $bearsamppTools->getPowerShell()->getTabTitlePostgresql(),
249 null, // self::ICON_DB - Icon not supported in native PowerShell console
250 $shell,
251 $bearsamppBins->getPostgresql()->getSymlinkPath()
252 ) . PHP_EOL;
253 }

References $bearsamppBins, and getTab().

Referenced by getTabsSection().

◆ getTabPowerShellSection()

getTabPowerShellSection ( )
staticprivate

Generates the structure for the PowerShell tab section.

This function creates a structure defining the PowerShell tab and its configuration. It retrieves the PowerShell path and sets the root path.

Returns
string The formatted string for the PowerShell tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 118 of file class.tpl.powershell.php.

119 {
120 global $bearsamppRoot, $bearsamppTools;
121
122 $powerShellPath = Util::getPowerShellPath();
123 if ($powerShellPath !== false) {
124 return self::getTab(
125 $bearsamppTools->getPowerShell()->getTabTitlePowershell(),
126 null, // self::ICON_POWERSHELL - Icon not supported in native PowerShell console
127 $powerShellPath,
128 $bearsamppRoot->getRootPath()
129 ) . PHP_EOL;
130 }
131
132 return "";
133 }
static getPowerShellPath()

References $bearsamppRoot, Util\getPowerShellPath(), and getTab().

Referenced by getTabsSection().

◆ getTabPythonSection()

getTabPythonSection ( )
staticprivate

Generates the structure for the Python tab section.

This function creates a structure defining the Python tab and its configuration. It retrieves the Python executable path and sets the WWW path.

Returns
string The formatted string for the Python tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 351 of file class.tpl.powershell.php.

352 {
353 global $bearsamppRoot, $bearsamppTools;
354
355 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getPython()->getExe() . '"');
356 if (!file_exists($bearsamppTools->getPython()->getExe())) {
357 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getPython()->getExe() . ' not found');
358 }
359
360 return self::getTab(
361 $bearsamppTools->getPowerShell()->getTabTitlePython(),
362 null, // self::ICON_PYTHON - Icon not supported in native PowerShell console
363 $shell,
364 $bearsamppRoot->getWwwPath()
365 ) . PHP_EOL;
366 }

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabRubySection()

getTabRubySection ( )
staticprivate

Generates the structure for the Ruby tab section.

This function creates a structure defining the Ruby tab and its configuration. It retrieves the Ruby executable path and sets the WWW path.

Returns
string The formatted string for the Ruby tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 379 of file class.tpl.powershell.php.

380 {
381 global $bearsamppRoot, $bearsamppTools;
382
383 // Check if Ruby exists first
384 if (!file_exists($bearsamppTools->getRuby()->getExe())) {
385 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getRuby()->getExe() . ' not found');
386 } else {
387 // Use irb (Interactive Ruby) for an interactive shell
388 $rubyDir = dirname($bearsamppTools->getRuby()->getExe());
389 $irbExe = $rubyDir . '/irb.bat';
390
391 // Check if irb.bat exists, otherwise try irb.cmd or just use ruby with -i flag
392 if (file_exists($irbExe)) {
393 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $irbExe . '"');
394 } elseif (file_exists($rubyDir . '/irb.cmd')) {
395 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $rubyDir . '/irb.cmd' . '"');
396 } elseif (file_exists($rubyDir . '/irb')) {
397 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $rubyDir . '/irb' . '"');
398 } else {
399 // Fallback to just opening a shell in the Ruby directory
400 $shell = $bearsamppTools->getPowerShell()->getShell();
401 }
402 }
403
404 return self::getTab(
405 $bearsamppTools->getPowerShell()->getTabTitleRuby(),
406 null, // self::ICON_RUBY - Icon not supported in native PowerShell console
407 $shell,
408 $bearsamppRoot->getWwwPath()
409 ) . PHP_EOL;
410 }

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

◆ getTabsSection()

getTabsSection ( )
staticprivate

Generates the tabs section.

This function creates a structure defining various tabs and their configurations. It includes multiple tab sections such as command, PowerShell, PEAR, MySQL, MariaDB, PostgreSQL, Ghostscript, Git, Node.js, Composer, Perl, Python, Ruby and Ngrok.

Returns
string The formatted string for the tabs section.

Definition at line 66 of file class.tpl.powershell.php.

67 {
68 return self::getTabCmdSection() .
82 }
static getTabGhostscriptSection()

References getTabCmdSection(), getTabComposerSection(), getTabGhostscriptSection(), getTabGitSection(), getTabMariadbSection(), getTabMysqlSection(), getTabNgrokSection(), getTabNodejsSection(), getTabPearSection(), getTabPerlSection(), getTabPostgresqlSection(), getTabPowerShellSection(), getTabPythonSection(), and getTabRubySection().

◆ process()

process ( )
static

Process PowerShell configuration.

PowerShell 7+ uses profile scripts and Oh My Posh for configuration, not XML like ConsoleZ. This method is maintained for compatibility.

Definition at line 50 of file class.tpl.powershell.php.

51 {
52 // PowerShell uses profile scripts (Microsoft.PowerShell_profile.ps1)
53 // and Oh My Posh for configuration - no processing needed here
54 return true;
55 }

Referenced by ActionReload\__construct().


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