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

Static Public Member Functions

static getActionChangePostgresqlPort ()
static getActionChangePostgresqlRootPwd ()
static getActionEnablePostgresql ($enable)
static getActionInstallPostgresqlService ()
static getActionRemovePostgresqlService ()
static getActionSwitchPostgresqlVersion ($version)
static getMenuPostgresql ()
static getMenuPostgresqlDebug ()
static getMenuPostgresqlService ()
static getMenuPostgresqlVersions ()
static process ()

Data Fields

const ACTION_CHANGE_PORT = 'changePostgresqlPort'
const ACTION_CHANGE_ROOT_PWD = 'changePostgresqlRootPwd'
const ACTION_ENABLE = 'enablePostgresql'
const ACTION_INSTALL_SERVICE = 'installPostgresqlService'
const ACTION_REMOVE_SERVICE = 'removePostgresqlService'
const ACTION_SWITCH_VERSION = 'switchPostgresqlVersion'
const MENU = 'postgresql'
const MENU_DEBUG = 'postgresqlDebug'
const MENU_SERVICE = 'postgresqlService'
const MENU_VERSIONS = 'postgresqlVersions'

Detailed Description

Class TplAppPostgresql

This class provides methods to generate menu items and actions for managing PostgreSQL services within the Bearsampp application. It includes functionalities for enabling/disabling PostgreSQL, switching versions, changing ports, changing root passwords, and managing services.

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

Member Function Documentation

◆ getActionChangePostgresqlPort()

getActionChangePostgresqlPort ( )
static

Generates the action to change the PostgreSQL port.

Returns
string The generated action to change the PostgreSQL port. @global object $bearsamppBins Provides access to system binaries and their configurations.

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

287 {
288 global $bearsamppBins;
289
290 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getPostgresql()->getName())) . PHP_EOL .
292 }
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:

◆ getActionChangePostgresqlRootPwd()

getActionChangePostgresqlRootPwd ( )
static

Generates the action to change the PostgreSQL root password.

Returns
string The generated action to change the PostgreSQL root password. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 301 of file class.tpl.app.postgresql.php.

302 {
303 global $bearsamppBins;
304
305 return TplApp::getActionRun(Action::CHANGE_DB_ROOT_PWD, array($bearsamppBins->getPostgresql()->getName())) . PHP_EOL .
307 }
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:

◆ getActionEnablePostgresql()

getActionEnablePostgresql ( $enable)
static

Generates the action to enable or disable PostgreSQL.

Parameters
int$enableThe flag to enable (1) or disable (0) PostgreSQL.
Returns
string The generated action to enable or disable PostgreSQL. @global object $bearsamppBins Provides access to system binaries and their configurations.

Definition at line 160 of file class.tpl.app.postgresql.php.

161 {
162 global $bearsamppBins;
163
164 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getPostgresql()->getName(), $enable)) . PHP_EOL .
166 }
const ENABLE

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

Here is the call graph for this function:

◆ getActionInstallPostgresqlService()

getActionInstallPostgresqlService ( )
static

Generates the action to install the PostgreSQL service.

Returns
string The generated action to install the PostgreSQL service.

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

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

Here is the call graph for this function:

◆ getActionRemovePostgresqlService()

getActionRemovePostgresqlService ( )
static

Generates the action to remove the PostgreSQL service.

Returns
string The generated action to remove the PostgreSQL service.

Definition at line 325 of file class.tpl.app.postgresql.php.

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

Here is the call graph for this function:

◆ getActionSwitchPostgresqlVersion()

getActionSwitchPostgresqlVersion ( $version)
static

Generates the action to switch the PostgreSQL version.

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

Definition at line 177 of file class.tpl.app.postgresql.php.

178 {
179 global $bearsamppBins;
180
181 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getPostgresql()->getName(), $version)) . PHP_EOL .
183 }
const SWITCH_VERSION

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

Here is the call graph for this function:

◆ getMenuPostgresql()

getMenuPostgresql ( )
static

Generates the PostgreSQL menu with options for versions, service, debug, and console access.

Returns
string The generated menu items and actions for PostgreSQL. @global object $bearsamppLang Provides language support for retrieving language-specific values. @global object $bearsamppTools Provides access to various tools and utilities.

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

Definition at line 55 of file class.tpl.app.postgresql.php.

56 {
57 global $bearsamppBins, $bearsamppLang, $bearsamppTools;
58 $resultItems = $resultActions = '';
59
60 $isEnabled = $bearsamppBins->getPostgresql()->isEnable();
61
62 // Download
63 $resultItems .= TplAestan::getItemLink(
65 HttpClient::getWebsiteUrl('module/postgresql', '#releases'),
66 false,
68 ) . PHP_EOL;
69
70 // Enable
71 $tplEnable = TplApp::getActionMulti(
72 self::ACTION_ENABLE,
73 array($isEnabled ? Config::DISABLED : Config::ENABLED),
74 array($bearsamppLang->getValue(Lang::MENU_ENABLE), $isEnabled ? TplAestan::GLYPH_CHECK : ''),
75 false,
76 get_called_class()
77 );
78 $resultItems .= $tplEnable[TplApp::SECTION_CALL] . PHP_EOL;
79 $resultActions .= $tplEnable[TplApp::SECTION_CONTENT] . PHP_EOL;
80
81 if ($isEnabled) {
82 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
83
84 // Versions
85 $tplVersions = TplApp::getMenu($bearsamppLang->getValue(Lang::VERSIONS), self::MENU_VERSIONS, get_called_class());
86 $resultItems .= $tplVersions[TplApp::SECTION_CALL] . PHP_EOL;
87 $resultActions .= $tplVersions[TplApp::SECTION_CONTENT] . PHP_EOL;
88
89 // Service
90 $tplService = TplApp::getMenu($bearsamppLang->getValue(Lang::SERVICE), self::MENU_SERVICE, get_called_class());
91 $resultItems .= $tplService[TplApp::SECTION_CALL] . PHP_EOL;
92 $resultActions .= $tplService[TplApp::SECTION_CONTENT] . PHP_EOL;
93
94 // Debug
95 $tplDebug = TplApp::getMenu($bearsamppLang->getValue(Lang::DEBUG), self::MENU_DEBUG, get_called_class());
96 $resultItems .= $tplDebug[TplApp::SECTION_CALL] . PHP_EOL;
97 $resultActions .= $tplDebug[TplApp::SECTION_CONTENT];
98
99 // Console
100 $resultItems .= TplAestan::getItemPowerShell(
101 $bearsamppLang->getValue(Lang::CONSOLE),
103 null,
104 $bearsamppTools->getPowerShell()->getTabTitlePostgresql(),
106 null
107 ) . PHP_EOL;
108
109 // Conf
110 $resultItems .= TplAestan::getItemNotepad(basename($bearsamppBins->getPostgresql()->getConf()), $bearsamppBins->getPostgresql()->getConf()) . PHP_EOL;
111
112 // Errors log
113 $resultItems .= TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_ERROR_LOGS), $bearsamppBins->getPostgresql()->getErrorLog()) . PHP_EOL;
114 }
115
116 return $resultItems . PHP_EOL . $resultActions;
117 }
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:

◆ getMenuPostgresqlDebug()

getMenuPostgresqlDebug ( )
static

Generates the PostgreSQL debug menu with options to run various debug commands.

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

Definition at line 268 of file class.tpl.app.postgresql.php.

269 {
270 global $bearsamppLang;
271
276 ) . PHP_EOL;
277 }
const DEBUG_POSTGRESQL
const DEBUG_POSTGRESQL_VERSION

References $bearsamppLang, BinPostgresql\CMD_VERSION, Action\DEBUG_POSTGRESQL, Lang\DEBUG_POSTGRESQL_VERSION, TplApp\getActionRun(), and TplAestan\GLYPH_DEBUG.

Here is the call graph for this function:

◆ getMenuPostgresqlService()

getMenuPostgresqlService ( )
static

Generates the PostgreSQL service menu with options to start, stop, restart, and manage the service.

Returns
string The generated menu items and actions for PostgreSQL service. @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 193 of file class.tpl.app.postgresql.php.

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

◆ getMenuPostgresqlVersions()

getMenuPostgresqlVersions ( )
static

Generates the PostgreSQL versions menu with options to switch between different versions.

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

Definition at line 126 of file class.tpl.app.postgresql.php.

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

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

Generates the main PostgreSQL menu with options to enable/disable PostgreSQL and access submenus.

Returns
array The generated menu items and actions for PostgreSQL. @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 39 of file class.tpl.app.postgresql.php.

40 {
42
43 return TplApp::getMenuEnable($bearsamppLang->getValue(Lang::POSTGRESQL), self::MENU, get_called_class(), $bearsamppBins->getPostgresql()->isEnable());
44 }
const POSTGRESQL
static getMenuEnable($caption, $menu, $class, $enabled=true)

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

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 = 'changePostgresqlPort'

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

◆ ACTION_CHANGE_ROOT_PWD

const ACTION_CHANGE_ROOT_PWD = 'changePostgresqlRootPwd'

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

◆ ACTION_ENABLE

const ACTION_ENABLE = 'enablePostgresql'

Definition at line 24 of file class.tpl.app.postgresql.php.

◆ ACTION_INSTALL_SERVICE

const ACTION_INSTALL_SERVICE = 'installPostgresqlService'

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

◆ ACTION_REMOVE_SERVICE

const ACTION_REMOVE_SERVICE = 'removePostgresqlService'

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

◆ ACTION_SWITCH_VERSION

const ACTION_SWITCH_VERSION = 'switchPostgresqlVersion'

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

◆ MENU

const MENU = 'postgresql'

Definition at line 19 of file class.tpl.app.postgresql.php.

◆ MENU_DEBUG

const MENU_DEBUG = 'postgresqlDebug'

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

◆ MENU_SERVICE

const MENU_SERVICE = 'postgresqlService'

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

◆ MENU_VERSIONS

const MENU_VERSIONS = 'postgresqlVersions'

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


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