Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.tpl.app.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2026 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
17class TplApp
18{
19 // Constants for item and section identifiers
20 const ITEM_CAPTION = 0;
21 const ITEM_GLYPH = 1;
22
23 const SECTION_CALL = 0;
24 const SECTION_CONTENT = 1;
25
29 private function __construct()
30 {
31 }
32
43 public static function process()
44 {
45 global $bearsamppCore;
46
47 return TplAestan::getSectionConfig() . PHP_EOL .
48 self::getSectionServices() . PHP_EOL .
52 TplAestan::getSectionMenuLeftSettings(APP_TITLE . ' ' . $bearsamppCore->getAppVersion()) . PHP_EOL .
53 self::getSectionMenuRight() . PHP_EOL .
54 self::getSectionMenuLeft() . PHP_EOL;
55 }
56
64 public static function processLight()
65 {
66 return TplAestan::getSectionConfig() . PHP_EOL .
67 self::getSectionServices() . PHP_EOL .
70 }
71
80 public static function getSectionName($name, $args = array())
81 {
82 return ucfirst($name) . (!empty($args) ? '-' . md5(serialize($args)) : '');
83 }
84
94 public static function getSectionContent($name, $class, $args = array())
95 {
96 $baseMethod = 'get' . ucfirst($name);
97 $args = $args == null ? array() : $args;
98
99 return '[' . self::getSectionName($name, $args) . ']' . PHP_EOL .
100 call_user_func_array($class . '::' . $baseMethod, $args);
101 }
102
116 public static function getActionRun($action, $args = array(), $item = array(), $waitUntilTerminated = true)
117 {
119 $args = $args == null ? array() : $args;
120
121 $argImp = '';
122 foreach ($args as $arg) {
123 $argImp .= ' ' . base64_encode($arg);
124 }
125
126 $result = 'Action: run; ' .
127 'FileName: "' . Path::getPhpExe(true) . '"; ' .
128 'Parameters: "' . Core::isRoot_FILE . ' ' . $action . $argImp . '"; ' .
129 'WorkingDir: "' . Path::getCorePath(true) . '"';
130
131 if (!empty($item)) {
132 $result = 'Type: item; ' . $result .
133 '; Caption: "' . $item[self::ITEM_CAPTION] . '"' .
134 (!empty($item[self::ITEM_GLYPH]) ? '; Glyph: "' . $item[self::ITEM_GLYPH] . '"' : '');
135 } elseif ($waitUntilTerminated) {
136 $result .= '; Flags: waituntilterminated';
137 }
138
139 return $result;
140 }
141
153 public static function getActionMulti($action, $args = array(), $item = array(), $disabled = false, $class = false)
154 {
155 $action = 'action' . ucfirst($action);
156 $args = $args == null ? array() : $args;
157 $sectionName = self::getSectionName($action, $args);
158
159 $call = 'Action: multi; Actions: ' . $sectionName;
160
161 if (!empty($item)) {
162 $call = 'Type: item; ' . $call .
163 '; Caption: "' . $item[self::ITEM_CAPTION] . '"' .
164 (!empty($item[self::ITEM_GLYPH]) ? '; Glyph: "' . $item[self::ITEM_GLYPH] . '"' : '');
165 } else {
166 $call .= '; Flags: waituntilterminated';
167 }
168
169 return array($call, self::getSectionContent($action, $class, $args));
170 }
171
177 public static function getActionExec()
178 {
179 return self::getActionRun(Action::EXEC, array(), array(), false);
180 }
181
191 public static function getMenu($caption, $menu, $class)
192 {
193 $menu = 'menu' . ucfirst($menu);
194
195 $call = 'Type: submenu; ' .
196 'Caption: "' . $caption . '"; ' .
197 'SubMenu: ' . self::getSectionName($menu) . '; ' .
199
200 return array($call, self::getSectionContent($menu, $class, null));
201 }
202
213 public static function getMenuEnable($caption, $menu, $class, $enabled = true)
214 {
215 $menu = 'menu' . ucfirst($menu);
216
217 $call = 'Type: submenu; ' .
218 'Caption: "' . $caption . '"; ' .
219 'SubMenu: ' . self::getSectionName($menu) . '; ' .
221
222 return array($call, self::getSectionContent($menu, $class, null));
223 }
224
232 private static function getSectionServices()
233 {
234 global $bearsamppBins;
235
236 $result = '[Services]' . PHP_EOL;
237 foreach ($bearsamppBins->getServices() as $service) {
238 $result .= 'Name: ' . $service->getName() . PHP_EOL;
239 }
240
241 return $result;
242 }
243
249 private static function getSectionStartupAction()
250 {
251 return '[StartupAction]' . PHP_EOL .
255 self::getActionExec() . PHP_EOL;
256 }
257
265 private static function getSectionMenuRight()
266 {
267 global $bearsamppLang;
268
269 $tplReload = TplAppReload::process();
270 $tplBrowser = TplAppBrowser::process();
271 $tplLang = TplAppLang::process();
272 $tplLogsVerbose = TplAppLogsVerbose::process();
273 $tplLaunchStartup = TplAppLaunchStartup::process();
274 $tplExit = TplAppExit::process();
275
276 return
277 // Items
278 '[Menu.Right]' . PHP_EOL .
284 ) . PHP_EOL .
285 TplAestan::getItemLink($bearsamppLang->getValue(Lang::DOCUMENTATION), 'https://documentation.bearsampp.com/') . PHP_EOL .
286 TplAestan::getItemLink('FAQ', HttpClient::getWebsiteUrl('documentation/faqs')) . PHP_EOL .
288
289 TplAestan::getItemSeparator() . PHP_EOL .
290 TplAppClearFolders::process() . PHP_EOL .
291 TplAppRebuildIni::process() . PHP_EOL .
292 $tplReload[self::SECTION_CALL] . PHP_EOL .
293
294 TplAestan::getItemSeparator() . PHP_EOL .
295 $tplBrowser[self::SECTION_CALL] . PHP_EOL .
296 TplAppEditConf::process() . PHP_EOL .
297 $tplLang[self::SECTION_CALL] . PHP_EOL .
298 $tplLogsVerbose[self::SECTION_CALL] . PHP_EOL .
299
300 TplAestan::getItemSeparator() . PHP_EOL .
301 $tplLaunchStartup[self::SECTION_CALL] . PHP_EOL .
302 $tplExit[self::SECTION_CALL] . PHP_EOL .
303
304 // Actions
305 PHP_EOL . $tplBrowser[self::SECTION_CONTENT] . PHP_EOL .
306 PHP_EOL . $tplLang[self::SECTION_CONTENT] .
307 PHP_EOL . $tplLaunchStartup[self::SECTION_CONTENT] .
308 PHP_EOL . $tplLogsVerbose[self::SECTION_CONTENT] .
309 PHP_EOL . $tplReload[self::SECTION_CONTENT] . PHP_EOL .
310 PHP_EOL . $tplExit[self::SECTION_CONTENT] . PHP_EOL;
311 }
312
322 private static function getSectionMenuLeft()
323 {
325
326 $tplApache = TplAppApache::process();
327 $tplMailpit = TplAppMailpit::process();
328 $tplMariadb = TplAppMariadb::process();
329 $tplMemcached = TplAppMemcached::process();
330 $tplMysql = TplAppMysql::process();
331 $tplNodejs = TplAppNodejs::process();
332 $tplPhp = TplAppPhp::process();
333 $tplPostgresql = TplAppPostgresql::process();
334 $tplXlight = TplAppXlight::process();
335
336 $tplApps = TplAppApps::process();
337 $tplLogs = TplAppLogs::process();
338 $tplTools = TplAppTools::process();
339
340 $tplServices = TplAppServices::process();
341
342 $tplOnline = TplAppOnline::process();
343
344 $httpUrl = 'http://localhost' . ($bearsamppBins->getApache()->getPort() != 80 ? ':' . $bearsamppBins->getApache()->getPort() : '');
345 $httpsUrl = 'https://localhost' . ($bearsamppBins->getApache()->getSslPort() != 443 ? ':' . $bearsamppBins->getApache()->getSslPort() : '');
346
347 return
348 // Items
349 '[Menu.Left]' . PHP_EOL .
350 TplAestan::getItemLink($bearsamppLang->getValue(Lang::MENU_LOCALHOST), $httpUrl) . PHP_EOL .
351 TplAestan::getItemLink($bearsamppLang->getValue(Lang::MENU_LOCALHOST) . ' (SSL)', $httpsUrl) . PHP_EOL .
353
355 TplAestan::getItemSeparator() . PHP_EOL .
356 $tplApache[self::SECTION_CALL] . PHP_EOL .
357 $tplMailpit[self::SECTION_CALL] . PHP_EOL .
358 $tplMariadb[self::SECTION_CALL] . PHP_EOL .
359 $tplMemcached[self::SECTION_CALL] . PHP_EOL .
360 $tplMysql[self::SECTION_CALL] . PHP_EOL .
361 $tplNodejs[self::SECTION_CALL] . PHP_EOL .
362 $tplPhp[self::SECTION_CALL] . PHP_EOL .
363 $tplPostgresql[self::SECTION_CALL] . PHP_EOL .
364 $tplXlight[self::SECTION_CALL] . PHP_EOL .
365
367 TplAestan::getItemSeparator() . PHP_EOL .
368 $tplApps[self::SECTION_CALL] . PHP_EOL .
369 $tplLogs[self::SECTION_CALL] . PHP_EOL .
370 $tplTools[self::SECTION_CALL] . PHP_EOL .
371
373 TplAestan::getItemSeparator() . PHP_EOL .
374 $tplServices[self::SECTION_CALL] .
375
377 TplAestan::getItemSeparator() . PHP_EOL .
378 $tplOnline[self::SECTION_CALL] . PHP_EOL .
379
380 // Actions
381 PHP_EOL . $tplApache[self::SECTION_CONTENT] .
382 PHP_EOL . $tplMailpit[self::SECTION_CONTENT] .
383 PHP_EOL . $tplMariadb[self::SECTION_CONTENT] .
384 PHP_EOL . $tplMemcached[self::SECTION_CONTENT] .
385 PHP_EOL . $tplMysql[self::SECTION_CONTENT] .
386 PHP_EOL . $tplNodejs[self::SECTION_CONTENT] .
387 PHP_EOL . $tplPhp[self::SECTION_CONTENT] .
388 PHP_EOL . $tplPostgresql[self::SECTION_CONTENT] .
389 PHP_EOL . $tplXlight[self::SECTION_CONTENT] .
390 PHP_EOL . $tplApps[self::SECTION_CONTENT] .
391 PHP_EOL . $tplLogs[self::SECTION_CONTENT] .
392 PHP_EOL . $tplTools[self::SECTION_CONTENT] .
393 PHP_EOL . $tplServices[self::SECTION_CONTENT] .
394 PHP_EOL . $tplOnline[self::SECTION_CONTENT];
395 }
396}
$result
global $bearsamppBins
global $bearsamppLang
global $bearsamppRoot
global $bearsamppCore
const CHECK_VERSION
const ABOUT
const EXEC
const STARTUP
const isRoot_FILE
const PAGE_CACHE_STATS
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
const DOCUMENTATION
const MENU_LOCALHOST
const MENU_ABOUT
const MENU_CHECK_UPDATE
const MENU_WWW_DIRECTORY
const MENU_VIEW_CACHE_STATS
static getCorePath($aetrayPath=false)
static getLocalUrl($request=null)
static getWwwPath($aetrayPath=false)
static getPhpExe($aetrayPath=false)
static getSectionConfig()
const GLYPH_FOLDER_DISABLED
const GLYPH_FOLDER_CLOSE
static getSectionMessages()
static getSectionMenuLeftSettings($caption)
static getItemExplore($caption, $path)
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getSectionMenuRightSettings()
static getItemSeparator()
static getSectionStartupAction()
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
static getMenu($caption, $menu, $class)
static getSectionMenuLeft()
static getSectionName($name, $args=array())
const ITEM_GLYPH
static getSectionMenuRight()
static processLight()
static process()
static getSectionContent($name, $class, $args=array())
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
static getSectionServices()
const SECTION_CALL
const SECTION_CONTENT
const ITEM_CAPTION
static getActionExec()
static getMenuEnable($caption, $menu, $class, $enabled=true)
const APP_TITLE
Definition root.php:19