Bearsampp 2026.3.26
API documentation
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.

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

Returns
string The generated action string for changing MySQL port.

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

298 {
299 global $bearsamppBins;
300
301 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getMysql()->getName())) . PHP_EOL .
303 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

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

◆ getActionChangeMysqlRootPwd()

getActionChangeMysqlRootPwd ( )
static

Generates the action to change MySQL root password.

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

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

Returns
string The generated action string for changing MySQL root password.

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

315 {
316 global $bearsamppBins;
317
318 return TplApp::getActionRun(Action::CHANGE_DB_ROOT_PWD, array($bearsamppBins->getMysql()->getName())) . PHP_EOL .
320 }
const CHANGE_DB_ROOT_PWD

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

◆ getActionEnableMysql()

getActionEnableMysql ( $enable)
static

Generates the action to enable or disable MySQL.

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

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

Parameters
int$enableThe enable/disable flag (1 for enable, 0 for disable).
Returns
string The generated action string for enabling/disabling MySQL.

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

165 {
166 global $bearsamppBins;
167
168 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getMysql()->getName(), $enable)) . PHP_EOL .
170 }
const ENABLE

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

◆ 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 329 of file class.tpl.app.mysql.php.

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

◆ 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 342 of file class.tpl.app.mysql.php.

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

◆ getActionSwitchMysqlVersion()

getActionSwitchMysqlVersion ( $version)
static

Generates the action to switch MySQL version.

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

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

Parameters
string$versionThe version to switch to.
Returns
string The generated action string for switching MySQL version.

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

183 {
184 global $bearsamppBins;
185
186 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getMysql()->getName(), $version)) . PHP_EOL .
188 }
const SWITCH_VERSION

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

◆ 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.

@global object $bearsamppBins Provides access to system binaries and their configurations. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppTools Provides access to various tools used in the application.

Returns
string The generated MySQL menu items and actions.

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
70 Util::getWebsiteUrl('module/mysql', '#releases'),
71 false,
73 ) . PHP_EOL;
74
75 // Enable
76 $tplEnable = TplApp::getActionMulti(
77 self::ACTION_ENABLE, array($isEnabled ? Config::DISABLED : Config::ENABLED),
78 array($bearsamppLang->getValue(Lang::MENU_ENABLE), $isEnabled ? TplAestan::GLYPH_CHECK : ''),
79 false, get_called_class()
80 );
81 $resultItems .= $tplEnable[TplApp::SECTION_CALL] . PHP_EOL;
82 $resultActions .= $tplEnable[TplApp::SECTION_CONTENT] . PHP_EOL;
83
84 if ($isEnabled) {
85 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
86
87 // Versions
88 $tplVersions = TplApp::getMenu($bearsamppLang->getValue(Lang::VERSIONS), self::MENU_VERSIONS, get_called_class());
89 $resultItems .= $tplVersions[TplApp::SECTION_CALL] . PHP_EOL;
90 $resultActions .= $tplVersions[TplApp::SECTION_CONTENT] . PHP_EOL;
91
92 // Service
93 $tplService = TplApp::getMenu($bearsamppLang->getValue(Lang::SERVICE), self::MENU_SERVICE, get_called_class());
94 $resultItems .= $tplService[TplApp::SECTION_CALL] . PHP_EOL;
95 $resultActions .= $tplService[TplApp::SECTION_CONTENT] . PHP_EOL;
96
97 // Debug
98 $tplDebug = TplApp::getMenu($bearsamppLang->getValue(Lang::DEBUG), self::MENU_DEBUG, get_called_class());
99 $resultItems .= $tplDebug[TplApp::SECTION_CALL] . PHP_EOL;
100 $resultActions .= $tplDebug[TplApp::SECTION_CONTENT];
101
102 // Console
103 $resultItems .= TplAestan::getItemPowerShell(
104 $bearsamppLang->getValue(Lang::CONSOLE),
106 null,
107 $bearsamppTools->getPowerShell()->getTabTitleMysql(),
108 $bearsamppBins->getMysql()->getSymlinkPath(),
109 null
110 ) . PHP_EOL;
111
112 // Conf
113 $resultItems .= TplAestan::getItemNotepad(basename($bearsamppBins->getMysql()->getConf()), $bearsamppBins->getMysql()->getConf()) . PHP_EOL;
114
115 // Errors log
116 $resultItems .= TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_ERROR_LOGS), $bearsamppBins->getMysql()->getErrorLog()) . PHP_EOL;
117 }
118
119 return $resultItems . PHP_EOL . $resultActions;
120 }
global $bearsamppLang
const DISABLED
const ENABLED
const MENU_ENABLE
const SERVICE
const DOWNLOAD_MORE
const CONSOLE
const DEBUG
const MENU_ERROR_LOGS
const VERSIONS
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
static getWebsiteUrl($path='', $fragment='', $utmSource=true)

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(), Util\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.

