2024.8.23
Loading...
Searching...
No Matches
class.tpl.consolez.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
10/**
11 * Class TplConsoleZ
12 *
13 * This class is responsible for generating the configuration file for ConsoleZ.
14 * It includes methods to define various sections of the configuration such as console settings,
15 * appearance, behavior, hotkeys, mouse actions, and tabs.
16 */
18{
19 const ICON_APP = 'app.ico';
20 const ICON_POWERSHELL = 'powershell.ico';
21 const ICON_PEAR = 'pear.ico';
22 const ICON_DB = 'db.ico';
23 const ICON_GHOSTSCRIPT = 'ghostscript.ico';
24 const ICON_GIT = 'git.ico';
25 const ICON_NODEJS = 'nodejs.ico';
26 const ICON_COMPOSER = 'composer.ico';
27 const ICON_PYTHON = 'python.ico';
28 const ICON_RUBY = 'ruby.ico';
29 const ICON_YARN = 'yarn.ico';
30 const ICON_PERL = 'perl.ico';
31 const ICON_NGROK = 'ngrok.ico';
32
33 /**
34 * Private constructor to prevent instantiation.
35 */
36 private function __construct()
37 {
38 }
39
40 /**
41 * Generates the ConsoleZ configuration file.
42 *
43 * This method constructs the XML structure for the ConsoleZ configuration by calling
44 * various helper methods to generate different sections of the configuration.
45 * The resulting XML is then written to the configuration file.
46 */
47 public static function process()
48 {
49 global $bearsamppTools;
50 $result = '<?xml version="1.0"?>' . PHP_EOL . '<settings>' . PHP_EOL .
51 self::getConsoleSection() . PHP_EOL .
52 self::getAppearanceSection() . PHP_EOL .
53 self::getBehaviorSection() . PHP_EOL .
54 self::getHotkeysSection() . PHP_EOL .
55 self::getMouseSection() . PHP_EOL .
56 self::getTabsSection() . PHP_EOL .
57 '</settings>';
58
59 file_put_contents($bearsamppTools->getConsoleZ()->getConf(), $result);
60 }
61
62 /**
63 * Generates the XML section for console settings.
64 *
65 * This method constructs the XML string for the console settings of the ConsoleZ configuration.
66 * It includes settings for refresh rates, buffer sizes, and initial directory.
67 *
68 * @return string The XML string representing the console settings.
69 */
70 private static function getConsoleSection()
71 {
72 global $bearsamppRoot, $bearsamppTools;
73
74 $sectionConsoleStart = self::getIncrStr(1) . '<console ' .
75 'change_refresh="10" ' .
76 'refresh="100" ' .
77 'rows="' . $bearsamppTools->getConsoleZ()->getRows() . '" ' .
78 'columns="' . $bearsamppTools->getConsoleZ()->getCols() . '" ' .
79 'buffer_rows="2048" ' .
80 'buffer_columns="0" ' .
81 'shell="" ' .
82 'init_dir="' . $bearsamppRoot->getRootPath() . '" ' .
83 'start_hidden="0" ' .
84 'save_size="0">' . PHP_EOL;
85
86 $sectionColors = self::getIncrStr(2) . '<colors>' . PHP_EOL .
87 self::getIncrStr(3) . '<color id="0" r="39" g="40" b="34"/>' . PHP_EOL .
88 self::getIncrStr(3) . '<color id="1" r="88" g="194" b="229"/>' . PHP_EOL .
89 self::getIncrStr(3) . '<color id="2" r="88" g="194" b="229"/>' . PHP_EOL .
90 self::getIncrStr(3) . '<color id="3" r="198" g="197" b="254"/>' . PHP_EOL .
91 self::getIncrStr(3) . '<color id="4" r="168" g="125" b="184"/>' . PHP_EOL .
92 self::getIncrStr(3) . '<color id="5" r="243" g="4" b="75"/>' . PHP_EOL .
93 self::getIncrStr(3) . '<color id="6" r="243" g="4" b="75"/>' . PHP_EOL .
94 self::getIncrStr(3) . '<color id="7" r="238" g="238" b="238"/>' . PHP_EOL .
95 self::getIncrStr(3) . '<color id="8" r="124" g="124" b="124"/>' . PHP_EOL .
96 self::getIncrStr(3) . '<color id="9" r="3" g="131" b="245"/>' . PHP_EOL .
97 self::getIncrStr(3) . '<color id="10" r="141" g="208" b="6"/>' . PHP_EOL .
98 self::getIncrStr(3) . '<color id="11" r="88" g="194" b="229"/>' . PHP_EOL .
99 self::getIncrStr(3) . '<color id="12" r="168" g="125" b="184"/>' . PHP_EOL .
100 self::getIncrStr(3) . '<color id="13" r="243" g="4" b="75"/>' . PHP_EOL .
101 self::getIncrStr(3) . '<color id="14" r="204" g="204" b="129"/>' . PHP_EOL .
102 self::getIncrStr(3) . '<color id="15" r="255" g="255" b="255"/>' . PHP_EOL .
103 self::getIncrStr(2) . '</colors>' . PHP_EOL;
104
105 $sectionConsoleEnd = self::getIncrStr(1) . '</console>';
106
107 return $sectionConsoleStart . $sectionColors . $sectionConsoleEnd;
108 }
109
110 /**
111 * Generates the XML section for appearance settings.
112 *
113 * This method constructs the XML string for the appearance settings of the ConsoleZ configuration.
114 * It includes settings for font, window properties, controls, styles, position, and transparency.
115 *
116 * @return string The XML string representing the appearance settings.
117 */
118 private static function getAppearanceSection()
119 {
120 $sectionFont = self::getIncrStr(2) . '<font name="Courier New" size="10" bold="0" italic="0" smoothing="0">' . PHP_EOL .
121 self::getIncrStr(3) . '<color use="0" r="0" g="255" b="0"/>' . PHP_EOL .
122 self::getIncrStr(2) . '</font>';
123
124 $windowSection = self::getIncrStr(2) . '<window ' .
125 'title="ConsoleZ" ' .
126 'icon="" ' .
127 'use_tab_icon="1" ' .
128 'use_console_title="0" ' .
129 'show_cmd="0" ' .
130 'show_cmd_tabs="0" ' .
131 'use_tab_title="1" ' .
132 'trim_tab_titles="20" ' .
133 'trim_tab_titles_right="0"/>';
134
135 $controlsSection = self::getIncrStr(2) . '<controls ' .
136 'show_menu="0" ' .
137 'show_toolbar="1" ' .
138 'show_statusbar="1" ' .
139 'show_tabs="1" ' .
140 'hide_single_tab="1" ' .
141 'show_scrollbars="1" ' .
142 'flat_scrollbars="0" ' .
143 'tabs_on_bottom="0"/>';
144
145 $stylesSection = self::getIncrStr(2) . '<styles caption="1" resizable="1" taskbar_button="1" border="1" inside_border="2" tray_icon="0">' . PHP_EOL .
146 self::getIncrStr(3) . '<selection_color r="255" g="255" b="255"/>' . PHP_EOL .
147 self::getIncrStr(2) . '</styles>';
148
149 $positionSection = self::getIncrStr(2) . '<divosition ' .
150 'x="-1" ' .
151 'y="-1" ' .
152 'dock="-1" ' .
153 'snap="0" ' .
154 'z_order="0" ' .
155 'save_position="0"/>';
156
157 $transparencySection = self::getIncrStr(2) . '<transparency ' .
158 'type="1" ' .
159 'active_alpha="240" ' .
160 'inactive_alpha="225" ' .
161 'r="0" ' .
162 'g="0" ' .
163 'b="0"/>';
164
165 return self::getIncrStr(1) . '<appearance>' . PHP_EOL .
166 $sectionFont . PHP_EOL .
167 $windowSection . PHP_EOL .
168 $controlsSection . PHP_EOL .
169 $stylesSection . PHP_EOL .
170 $positionSection . PHP_EOL .
171 $transparencySection . PHP_EOL .
172 self::getIncrStr(1) . '</appearance>';
173 }
174
175 /**
176 * Generates the XML section for behavior settings.
177 *
178 * This method constructs the XML string for the behavior settings of the ConsoleZ configuration.
179 * It includes settings for copy-paste behavior, scroll behavior, and tab highlight behavior.
180 *
181 * @return string The XML string representing the behavior settings.
182 */
183 private static function getBehaviorSection()
184 {
185 $sectionCopyPaste = self::getIncrStr(2) . '<copy_paste ' .
186 'copy_on_select="0" ' .
187 'clear_on_copy="1" ' .
188 'no_wrap="1" ' .
189 'trim_spaces="1" ' .
190 'copy_newline_char="0" ' .
191 'sensitive_copy="1"/>';
192
193 $sectionScroll = self::getIncrStr(2) . '<scroll page_scroll_rows="0"/>';
194
195 $sectionTabHighlight = self::getIncrStr(2) . '<tab_highlight flashes="3" stay_highligted="1"/>';
196
197 return self::getIncrStr(1) . '<behavior>' . PHP_EOL .
198 $sectionCopyPaste . PHP_EOL .
199 $sectionScroll . PHP_EOL .
200 $sectionTabHighlight . PHP_EOL .
201 self::getIncrStr(1) . '</behavior>';
202 }
203
204 /**
205 * Generates the XML section for hotkeys settings.
206 *
207 * This method constructs the XML string for the hotkeys settings of the ConsoleZ configuration.
208 * It includes settings for various hotkey combinations and their corresponding commands.
209 *
210 * @return string The XML string representing the hotkeys settings.
211 */
212 private static function getHotkeysSection()
213 {
214 return self::getIncrStr(1) . '<hotkeys use_scroll_lock="0">' . PHP_EOL .
215 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="83" command="settings"/>' . PHP_EOL .
216 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="112" command="help"/>' . PHP_EOL .
217 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="1" extended="0" code="115" command="exit"/>' . PHP_EOL .
218 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="112" command="newtab1"/>' . PHP_EOL .
219 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="113" command="newtab2"/>' . PHP_EOL .
220 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="114" command="newtab3"/>' . PHP_EOL .
221 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="115" command="newtab4"/>' . PHP_EOL .
222 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="116" command="newtab5"/>' . PHP_EOL .
223 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="117" command="newtab6"/>' . PHP_EOL .
224 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="118" command="newtab7"/>' . PHP_EOL .
225 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="119" command="newtab8"/>' . PHP_EOL .
226 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="120" command="newtab9"/>' . PHP_EOL .
227 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="121" command="newtab10"/>' . PHP_EOL .
228 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="49" command="switchtab1"/>' . PHP_EOL .
229 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="50" command="switchtab2"/>' . PHP_EOL .
230 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="51" command="switchtab3"/>' . PHP_EOL .
231 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="52" command="switchtab4"/>' . PHP_EOL .
232 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="53" command="switchtab5"/>' . PHP_EOL .
233 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="54" command="switchtab6"/>' . PHP_EOL .
234 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="55" command="switchtab7"/>' . PHP_EOL .
235 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="56" command="switchtab8"/>' . PHP_EOL .
236 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="57" command="switchtab9"/>' . PHP_EOL .
237 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="48" command="switchtab10"/>' . PHP_EOL .
238 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="9" command="nexttab"/>' . PHP_EOL .
239 self::getIncrStr(2) . '<hotkey ctrl="1" shift="1" alt="0" extended="0" code="9" command="prevtab"/>' . PHP_EOL .
240 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="87" command="closetab"/>' . PHP_EOL .
241 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="0" code="82" command="renametab"/>' . PHP_EOL .
242 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="1" code="45" command="copy"/>' . PHP_EOL .
243 self::getIncrStr(2) . '<hotkey ctrl="1" shift="0" alt="0" extended="1" code="46" command="clear_selection"/>' . PHP_EOL .
244 self::getIncrStr(2) . '<hotkey ctrl="0" shift="1" alt="0" extended="1" code="45" command="paste"/>' . PHP_EOL .
245 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="stopscroll"/>' . PHP_EOL .
246 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollrowup"/>' . PHP_EOL .
247 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollrowdown"/>' . PHP_EOL .
248 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpageup"/>' . PHP_EOL .
249 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpagedown"/>' . PHP_EOL .
250 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollcolleft"/>' . PHP_EOL .
251 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollcolright"/>' . PHP_EOL .
252 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpageleft"/>' . PHP_EOL .
253 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpageright"/>' . PHP_EOL .
254 self::getIncrStr(2) . '<hotkey ctrl="1" shift="1" alt="0" extended="0" code="112" command="dumpbuffer"/>' . PHP_EOL .
255 self::getIncrStr(2) . '<hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="activate"/>' . PHP_EOL .
256 self::getIncrStr(1) . '</hotkeys>';
257 }
258
259 /**
260 * Generates the XML structure for the mouse section.
261 *
262 * This function creates an XML structure defining mouse actions and their corresponding
263 * key combinations. It uses the `getIncrStr` method to format the XML with appropriate
264 * indentation.
265 *
266 * @return string The formatted XML string for the mouse section.
267 */
268 private static function getMouseSection()
269 {
270 return self::getIncrStr(1) . '<mouse>' . PHP_EOL .
271 self::getIncrStr(2) . '<actions>' . PHP_EOL .
272 self::getIncrStr(3) . '<action ctrl="0" shift="0" alt="0" button="1" name="copy"/>' . PHP_EOL .
273 self::getIncrStr(3) . '<action ctrl="0" shift="1" alt="0" button="1" name="select"/>' . PHP_EOL .
274 self::getIncrStr(3) . '<action ctrl="0" shift="0" alt="0" button="3" name="paste"/>' . PHP_EOL .
275 self::getIncrStr(3) . '<action ctrl="1" shift="0" alt="0" button="1" name="drag"/>' . PHP_EOL .
276 self::getIncrStr(3) . '<action ctrl="0" shift="0" alt="0" button="2" name="menu"/>' . PHP_EOL .
277 self::getIncrStr(2) . '</actions>' . PHP_EOL .
278 self::getIncrStr(1) . '</mouse>';
279 }
280
281 /**
282 * Generates the XML structure for the tabs section.
283 *
284 * This function creates an XML structure defining various tabs and their configurations.
285 * It includes multiple tab sections such as command, PowerShell, PEAR, MySQL, MariaDB,
286 * PostgreSQL, Ghostscript, Git, Node.js, Composer, Perl, Python, Ruby, Yarn, and Ngrok.
287 *
288 * @return string The formatted XML string for the tabs section.
289 */
310
311 /**
312 * Generates the XML structure for the command tab section.
313 *
314 * This function creates an XML structure defining the command tab and its configuration.
315 * It retrieves the tab title and shell command from the ConsoleZ tool and sets the root path.
316 *
317 * @return string The formatted XML string for the command tab section.
318 * @global Tools $bearsamppTools The tools object of the application.
319 *
320 * @global Root $bearsamppRoot The root object of the application.
321 */
322 private static function getTabCmdSection()
323 {
324 global $bearsamppRoot, $bearsamppTools;
325
326 return self::getTab(
327 $bearsamppTools->getConsoleZ()->getTabTitleDefault(),
328 self::ICON_APP,
329 $bearsamppTools->getConsoleZ()->getShell(),
330 $bearsamppRoot->getRootPath()
331 ) . PHP_EOL;
332 }
333
334 /**
335 * Generates the XML structure for the PowerShell tab section.
336 *
337 * This function creates an XML structure defining the PowerShell tab and its configuration.
338 * It retrieves the PowerShell path and sets the root path.
339 *
340 * @return string The formatted XML string for the PowerShell tab section.
341 * @global Tools $bearsamppTools The tools object of the application.
342 *
343 * @global Root $bearsamppRoot The root object of the application.
344 */
345 private static function getTabPowerShellSection()
346 {
347 global $bearsamppRoot, $bearsamppTools;
348
349 $powerShellPath = Util::getPowerShellPath();
350 if ($powerShellPath !== false) {
351 return self::getTab(
352 $bearsamppTools->getConsoleZ()->getTabTitlePowershell(),
353 self::ICON_POWERSHELL,
354 $powerShellPath,
355 $bearsamppRoot->getRootPath()
356 ) . PHP_EOL;
357 }
358
359 return "";
360 }
361
362 /**
363 * Generates the XML structure for the PEAR tab section.
364 *
365 * This function creates an XML structure defining the PEAR tab and its configuration.
366 * It retrieves the PEAR executable path and sets the symlink path.
367 *
368 * @return string The formatted XML string for the PEAR tab section.
369 * @global Tools $bearsamppTools The tools object of the application.
370 *
371 * @global Bins $bearsamppBins The bins object of the application.
372 */
373 private static function getTabPearSection()
374 {
375 global $bearsamppBins, $bearsamppTools;
376
377 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppBins->getPhp()->getPearExe() . '&quot; -V');
378 if (!file_exists($bearsamppBins->getPhp()->getPearExe())) {
379 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppBins->getPhp()->getPearExe() . ' not found');
380 }
381
382 return self::getTab(
383 $bearsamppTools->getConsoleZ()->getTabTitlePear(),
384 self::ICON_PEAR,
385 $shell,
386 $bearsamppBins->getPhp()->getSymlinkPath() . '/pear'
387 ) . PHP_EOL;
388 }
389
390 /**
391 * Generates the XML structure for the MySQL tab section.
392 *
393 * This function creates an XML structure defining the MySQL tab and its configuration.
394 * It retrieves the MySQL CLI executable path and sets the symlink path.
395 *
396 * @return string The formatted XML string for the MySQL tab section.
397 * @global Tools $bearsamppTools The tools object of the application.
398 *
399 * @global Bins $bearsamppBins The bins object of the application.
400 */
401 private static function getTabMysqlSection()
402 {
403 global $bearsamppBins, $bearsamppTools;
404
405 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppBins->getMysql()->getCliExe() . '&quot; -u' .
406 $bearsamppBins->getMysql()->getRootUser() .
407 ($bearsamppBins->getMysql()->getRootPwd() ? ' -p' : ''));
408 if (!file_exists($bearsamppBins->getMysql()->getCliExe())) {
409 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppBins->getMysql()->getCliExe() . ' not found');
410 }
411
412 return self::getTab(
413 $bearsamppTools->getConsoleZ()->getTabTitleMysql(),
414 self::ICON_DB,
415 $shell,
416 $bearsamppBins->getMysql()->getSymlinkPath()
417 ) . PHP_EOL;
418 }
419
420 /**
421 * Generates the XML structure for the MariaDB tab section.
422 *
423 * This function creates an XML structure defining the MariaDB tab and its configuration.
424 * It retrieves the MariaDB CLI executable path and sets the symlink path.
425 *
426 * @return string The formatted XML string for the MariaDB tab section.
427 * @global Tools $bearsamppTools The tools object of the application.
428 *
429 * @global Bins $bearsamppBins The bins object of the application.
430 */
431 private static function getTabMariadbSection()
432 {
433 global $bearsamppBins, $bearsamppTools;
434
435 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppBins->getMariadb()->getCliExe() . '&quot; -u' .
436 $bearsamppBins->getMariadb()->getRootUser() .
437 ($bearsamppBins->getMariadb()->getRootPwd() ? ' -p' : ''));
438 if (!file_exists($bearsamppBins->getMariadb()->getCliExe())) {
439 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppBins->getMariadb()->getCliExe() . ' not found');
440 }
441
442 return self::getTab(
443 $bearsamppTools->getConsoleZ()->getTabTitleMariadb(),
444 self::ICON_DB,
445 $shell,
446 $bearsamppBins->getMariadb()->getSymlinkPath()
447 ) . PHP_EOL;
448 }
449
450 /**
451 * Generates the XML structure for the PostgreSQL tab section.
452 *
453 * This function creates an XML structure defining the PostgreSQL tab and its configuration.
454 * It retrieves the PostgreSQL CLI executable path and sets the symlink path.
455 *
456 * @return string The formatted XML string for the PostgreSQL tab section.
457 * @global Tools $bearsamppTools The tools object of the application.
458 *
459 * @global Bins $bearsamppBins The bins object of the application.
460 */
461 private static function getTabPostgresqlSection()
462 {
463 global $bearsamppBins, $bearsamppTools;
464
465 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppBins->getPostgresql()->getCliExe() . '&quot;' .
466 ' -h 127.0.0.1' .
467 ' -p ' . $bearsamppBins->getPostgresql()->getPort() .
468 ' -U ' . $bearsamppBins->getPostgresql()->getRootUser() .
469 ' -d postgres');
470 if (!file_exists($bearsamppBins->getPostgresql()->getCliExe())) {
471 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppBins->getPostgresql()->getCliExe() . ' not found');
472 }
473
474 return self::getTab(
475 $bearsamppTools->getConsoleZ()->getTabTitlePostgresql(),
476 self::ICON_DB,
477 $shell,
478 $bearsamppBins->getPostgresql()->getSymlinkPath()
479 ) . PHP_EOL;
480 }
481
482 /**
483 * Generates the XML structure for the Git tab section.
484 *
485 * This function creates an XML structure defining the Git tab and its configuration.
486 * It retrieves the Git executable path and sets the WWW path.
487 *
488 * @return string The formatted XML string for the Git tab section.
489 * @global Tools $bearsamppTools The tools object of the application.
490 *
491 * @global Root $bearsamppRoot The root object of the application.
492 */
493 private static function getTabGitSection()
494 {
495 global $bearsamppRoot, $bearsamppTools;
496
497 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppTools->getGit()->getExe() . '&quot; --version');
498 if (!file_exists($bearsamppTools->getGit()->getExe())) {
499 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppTools->getGit()->getExe() . ' not found');
500 }
501
502 return self::getTab(
503 $bearsamppTools->getConsoleZ()->getTabTitleGit(),
504 self::ICON_GIT,
505 $shell,
506 $bearsamppRoot->getWwwPath()
507 ) . PHP_EOL;
508 }
509
510 /**
511 * Generates the XML structure for the Node.js tab section.
512 *
513 * This function creates an XML structure defining the Node.js tab and its configuration.
514 * It retrieves the Node.js launch path and sets the WWW path.
515 *
516 * @return string The formatted XML string for the Node.js tab section.
517 * @global Bins $bearsamppBins The bins object of the application.
518 * @global Tools $bearsamppTools The tools object of the application.
519 *
520 * @global Root $bearsamppRoot The root object of the application.
521 */
522 private static function getTabNodejsSection()
523 {
524 global $bearsamppRoot, $bearsamppBins, $bearsamppTools;
525
526 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppBins->getNodejs()->getLaunch() . '&quot;');
527 if (!file_exists($bearsamppBins->getNodejs()->getLaunch())) {
528 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppBins->getNodejs()->getLaunch() . ' not found');
529 }
530
531 return self::getTab(
532 $bearsamppTools->getConsoleZ()->getTabTitleNodejs(),
533 self::ICON_NODEJS,
534 $shell,
535 $bearsamppRoot->getWwwPath()
536 ) . PHP_EOL;
537 }
538
539 /**
540 * Generates the XML structure for the Composer tab section.
541 *
542 * This function creates an XML structure defining the Composer tab and its configuration.
543 * It retrieves the Composer executable path and sets the WWW path.
544 *
545 * @return string The formatted XML string for the Composer tab section.
546 * @global Tools $bearsamppTools The tools object of the application.
547 *
548 * @global Root $bearsamppRoot The root object of the application.
549 */
550 private static function getTabComposerSection()
551 {
552 global $bearsamppRoot, $bearsamppTools;
553
554 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppTools->getComposer()->getExe() . '&quot; -V');
555 if (!file_exists($bearsamppTools->getComposer()->getExe())) {
556 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppTools->getComposer()->getExe() . ' not found');
557 }
558
559 return self::getTab(
560 $bearsamppTools->getConsoleZ()->getTabTitleComposer(),
561 self::ICON_COMPOSER,
562 $shell,
563 $bearsamppRoot->getWwwPath()
564 ) . PHP_EOL;
565 }
566
567 /**
568 * Generates the XML structure for the Python tab section.
569 *
570 * This function creates an XML structure defining the Python tab and its configuration.
571 * It retrieves the Python executable path and sets the WWW path.
572 *
573 * @return string The formatted XML string for the Python tab section.
574 * @global Tools $bearsamppTools The tools object of the application.
575 *
576 * @global Root $bearsamppRoot The root object of the application.
577 */
578 private static function getTabPythonSection()
579 {
580 global $bearsamppRoot, $bearsamppTools;
581
582 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppTools->getPython()->getExe() . '&quot; -V');
583 if (!file_exists($bearsamppTools->getPython()->getExe())) {
584 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppTools->getPython()->getExe() . ' not found');
585 }
586
587 return self::getTab(
588 $bearsamppTools->getConsoleZ()->getTabTitlePython(),
589 self::ICON_PYTHON,
590 $shell,
591 $bearsamppRoot->getWwwPath()
592 ) . PHP_EOL;
593 }
594
595 /**
596 * Generates the XML structure for the Ruby tab section.
597 *
598 * This function creates an XML structure defining the Ruby tab and its configuration.
599 * It retrieves the Ruby executable path and sets the WWW path.
600 *
601 * @return string The formatted XML string for the Ruby tab section.
602 * @global Tools $bearsamppTools The tools object of the application.
603 *
604 * @global Root $bearsamppRoot The root object of the application.
605 */
606 private static function getTabRubySection()
607 {
608 global $bearsamppRoot, $bearsamppTools;
609
610 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppTools->getRuby()->getExe() . '&quot; -v');
611 if (!file_exists($bearsamppTools->getRuby()->getExe())) {
612 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppTools->getRuby()->getExe() . ' not found');
613 }
614
615 return self::getTab(
616 $bearsamppTools->getConsoleZ()->getTabTitleRuby(),
617 self::ICON_RUBY,
618 $shell,
619 $bearsamppRoot->getWwwPath()
620 ) . PHP_EOL;
621 }
622
623 /**
624 * Generates the XML structure for the Yarn tab section.
625 *
626 * This function creates an XML structure defining the Yarn tab and its configuration.
627 * It retrieves the Yarn executable path and sets the WWW path.
628 *
629 * @return string The formatted XML string for the Yarn tab section.
630 * @global Tools $bearsamppTools The tools object of the application.
631 *
632 * @global Root $bearsamppRoot The root object of the application.
633 */
634 private static function getTabYarnSection()
635 {
636 global $bearsamppRoot, $bearsamppTools;
637
638 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppTools->getYarn()->getExe() . '&quot; --version');
639 if (!file_exists($bearsamppTools->getYarn()->getExe())) {
640 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppTools->getYarn()->getExe() . ' not found');
641 }
642
643 return self::getTab(
644 $bearsamppTools->getConsoleZ()->getTabTitleYarn(),
645 self::ICON_YARN,
646 $shell,
647 $bearsamppRoot->getWwwPath()
648 ) . PHP_EOL;
649 }
650
651 /**
652 * Generates the XML structure for the Perl tab section.
653 *
654 * This function creates an XML structure defining the Perl tab and its configuration.
655 * It retrieves the Perl executable path and sets the WWW path.
656 *
657 * @return string The formatted XML string for the Perl tab section.
658 * @global Tools $bearsamppTools The tools object of the application.
659 *
660 * @global Root $bearsamppRoot The root object of the application.
661 */
662 private static function getTabPerlSection()
663 {
664 global $bearsamppRoot, $bearsamppTools;
665
666 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppTools->getPerl()->getExe() . '&quot; -v');
667 if (!file_exists($bearsamppTools->getPerl()->getExe())) {
668 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppTools->getPerl()->getExe() . ' not found');
669 }
670
671 return self::getTab(
672 $bearsamppTools->getConsoleZ()->getTabTitlePerl(),
673 self::ICON_PERL,
674 $shell,
675 $bearsamppRoot->getWwwPath()
676 ) . PHP_EOL;
677 }
678
679 /**
680 * Generates the tab section for Ghostscript in the console.
681 *
682 * This function constructs a shell command to check the version of Ghostscript
683 * and verifies if the executable exists. If the executable is not found, it
684 * returns a message indicating the absence of the executable. It then creates
685 * a tab section with the appropriate title, icon, shell command, and initial
686 * directory.
687 *
688 * @return string The HTML structure for the Ghostscript tab section.
689 * @global Tools $bearsamppTools The tools object of the application.
690 * @global Root $bearsamppRoot The root object of the application.
691 */
692 private static function getTabGhostscriptSection()
693 {
694 global $bearsamppRoot, $bearsamppTools;
695
696 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppTools->getGhostscript()->getExeConsole() . '&quot; -v');
697 if (!file_exists($bearsamppTools->getGhostscript()->getExeConsole())) {
698 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppTools->getGhostscript()->getExeConsole() . ' not found');
699 }
700
701 return self::getTab(
702 $bearsamppTools->getConsoleZ()->getTabTitleGhostscript(),
703 self::ICON_GHOSTSCRIPT,
704 $shell,
705 $bearsamppRoot->getWwwPath()
706 ) . PHP_EOL;
707 }
708
709 /**
710 * Generates the tab section for Ngrok in the console.
711 *
712 * This function constructs a shell command to check the version of Ngrok
713 * and verifies if the executable exists. If the executable is not found, it
714 * returns a message indicating the absence of the executable. It then creates
715 * a tab section with the appropriate title, icon, shell command, and initial
716 * directory.
717 *
718 * @return string The HTML structure for the Ngrok tab section.
719 * @global Tools $bearsamppTools The tools object of the application.
720 * @global Root $bearsamppRoot The root object of the application.
721 */
722 private static function getTabNgrokSection()
723 {
724 global $bearsamppRoot, $bearsamppTools;
725
726 $shell = $bearsamppTools->getConsoleZ()->getShell('&quot;' . $bearsamppTools->getNgrok()->getExe() . '&quot; version');
727 if (!file_exists($bearsamppTools->getNgrok()->getExe())) {
728 $shell = $bearsamppTools->getConsoleZ()->getShell('echo ' . $bearsamppTools->getNgrok()->getExe() . ' not found');
729 }
730
731 return self::getTab(
732 $bearsamppTools->getConsoleZ()->getTabTitleNgrok(),
733 self::ICON_NGROK,
734 $shell,
735 $bearsamppRoot->getWwwPath()
736 ) . PHP_EOL;
737 }
738
739 /**
740 * Generates the HTML structure for a tab in the console.
741 *
742 * This function constructs the HTML structure for a tab, including the title,
743 * icon, shell command, initial directory, cursor style, and background settings.
744 *
745 * @param string $title The title of the tab.
746 * @param string $icon The icon for the tab.
747 * @param string $shell The shell command to be executed in the tab.
748 * @param string $initDir The initial directory for the tab.
749 * @return string The HTML structure for the tab.
750 * @global Core $bearsamppCore The core object of the application.
751 */
752 private static function getTab($title, $icon, $shell, $initDir)
753 {
754 global $bearsamppCore;
755 return self::getIncrStr(2) . '<tab title="' . $title . '" icon="' . $bearsamppCore->getIconsPath(false) . '/' . $icon . '" use_default_icon="0">' . PHP_EOL .
756 self::getIncrStr(3) . '<console shell="' . $shell . '" init_dir="' . $initDir . '" run_as_user="0" user=""/>' . PHP_EOL .
757 self::getIncrStr(3) . '<cursor style="0" r="255" g="255" b="255"/>' . PHP_EOL .
758 self::getIncrStr(3) . '<background type="0" r="0" g="0" b="0">' . PHP_EOL .
759 self::getIncrStr(4) . '<image file="" relative="0" extend="0" position="0">' . PHP_EOL .
760 self::getIncrStr(5) . '<tint opacity="0" r="0" g="0" b="0"/>' . PHP_EOL .
761 self::getIncrStr(4) . '</image>' . PHP_EOL .
762 self::getIncrStr(3) . '</background>' . PHP_EOL .
763 self::getIncrStr(2) . '</tab>';
764 }
765
766 /**
767 * Generates a string of incremented tabs.
768 *
769 * This function constructs a string consisting of a specified number of tab characters.
770 *
771 * @param int $size The number of tabs to include in the string.
772 * @return string The string of incremented tabs.
773 */
774 private static function getIncrStr($size = 1)
775 {
776 $result = '';
777 for ($i = 0; $i <= $size; $i++) {
779 }
780 return $result;
781 }
782}
$result
global $bearsamppBins
global $bearsamppRoot
global $bearsamppCore
static getAppearanceSection()
static getTabGhostscriptSection()
static getTabMysqlSection()
static getTabPearSection()
static getHotkeysSection()
static getBehaviorSection()
static getTabNodejsSection()
static getTabMariadbSection()
static getTabComposerSection()
static getTabPythonSection()
static getTabNgrokSection()
static getConsoleSection()
static getTabCmdSection()
static getTabPerlSection()
static getTabGitSection()
static getTabPostgresqlSection()
static getTabPowerShellSection()
static getIncrStr($size=1)
static getTab($title, $icon, $shell, $initDir)
static getTabRubySection()
static getTabYarnSection()
static getPowerShellPath()
const RETURN_TAB
Definition root.php:19