Bearsampp 2026.9.23
Loading...
Searching...
No Matches
TplAppMysql Class Reference

Static Public Member Functions

static getActionChangeMysqlPort ()
static getActionChangeMysqlRootPwd ()
static getActionEnableMysql ($enable)
static getActionInstallMysqlService ()
static getActionRemoveMysqlService ()
static getActionSwitchMysqlVersion ($version)
static getMenuMysql ()
static getMenuMysqlDebug ()
static getMenuMysqlService ()
static getMenuMysqlVersions ()
static process ()

Data Fields

const ACTION_CHANGE_PORT = 'changeMysqlPort'
const ACTION_CHANGE_ROOT_PWD = 'changeMysqlRootPwd'
const ACTION_ENABLE = 'enableMysql'
const ACTION_INSTALL_SERVICE = 'installMysqlService'
const ACTION_REMOVE_SERVICE = 'removeMysqlService'
const ACTION_SWITCH_VERSION = 'switchMysqlVersion'
const MENU = 'mysql'
const MENU_DEBUG = 'mysqlDebug'
const MENU_SERVICE = 'mysqlService'
const MENU_VERSIONS = 'mysqlVersions'

Detailed Description

Class TplAppMysql

This class provides methods to generate and manage menu items, actions, and sections related to MySQL within the Bearsampp application. It includes functionalities for enabling/disabling MySQL, switching versions, changing ports, managing services, and debugging.

Definition at line 17 of file class.tpl.app.mysql.php.

Member Function Documentation

◆ getActionChangeMysqlPort()

getActionChangeMysqlPort ( )
static

Generates the action to change MySQL port.

This method creates the action string for changing the MySQL port.

Returns
string The generated action string for changing MySQL port. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 316 of file class.tpl.app.mysql.php.

317 {
318 global $bearsamppBins;
319
320 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getMysql()->getName())) . PHP_EOL .
322 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

References $bearsamppBins, Action\CHANGE_PORT, TplAppReload\getActionReload(), and TplApp\getActionRun().

Here is the call graph for this function:

◆ getActionChangeMysqlRootPwd()

getActionChangeMysqlRootPwd ( )
static

Generates the action to change MySQL root password.

This method creates the action string for changing the MySQL root password.

Returns
string The generated action string for changing MySQL root password. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 333 of file class.tpl.app.mysql.php.

334 {
335 global $bearsamppBins;
336
337 return TplApp::getActionRun(Action::CHANGE_DB_ROOT_PWD, array($bearsamppBins->getMysql()->getName())) . PHP_EOL .
339 }
const CHANGE_DB_ROOT_PWD

References $bearsamppBins, Action\CHANGE_DB_ROOT_PWD, TplAppReload\getActionReload(), and TplApp\getActionRun().

Here is the call graph for this function:

◆ getActionEnableMysql()

getActionEnableMysql ( $enable)
static

Generates the action to enable or disable MySQL.

This method creates the action string for enabling or disabling MySQL.

Parameters
int$enableThe enable/disable flag (1 for enable, 0 for disable).
Returns
string The generated action string for enabling/disabling MySQL. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 170 of file class.tpl.app.mysql.php.

171 {
172 global $bearsamppBins;
173
174 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getMysql()->getName(), $enable)) . PHP_EOL .
176 }
const ENABLE

References $bearsamppBins, Action\ENABLE, TplAppReload\getActionReload(), and TplApp\getActionRun().

Here is the call graph for this function:

◆ getActionInstallMysqlService()

getActionInstallMysqlService ( )
static

Generates the action to install MySQL service.

This method creates the action string for installing the MySQL service.

Returns
string The generated action string for installing MySQL service.

Definition at line 348 of file class.tpl.app.mysql.php.

References TplAppReload\getActionReload(), TplApp\getActionRun(), ActionService\INSTALL, Action\SERVICE, and BinMysql\SERVICE_NAME.

Here is the call graph for this function:

◆ getActionRemoveMysqlService()

getActionRemoveMysqlService ( )
static

Generates the action to remove MySQL service.

This method creates the action string for removing the MySQL service.

Returns
string The generated action string for removing MySQL service.

Definition at line 361 of file class.tpl.app.mysql.php.

References TplAppReload\getActionReload(), TplApp\getActionRun(), ActionService\REMOVE, Action\SERVICE, and BinMysql\SERVICE_NAME.

Here is the call graph for this function:

◆ getActionSwitchMysqlVersion()

getActionSwitchMysqlVersion ( $version)
static

Generates the action to switch MySQL version.

This method creates the action string for switching to a different MySQL version.

Parameters
string$versionThe version to switch to.
Returns
string The generated action string for switching MySQL version. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 189 of file class.tpl.app.mysql.php.

