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

static TplAppPostgresql::getActionChangePostgresqlPort ( )
static

Generates the action to change the PostgreSQL port.

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

Returns
string The generated action to change the PostgreSQL port.

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

268 {
269 global $bearsamppBins;
270
271 return TplApp::getActionRun(Action::CHANGE_PORT, array($bearsamppBins->getPostgresql()->getName())) . PHP_EOL .
273 }
global $bearsamppBins
const CHANGE_PORT
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)

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

◆ getActionChangePostgresqlRootPwd()

static TplAppPostgresql::getActionChangePostgresqlRootPwd ( )
static

Generates the action to change the PostgreSQL root password.

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

Returns
string The generated action to change the PostgreSQL root password.

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

283 {
284 global $bearsamppBins;
285
286 return TplApp::getActionRun(Action::CHANGE_DB_ROOT_PWD, array($bearsamppBins->getPostgresql()->getName())) . PHP_EOL .
288 }
const CHANGE_DB_ROOT_PWD

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

◆ getActionEnablePostgresql()

static TplAppPostgresql::getActionEnablePostgresql ( $enable)
static

Generates the action to enable or disable PostgreSQL.

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

Parameters
int$enableThe flag to enable (1) or disable (0) PostgreSQL.
Returns
string The generated action to enable or disable PostgreSQL.

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

153 {
154 global $bearsamppBins;
155
156 return TplApp::getActionRun(Action::ENABLE, array($bearsamppBins->getPostgresql()->getName(), $enable)) . PHP_EOL .
158 }
const ENABLE

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

◆ getActionInstallPostgresqlService()

static TplAppPostgresql::getActionInstallPostgresqlService ( )
static

Generates the action to install the PostgreSQL service.

Returns
string The generated action to install the PostgreSQL service.

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

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

◆ getActionRemovePostgresqlService()

static TplAppPostgresql::getActionRemovePostgresqlService ( )
static

Generates the action to remove the PostgreSQL service.

Returns
string The generated action to remove the PostgreSQL service.

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

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

◆ getActionSwitchPostgresqlVersion()

static TplAppPostgresql::getActionSwitchPostgresqlVersion ( $version)
static

Generates the action to switch the PostgreSQL version.

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

Parameters
string$versionThe version to switch to.
Returns
string The generated action to switch the PostgreSQL version.

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

169 {
170 global $bearsamppBins;
171
172 return TplApp::getActionRun(Action::SWITCH_VERSION, array($bearsamppBins->getPostgresql()->getName(), $version)) . PHP_EOL .
174 }
const SWITCH_VERSION

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

◆ getMenuPostgresql()

static TplAppPostgresql::getMenuPostgresql ( )
static

Generates the PostgreSQL menu with options for versions, service, debug, and console 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 and utilities.

Returns
string The generated menu items and actions for PostgreSQL.

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 Util::getWebsiteUrl('module/postgresql', '#releases'),
66 false,
68 ) . PHP_EOL;
69
70 // Enable
71 $tplEnable = TplApp::getActionMulti(
72 self::ACTION_ENABLE, array($isEnabled ? Config::DISABLED : Config::ENABLED),
73 array($bearsamppLang->getValue(Lang::MENU_ENABLE), $isEnabled ? TplAestan::GLYPH_CHECK : ''),
74 false, get_called_class()
75 );
76 $resultItems .= $tplEnable[TplApp::SECTION_CALL] . PHP_EOL;
77 $resultActions .= $tplEnable[TplApp::SECTION_CONTENT] . PHP_EOL;
78
79 if ($isEnabled) {
80 $resultItems .= TplAestan::getItemSeparator() . PHP_EOL;
81
82 // Versions
83 $tplVersions = TplApp::getMenu($bearsamppLang->getValue(Lang::VERSIONS), self::MENU_VERSIONS, get_called_class());
84 $resultItems .= $tplVersions[TplApp::SECTION_CALL] . PHP_EOL;
85 $resultActions .= $tplVersions[TplApp::SECTION_CONTENT] . PHP_EOL;
86
87 // Service
88 $tplService = TplApp::getMenu($bearsamppLang->getValue(Lang::SERVICE), self::MENU_SERVICE, get_called_class());
89 $resultItems .= $tplService[TplApp::SECTION_CALL] . PHP_EOL;
90 $resultActions .= $tplService[TplApp::SECTION_CONTENT] . PHP_EOL;
91
92 // Debug
93 $tplDebug = TplApp::getMenu($bearsamppLang->getValue(Lang::DEBUG), self::MENU_DEBUG, get_called_class());
94 $resultItems .= $tplDebug[TplApp::SECTION_CALL] . PHP_EOL;
95 $resultActions .= $tplDebug[TplApp::SECTION_CONTENT];
96
97 // Console
98 $resultItems .= TplAestan::getItemConsoleZ(
101 $bearsamppTools->getConsoleZ()->getTabTitlePostgresql()
102 ) . PHP_EOL;
103
104 // Conf
105 $resultItems .= TplAestan::getItemNotepad(basename($bearsamppBins->getPostgresql()->getConf()), $bearsamppBins->getPostgresql()->getConf()) . PHP_EOL;
106
107 // Errors log
108 $resultItems .= TplAestan::getItemNotepad($bearsamppLang->getValue(Lang::MENU_ERROR_LOGS), $bearsamppBins->getPostgresql()->getErrorLog()) . PHP_EOL;
109 }
110
111 return $resultItems . PHP_EOL . $resultActions;
112 }
global $bearsamppLang
const DISABLED
const MENU_ERROR_LOGS
const VERSIONS
const DEBUG
const DOWNLOAD_MORE
const CONSOLE
const SERVICE
static getItemSeparator()
static getItemConsoleZ($caption, $glyph, $id=null, $title=null, $initDir=null, $command=null)
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
static getItemNotepad($caption, $path)
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
const SECTION_CALL
const SECTION_CONTENT
static getMenu($caption, $menu, $class)
static getWebsiteUrl($path='', $fragment='', $utmSource=true)

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

