2024.8.23
Loading...
Searching...
No Matches
class.tpl.app.tools.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 TplAppTools
12 *
13 * This class provides methods to generate menu items and actions for managing various tools
14 * within the Bearsampp application. It includes functionalities for accessing tools like Git, Python,
15 * Composer, Ghostscript, Ngrok, Pear, Perl, Ruby, XDebugClient, Yarn, and more.
16 */
18{
19 // Constants for menu and action identifiers
20 const MENU = 'tools';
21 const ACTION_GEN_SSL_CERTIFICATE = 'genSslCertificate';
22
23 /**
24 * Generates the main Tools menu with options to access various tools.
25 *
26 * @global object $bearsamppLang Provides language support for retrieving language-specific values.
27 *
28 * @return array The generated menu items and actions for Tools.
29 */
30 public static function process()
31 {
32 global $bearsamppLang;
33
34 return TplApp::getMenu($bearsamppLang->getValue(Lang::TOOLS), self::MENU, get_called_class());
35 }
36
37 /**
38 * Generates the Tools menu with options for accessing various tools like Git, Python, Composer, etc.
39 *
40 * @global object $bearsamppLang Provides language support for retrieving language-specific values.
41 * @global object $bearsamppCore Provides access to core functionalities and configurations.
42 * @global object $bearsamppTools Provides access to various tools and their configurations.
43 *
44 * @return string The generated menu items and actions for Tools.
45 */
46 public static function getMenuTools()
47 {
48 global $bearsamppLang, $bearsamppCore, $bearsamppTools;
49 $resultItems = $resultActions = '';
50
51 // Git
52 $tplGit = TplAppGit::process();
53 $resultItems .= $tplGit[TplApp::SECTION_CALL] . PHP_EOL;
54 $resultActions .= $tplGit[TplApp::SECTION_CONTENT] . PHP_EOL;
55
56 // Python
57 $tplPython = TplAppPython::process();
58 $resultItems .= $tplPython[TplApp::SECTION_CALL] . PHP_EOL;
59 $resultActions .= $tplPython[TplApp::SECTION_CONTENT] . PHP_EOL;
60
61 // Composer
62 $resultItems .= TplAestan::getItemConsoleZ(
65 $bearsamppTools->getConsoleZ()->getTabTitleComposer()
66 ) . PHP_EOL;
67
68 // Ghostscript
69 $resultItems .= TplAestan::getItemConsoleZ(
72 $bearsamppTools->getConsoleZ()->getTabTitleGhostscript()
73 ) . PHP_EOL;
74
75 // Ngrok
76 $resultItems .= TplAestan::getItemConsoleZ(
77 $bearsamppLang->getValue(Lang::NGROK),
79 $bearsamppTools->getConsoleZ()->getTabTitleNgrok()
80 ) . PHP_EOL;
81
82 // Pear
83 $resultItems .= TplAestan::getItemConsoleZ(
84 $bearsamppLang->getValue(Lang::PEAR),
86 $bearsamppTools->getConsoleZ()->getTabTitlePear()
87 ) . PHP_EOL;
88
89 // Perl
90 $resultItems .= TplAestan::getItemConsoleZ(
91 $bearsamppLang->getValue(Lang::PERL),
93 $bearsamppTools->getConsoleZ()->getTabTitlePerl()
94 ) . PHP_EOL;
95
96 // Ruby
97 $resultItems .= TplAestan::getItemConsoleZ(
98 $bearsamppLang->getValue(Lang::RUBY),
100 $bearsamppTools->getConsoleZ()->getTabTitleRuby()
101 ) . PHP_EOL;
102
103 // XDebugClient
104 $resultItems .= TplAestan::getItemExe(
105 $bearsamppLang->getValue(Lang::XDC),
106 $bearsamppTools->getXdc()->getExe(),
108 ) . PHP_EOL;
109
110 // Yarn
111 $resultItems .= TplAestan::getItemConsoleZ(
112 $bearsamppLang->getValue(Lang::YARN),
114 $bearsamppTools->getConsoleZ()->getTabTitleYarn()
115 ) . PHP_EOL;
116 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
117
118 // Console
119 $resultItems .= TplAestan::getItemConsoleZ(
120 $bearsamppLang->getValue(Lang::CONSOLE),
122 ) . PHP_EOL;
123
124 // HostsEditor
125 $resultItems .= TplAestan::getItemExe(
127 $bearsamppCore->getHostsEditorExe(),
129 ) . PHP_EOL;
130
131 // Generate SSL Certificate
132 $tplGenSslCertificate = TplApp::getActionMulti(
133 self::ACTION_GEN_SSL_CERTIFICATE, null,
135 false, get_called_class()
136 );
137 $resultItems .= $tplGenSslCertificate[TplApp::SECTION_CALL] . PHP_EOL;
138 $resultActions .= $tplGenSslCertificate[TplApp::SECTION_CONTENT];
139
140 // Pwgen password manager
141 $resultItems .= TplAestan::getItemExe(
142 $bearsamppLang->getValue(Lang::PWGEN),
143 $bearsamppCore->getPwgenExe(),
145 ) . PHP_EOL;
146
147 return $resultItems . PHP_EOL . $resultActions;
148 }
149
150 /**
151 * Generates the action to generate an SSL certificate.
152 *
153 * @return string The generated action to generate an SSL certificate.
154 */
155 public static function getActionGenSslCertificate()
156 {
158 }
159}
global $bearsamppLang
global $bearsamppCore
const GEN_SSL_CERTIFICATE
const RUBY
const HOSTSEDITOR
const PWGEN
const YARN
const NGROK
const COMPOSER
const TOOLS
const PEAR
const GHOSTSCRIPT
const XDC
const PERL
const CONSOLE
const MENU_GEN_SSL_CERTIFICATE
const GLYPH_GHOSTSCRIPT
static getItemSeparator()
static getItemConsoleZ($caption, $glyph, $id=null, $title=null, $initDir=null, $command=null)
const GLYPH_HOSTSEDITOR
const GLYPH_SSL_CERTIFICATE
static getItemExe($caption, $exe, $glyph, $params=null)
const ACTION_GEN_SSL_CERTIFICATE
static getActionGenSslCertificate()
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
const SECTION_CALL
const SECTION_CONTENT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
static getMenu($caption, $menu, $class)