/**
* Search for a variable in the stack
*
- * @param $var The variable we are looking for
- * @param $stack Optional variable stack to look in
- * @return $index FALSE means not found, >=0 means found on a specific index
+ * @param $variableName The variable we are looking for
+ * @param $stack Optional variable stack to look in
+ * @return $index FALSE means not found, >=0 means found on a specific index
*/
- private function getVariableIndex ($var, $stack = NULL) {
+ private function getVariableIndex ($variableName, $stack = NULL) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// First everything is not found
$found = false;
if ($this->isVarStackSet($stack)) {
// Now search for it
foreach ($this->getVarStack($stack) as $index => $currEntry) {
- //* DEBUG: */ $this->debugOutput(__METHOD__.':currGroup=' . $stack . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',var=' . $var);
+ //* DEBUG: */ $this->debugOutput(__METHOD__.':currGroup=' . $stack . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName);
// Is the entry found?
- if ($currEntry['name'] == $var) {
+ if ($currEntry['name'] == $variableName) {
// Found!
//* DEBUG: */ $this->debugOutput(__METHOD__.':FOUND!');
$found = $index;
/**
* Return a content of a variable or null if not found
*
- * @param $var The variable we are looking for
- * @param $stack Optional variable stack to look in
- * @return $content Content of the variable or null if not found
+ * @param $variableName The variable we are looking for
+ * @param $stack Optional variable stack to look in
+ * @return $content Content of the variable or null if not found
*/
- protected function readVariable ($var, $stack = NULL) {
+ protected function readVariable ($variableName, $stack = NULL) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// First everything is not found
$content = NULL;
} // END - if
// Get variable index
- $found = $this->getVariableIndex($var, $stack);
+ $found = $this->getVariableIndex($variableName, $stack);
// Is the variable found?
if ($found !== false) {
} // END - if
// Return the current position
- //* DEBUG: */ $this->debugOutput(__METHOD__.': group=' . $stack . ',var=' . $var . ', content[' . gettype($content) . ']=' . $content);
+ //* DEBUG: */ $this->debugOutput(__METHOD__.': group=' . $stack . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content);
return $content;
}
/**
* Add a variable to the stack
*
- * @param $var The variable we are looking for
+ * @param $variableName The variable we are looking for
* @param $value The value we want to store in the variable
* @return void
*/
- private function addVariable ($var, $value) {
+ private function addVariable ($variableName, $value) {
// Set general variable group
$this->setVariableGroup('general');
// Add it to the stack
- $this->addGroupVariable($var, $value);
+ $this->addGroupVariable($variableName, $value);
}
/**
/**
* Adds a variable to current group
*
- * @param $var Variable to set
- * @param $value Value to store in variable
+ * @param $variableName Variable to set
+ * @param $value Value to store in variable
* @return void
*/
- public function addGroupVariable ($var, $value) {
+ public function addGroupVariable ($variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__.': group=' . $this->currGroup . ', var=' . $var . ', value=' . $value);
+ //* DEBUG: */ $this->debugOutput(__METHOD__.': group=' . $this->currGroup . ', variableName=' . $variableName . ', value=' . $value);
// Get current variables in group
$currVars = $this->readCurrentGroup();
// Append our variable
- $currVars[] = $this->generateVariableArray($var, $value);
+ $currVars[] = $this->generateVariableArray($variableName, $value);
// Add it to the stack
$this->setVarStack($this->currGroup, $currVars);
/**
* Modify an entry on the stack
*
- * @param $var The variable we are looking for
- * @param $value The value we want to store in the variable
+ * @param $variableName The variable we are looking for
+ * @param $value The value we want to store in the variable
* @return void
* @throws NoVariableException If the given variable is not found
*/
- private function modifyVariable ($var, $value) {
+ private function modifyVariable ($variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// Get index for variable
- $index = $this->getVariableIndex($var);
+ $index = $this->getVariableIndex($variableName);
// Is the variable set?
if ($index === false) {
// Unset variables cannot be modified
- throw new NoVariableException(array($this, $var, $value), self::EXCEPTION_VARIABLE_IS_MISSING);
+ throw new NoVariableException(array($this, $variableName, $value), self::EXCEPTION_VARIABLE_IS_MISSING);
} // END - if
// Then modify it
* variable is already set. If so, the variable got modified, otherwise
* added.
*
- * @param $varGroup Variable group to use
- * @param $var Variable to set
- * @param $value Value to set
+ * @param $varGroup Variable group to use
+ * @param $variableName Variable to set
+ * @param $value Value to set
* @return void
*/
- protected function setVariable ($varGroup, $var, $value) {
+ protected function setVariable ($varGroup, $variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// Get index for variable
- $index = $this->getVariableIndex($var);
+ $index = $this->getVariableIndex($variableName);
// Is the variable set?
if ($index === false) {
// Not found, add it
- $this->varStack[$varGroup][] = $this->generateVariableArray($var, $value);
+ $this->varStack[$varGroup][] = $this->generateVariableArray($variableName, $value);
} else {
// Then modify it
$this->setVariableValue($this->currGroup, $index, $value);
* "Generates" (better returns) an array for all variables for given
* variable/value pay.
*
- * @param $var Variable to set
- * @param $value Value to set
- * @return $varData Variable data array
+ * @param $variableName Variable to set
+ * @param $value Value to set
+ * @return $varData Variable data array
*/
- private function generateVariableArray ($var, $value) {
+ private function generateVariableArray ($variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// Generate the temporary array
$varData = array(
- 'name' => $var,
+ 'name' => $variableName,
'value' => $value
);
/**
* Assign (add) a given variable with a value
*
- * @param $var The variable we are looking for
- * @param $value The value we want to store in the variable
+ * @param $variableName The variable we are looking for
+ * @param $value The value we want to store in the variable
* @return void
* @throws EmptyVariableException If the variable name is left empty
*/
- public final function assignVariable ($var, $value) {
+ public final function assignVariable ($variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// Empty variable found?
- if (empty($var)) {
+ if (empty($variableName)) {
// Throw an exception
- throw new EmptyVariableException(array($this, 'var'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new EmptyVariableException(array($this, 'variableName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} // END - if
// First search for the variable if it was already added
- $index = $this->getVariableIndex($var);
+ $index = $this->getVariableIndex($variableName);
// Was it found?
if ($index === false) {
// Add it to the stack
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':ADD: ' . $var . '[' . gettype($value) . ']=' . $value);
- $this->addVariable($var, $value);
+ //* DEBUG: */ $this->debugOutput(__METHOD__ . ':ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
+ $this->addVariable($variableName, $value);
} elseif (!empty($value)) {
// Modify the stack entry
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ':MOD: ' . $var . '[' . gettype($value) . ']=' . $value);
- $this->modifyVariable($var, $value);
+ //* DEBUG: */ $this->debugOutput(__METHOD__ . ':MOD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
+ $this->modifyVariable($variableName, $value);
}
}
/**
* Removes a given variable
*
- * @param $var The variable we are looking for
+ * @param $variableName The variable we are looking for
* @return void
*/
- public final function removeVariable ($var) {
+ public final function removeVariable ($variableName) {
// First search for the variable if it was already added
- $index = $this->getVariableIndex($var);
+ $index = $this->getVariableIndex($variableName);
// Was it found?
if ($index !== false) {
* Try to assign an extracted template variable as a "content" or 'config'
* variable.
*
- * @param $varName The variable's name (shall be content orconfig) by
- * default
- * @param $var The variable we want to assign
+ * @param $varName The variable's name (shall be content or config)
+ * by default
+ * @param $variableName The variable we want to assign
+ * @return void
*/
private function assignTemplateVariable ($varName, $var) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// Debug message
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': varName=' . $varName . ',var=' . $var);
+ //* DEBUG: */ $this->debugOutput(__METHOD__ . ': varName=' . $varName . ',variableName=' . $variableName);
// Is it not a config variable?
if ($varName != 'config') {
// Regular template variables
- $this->assignVariable($var, '');
+ $this->assignVariable($variableName, '');
} else {
// Configuration variables
- $this->assignConfigVariable($var);
+ $this->assignConfigVariable($variableName);
}
}
} // END - if
// Do we have some quotes left and right side? Then it is free text
- if ((substr($varMatches[2][$key], 0, 1) == "\"") && (substr($varMatches[2][$key], -1, 1) == "\"")) {
+ if ((substr($varMatches[2][$key], 0, 1) == '"') && (substr($varMatches[2][$key], -1, 1) == '"')) {
// Free string detected! Which we can assign directly
$this->assignVariable($var, $varMatches[3][$key]);
} elseif (!empty($varMatches[2][$key])) {
/**
* Assign a given congfiguration variable with a value
*
- * @param $var The configuration variable we want to assign
+ * @param $variableName The configuration variable we want to assign
* @return void
*/
- public function assignConfigVariable ($var) {
+ public function assignConfigVariable ($variableName) {
// Replace all dashes to underscores to match variables with configuration entries
- $var = trim($this->convertDashesToUnderscores($var));
+ $variableName = trim($this->convertDashesToUnderscores($variableName));
// Sweet and simple...
- //* DEBUG: */ $this->debugOutput(__METHOD__ . ': var=' . $var . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($var));
- $this->setVariable('config', $var, $this->getConfigInstance()->getConfigEntry($var));
+ //* DEBUG: */ $this->debugOutput(__METHOD__ . ': variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName));
+ $this->setVariable('config', $variableName, $this->getConfigInstance()->getConfigEntry($variableName));
}
/**
//* DEBUG: */ $this->debugOutput(__METHOD__ . ': name=' . $currVariable['name'] . ',value=' . $value);
// Remove it from stack
- $this->removeVariable($index, 'general');
+ $this->removeVariable($currVariable['name'], 'general');
// Re-assign the variable
//* DEBUG: */ $this->debugOutput(__METHOD__ . ': value='. $value . ',name=' . $currVariable['name'] . ',index=' . $index);