190 {
191 global $bearsamppBins;
192
193 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getMysql()->getName(), $version)) . PHP_EOL .
195 }
const SWITCH_VERSION

References $bearsamppBins, TplAppReload\getActionReload(), TplApp\getActionRun(), and Action\SWITCH_VERSION.

Here is the call graph for this function:

◆ getMenuMysql()

getMenuMysql ( )
static

Generates the MySQL menu items and actions.

This method creates menu items and actions for MySQL, including download links, enabling/disabling, version switching, service management, debugging, and configuration file access.

Returns
string The generated MySQL menu items and actions. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppTools Provides access to various tools used in the application.

@global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 61 of file class.tpl.app.mysql.php.

62 {
63 global $bearsamppBins, $bearsamppLang, $bearsamppTools;
64 $resultItems = $resultActions = '';
65
66 $isEnabled = $bearsamppBins->getMysql()->isEnable();
67
68 // Download
69 $resultItems .= TplAestan::getItemLink(
71 HttpClient::getWebsiteUrl('module/mysql', '#releases'),
72 false,
74 ) . PHP_EOL;
75
76 // Enable
77 $tplEnable = TplApp::getActionMulti(
78 self::ACTION_ENABLE,
79 array($isEnabled ? Config::DISABLED : Config::ENABLED),
80 array($bearsamppLang->getValue(Lang::MENU_ENABLE), $isEnabled ? TplAestan::GLYPH_CHECK : ''),
81 false,
82 get_called_class()
83 );
84 $resultItems .= $tplEnable[TplApp::SECTION_CALL] . PHP_EOL;
85 $resultActions .= $tplEnable[TplApp::SECTION_CONTENT] . PHP_EOL;
86
87 if ($isEnabled) {
88 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
89
90 // Versions
91 $tplVersions = TplApp::getMenu($bearsamppLang->getValue(Lang::VERSIONS), self::MENU_VERSIONS, get_called_class());
92 $resultItems .= $tplVersions[TplApp::SECTION_CALL] . PHP_EOL;
93 $resultActions .= $tplVersions[TplApp::SECTION_CONTENT] . PHP_EOL;
94
95 // Service
96 $tplService = TplApp::getMenu($bearsamppLang->getValue(Lang::SERVICE), self::MENU_SERVICE, get_called_class());
97 $resultItems .= $tplService[TplApp::SECTION_CALL] . PHP_EOL;
98 $resultActions .= $tplService[TplApp::SECTION_CONTENT] . PHP_EOL;
99
100 // Debug
101 $tplDebug = TplApp::getMenu($bearsamppLang->getValue(Lang::DEBUG), self::MENU_DEBUG, get_called_class());
102 $resultItems .= $tplDebug[TplApp::SECTION_CALL] . PHP_EOL;
103 $resultActions .= $tplDebug[TplApp::SECTION_CONTENT];
104
105 // Console
106 $resultItems .= TplAestan::getItemPowerShell(
107 $bearsamppLang->getValue(Lang::CONSOLE),
109 null,
110 $bearsamppTools->getPowerShell()->getTabTitleMysql(),
112 null
113 ) . PHP_EOL;
114
115 // Conf
116 $resultItems .= TplAestan::getItemNotepad(basename($bearsamppBins->getMysql()->getConf()), $bearsamppBins->getMysql()->getConf()) . PHP_EOL;
117
118 // Errors log
119 $resultItems .= TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_ERROR_LOGS), $bearsamppBins->getMysql()->getErrorLog()) . PHP_EOL;
120 }
121
122 return $resultItems . PHP_EOL . $resultActions;
123 }
global $bearsamppLang
const DISABLED
const ENABLED
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
const MENU_ENABLE
const SERVICE
const DOWNLOAD_MORE
const CONSOLE
const DEBUG
const MENU_ERROR_LOGS
const VERSIONS
static getModuleSymlinkPath($module)
static getItemPowerShell($caption, $glyph, $id=null, $title=null, $initDir=null, $command=null)
const GLYPH_POWERSHELL
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemNotepad($caption, $path)
static getItemSeparator()
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
static getMenu($caption, $menu, $class)
const SECTION_CALL
const SECTION_CONTENT

References $bearsamppBins, $bearsamppLang, Lang\CONSOLE, Lang\DEBUG, Config\DISABLED, Lang\DOWNLOAD_MORE, Config\ENABLED, TplApp\getActionMulti(), TplAestan\getItemLink(), TplAestan\getItemNotepad(), TplAestan\getItemPowerShell(), TplAestan\getItemSeparator(), TplApp\getMenu(), Path\getModuleSymlinkPath(), HttpClient\getWebsiteUrl(), TplAestan\GLYPH_BROWSER, TplAestan\GLYPH_CHECK, TplAestan\GLYPH_POWERSHELL, Lang\MENU_ENABLE, Lang\MENU_ERROR_LOGS, TplApp\SECTION_CALL, TplApp\SECTION_CONTENT, Lang\SERVICE, and Lang\VERSIONS.

