Bearsampp 2026.9.23
Loading...
Searching...
No Matches
ToolPowerShell Class Reference
Inheritance diagram for ToolPowerShell:
Collaboration diagram for ToolPowerShell:

Public Member Functions

 __construct ($id, $type)
 getCols ()
 getConf ()
 getExe ()
 getLaunchExe ()
 getRows ()
 getShell ($args=null)
 getTabTitleComposer ()
 getTabTitleDefault ()
 getTabTitleGhostscript ()
 getTabTitleGit ($repoPath=null)
 getTabTitleMariadb ()
 getTabTitleMysql ()
 getTabTitleNgrok ()
 getTabTitleNodejs ()
 getTabTitlePear ()
 getTabTitlePerl ()
 getTabTitlePostgresql ()
 getTabTitlePowershell ()
 getTabTitlePython ()
 getTabTitleRuby ()
 reload ($id=null, $type=null)
 setVersion ($version)
Public Member Functions inherited from Module
 __toString ()
 getId ()
 getName ()
 getRelease ()
 getType ()
 getVersion ()
 getVersionList ()
 isEnable ()
 update ($sub=0, $showWindow=false)

Data Fields

const LOCAL_CFG_COLS = 'powershellCols'
const LOCAL_CFG_CONF = 'powershellConf'
const LOCAL_CFG_EXE = 'powershellExe'
const LOCAL_CFG_LAUNCH_EXE = 'powershellLaunchExe'
const LOCAL_CFG_ROWS = 'powershellRows'
const ROOT_CFG_VERSION = 'powershellVersion'
Data Fields inherited from Module
 $currentPath
 $rootPath
 $symlinkPath

Private Attributes

 $cols
 $conf
 $exe
 $launchExe
 $rows

Additional Inherited Members

Static Public Member Functions inherited from Module
static clearMemoryCache ()
static invalidateConfigCacheForPath ($sourcePath)
Protected Member Functions inherited from Module
 __construct ()
 replace ($key, $value)
 replaceAll ($params)
 updateConfig ($version=null, $sub=0, $showWindow=false)
Protected Attributes inherited from Module
 $bearsamppConf
 $bearsamppConfRaw
 $enable
 $name
 $release = 'N/A'
 $version

Detailed Description

Class ToolPowerShell

This class represents the PowerShell tool in the Bearsampp application. It extends the Module class and provides functionalities specific to PowerShell.

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

Constructor & Destructor Documentation

◆ __construct()

__construct ( $id,
$type )

Constructor for the ToolPowerShell class.

Parameters
string$idThe ID of the module.
string$typeThe type of the module.

Definition at line 71 of file class.tool.powershell.php.

72 {
73 Log::initClass($this);
74 $this->reload($id, $type);
75 }
static initClass($classInstance)
reload($id=null, $type=null)

References Module\$id, Module\$type, Log\initClass(), and reload().

Here is the call graph for this function:

Member Function Documentation

◆ getCols()

getCols ( )

Gets the number of columns for the PowerShell window.

Returns
int The number of columns.

Definition at line 191 of file class.tool.powershell.php.

192 {
193 return $this->cols;
194 }

References $cols.

◆ getConf()

getConf ( )

Gets the configuration file path for PowerShell.

Returns
string The configuration file path.

Definition at line 171 of file class.tool.powershell.php.

172 {
173 return $this->conf;
174 }

References $conf.

◆ getExe()

getExe ( )

Gets the executable path for PowerShell.

Returns
string The executable path.

Definition at line 151 of file class.tool.powershell.php.

152 {
153 return $this->exe;
154 }

References $exe.

◆ getLaunchExe()

getLaunchExe ( )

Gets the launch executable path for PowerShell.

Returns
string The launch executable path.

Definition at line 161 of file class.tool.powershell.php.

162 {
163 return $this->launchExe;
164 }

References $launchExe.

Referenced by getShell().

Here is the caller graph for this function:

◆ getRows()

getRows ( )

Gets the number of rows for the PowerShell window.

Returns
int The number of rows.

Definition at line 181 of file class.tool.powershell.php.

182 {
183 return $this->rows;
184 }

References $rows.

◆ getShell()

getShell ( $args = null)

Gets the shell command to launch PowerShell.

Parameters
string | null$argsAdditional arguments for the shell command.
Returns
string The shell command.

Definition at line 203 of file class.tool.powershell.php.

204 {
205 if (empty($args)) {
206 return 'cmd /c "' . Path::formatWindowsPath($this->launchExe) . '"';
207 } else {
208 return 'cmd /c ""' . Path::formatWindowsPath($this->getLaunchExe()) . '" & ' . Path::formatWindowsPath($args) . '"';
209 }
210 }
static formatWindowsPath($path)

References Path\formatWindowsPath(), and getLaunchExe().

Here is the call graph for this function:

◆ getTabTitleComposer()

getTabTitleComposer ( )

Gets the tab title for Composer.

Returns
string The tab title for Composer.

Definition at line 315 of file class.tool.powershell.php.

316 {
317 global $bearsamppLang, $bearsamppTools;
318
319 return $bearsamppLang->getValue(Lang::COMPOSER) . ' ' . $bearsamppTools->getComposer()->getVersion();
320 }
global $bearsamppLang
const COMPOSER

References $bearsamppLang, and Lang\COMPOSER.

◆ getTabTitleDefault()

getTabTitleDefault ( )

Gets the default tab title for PowerShell.

Returns
string The default tab title.

Definition at line 217 of file class.tool.powershell.php.

218 {
219 return 'Bearsampp PowerShell Console';
220 }

◆ getTabTitleGhostscript()

getTabTitleGhostscript ( )

Gets the tab title for Ghostscript.

Returns
string The tab title for Ghostscript.

Definition at line 363 of file class.tool.powershell.php.

364 {
365 global $bearsamppLang, $bearsamppTools;
366
367 return $bearsamppLang->getValue(Lang::GHOSTSCRIPT) . ' ' . $bearsamppTools->getGhostscript()->getVersion();
368 }
const GHOSTSCRIPT

References $bearsamppLang, and Lang\GHOSTSCRIPT.

◆ getTabTitleGit()

getTabTitleGit ( $repoPath = null)

Gets the tab title for Git.

Parameters
string | null$repoPathThe repository path.
Returns
string The tab title for Git.

Definition at line 287 of file class.tool.powershell.php.

288 {
289 global $bearsamppLang, $bearsamppTools;
290 $result = $bearsamppLang->getValue(Lang::GIT) . ' ' . $bearsamppTools->getGit()->getVersion();
291 if ($repoPath != null) {
292 $result .= ' - ' . basename($repoPath);
293 }
294
295 return $result;
296 }
$result
const GIT

References $bearsamppLang, $result, and Lang\GIT.

◆ getTabTitleMariadb()

getTabTitleMariadb ( )

Gets the tab title for MariaDB.

Returns
string The tab title for MariaDB.

Definition at line 261 of file class.tool.powershell.php.

262 {
264
265 return $bearsamppLang->getValue(Lang::MARIADB) . ' ' . $bearsamppBins->getMariadb()->getVersion();
266 }
global $bearsamppBins
const MARIADB

References $bearsamppBins, $bearsamppLang, and Lang\MARIADB.

◆ getTabTitleMysql()

getTabTitleMysql ( )

Gets the tab title for MySQL.

Returns
string The tab title for MySQL.

Definition at line 249 of file class.tool.powershell.php.

250 {
252
253 return $bearsamppLang->getValue(Lang::MYSQL) . ' ' . $bearsamppBins->getMysql()->getVersion();
254 }
const MYSQL

References $bearsamppBins, $bearsamppLang, and Lang\MYSQL.

◆ getTabTitleNgrok()

getTabTitleNgrok ( )

Gets the tab title for Ngrok.

Returns
string The tab title for Ngrok.

Definition at line 375 of file class.tool.powershell.php.

376 {
377 global $bearsamppLang, $bearsamppTools;
378
379 return $bearsamppLang->getValue(Lang::NGROK) . ' ' . $bearsamppTools->getNgrok()->getVersion();
380 }
const NGROK

References $bearsamppLang, and Lang\NGROK.

◆ getTabTitleNodejs()

getTabTitleNodejs ( )

Gets the tab title for Node.js.

Returns
string The tab title for Node.js.

Definition at line 303 of file class.tool.powershell.php.

304 {
306
307 return $bearsamppLang->getValue(Lang::NODEJS) . ' ' . $bearsamppBins->getNodejs()->getVersion();
308 }
const NODEJS

References $bearsamppBins, $bearsamppLang, and Lang\NODEJS.

◆ getTabTitlePear()

getTabTitlePear ( )

Gets the tab title for PEAR.

Returns
string The tab title for PEAR.

Definition at line 237 of file class.tool.powershell.php.

238 {
240
241 return $bearsamppLang->getValue(Lang::PEAR) . ' ' . $bearsamppBins->getPhp()->getPearVersion(true);
242 }
const PEAR

References $bearsamppBins, $bearsamppLang, and Lang\PEAR.

◆ getTabTitlePerl()

getTabTitlePerl ( )

Gets the tab title for Perl.

Returns
string The tab title for Perl.

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

352 {
353 global $bearsamppLang, $bearsamppTools;
354
355 return $bearsamppLang->getValue(Lang::PERL) . ' ' . $bearsamppTools->getPerl()->getVersion();
356 }
const PERL

References $bearsamppLang, and Lang\PERL.

◆ getTabTitlePostgresql()

getTabTitlePostgresql ( )

Gets the tab title for PostgreSQL.

Returns
string The tab title for PostgreSQL.

Definition at line 273 of file class.tool.powershell.php.

274 {
276
277 return $bearsamppLang->getValue(Lang::POSTGRESQL) . ' ' . $bearsamppBins->getPostgresql()->getVersion();
278 }
const POSTGRESQL

References $bearsamppBins, $bearsamppLang, and Lang\POSTGRESQL.

◆ getTabTitlePowershell()

getTabTitlePowershell ( )

Gets the tab title for PowerShell.

Returns
string The tab title for PowerShell.

Definition at line 227 of file class.tool.powershell.php.

228 {
229 return 'PowerShell';
230 }

◆ getTabTitlePython()

getTabTitlePython ( )

Gets the tab title for Python.

Returns
string The tab title for Python.

Definition at line 327 of file class.tool.powershell.php.

328 {
329 global $bearsamppLang, $bearsamppTools;
330
331 return $bearsamppLang->getValue(Lang::PYTHON) . ' ' . $bearsamppTools->getPython()->getVersion();
332 }
const PYTHON

References $bearsamppLang, and Lang\PYTHON.

◆ getTabTitleRuby()

getTabTitleRuby ( )

Gets the tab title for Ruby.

Returns
string The tab title for Ruby.

Definition at line 339 of file class.tool.powershell.php.

340 {
341 global $bearsamppLang, $bearsamppTools;
342
343 return $bearsamppLang->getValue(Lang::RUBY) . ' ' . $bearsamppTools->getRuby()->getVersion();
344 }
const RUBY

References $bearsamppLang, and Lang\RUBY.

◆ reload()

reload ( $id = null,
$type = null )

Reloads the configuration for the PowerShell tool.

Parameters
string | null$idThe ID of the module. If null, the current ID is used.
string | null$typeThe type of the module. If null, the current type is used.

Reimplemented from Module.

Definition at line 83 of file class.tool.powershell.php.

84 {
86 Log::reloadClass($this);
87
88 $this->name = $bearsamppLang->getValue(Lang::POWERSHELL);
89 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
90 parent::reload($id, $type);
91
92 if ($this->bearsamppConfRaw !== false) {
93 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
94 $this->launchExe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_LAUNCH_EXE];
95 $this->conf = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
96 $this->rows = intval($this->bearsamppConfRaw[self::LOCAL_CFG_ROWS]);
97 $this->cols = intval($this->bearsamppConfRaw[self::LOCAL_CFG_COLS]);
98 }
99
100 if (!$this->enable) {
101 Log::info($this->name . ' is not enabled!');
102
103 return;
104 }
105 if (!is_dir($this->currentPath)) {
106 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
107 }
108 if (!is_dir($this->symlinkPath)) {
109 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
110
111 return;
112 }
113 if (!is_file($this->bearsamppConf)) {
114 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
115 }
116 if (!is_file($this->exe)) {
117 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
118 }
119 if (!is_file($this->launchExe)) {
120 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->launchExe));
121 }
122 if (!is_file($this->conf)) {
123 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->conf));
124 }
125 if (!is_numeric($this->rows) || $this->rows <= 0) {
126 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_INVALID_PARAMETER), self::LOCAL_CFG_ROWS, $this->rows));
127 }
128 if (!is_numeric($this->cols) || $this->cols <= 0) {
129 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_INVALID_PARAMETER), self::LOCAL_CFG_COLS, $this->cols));
130 }
131 }
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const POWERSHELL
const ERROR_INVALID_PARAMETER
const ERROR_FILE_NOT_FOUND
static info($data, $file=null)
static reloadClass($classInstance)
static error($data, $file=null)
global $bearsamppConfig
Definition homepage.php:46

References $bearsamppConfig, $bearsamppLang, Module\$id, Module\$type, Log\error(), Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_EXE_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, Lang\ERROR_INVALID_PARAMETER, Log\info(), Lang\POWERSHELL, and Log\reloadClass().

Referenced by __construct(), and setVersion().

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

◆ setVersion()

setVersion ( $version)

Sets the version of the PowerShell tool.

Parameters
string$versionThe version to set.

Reimplemented from Module.

Definition at line 138 of file class.tool.powershell.php.

139 {
140 global $bearsamppConfig;
141 $this->version = $version;
142 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
143 $this->reload();
144 }

References $bearsamppConfig, Module\$version, and reload().

Here is the call graph for this function:

Field Documentation

◆ $cols

$cols
private

Definition at line 63 of file class.tool.powershell.php.

Referenced by getCols().

◆ $conf

$conf
private

Definition at line 55 of file class.tool.powershell.php.

Referenced by getConf().

◆ $exe

$exe
private

Definition at line 47 of file class.tool.powershell.php.

Referenced by getExe().

◆ $launchExe

$launchExe
private

Definition at line 51 of file class.tool.powershell.php.

Referenced by getLaunchExe().

◆ $rows

$rows
private

Definition at line 59 of file class.tool.powershell.php.

Referenced by getRows().

◆ LOCAL_CFG_COLS

const LOCAL_CFG_COLS = 'powershellCols'

Configuration key for the PowerShell window columns in the local configuration.

Definition at line 42 of file class.tool.powershell.php.

◆ LOCAL_CFG_CONF

const LOCAL_CFG_CONF = 'powershellConf'

Configuration key for the PowerShell configuration file in the local configuration.

Definition at line 30 of file class.tool.powershell.php.

◆ LOCAL_CFG_EXE

const LOCAL_CFG_EXE = 'powershellExe'

Configuration key for the PowerShell executable in the local configuration.

Definition at line 26 of file class.tool.powershell.php.

◆ LOCAL_CFG_LAUNCH_EXE

const LOCAL_CFG_LAUNCH_EXE = 'powershellLaunchExe'

Configuration key for the PowerShell launch executable in the local configuration.

Definition at line 34 of file class.tool.powershell.php.

◆ LOCAL_CFG_ROWS

const LOCAL_CFG_ROWS = 'powershellRows'

Configuration key for the PowerShell window rows in the local configuration.

Definition at line 38 of file class.tool.powershell.php.

◆ ROOT_CFG_VERSION

const ROOT_CFG_VERSION = 'powershellVersion'

Configuration key for the PowerShell version in the root configuration.

Definition at line 21 of file class.tool.powershell.php.


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