◆ getMenuPostgresqlDebug()

static TplAppPostgresql::getMenuPostgresqlDebug ( )
static

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

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

Returns
string The generated menu items and actions for PostgreSQL debug.

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

251 {
252 global $bearsamppLang;
253
257 ) . PHP_EOL;
258 }
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.

◆ getMenuPostgresqlService()

static TplAppPostgresql::getMenuPostgresqlService ( )
static

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

@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 menu items and actions for PostgreSQL service.

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

185 {
187
188 $tplChangePort = TplApp::getActionMulti(
189 self::ACTION_CHANGE_PORT, null,
191 false, get_called_class()
192 );
193
194 $isInstalled = $bearsamppBins->getPostgresql()->getService()->isInstalled();
195
196 $result = TplAestan::getItemActionServiceStart($bearsamppBins->getPostgresql()->getService()->getName()) . PHP_EOL .
197 TplAestan::getItemActionServiceStop($bearsamppBins->getPostgresql()->getService()->getName()) . PHP_EOL .
198 TplAestan::getItemActionServiceRestart($bearsamppBins->getPostgresql()->getService()->getName()) . PHP_EOL .
199 TplAestan::getItemSeparator() . PHP_EOL .
201 Action::CHECK_PORT, array($bearsamppBins->getPostgresql()->getName(), $bearsamppBins->getPostgresql()->getPort()),
202 array(sprintf($bearsamppLang->getValue(Lang::MENU_CHECK_PORT), $bearsamppBins->getPostgresql()->getPort()), TplAestan::GLYPH_LIGHT)
203 ) . PHP_EOL .
204 $tplChangePort[TplApp::SECTION_CALL] . PHP_EOL;
205
206 $tplChangeRootPwd = null;
207 if ($isInstalled) {
208 $tplChangeRootPwd = TplApp::getActionMulti(
209 self::ACTION_CHANGE_ROOT_PWD, null,
211 !$isInstalled, get_called_class()
212 );
213
214 $result .= $tplChangeRootPwd[TplApp::SECTION_CALL] . PHP_EOL;
215 }
216
217 if (!$isInstalled) {
218 $tplInstallService = TplApp::getActionMulti(
219 self::ACTION_INSTALL_SERVICE, null,
221 $isInstalled, get_called_class()
222 );
223
224 $result .= $tplInstallService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
225 $tplInstallService[TplApp::SECTION_CONTENT] . PHP_EOL;
226 } else {
227 $tplRemoveService = TplApp::getActionMulti(
228 self::ACTION_REMOVE_SERVICE, null,
230 !$isInstalled, get_called_class()
231 );
232
233 $result .= $tplRemoveService[TplApp::SECTION_CALL] . PHP_EOL . PHP_EOL .
234 $tplRemoveService[TplApp::SECTION_CONTENT] . PHP_EOL;
235 }
236
237 $result .= $tplChangePort[TplApp::SECTION_CONTENT] . PHP_EOL .
238 ($tplChangeRootPwd != null ? $tplChangeRootPwd[TplApp::SECTION_CONTENT] . PHP_EOL : '');
239
240 return $result;
241 }
$result
const CHECK_PORT
const MENU_INSTALL_SERVICE
const MENU_CHANGE_ROOT_PWD
const MENU_REMOVE_SERVICE
const MENU_CHECK_PORT
const MENU_CHANGE_PORT
const GLYPH_SERVICE_REMOVE
static getItemActionServiceStop($service)
static getItemActionServiceStart($service)
static getItemActionServiceRestart($service)
const GLYPH_SERVICE_INSTALL

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.

◆ getMenuPostgresqlVersions()

static TplAppPostgresql::getMenuPostgresqlVersions ( )
static

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

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

Returns
string The generated menu items and actions for PostgreSQL versions.

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

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

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

◆ process()

static TplAppPostgresql::process ( )
static

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

@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 menu items and actions for PostgreSQL.

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 caller graph for this function:

Field Documentation

◆ ACTION_CHANGE_PORT

const TplAppPostgresql::ACTION_CHANGE_PORT = 'changePostgresqlPort'

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

◆ ACTION_CHANGE_ROOT_PWD

const TplAppPostgresql::ACTION_CHANGE_ROOT_PWD = 'changePostgresqlRootPwd'

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

◆ ACTION_ENABLE

const TplAppPostgresql::ACTION_ENABLE = 'enablePostgresql'

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

◆ ACTION_INSTALL_SERVICE

const TplAppPostgresql::ACTION_INSTALL_SERVICE = 'installPostgresqlService'

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

◆ ACTION_REMOVE_SERVICE

const TplAppPostgresql::ACTION_REMOVE_SERVICE = 'removePostgresqlService'

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

◆ ACTION_SWITCH_VERSION

const TplAppPostgresql::ACTION_SWITCH_VERSION = 'switchPostgresqlVersion'

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

◆ MENU

const TplAppPostgresql::MENU = 'postgresql'

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

◆ MENU_DEBUG

const TplAppPostgresql::MENU_DEBUG = 'postgresqlDebug'

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

◆ MENU_SERVICE

const TplAppPostgresql::MENU_SERVICE = 'postgresqlService'

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

◆ MENU_VERSIONS

const TplAppPostgresql::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: