Skip to content
Snippets Groups Projects
Commit 14e6a99c authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

config-replacements: fix parser problems

parent fc97cf97
No related branches found
No related tags found
1 merge request!66php8 only; added variable types; short array syntax; remove glyphicons
...@@ -10,12 +10,14 @@ require_once 'project.class.php'; ...@@ -10,12 +10,14 @@ require_once 'project.class.php';
* reads templatefiles and scans its placeholders for replacements * reads templatefiles and scans its placeholders for replacements
* *
* @author hahn * @author hahn
*
* 2024-08-23 v1.1 Axel Hahn fix php parser problems
*/ */
class configreplacement { class configreplacement {
/** /**
* project class * project class
* @var type * @var object
*/ */
protected $_oProject = false; protected $_oProject = false;
protected $_sPhase = false; protected $_sPhase = false;
...@@ -23,15 +25,13 @@ class configreplacement { ...@@ -23,15 +25,13 @@ class configreplacement {
/** /**
* init * Constructor
* @param string $sProject optional: project id; you can use setProject() too * @param string $sProject optional: project id; you can use setProject() too
* @return boolean
*/ */
public function __construct($sProject = false) { public function __construct($sProject = '') {
if ($sProject){ if ($sProject){
$this->setProject($sProject); $this->setProject($sProject);
} }
return true;
} }
...@@ -61,13 +61,13 @@ class configreplacement { ...@@ -61,13 +61,13 @@ class configreplacement {
/** /**
* get an array with all template files (basename) and its replacement fields * get an array with all template files (basename) and its replacement fields
* @return array * @return bool|array
*/ */
public function getReplacements(){ public function getReplacements(){
if (!$this->_sPhase){ if (!$this->_sPhase){
return false; return false;
} }
$aFiles=$this->getTemplatefiles($this->_sPhase); $aFiles=$this->getTemplatefiles();
if (!$aFiles){ if (!$aFiles){
return false; return false;
} }
...@@ -96,8 +96,8 @@ class configreplacement { ...@@ -96,8 +96,8 @@ class configreplacement {
/** /**
* get replacement definitions from foreman * get replacement definitions from foreman
* @global type $aConfig * @global array $aConfig
* @return boolean * @return bool|array
*/ */
protected function _getForemanReplacement(){ protected function _getForemanReplacement(){
global $aConfig; global $aConfig;
...@@ -259,9 +259,10 @@ class configreplacement { ...@@ -259,9 +259,10 @@ class configreplacement {
} }
/** /**
* get html code for links to edit each host of the current phase in foreman * Get html code for links to edit each host of the current phase in foreman
* It returns false if foreman is not activated or there is no phase.
* *
* @return boolean * @return bool|string
*/ */
public function getForemanlink2Host(){ public function getForemanlink2Host(){
$sForemanurl=$this->_getForemanBaseUrl(); $sForemanurl=$this->_getForemanBaseUrl();
...@@ -288,9 +289,10 @@ class configreplacement { ...@@ -288,9 +289,10 @@ class configreplacement {
} }
/** /**
* get html code for a link to edit hostgroup in foreman * Get html code for a link to edit hostgroup in foreman
* It returns false if foreman is not activated or there is no hostgroup in the project phase
* *
* @return boolean * @return bool|string
*/ */
public function getForemanlink2Hostgroup(){ public function getForemanlink2Hostgroup(){
$iEffectiveHostgroup=$this->getForemanHostgroup(); $iEffectiveHostgroup=$this->getForemanHostgroup();
...@@ -315,7 +317,7 @@ class configreplacement { ...@@ -315,7 +317,7 @@ class configreplacement {
/** /**
* get replacements in foreman * get replacements in foreman
* @return type * @return bool|array
*/ */
public function getForemanReplacements(){ public function getForemanReplacements(){
return $this->_getForemanReplacement(); return $this->_getForemanReplacement();
...@@ -323,7 +325,8 @@ class configreplacement { ...@@ -323,7 +325,8 @@ class configreplacement {
/** /**
* switch to a project * switch to a project
* @param type $sProject * @param string $sProject project id
* @param string $sPhase optional: a phase; one of preview|stage|live
*/ */
public function setProject($sProject, $sPhase=false){ public function setProject($sProject, $sPhase=false){
$this->_oProject = new project($sProject); $this->_oProject = new project($sProject);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment