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

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 = 'adminerConf'
 
const ROOT_CFG_VERSION = 'adminerVersion'
 
- 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 AppAdminer

This class represents the Adminer application module in the Bearsampp application. It extends the Module class and provides functionalities specific to the Adminer module, such as configuration management and version control.

Definition at line 17 of file class.app.adminer.php.

Constructor & Destructor Documentation

◆ __construct()

AppAdminer::__construct ( $id,
$type )

Constructor for the AppAdminer class.

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

Definition at line 40 of file class.app.adminer.php.

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

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

Member Function Documentation

◆ getConf()

AppAdminer::getConf ( )

Gets the path to the Adminer configuration file.

Returns
string The path to the Adminer configuration file.

Definition at line 152 of file class.app.adminer.php.

152 {
153 return $this->conf;
154 }

Referenced by updateConfig().

+ Here is the caller graph for this function:

◆ reload()

AppAdminer::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 51 of file class.app.adminer.php.

51 {
54
55 $this->name = $bearsamppLang->getValue(Lang::ADMINER);
56 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
57 parent::reload($id, $type);
58
59 if ($this->bearsamppConfRaw !== false) {
60 $this->conf = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
61 }
62
63 if (!$this->enable) {
64 Util::logInfo($this->name . ' is not enabled!');
65 return;
66 }
67 if (!is_dir($this->currentPath)) {
68 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
69 }
70 if (!is_dir($this->symlinkPath)) {
71 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
72 return;
73 }
74 if (!is_file($this->bearsamppConf)) {
75 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
76 }
77 if (!is_file($this->conf)) {
78 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->conf));
79 }
80 }
global $bearsamppLang
const ERROR_FILE_NOT_FOUND
const ADMINER
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\ADMINER, Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, LOCAL_CFG_CONF, Util\logError(), Util\logInfo(), and Util\logReloadClass().

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setVersion()

AppAdminer::setVersion ( $version)

Sets the version of the module.

Parameters
string$versionThe version to set.

Reimplemented from Module.

Definition at line 140 of file class.app.adminer.php.

140 {
141 global $bearsamppConfig;
142 $this->version = $version;
143 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
144 $this->reload();
145 }

◆ updateConfig()

AppAdminer::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 90 of file class.app.adminer.php.

90 {
92
93 if (!$this->enable) {
94 return true;
95 }
96
97 $version = $version == null ? $this->version : $version;
98 Util::logDebug(($sub > 0 ? str_repeat(' ', 2 * $sub) : '') . 'Update ' . $this->name . ' ' . $version . ' config');
99
100 $alias = $bearsamppRoot->getAliasPath() . '/adminer.conf';
101 if (is_file($alias)) {
102 Util::replaceInFile($alias, array(
103 '/^Alias\s\/adminer\s.*/' => 'Alias /adminer "' . $this->getSymlinkPath() . '/"',
104 '/^<Directory\s.*/' => '<Directory "' . $this->getSymlinkPath() . '/">',
105 ));
106 } else {
107 Util::logError($this->getName() . ' alias not found : ' . $alias);
108 }
109
110 if ($bearsamppBins->getMysql()->isEnable()) {
111 Util::replaceInFile($this->getConf(), array(
112 '/^\$mysqlPort\s=\s(\d+)/' => '$mysqlPort = ' . $bearsamppBins->getMysql()->getPort() . ';',
113 '/^\$mysqlRootUser\s=\s/' => '$mysqlRootUser = \'' . $bearsamppBins->getMysql()->getRootUser() . '\';',
114 '/^\$mysqlRootPwd\s=\s/' => '$mysqlRootPwd = \'' . $bearsamppBins->getMysql()->getRootPwd() . '\';'
115 ));
116 }
117 if ($bearsamppBins->getMariadb()->isEnable()) {
118 Util::replaceInFile($this->getConf(), array(
119 '/^\$mariadbPort\s=\s(\d+)/' => '$mariadbPort = ' . $bearsamppBins->getMariadb()->getPort() . ';',
120 '/^\$mariadbRootUser\s=\s/' => '$mariadbRootUser = \'' . $bearsamppBins->getMariadb()->getRootUser() . '\';',
121 '/^\$mariadbRootPwd\s=\s/' => '$mariadbRootPwd = \'' . $bearsamppBins->getMariadb()->getRootPwd() . '\';'
122 ));
123 }
124 if ($bearsamppBins->getPostgresql()->isEnable()) {
125 Util::replaceInFile($this->getConf(), array(
126 '/^\$postgresqlPort\s=\s(\d+)/' => '$postgresqlPort = ' . $bearsamppBins->getPostgresql()->getPort() . ';',
127 '/^\$postgresqlRootUser\s=\s/' => '$postgresqlRootUser = \'' . $bearsamppBins->getPostgresql()->getRootUser() . '\';',
128 '/^\$postgresqlRootPwd\s=\s/' => '$postgresqlRootPwd = \'' . $bearsamppBins->getPostgresql()->getRootPwd() . '\';'
129 ));
130 }
131
132 return true;
133 }
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

AppAdminer::$conf
private

Definition at line 32 of file class.app.adminer.php.

◆ LOCAL_CFG_CONF

const AppAdminer::LOCAL_CFG_CONF = 'adminerConf'

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

Definition at line 27 of file class.app.adminer.php.

Referenced by reload().

◆ ROOT_CFG_VERSION

const AppAdminer::ROOT_CFG_VERSION = 'adminerVersion'

Configuration key for the Adminer version in the root configuration.

Definition at line 22 of file class.app.adminer.php.


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