◆ getMenuMysqlDebug()

getMenuMysqlDebug ( )
static

Generates the MySQL debug menu.

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

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

Returns
string The generated MySQL debug menu items and actions.

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

271 {
272 global $bearsamppLang;
273
277 ) . PHP_EOL .
281 ) . PHP_EOL .
285 ) . PHP_EOL;
286 }
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.

◆ 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.

@global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
string The generated MySQL service menu items and actions.

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

202 {
204
205 $tplChangePort = TplApp::getActionMulti(
206 self::ACTION_CHANGE_PORT, null,
208 false, get_called_class()
209 );
210
211 $isInstalled = $bearsamppBins->getMysql()->getService()->isInstalled();
212
213 $result = TplAestan::getItemActionServiceStart($bearsamppBins->getMysql()->getService()->getName()) . PHP_EOL .
214 TplAestan::getItemActionServiceStop($bearsamppBins->getMysql()->getService()->getName()) . PHP_EOL .
215 TplAestan::getItemActionServiceRestart($bearsamppBins->getMysql()->getService()->getName()) . PHP_EOL .
216 TplAestan::getItemSeparator() . PHP_EOL .
218 Action::CHECK_PORT, array($bearsamppBins->getMysql()->getName(), $bearsamppBins->getMysql()->getPort()),
219 array(sprintf($bearsamppLang->getValue(Lang::MENU_CHECK_PORT), $bearsamppBins->getMysql()->getPort()), TplAestan::GLYPH_LIGHT)
220 ) . PHP_EOL .
221 $tplChangePort[TplApp::SECTION_CALL] . PHP_EOL;
222
223 $tplChangeRootPwd = null;
224 if ($isInstalled) {
225 $tplChangeRootPwd = TplApp::getActionMulti(
226 self::ACTION_CHANGE_ROOT_PWD, null,
228 !$isInstalled, get_called_class()
229 );
230
231 $result .= $tplChangeRootPwd[TplApp::SECTION_CALL] . PHP_EOL;
232 }
233
234 if (!$isInstalled) {
235 $tplInstallService = TplApp::getActionMulti(
236 self::ACTION_INSTALL_SERVICE, null,
238 $isInstalled, get_called_class()
239 );
240
241 $result .= $tplInstallService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
242 $tplInstallService[TplApp::SECTION_CONTENT] . PHP_EOL;
243 } else {
244 $tplRemoveService = TplApp::getActionMulti(
245 self::ACTION_REMOVE_SERVICE, null,
247 !$isInstalled, get_called_class()
248 );
249
250 $result .= $tplRemoveService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
251 $tplRemoveService[TplApp::SECTION_CONTENT] . PHP_EOL;
252 }
253
254 $result .= $tplChangePort[TplApp::SECTION_CONTENT] . PHP_EOL .
255 ($tplChangeRootPwd != null ? $tplChangeRootPwd[TplApp::SECTION_CONTENT] . PHP_EOL : '');
256
257 return $result;
258 }
$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.

◆ getMenuMysqlVersions()

getMenuMysqlVersions ( )
static

Generates the MySQL versions menu.

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

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

Returns
string The generated MySQL versions menu items and actions.

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

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

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

◆ process()

process ( )
static

Processes and generates the MySQL menu.

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

@global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppBins Provides access to system binaries and their configurations.

Returns
array The generated MySQL menu.

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().

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: