/**
* A generic template engine
*
- * @author Roland Haeder <webmaster@ship-simu.org>
+ * @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
* @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
+ * @link http://www.shipsimu.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
// First everything is not found
$found = FALSE;
- // If the stack is null, use the current group
+ // If the stack is NULL, use the current group
if (is_null($variableGroup)) {
// Use current group
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
// First everything is not found
$content = NULL;
- // If the stack is null, use the current group
+ // If the stack is NULL, use the current group
if (is_null($variableGroup)) {
// Use current group
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!');
$currVars = $this->readCurrentGroup();
// Append our variable
- $currVars[] = $this->generateVariableArray($variableName, $value);
+ array_push($currVars, $this->generateVariableArray($variableName, $value));
// Add it to the stack
$this->setVarStack($this->currGroup, $currVars);
// Is the variable set?
if ($index === FALSE) {
+ // Is the stack there?
+ if (!isset($this->varStack[$varGroup])) {
+ // Then initialize it here
+ $this->varStack[$varGroup] = array();
+ } // END - if
+
// Not found, add it
- $this->varStack[$varGroup][] = $this->generateVariableArray($variableName, $value);
+ array_push($this->varStack[$varGroup], $this->generateVariableArray($variableName, $value));
} else {
// Then modify it
$this->setVariableValue($this->currGroup, $index, $value);
// Is language support enabled?
if ($this->isLanguageSupportEnabled()) {
// Construct the FQFN for the template by honoring the current language
- $fqfn = sprintf("%s%s%s%s/%s/%s%s",
+ $fqfn = sprintf('%s%s%s%s/%s/%s%s',
$this->getConfigInstance()->getConfigEntry('base_path'),
$this->getTemplateBasePath(),
$this->getGenericBasePath(),
);
} else {
// Construct the FQFN for the template without language
- $fqfn = sprintf("%s%s%s%s/%s%s",
+ $fqfn = sprintf('%s%s%s%s/%s%s',
$this->getConfigInstance()->getConfigEntry('base_path'),
$this->getTemplateBasePath(),
$this->getGenericBasePath(),
$this->loadedRawData[$template] = $this->readVariable($template, 'config');
// Recursive protection:
- $this->loadedTemplates[] = $template;
+ array_push($this->loadedTemplates, $template);
} elseif ($this->getVariableIndex($template) !== FALSE) {
// Use that content here
$this->loadedRawData[$template] = $this->readVariable($template);
// Recursive protection:
- $this->loadedTemplates[] = $template;
+ array_push($this->loadedTemplates, $template);
} else {
// Then try to search for code-templates
try {
// Remember this template for recursion detection
// RECURSIVE PROTECTION!
- $this->loadedTemplates[] = $template;
+ array_push($this->loadedTemplates, $template);
} catch (FileIoException $e) {
// Even this is not done... :/
- $this->rawTemplates[] = $template;
+ array_push($this->rawTemplates, $template);
}
}
} // END - if
} // END - if
// Remember this template being compiled
- $this->compiledTemplates[] = $template;
+ array_push($this->compiledTemplates, $template);
// Compile the loaded code in five steps:
//
// Remember this template for recursion detection
// RECURSIVE PROTECTION!
- $this->loadedTemplates[] = $template;
+ array_push($this->loadedTemplates, $template);
} catch (FileIoException $e) {
// This template was never found. We silently ignore it
unset($this->rawTemplates[$key]);
$this->finalizeVariableCompilation();
// Prepare the eval() command for comiling the template
- $eval = sprintf("\$result = \"%s\";",
+ $eval = sprintf('$result = "%s";',
addslashes($this->getRawTemplateData())
);
$evalRight = substr($evalRight, (strpos($evalRight, $this->codeEnd) + 2));
// And put all together
- $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight);
+ $eval = sprintf('%s<%%php %s %%>%s', $evalLeft, $evalMiddle, $evalRight);
} // END - while
// Prepare PHP code for eval() command
$eval = str_replace(
- "<%php", "\";",
+ '<%php', '";',
str_replace(
- "%>",
+ '%>',
"\n\$result .= \"",
$eval
)
// Goes something wrong?
if ((!isset($result)) || (empty($result))) {
// Output eval command
- self::createDebugInstance(__CLASS__)->debugOutput(sprintf("Failed eval() code: <pre>%s</pre>", $this->markupCode($eval, TRUE)), TRUE);
+ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('Failed eval() code: <pre>%s</pre>', $this->markupCode($eval, TRUE)), TRUE);
// Output backtrace here
$this->debugBackTrace();