Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
ToolPowerShell Class Reference
Inheritance 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 ()
 getCurrentPath ()
 getId ()
 getName ()
 getRelease ()
 getRootPath ()
 getSymlinkPath ()
 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
const BUNDLE_RELEASE = 'bundleRelease'

Private Attributes

 $cols
 $conf
 $exe
 $launchExe
 $rows

Additional Inherited Members

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
 $currentPath
 $enable
 $name
 $release = 'N/A'
 $rootPath
 $symlinkPath
 $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 38 of file class.tool.powershell.php.

38 {
39 Util::logInitClass($this);
40 $this->reload($id, $type);
41 }
reload($id=null, $type=null)
static logInitClass($classInstance)

References Module\$id, Module\$type, Util\logInitClass(), and reload().

Member Function Documentation

◆ getCols()

getCols ( )

Gets the number of columns for the PowerShell window.

Returns
int The number of columns.

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

149 {
150 return $this->cols;
151 }

References $cols.

◆ getConf()

getConf ( )

Gets the configuration file path for PowerShell.

Returns
string The configuration file path.

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

131 {
132 return $this->conf;
133 }

References $conf.

◆ getExe()

getExe ( )

Gets the executable path for PowerShell.

Returns
string The executable path.

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

113 {
114 return $this->exe;
115 }

References $exe.

◆ getLaunchExe()

getLaunchExe ( )

Gets the launch executable path for PowerShell.

Returns
string The launch executable path.

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

122 {
123 return $this->launchExe;
124 }

References $launchExe.

Referenced by getShell().

◆ getRows()

getRows ( )

Gets the number of rows for the PowerShell window.

Returns
int The number of rows.

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

140 {
141 return $this->rows;
142 }

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 159 of file class.tool.powershell.php.

159 {
160 if (empty($args)) {
161 return 'cmd /k "' . Util::formatWindowsPath($this->launchExe) . '"';
162 } else {
163 return 'cmd /k ""' . Util::formatWindowsPath($this->getLaunchExe()) . '" & ' . Util::formatWindowsPath($args) . '"';
164 }
165 }
static formatWindowsPath($path)

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

◆ getTabTitleComposer()

getTabTitleComposer ( )

Gets the tab title for Composer.

Returns
string The tab title for Composer.

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

255 {
256 global $bearsamppLang, $bearsamppTools;
257 return $bearsamppLang->getValue(Lang::COMPOSER) . ' ' . $bearsamppTools->getComposer()->getVersion();
258 }
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 172 of file class.tool.powershell.php.

172 {
173 return 'Bearsampp Powershell Console';
174 }

◆ getTabTitleGhostscript()

getTabTitleGhostscript ( )

Gets the tab title for Ghostscript.

Returns
string The tab title for Ghostscript.

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

295 {
296 global $bearsamppLang, $bearsamppTools;
297 return $bearsamppLang->getValue(Lang::GHOSTSCRIPT) . ' ' . $bearsamppTools->getGhostscript()->getVersion();
298 }
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 231 of file class.tool.powershell.php.

231 {
232 global $bearsamppLang, $bearsamppTools;
233 $result = $bearsamppLang->getValue(Lang::GIT) . ' ' . $bearsamppTools->getGit()->getVersion();
234 if ($repoPath != null) {
235 $result .= ' - ' . basename($repoPath);
236 }
237 return $result;
238 }
$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 210 of file class.tool.powershell.php.

210 {
212 return $bearsamppLang->getValue(Lang::MARIADB) . ' ' . $bearsamppBins->getMariadb()->getVersion();
213 }
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 200 of file class.tool.powershell.php.

200 {
202 return $bearsamppLang->getValue(Lang::MYSQL) . ' ' . $bearsamppBins->getMysql()->getVersion();
203 }
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 305 of file class.tool.powershell.php.

305 {
306 global $bearsamppLang, $bearsamppTools;
307 return $bearsamppLang->getValue(Lang::NGROK) . ' ' . $bearsamppTools->getNgrok()->getVersion();
308 }
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 245 of file class.tool.powershell.php.

245 {
247 return $bearsamppLang->getValue(Lang::NODEJS) . ' ' . $bearsamppBins->getNodejs()->getVersion();
248 }
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 190 of file class.tool.powershell.php.

190 {
192 return $bearsamppLang->getValue(Lang::PEAR) . ' ' . $bearsamppBins->getPhp()->getPearVersion(true);
193 }
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 285 of file class.tool.powershell.php.