Here is the call graph for this function:

◆ getMenuMysqlDebug()

getMenuMysqlDebug ( )
static

Generates the MySQL debug menu.

This method creates menu items and actions for debugging MySQL, including checking version, variables, and syntax.

Returns
string The generated MySQL debug menu items and actions. @global object $bearsamppLang Provides language support for retrieving language-specific values.

Definition at line 286 of file class.tpl.app.mysql.php.

287 {
288 global $bearsamppLang;
289
294 ) . PHP_EOL .
299 ) . PHP_EOL .
304 ) . PHP_EOL;
305 }
const DEBUG_MYSQL
const CMD_SYNTAX_CHECK
const CMD_VERSION
const CMD_VARIABLES
const DEBUG_MYSQL_SYNTAX_CHECK
const DEBUG_MYSQL_VERSION
const DEBUG_MYSQL_VARIABLES

References $bearsamppLang, BinMysql\CMD_SYNTAX_CHECK, BinMysql\CMD_VARIABLES, BinMysql\CMD_VERSION, Action\DEBUG_MYSQL, Lang\DEBUG_MYSQL_SYNTAX_CHECK, Lang\DEBUG_MYSQL_VARIABLES, Lang\DEBUG_MYSQL_VERSION, TplApp\getActionRun(), and TplAestan\GLYPH_DEBUG.

Here is the call graph for this function:

◆ getMenuMysqlService()

getMenuMysqlService ( )
static

Generates the MySQL service menu.

This method creates menu items and actions for managing MySQL services, including starting, stopping, restarting, changing ports, and managing root passwords.

Returns
string The generated MySQL service menu items and actions. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppLang Provides language support for retrieving language-specific values.

Definition at line 208 of file class.tpl.app.mysql.php.

209 {
211
212 $tplChangePort = TplApp::getActionMulti(
213 self::ACTION_CHANGE_PORT,
214 null,
216 false,
217 get_called_class()
218 );
219
220 $isInstalled = $bearsamppBins->getMysql()->getService()->isInstalled();
221
222 $result = TplAestan::getItemActionServiceStart($bearsamppBins->getMysql()->getService()->getName()) . PHP_EOL .
223 TplAestan::getItemActionServiceStop($bearsamppBins->getMysql()->getService()->getName()) . PHP_EOL .
224 TplAestan::getItemActionServiceRestart($bearsamppBins->getMysql()->getService()->getName()) . PHP_EOL .
225 TplAestan::getItemSeparator() . PHP_EOL .
228 array($bearsamppBins->getMysql()->getName(), $bearsamppBins->getMysql()->getPort()),
229 array(sprintf($bearsamppLang->getValue(Lang::MENU_CHECK_PORT), $bearsamppBins->getMysql()->getPort()), TplAestan::GLYPH_LIGHT)
230 ) . PHP_EOL .
231 $tplChangePort[TplApp::SECTION_CALL] . PHP_EOL;
232
233 $tplChangeRootPwd = null;
234 if ($isInstalled) {
235 $tplChangeRootPwd = TplApp::getActionMulti(
236 self::ACTION_CHANGE_ROOT_PWD,
237 null,
239 !$isInstalled,
240 get_called_class()
241 );
242
243 $result .= $tplChangeRootPwd[TplApp::SECTION_CALL] . PHP_EOL;
244 }
245
246 if (!$isInstalled) {
247 $tplInstallService = TplApp::getActionMulti(
248 self::ACTION_INSTALL_SERVICE,
249 null,
251 $isInstalled,
252 get_called_class()
253 );
254
255 $result .= $tplInstallService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
256 $tplInstallService[TplApp::SECTION_CONTENT] . PHP_EOL;
257 } else {
258 $tplRemoveService = TplApp::getActionMulti(
259 self::ACTION_REMOVE_SERVICE,
260 null,
262 !$isInstalled,
263 get_called_class()
264 );
265
266 $result .= $tplRemoveService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
267 $tplRemoveService[TplApp::SECTION_CONTENT] . PHP_EOL;
268 }
269
270 $result .= $tplChangePort[TplApp::SECTION_CONTENT] . PHP_EOL .
271 ($tplChangeRootPwd != null ? $tplChangeRootPwd[TplApp::SECTION_CONTENT] . PHP_EOL : '');
272
273 return $result;
274 }
$result
const CHECK_PORT
const MENU_CHANGE_ROOT_PWD
const MENU_CHANGE_PORT
const MENU_INSTALL_SERVICE
const MENU_REMOVE_SERVICE
const MENU_CHECK_PORT
const GLYPH_SERVICE_REMOVE
static getItemActionServiceStop($service)
const GLYPH_SERVICE_INSTALL
static getItemActionServiceStart($service)
static getItemActionServiceRestart($service)

