Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
class.tpl.app.git.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
18{
19 // Constants for menu and action identifiers
20 const MENU = 'git';
21 const MENU_REPOS = 'gitRepos';
22
23 const ACTION_REFRESH_REPOS = 'refreshGitRepos';
24 const ACTION_REFRESH_REPOS_STARTUP = 'refreshGitReposStartup';
25
36 public static function process()
37 {
38 global $bearsamppLang;
39
40 return TplApp::getMenu($bearsamppLang->getValue(Lang::GIT), self::MENU, get_called_class());
41 }
42
54 public static function getMenuGit()
55 {
56 global $bearsamppLang, $bearsamppTools, $bearsamppRoot;
57
58 $tplRepos = TplApp::getMenu($bearsamppLang->getValue(Lang::REPOS), self::MENU_REPOS, get_called_class());
59 $emptyRepos = count(explode(PHP_EOL, $tplRepos[TplApp::SECTION_CONTENT])) == 2;
60 $isScanStartup = $bearsamppTools->getGit()->isScanStartup();
61
62 $tplRefreshRepos = TplApp::getActionMulti(
63 self::ACTION_REFRESH_REPOS, null,
65 false, get_called_class()
66 );
67 $tplRefreshReposStartup = TplApp::getActionMulti(
68 self::ACTION_REFRESH_REPOS_STARTUP, array($isScanStartup ? Config::DISABLED : Config::ENABLED),
69 array($bearsamppLang->getValue(Lang::MENU_SCAN_REPOS_STARTUP), $isScanStartup ? TplAestan::GLYPH_CHECK : ''),
70 false, get_called_class()
71 );
72
73 /* get path for git gui */
74 $gitgui = $bearsamppTools->getGit()->getSymlinkPath() . '/cmd';
75
79 null,
80 $bearsamppTools->getPowerShell()->getTabTitleGit(),
81 $bearsamppRoot->getWwwPath(),
82 null
83 ) . PHP_EOL .
86 $gitgui . '/git-gui',
88 ) . PHP_EOL .
89 TplAestan::getItemSeparator() . PHP_EOL .
90
91 // Items
92 (!$emptyRepos ? $tplRepos[TplApp::SECTION_CALL] . PHP_EOL : '') .
93 $tplRefreshRepos[TplApp::SECTION_CALL] . PHP_EOL .
94 $tplRefreshReposStartup[TplApp::SECTION_CALL] . PHP_EOL .
95
96 // Actions
97 (!$emptyRepos ? $tplRepos[TplApp::SECTION_CONTENT] . PHP_EOL : PHP_EOL) .
98 $tplRefreshRepos[TplApp::SECTION_CONTENT] . PHP_EOL .
99 $tplRefreshReposStartup[TplApp::SECTION_CONTENT];
100 }
101
112 public static function getMenuGitRepos()
113 {
114 global $bearsamppTools;
115 $result = '';
116
117 foreach ($bearsamppTools->getGit()->findRepos() as $repo) {
119 basename($repo),
121 null,
122 $bearsamppTools->getPowerShell()->getTabTitleGit($repo),
123 $repo,
124 null
125 ) . PHP_EOL;
126 }
127
128 return $result;
129 }
130
139 public static function getActionRefreshGitRepos()
140 {
143 }
144
155 public static function getActionRefreshGitReposStartup($scanStartup)
156 {
157 return TplApp::getActionRun(Action::REFRESH_REPOS_STARTUP, array(ActionRefreshRepos::GIT, $scanStartup)) . PHP_EOL .
159 }
160}
$result
global $bearsamppLang
global $bearsamppRoot
const REFRESH_REPOS
const REFRESH_REPOS_STARTUP
const DISABLED
const ENABLED
const MENU_SCAN_REPOS_STARTUP
const REPOS
const GITGUI
const GIT_CONSOLE
const GIT
const MENU_REFRESH_REPOS
static getItemPowerShell($caption, $glyph, $id=null, $title=null, $initDir=null, $command=null)
static getItemExe($caption, $exe, $glyph, $params=null)
static getItemSeparator()
const ACTION_REFRESH_REPOS_STARTUP
static getActionRefreshGitRepos()
const ACTION_REFRESH_REPOS
static getActionRefreshGitReposStartup($scanStartup)
static getMenuGit()
static getMenuGitRepos()
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
static getMenu($caption, $menu, $class)
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
const SECTION_CALL
const SECTION_CONTENT