Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.tpl.aestan.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2021-2026 Bearsampp
5 * * License: GNU General Public License version 3 or later; see LICENSE.txt
6 * * Website: https://bearsampp.com
7 * * Github: https://github.com/Bearsampp
8 *
9 */
10
47{
48 // Glyph constants
50 const GLYPH_ADD = 1;
53 const GLYPH_BROWSER = 5;
54 const GLYPH_FILE = 6;
57 const GLYPH_START = 9;
58 const GLYPH_PAUSE = 10;
59 const GLYPH_STOP = 11;
60 const GLYPH_RELOAD = 12;
61 const GLYPH_CHECK = 13;
65 const GLYPH_WARNING = 19;
66 const GLYPH_EXIT = 20;
67 const GLYPH_ABOUT = 21;
71 const GLYPH_LIGHT = 25;
72 const GLYPH_GIT = 26;
73 const GLYPH_NODEJS = 28;
74 const GLYPH_NETWORK = 29;
75 const GLYPH_WEB_PAGE = 30;
76 const GLYPH_DEBUG = 31;
77 const GLYPH_TRASHCAN = 32;
78 const GLYPH_UPDATE = 33;
79 const GLYPH_RESTART = 34;
81 const GLYPH_RED_LIGHT = 36;
82 const GLYPH_COMPOSER = 37;
83 const GLYPH_PEAR = 38;
86 const GLYPH_NOTEPAD2 = 42;
87 const GLYPH_PASSWORD = 45;
90 const GLYPH_PYTHON = 50;
91 const GLYPH_RUBY = 52;
92 const GLYPH_PERL = 55;
94 const GLYPH_NGROK = 57;
95 const GLYPH_PWGEN = 58;
96 const GLYPH_XLIGHT = 59;
98 const GLYPH_BRUNO = 61;
99
100 // Service actions
101 const SERVICE_START = 'startresume';
102 const SERVICE_STOP = 'stop';
103 const SERVICE_RESTART = 'restart';
104 const SERVICES_CLOSE = 'closeservices';
105
106 // Image files
107 const IMG_BAR_PICTURE = 'bar.dat';
108 const IMG_GLYPH_SPRITES = 'sprites.dat';
109
117 public static function getGlyphFlah($lang)
118 {
119 }
120
126 public static function getItemSeparator()
127 {
128 return 'Type: separator';
129 }
130
143 public static function getItemPowerShell($caption, $glyph, $id = null, $title = null, $initDir = null, $command = null)
144 {
145 global $bearsamppTools;
146
147 if ($title === null) {
148 $title = $bearsamppTools->getPowerShell()->getTabTitleDefault();
149 }
150
151 // Launch pwsh.exe directly — no powershell.bat wrapper, no cmd.exe, no flashing window.
152 // Registry font settings are pre-written during reload by TplPowerShell::process().
153 $pwsh = $bearsamppTools->getPowerShell()->getExe();
154 $profilePath = Path::formatWindowsPath($bearsamppTools->getPowerShell()->getConf());
155
156 // Build the inline PowerShell -Command string.
157 // Single-quoted strings are used for paths/titles so backslashes need no escaping.
158 // $Host and [Console] are PowerShell syntax; no shell variable expansion occurs here
159 // because Aestan calls CreateProcess directly (no cmd.exe intermediary).
160 $psCommand = '[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;' .
161 '[Console]::InputEncoding=[System.Text.Encoding]::UTF8;' .
162 '$Host.UI.RawUI.WindowTitle=\'' . $title . '\';';
163
164 if ($command !== null) {
165 $psCommand .= $command . ';';
166 }
167
168 $psCommand .= '. \'' . $profilePath . '\'';
169
170 // Build pwsh.exe argument string using Aestan's "" escaping for embedded double quotes.
171 // -WorkingDirectory sets the initial directory (PowerShell 7+), avoiding Set-Location.
172 $params = '-NoExit -NoProfile';
173 if ($initDir !== null) {
174 $params .= ' -WorkingDirectory ""' . $initDir . '""';
175 }
176 $params .= ' -Command ""' . $psCommand . '""';
177
178 return self::getItemExe($caption, $pwsh, $glyph, $params);
179 }
180
191 public static function getItemLink($caption, $link, $local = false, $glyph = self::GLYPH_WEB_PAGE)
192 {
194
195 if ($local) {
196 $link = Path::getLocalUrl($link);
197 }
198
199 return self::getItemExe(
200 $caption,
201 $bearsamppConfig->getBrowser(),
202 $glyph,
203 $link
204 );
205 }
206
215 public static function getItemNotepad($caption, $path)
216 {
217 global $bearsamppConfig;
218
219 return self::getItemExe(
220 $caption,
221 $bearsamppConfig->getNotepad(),
222 self::GLYPH_FILE,
223 $path
224 );
225 }
226
237 public static function getItemExe($caption, $exe, $glyph, $params = null)
238 {
239 return 'Type: item; ' .
240 'Caption: "' . $caption . '"; ' .
241 'Action: run; ' .
242 'FileName: "' . $exe . '"; ' .
243 (!empty($params) ? 'Parameters: "' . $params . '"; ' : '') .
244 'Glyph: ' . $glyph;
245 }
246
255 public static function getItemExplore($caption, $path)
256 {
257 return 'Type: item; ' .
258 'Caption: "' . $caption . '"; ' .
259 'Action: shellexecute; ' .
260 'FileName: "' . $path . '"; ' .
261 'Glyph: ' . self::GLYPH_FOLDER_OPEN;
262 }
263
273 private static function getActionService($service, $action, $item = false)
274 {
275 global $bearsamppLang;
276 $result = 'Action: ' . $action;
277
278 if ($service != null) {
279 $result = 'Action: service; ' .
280 'Service: ' . $service . '; ' .
281 'ServiceAction: ' . $action;
282 }
283
284 if ($item) {
285 $result = 'Type: item; ' . $result;
286 if ($action == self::SERVICE_START) {
287 $result .= '; Caption: "' . $bearsamppLang->getValue(Lang::MENU_START_SERVICE) . '"' .
288 '; Glyph: ' . self::GLYPH_START;
289 } elseif ($action == self::SERVICE_STOP) {
290 $result .= '; Caption: "' . $bearsamppLang->getValue(Lang::MENU_STOP_SERVICE) . '"' .
291 '; Glyph: ' . self::GLYPH_STOP;
292 } elseif ($action == self::SERVICE_RESTART) {
293 $result .= '; Caption: "' . $bearsamppLang->getValue(Lang::MENU_RESTART_SERVICE) . '"' .
294 '; Glyph: ' . self::GLYPH_RELOAD;
295 }
296 } elseif ($action != self::SERVICES_CLOSE) {
297 $result .= '; Flags: ignoreerrors waituntilterminated';
298 }
299
300 return $result;
301 }
302
310 public static function getActionServiceStart($service)
311 {
312 return self::getActionService($service, self::SERVICE_START, false);
313 }
314
322 public static function getItemActionServiceStart($service)
323 {
324 return self::getActionService($service, self::SERVICE_STOP, true);
325 }
326
334 public static function getActionServiceStop($service)
335 {
336 return self::getActionService($service, self::SERVICE_STOP, false);
337 }
338
346 public static function getItemActionServiceStop($service)
347 {
348 return self::getActionService($service, self::SERVICE_START, true);
349 }
350
358 public static function getActionServiceRestart($service)
359 {
360 return self::getActionService($service, self::SERVICE_RESTART, false);
361 }
362
370 public static function getItemActionServiceRestart($service)
371 {
372 return self::getActionService($service, self::SERVICE_RESTART, true);
373 }
374
380 public static function getActionServicesClose()
381 {
382 return self::getActionService(null, self::SERVICES_CLOSE, false);
383 }
384
390 public static function getItemActionServicesClose()
391 {
392 return self::getActionService(null, self::SERVICES_CLOSE, true);
393 }
394
400 public static function getSectionMessages()
401 {
402 global $bearsamppLang;
403
404 return '[Messages]' . PHP_EOL .
405 'AllRunningHint=' . $bearsamppLang->getValue(Lang::ALL_RUNNING_HINT) . PHP_EOL .
406 'SomeRunningHint=' . $bearsamppLang->getValue(Lang::SOME_RUNNING_HINT) . PHP_EOL .
407 'NoneRunningHint=' . $bearsamppLang->getValue(Lang::NONE_RUNNING_HINT) . PHP_EOL;
408 }
409
415 public static function getSectionConfig()
416 {
417 global $bearsamppCore;
418
419 return '[Config]' . PHP_EOL .
420 'ImageList=' . self::IMG_GLYPH_SPRITES . PHP_EOL .
421 'ServiceCheckInterval=1' . PHP_EOL .
422 'TrayIconAllRunning=' . self::GLYPH_SERVICE_ALL_RUNNING . PHP_EOL .
423 'TrayIconSomeRunning=' . self::GLYPH_SERVICE_SOME_RUNNING . PHP_EOL .
424 'TrayIconNoneRunning=' . self::GLYPH_SERVICE_NONE_RUNNING . PHP_EOL .
425 'ID={' . strtolower(APP_TITLE) . '}' . PHP_EOL .
426 'AboutHeader=' . APP_TITLE . PHP_EOL .
427 'AboutVersion=Version ' . $bearsamppCore->getAppVersion() . PHP_EOL;
428 }
429
435 public static function getSectionMenuRightSettings()
436 {
437 return '[Menu.Right.Settings]' . PHP_EOL .
438 'BarVisible=no' . PHP_EOL .
439 'SeparatorsAlignment=center' . PHP_EOL .
440 'SeparatorsFade=yes' . PHP_EOL .
441 'SeparatorsFadeColor=clBtnShadow' . PHP_EOL .
442 'SeparatorsFlatLines=yes' . PHP_EOL .
443 'SeparatorsGradientEnd=clSilver' . PHP_EOL .
444 'SeparatorsGradientStart=clGray' . PHP_EOL .
445 'SeparatorsGradientStyle=horizontal' . PHP_EOL .
446 'SeparatorsSeparatorStyle=shortline' . PHP_EOL;
447 }
448
456 public static function getSectionMenuLeftSettings($caption)
457 {
458 return '[Menu.Left.Settings]' . PHP_EOL .
459 'AutoLineReduction=no' . PHP_EOL .
460 'BarVisible=yes' . PHP_EOL .
461 'BarCaptionAlignment=bottom' . PHP_EOL .
462 'BarCaptionCaption=' . $caption . PHP_EOL .
463 'BarCaptionDepth=1' . PHP_EOL .
464 'BarCaptionDirection=downtoup' . PHP_EOL .
465 'BarCaptionFont=Tahoma,14,clWhite' . PHP_EOL .
466 'BarCaptionHighlightColor=clNone' . PHP_EOL .
467 'BarCaptionOffsetY=0' . PHP_EOL .
468 'BarCaptionShadowColor=clNone' . PHP_EOL .
469 'BarPictureHorzAlignment=center' . PHP_EOL .
470 'BarPictureOffsetX=0' . PHP_EOL .
471 'BarPictureOffsetY=0' . PHP_EOL .
472 'BarPicturePicture=' . self::IMG_BAR_PICTURE . PHP_EOL .
473 'BarPictureTransparent=yes' . PHP_EOL .
474 'BarPictureVertAlignment=bottom' . PHP_EOL .
475 'BarBorder=clNone' . PHP_EOL .
476 'BarGradientEnd=$00c07840' . PHP_EOL .
477 'BarGradientStart=$00c07840' . PHP_EOL .
478 'BarGradientStyle=horizontal' . PHP_EOL .
479 'BarSide=left' . PHP_EOL .
480 'BarSpace=0' . PHP_EOL .
481 'BarWidth=32' . PHP_EOL .
482 'SeparatorsAlignment=center' . PHP_EOL .
483 'SeparatorsFade=yes' . PHP_EOL .
484 'SeparatorsFadeColor=clBtnShadow' . PHP_EOL .
485 'SeparatorsFlatLines=yes' . PHP_EOL .
486 'SeparatorsFont=Arial,8,clWhite,bold' . PHP_EOL .
487 'SeparatorsGradientEnd=$00FFAA55' . PHP_EOL .
488 'SeparatorsGradientStart=$00550000' . PHP_EOL .
489 'SeparatorsGradientStyle=horizontal' . PHP_EOL .
490 'SeparatorsSeparatorStyle=caption' . PHP_EOL;
491 }
492}
493
$result
global $bearsamppLang
global $bearsamppRoot
global $bearsamppCore
const NONE_RUNNING_HINT
const MENU_STOP_SERVICE
const ALL_RUNNING_HINT
const MENU_RESTART_SERVICE
const SOME_RUNNING_HINT
const MENU_START_SERVICE
static getLocalUrl($request=null)
static formatWindowsPath($path)
static getActionService($service, $action, $item=false)
static getActionServiceStop($service)
const GLYPH_SERVICE_SOME_RUNNING
static getItemPowerShell($caption, $glyph, $id=null, $title=null, $initDir=null, $command=null)
static getItemExe($caption, $exe, $glyph, $params=null)
const GLYPH_SERVICE_NONE_RUNNING
static getSectionConfig()
const GLYPH_SERVICES_STOP
const GLYPH_POWERSHELL
const GLYPH_FOLDER_DISABLED
const IMG_GLYPH_SPRITES
const GLYPH_RED_LIGHT
const GLYPH_SERVICES_RESTART
const GLYPH_FOLDER_CLOSE
const GLYPH_SERVICE_REMOVE
static getItemActionServicesClose()
static getGlyphFlah($lang)
static getActionServiceStart($service)
const GLYPH_GHOSTSCRIPT
const GLYPH_FOLDER_ENABLED
static getSectionMessages()
static getItemActionServiceStop($service)
const GLYPH_SERVICES_START
const GLYPH_SERVICE_ALL_RUNNING
const GLYPH_HOSTSEDITOR
static getActionServiceRestart($service)
static getSectionMenuLeftSettings($caption)
static getItemExplore($caption, $path)
const GLYPH_FOLDER_OPEN
const GLYPH_SERVICE_INSTALL
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemNotepad($caption, $path)
const GLYPH_IMAGEMAGICK
static getSectionMenuRightSettings()
const GLYPH_SSL_CERTIFICATE
static getActionServicesClose()
static getItemActionServiceStart($service)
const GLYPH_REBUILD_INI
static getItemSeparator()
static getItemActionServiceRestart($service)
global $bearsamppConfig
Definition homepage.php:46
if( $raw) foreach($opts as $opt) if( $store_system_config) if($store_user_config) $command
Definition pearcmd.php:322
const APP_TITLE
Definition root.php:19