References $bearsamppBins, $bearsamppLang, $result, Action\CHECK_PORT, TplApp\getActionMulti(), TplApp\getActionRun(), TplAestan\getItemActionServiceRestart(), TplAestan\getItemActionServiceStart(), TplAestan\getItemActionServiceStop(), TplAestan\getItemSeparator(), TplAestan\GLYPH_LIGHT, TplAestan\GLYPH_NETWORK, TplAestan\GLYPH_PASSWORD, TplAestan\GLYPH_SERVICE_INSTALL, TplAestan\GLYPH_SERVICE_REMOVE, Lang\MENU_CHANGE_PORT, Lang\MENU_CHANGE_ROOT_PWD, Lang\MENU_CHECK_PORT, Lang\MENU_INSTALL_SERVICE, Lang\MENU_REMOVE_SERVICE, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Here is the call graph for this function:

◆ getMenuMysqlVersions()

getMenuMysqlVersions ( )
static

Generates the MySQL versions menu.

This method creates menu items and actions for switching between different MySQL versions.

Returns
string The generated MySQL versions menu items and actions. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 134 of file class.tpl.app.mysql.php.

135 {
136 global $bearsamppBins;
137 $items = '';
138 $actions = '';
139
140 foreach ($bearsamppBins->getMysql()->getVersionList() as $version) {
141 $tplSwitchMysqlVersion = TplApp::getActionMulti(
142 self::ACTION_SWITCH_VERSION,
143 array($version),
144 array($version, $version == $bearsamppBins->getMysql()->getVersion() ? TplAestan::GLYPH_CHECK : ''),
145 false,
146 get_called_class()
147 );
148
149 // Item
150 $items .= $tplSwitchMysqlVersion[TplApp::SECTION_CALL] . PHP_EOL;
151
152 // Action
153 $actions .= PHP_EOL . $tplSwitchMysqlVersion[TplApp::SECTION_CONTENT];
154 }
155
156 return $items . $actions;
157 }

References $bearsamppBins, TplApp\getActionMulti(), TplAestan\GLYPH_CHECK, TplApp\SECTION_CALL, and TplApp\SECTION_CONTENT.

Here is the call graph for this function:

◆ process()

process ( )
static

Processes and generates the MySQL menu.

This method generates the MySQL menu and determines if MySQL is enabled.

Returns
array The generated MySQL menu. @global object $bearsamppBins Provides access to system binaries and their configurations.

@global object $bearsamppLang Provides language support for retrieving language-specific values.

Definition at line 42 of file class.tpl.app.mysql.php.

43 {
45
46 return TplApp::getMenuEnable($bearsamppLang->getValue(Lang::MYSQL), self::MENU, get_called_class(), $bearsamppBins->getMysql()->isEnable());
47 }
const MYSQL
static getMenuEnable($caption, $menu, $class, $enabled=true)

References $bearsamppBins, $bearsamppLang, TplApp\getMenuEnable(), and Lang\MYSQL.

Referenced by TplApp\getSectionMenuLeft().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const ACTION_CHANGE_PORT = 'changeMysqlPort'

Definition at line 27 of file class.tpl.app.mysql.php.

◆ ACTION_CHANGE_ROOT_PWD

const ACTION_CHANGE_ROOT_PWD = 'changeMysqlRootPwd'

Definition at line 28 of file class.tpl.app.mysql.php.

◆ ACTION_ENABLE

const ACTION_ENABLE = 'enableMysql'

Definition at line 25 of file class.tpl.app.mysql.php.

◆ ACTION_INSTALL_SERVICE

const ACTION_INSTALL_SERVICE = 'installMysqlService'

Definition at line 29 of file class.tpl.app.mysql.php.

◆ ACTION_REMOVE_SERVICE

const ACTION_REMOVE_SERVICE = 'removeMysqlService'

Definition at line 30 of file class.tpl.app.mysql.php.

◆ ACTION_SWITCH_VERSION

const ACTION_SWITCH_VERSION = 'switchMysqlVersion'

Definition at line 26 of file class.tpl.app.mysql.php.

◆ MENU

const MENU = 'mysql'

Definition at line 20 of file class.tpl.app.mysql.php.

◆ MENU_DEBUG

const MENU_DEBUG = 'mysqlDebug'

Definition at line 23 of file class.tpl.app.mysql.php.

◆ MENU_SERVICE

const MENU_SERVICE = 'mysqlService'

Definition at line 22 of file class.tpl.app.mysql.php.

◆ MENU_VERSIONS

const MENU_VERSIONS = 'mysqlVersions'

Definition at line 21 of file class.tpl.app.mysql.php.


The documentation for this class was generated from the following file: