*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* All template groups except "general"
*/
- private $varGroups = array();
+ private $variableGroups = array();
/**
* Code begin
// Skip group 'general'
if (($groupName != 'general') && ($add === TRUE)) {
- $this->varGroups[$groupName] = 'OK';
+ $this->variableGroups[$groupName] = 'OK';
} // END - if
}
/**
* Getter for variable value, throws a NoVariableException if the variable is not found
*
- * @param $varGroup Variable group to use
+ * @param $variableGroup Variable group to use
* @param $index Index in variable array
* @return $value Value to set
*/
- private function getVariableValue ($varGroup, $index) {
+ private function getVariableValue ($variableGroup, $index) {
// Return it
- return $this->varStack[$varGroup][$index]['value'];
+ return $this->varStack[$variableGroup][$index]['value'];
}
/**
/**
* Sets a variable value for given variable group and index
*
- * @param $varGroup Variable group to use
+ * @param $variableGroup Variable group to use
* @param $index Index in variable array
* @param $value Value to set
* @return void
*/
- private function setVariableValue ($varGroup, $index, $value) {
- $this->varStack[$varGroup][$index]['value'] = $value;
+ private function setVariableValue ($variableGroup, $index, $value) {
+ $this->varStack[$variableGroup][$index]['value'] = $value;
}
/**
* variable is already set. If so, the variable got modified, otherwise
* added.
*
- * @param $varGroup Variable group to use
+ * @param $variableGroup Variable group to use
* @param $variableName Variable to set
* @param $value Value to set
* @return void
*/
- protected function setVariable ($varGroup, $variableName, $value) {
+ protected function setVariable ($variableGroup, $variableName, $value) {
// Replace all dashes to underscores to match variables with configuration entries
$variableName = trim($this->convertDashesToUnderscores($variableName));
// Is the variable set?
if ($index === FALSE) {
// Is the stack there?
- if (!isset($this->varStack[$varGroup])) {
+ if (!isset($this->varStack[$variableGroup])) {
// Then initialize it here
- $this->varStack[$varGroup] = array();
+ $this->varStack[$variableGroup] = array();
} // END - if
// Not found, add it
- array_push($this->varStack[$varGroup], $this->generateVariableArray($variableName, $value));
+ array_push($this->varStack[$variableGroup], $this->generateVariableArray($variableName, $value));
} else {
// Then modify it
$this->setVariableValue($this->currGroup, $index, $value);
$this->templateType = (string) $templateType;
}
+ /**
+ * Getter for template type
+ *
+ * @return $templateType The current template's type
+ */
+ public final function getTemplateType () {
+ return $this->templateType;
+ }
+
/**
* Setter for the last loaded template's FQFN
*
* @param $templateBasePath The relative base path for all templates
* @return void
*/
- public final function setTemplateBasePath ($templateBasePath) {
+ protected final function setTemplateBasePath ($templateBasePath) {
// And set it
$this->templateBasePath = (string) $templateBasePath;
}
* templates
* @return void
*/
- public final function setRawTemplateExtension ($templateExtension) {
+ protected final function setRawTemplateExtension ($templateExtension) {
// And set it
$this->templateExtension = (string) $templateExtension;
}
* templates
* @return void
*/
- public final function setCodeTemplateExtension ($codeExtension) {
+ protected final function setCodeTemplateExtension ($codeExtension) {
// And set it
$this->codeExtension = (string) $codeExtension;
}
* templates
* @return void
*/
- public final function setCompileOutputPath ($compileOutputPath) {
+ protected final function setCompileOutputPath ($compileOutputPath) {
// And set it
$this->compileOutputPath = (string) $compileOutputPath;
}
- /**
- * Getter for template type
- *
- * @return $templateType The current template's type
- */
- public final function getTemplateType () {
- return $this->templateType;
- }
-
/**
* Unsets the given offset in the variable group
*
*
* @return $compiledData Compiled template data
*/
- public final function getCompiledData () {
+ protected final function getCompiledData () {
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: ' . strlen($this->compiledData) . ' Bytes read.');
return $this->compiledData;
}
$this->loadTemplate($template, $ext);
} else {
// Throw it again
- throw new FileIoException($fqfn, FrameworkFileInputPointer::EXCEPTION_FILE_NOT_FOUND);
+ throw new FileIoException($fqfn, self::EXCEPTION_FILE_NOT_FOUND);
}
}
* Try to assign an extracted template variable as a "content" or 'config'
* variable.
*
- * @param $varName The variable's name (shall be content or config)
+ * @param $variableName 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) {
+ private function assignTemplateVariable ($variableName, $var) {
// Replace all dashes to underscores to match variables with configuration entries
$variableName = trim($this->convertDashesToUnderscores($variableName));
// Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: varName=' . $varName . ',variableName=' . $variableName);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: variableName=' . $variableName . ',variableName=' . $variableName);
// Is it not a config variable?
- if ($varName != 'config') {
+ if ($variableName != 'config') {
// Regular template variables
$this->assignVariable($variableName, '');
} else {
// Configuration variables
- $this->assignConfigVariable($variableName);
+ $this->assignConfigVariable($var);
}
}
// Initialize all missing variables
foreach ($variableMatches[3] as $key => $var) {
// Variable name
- $varName = $variableMatches[1][$key];
+ $variableName = $variableMatches[1][$key];
// Workarround: Do not assign empty variables
if (!empty($var)) {
// Try to assign it, empty strings are being ignored
- $this->assignTemplateVariable($varName, $var);
+ $this->assignTemplateVariable($variableName, $var);
} // END - if
} // END - foreach
} // END - if
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:template=' . $template);
// Template not found, but maybe variable assigned?
- if ($this->getVariableIndex($template, 'config') !== FALSE) {
- // Use that content here
- $this->loadedRawData[$template] = $this->readVariable($template, 'config');
-
- // Recursive protection:
- array_push($this->loadedTemplates, $template);
- } elseif ($this->getVariableIndex($template) !== FALSE) {
+ if ($this->getVariableIndex($template) !== FALSE) {
// Use that content here
$this->loadedRawData[$template] = $this->readVariable($template);
// Sweet and simple...
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName));
- $this->setVariable('config', $variableName, $this->getConfigInstance()->getConfigEntry($variableName));
+ $this->assignVariable($variableName, $this->getConfigInstance()->getConfigEntry($variableName));
}
/**
- * Injects an array of config variables into the stack of currently loaded
- * template. This method should only be used in very rare circumstances,
- * e.g. when you have to copy a whole set of variables into the template
- * engine. Before you use this method, please make sure you have considered
- * all other possiblities.
+ * Assigns a lot variables into the stack of currently loaded template.
+ * This method should only be used in very rare circumstances, e.g. when
+ * you have to copy a whole set of variables into the template engine.
+ * Before you use this method, please make sure you have considered all
+ * other possiblities.
*
- * @param $variables An array with variables to be injected
+ * @param $variables An array with variables to be assigned
* @return void
*/
- public function injectConfigVariables (array $variables) {
+ public function assignMultipleVariables (array $variables) {
// "Inject" all
foreach ($variables as $name => $value) {
// Set variable with name for 'config' group
- $this->setVariable('config', $name, $value);
+ $this->assignVariable($name, $value);
} // END - foreach
}
$this->assignConfigVariable($value);
} else {
// Re-assign the value directly
- $this->setVariable('config', $currVariable['name'], $value);
+ $this->assignVariable($currVariable['name'], $value);
}
} // END - foreach
}
/**
* Getter for variable group array
*
- * @return $vargroups All variable groups
+ * @return $variableGroups All variable groups
*/
public final function getVariableGroups () {
- return $this->varGroups;
+ return $this->variableGroups;
}
/**
// Get a XmlParser instance
$parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this));
- // Check if we have XML compacting enabled
+ // Check if XML compacting is enabled
if ($this->isXmlCompactingEnabled()) {
// Yes, so get a decorator class for transparent compacting
$parserInstance = ObjectFactory::createObjectByConfiguredName('deco_compacting_xml_parser_class', array($parserInstance));