2024.8.23
Loading...
Searching...
No Matches
AppPhppgadmin Class Reference
+ Inheritance diagram for AppPhppgadmin:
+ Collaboration diagram for AppPhppgadmin:

Public Member Functions

 __construct ($id, $type)
 
 getConf ()
 
 reload ($id=null, $type=null)
 
 setVersion ($version)
 
- Public Member Functions inherited from Module
 __toString ()
 
 getCurrentPath ()
 
 getId ()
 
 getName ()
 
 getRelease ()
 
 getRootPath ()
 
 getSymlinkPath ()
 
 getType ()
 
 getVersion ()
 
 getVersionList ()
 
 isEnable ()
 
 update ($sub=0, $showWindow=false)
 

Data Fields

const LOCAL_CFG_CONF = 'phppgadminConf'
 
const ROOT_CFG_VERSION = 'phppgadminVersion'
 
- Data Fields inherited from Module
const BUNDLE_RELEASE = 'bundleRelease'
 

Protected Member Functions

 updateConfig ($version=null, $sub=0, $showWindow=false)
 
- Protected Member Functions inherited from Module
 __construct ()
 
 replace ($key, $value)
 
 replaceAll ($params)
 

Private Attributes

 $conf
 

Additional Inherited Members

- Protected Attributes inherited from Module
 $bearsamppConf
 
 $bearsamppConfRaw
 
 $currentPath
 
 $enable
 
 $name
 
 $release = 'N/A'
 
 $rootPath
 
 $symlinkPath
 
 $version
 

Detailed Description

Class AppPhppgadmin

This class represents the phpPgAdmin application module in the Bearsampp application. It handles the initialization, configuration, and management of the phpPgAdmin module.

Definition at line 16 of file class.app.phppgadmin.php.

Constructor & Destructor Documentation

◆ __construct()

AppPhppgadmin::__construct ( $id,
$type )

Constructor for the AppPhppgadmin class.

Parameters
string$idThe ID of the module.
string$typeThe type of the module.

Definition at line 39 of file class.app.phppgadmin.php.

39 {
40 Util::logInitClass($this);
41 $this->reload($id, $type);
42 }
reload($id=null, $type=null)
static logInitClass($classInstance)

References Module\$id, Module\$type, Util\logInitClass(), and reload().

Member Function Documentation

◆ getConf()

AppPhppgadmin::getConf ( )

Gets the path to the phpPgAdmin configuration file.

Returns
string The path to the configuration file.

Definition at line 139 of file class.app.phppgadmin.php.

139 {
140 return $this->conf;
141 }

Referenced by updateConfig().

+ Here is the caller graph for this function:

◆ reload()

AppPhppgadmin::reload ( $id = null,
$type = null )

Reloads the module configuration based on the provided ID and type.

Parameters
string | null$idThe ID of the module. If null, the current ID is used.
string | null$typeThe type of the module. If null, the current type is used.

Reimplemented from Module.

Definition at line 50 of file class.app.phppgadmin.php.

50 {
53
54 $this->name = $bearsamppLang->getValue(Lang::PHPPGADMIN);
55 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
56 parent::reload($id, $type);
57
58 if ($this->bearsamppConfRaw !== false) {
59 $this->conf = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
60 }
61
62 if (!$this->enable) {
63 Util::logInfo($this->name . ' is not enabled!');
64 return;
65 }
66 if (!is_dir($this->currentPath)) {
67 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
68 }
69 if (!is_dir($this->symlinkPath)) {
70 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
71 return;
72 }
73 if (!is_file($this->bearsamppConf)) {
74 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
75 }
76 if (!is_file($this->conf)) {
77 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->conf));
78 }
79 }
global $bearsamppLang
const ERROR_FILE_NOT_FOUND
const PHPPGADMIN
const ERROR_CONF_NOT_FOUND
static logReloadClass($classInstance)
static logError($data, $file=null)
static logInfo($data, $file=null)
global $bearsamppConfig
Definition homepage.php:26