285 {
286 global $bearsamppLang, $bearsamppTools;
287 return $bearsamppLang->getValue(Lang::PERL) . ' ' . $bearsamppTools->getPerl()->getVersion();
288 }
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 220 of file class.tool.powershell.php.

220 {
222 return $bearsamppLang->getValue(Lang::POSTGRESQL) . ' ' . $bearsamppBins->getPostgresql()->getVersion();
223 }
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 181 of file class.tool.powershell.php.

181 {
182 return 'PowerShell';
183 }

◆ getTabTitlePython()

getTabTitlePython ( )

Gets the tab title for Python.

Returns
string The tab title for Python.

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

265 {
266 global $bearsamppLang, $bearsamppTools;
267 return $bearsamppLang->getValue(Lang::PYTHON) . ' ' . $bearsamppTools->getPython()->getVersion();
268 }
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 275 of file class.tool.powershell.php.

275 {
276 global $bearsamppLang, $bearsamppTools;
277 return $bearsamppLang->getValue(Lang::RUBY) . ' ' . $bearsamppTools->getRuby()->getVersion();
278 }
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 49 of file class.tool.powershell.php.

49 {
52
53 $this->name = $bearsamppLang->getValue(Lang::POWERSHELL);
54 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
55 parent::reload($id, $type);
56
57 if ($this->bearsamppConfRaw !== false) {
58 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
59 $this->launchExe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_LAUNCH_EXE];
60 $this->conf = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
61 $this->rows = intval($this->bearsamppConfRaw[self::LOCAL_CFG_ROWS]);
62 $this->cols = intval($this->bearsamppConfRaw[self::LOCAL_CFG_COLS]);
63 }
64
65 if (!$this->enable) {
66 Util::logInfo($this->name . ' is not enabled!');
67 return;
68 }
69 if (!is_dir($this->currentPath)) {
70 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
71 }
72 if (!is_dir($this->symlinkPath)) {
73 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
74 return;
75 }
76 if (!is_file($this->bearsamppConf)) {
77 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
78 }
79 if (!is_file($this->exe)) {
80 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
81 }
82 if (!is_file($this->launchExe)) {
83 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->launchExe));
84 }
85 if (!is_file($this->conf)) {
86 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->conf));
87 }
88 if (!is_numeric($this->rows) || $this->rows <= 0) {
89 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_INVALID_PARAMETER), self::LOCAL_CFG_ROWS, $this->rows));
90 }
91 if (!is_numeric($this->cols) || $this->cols <= 0) {
92 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_INVALID_PARAMETER), self::LOCAL_CFG_COLS, $this->cols));
93 }
94 }
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const POWERSHELL
const ERROR_INVALID_PARAMETER
const ERROR_FILE_NOT_FOUND
static logError($data, $file=null)
static logInfo($data, $file=null)
static logReloadClass($classInstance)
global $bearsamppConfig
Definition homepage.php:41

References $bearsamppConfig, $bearsamppLang, Module\$id, Module\$type, Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_EXE_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, Lang\ERROR_INVALID_PARAMETER, Util\logError(), Util\logInfo(), Util\logReloadClass(), and Lang\POWERSHELL.

Referenced by __construct(), and setVersion().

◆ setVersion()

setVersion ( $version)

Sets the version of the PowerShell tool.

Parameters
string$versionThe version to set.

Reimplemented from Module.

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

101 {
102 global $bearsamppConfig;
103 $this->version = $version;
104 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
105 $this->reload();
106 }

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

Field Documentation

◆ $cols

$cols
private

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

Referenced by getCols().

◆ $conf

$conf
private

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

Referenced by getConf().

◆ $exe

$exe
private

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

Referenced by getExe().

◆ $launchExe

$launchExe
private

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

Referenced by getLaunchExe().

◆ $rows

$rows
private

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

Referenced by getRows().

◆ LOCAL_CFG_COLS

const LOCAL_CFG_COLS = 'powershellCols'

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

◆ LOCAL_CFG_CONF

const LOCAL_CFG_CONF = 'powershellConf'

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

◆ LOCAL_CFG_EXE

const LOCAL_CFG_EXE = 'powershellExe'

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

◆ LOCAL_CFG_LAUNCH_EXE

const LOCAL_CFG_LAUNCH_EXE = 'powershellLaunchExe'

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

◆ LOCAL_CFG_ROWS

const LOCAL_CFG_ROWS = 'powershellRows'

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

◆ ROOT_CFG_VERSION

const ROOT_CFG_VERSION = 'powershellVersion'

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


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