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

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 = 'webgrindConf'
 
const ROOT_CFG_VERSION = 'webgrindVersion'
 
- 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 AppWebgrind

This class represents the Webgrind application module within the Bearsampp application. It extends the Module class and provides functionalities specific to Webgrind, such as configuration management and version handling.

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

Constructor & Destructor Documentation

◆ __construct()

AppWebgrind::__construct ( $id,
$type )

Constructor for the AppWebgrind class.

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

Definition at line 40 of file class.app.webgrind.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()

AppWebgrind::getConf ( )

Gets the path to the Webgrind configuration file.

Returns
string The path to the Webgrind configuration file.

Definition at line 130 of file class.app.webgrind.php.

130 {
131 return $this->conf;
132 }

References $conf.

◆ reload()

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

Reloads the Webgrind 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.webgrind.php.

51 {
54
55 $this->name = $bearsamppLang->getValue(Lang::WEBGRIND);
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 WEBGRIND
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\WEBGRIND.

Referenced by __construct(), and setVersion().

+ Here is the caller graph for this function:

◆ setVersion()

AppWebgrind::setVersion ( $version)

Sets the version of the Webgrind module.

Parameters
string$versionThe version to set.

Reimplemented from Module.

Definition at line 118 of file class.app.webgrind.php.

118 {
119 global $bearsamppConfig;
120 $this->version = $version;
121 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
122 $this->reload();
123 }

References $bearsamppConfig, Module\$version, and reload().

◆ updateConfig()

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

Updates the Webgrind module configuration.

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.webgrind.php.

90 {
91 global $bearsamppRoot;
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() . '/webgrind.conf';
101 if (is_file($alias)) {
102 Util::replaceInFile($alias, array(
103 '/^Alias\s\/webgrind\s.*/' => 'Alias /webgrind "' . $this->getSymlinkPath() . '/"',
104 '/^<Directory\s.*/' => '<Directory "' . $this->getSymlinkPath() . '/">',
105 ));
106 } else {
107 Util::logError($this->getName() . ' alias not found : ' . $alias);
108 }
109
110 return true;
111 }
global $bearsamppRoot
static replaceInFile($path, $replaceList)
static logDebug($data, $file=null)

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

Field Documentation

◆ $conf

AppWebgrind::$conf
private

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

Referenced by getConf().

◆ LOCAL_CFG_CONF

const AppWebgrind::LOCAL_CFG_CONF = 'webgrindConf'

Constant for the local configuration file key.

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

Referenced by reload().

◆ ROOT_CFG_VERSION

const AppWebgrind::ROOT_CFG_VERSION = 'webgrindVersion'

Constant for the root configuration version key.

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


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