References $bearsamppConfig, $bearsamppLang, Module\$id, Module\$type, Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, LOCAL_CFG_CONF, Util\logError(), Util\logInfo(), Util\logReloadClass(), and Lang\PHPPGADMIN.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setVersion()

AppPhppgadmin::setVersion ( $version)

Sets the version of the module.

Parameters
string$versionThe version to set.

Reimplemented from Module.

Definition at line 127 of file class.app.phppgadmin.php.

127 {
128 global $bearsamppConfig;
129 $this->version = $version;
130 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
131 $this->reload();
132 }

◆ updateConfig()

AppPhppgadmin::updateConfig ( $version = null,
$sub = 0,
$showWindow = false )
protected

Updates the module configuration with a specific version.

Parameters
string | null$versionThe version to update to. If null, the current version is used.
int$subThe sub-level for logging indentation.
bool$showWindowWhether to show a window during the update process.
Returns
bool True if the update was successful, false otherwise.

Reimplemented from Module.

Definition at line 89 of file class.app.phppgadmin.php.

89 {
91
92 if (!$this->enable) {
93 return true;
94 }
95
96 $version = $version == null ? $this->version : $version;
97 Util::logDebug(($sub > 0 ? str_repeat(' ', 2 * $sub) : '') . 'Update ' . $this->name . ' ' . $version . ' config');
98
99 $alias = $bearsamppRoot->getAliasPath() . '/phppgadmin.conf';
100 if (is_file($alias)) {
101 Util::replaceInFile($alias, array(
102 '/^Alias\s\/phppgadmin\s.*/' => 'Alias /phppgadmin "' . $this->getSymlinkPath() . '/"',
103 '/^<Directory\s.*/' => '<Directory "' . $this->getSymlinkPath() . '/">',
104 ));
105 } else {
106 Util::logError($this->getName() . ' alias not found : ' . $alias);
107 }
108
109 if ($bearsamppBins->getPostgresql()->isEnable()) {
110 Util::replaceInFile($this->getConf(), array(
111 '/^\$postgresqlPort\s=\s(\d+)/' => '$postgresqlPort = ' . $bearsamppBins->getPostgresql()->getPort() . ';',
112 '/^\$postgresqlRootUser\s=\s/' => '$postgresqlRootUser = \'' . $bearsamppBins->getPostgresql()->getRootUser() . '\';',
113 '/^\$postgresqlRootPwd\s=\s/' => '$postgresqlRootPwd = \'' . $bearsamppBins->getPostgresql()->getRootPwd() . '\';',
114 '/^\$postgresqlDumpExe\s=\s/' => '$postgresqlDumpExe = \'' . $bearsamppBins->getPostgresql()->getDumpExe() . '\';',
115 '/^\$postgresqlDumpAllExe\s=\s/' => '$postgresqlDumpAllExe = \'' . $bearsamppBins->getPostgresql()->getDumpAllExe() . '\';',
116 ));
117 }
118
119 return true;
120 }
global $bearsamppBins
global $bearsamppRoot
static replaceInFile($path, $replaceList)
static logDebug($data, $file=null)

References $bearsamppBins, $bearsamppRoot, Module\$version, getConf(), Module\getName(), Module\getSymlinkPath(), Util\logDebug(), Util\logError(), and Util\replaceInFile().

Field Documentation

◆ $conf

AppPhppgadmin::$conf
private

Definition at line 31 of file class.app.phppgadmin.php.

◆ LOCAL_CFG_CONF

const AppPhppgadmin::LOCAL_CFG_CONF = 'phppgadminConf'

Configuration key for the phpPgAdmin configuration file in the local configuration.

Definition at line 26 of file class.app.phppgadmin.php.

Referenced by reload().

◆ ROOT_CFG_VERSION

const AppPhppgadmin::ROOT_CFG_VERSION = 'phppgadminVersion'

Configuration key for the phpPgAdmin version in the root configuration.

Definition at line 21 of file class.app.phppgadmin.php.


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