/**
* 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
*/
private $regExpCodeTags = '/\{\?([a-z_]+)(:("[^"]+"|[^?}]+)+)?\?\}/';
+ /**
+ * A regular expression to find template comments like <!-- Comment here //-->
+ */
+ private $regExpComments = '/<!--[\w\W]*?(\/\/){0,1}-->/';
+
/**
* Loaded helpers
*/
// 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!');
// 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->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();
$compactedContent = str_replace(chr(9), '', str_replace(chr(10), '', str_replace(chr(13), '', $uncompactedContent)));
// Then regex all comments like <!-- //--> away
- preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
+ preg_match_all($this->regExpComments, $compactedContent, $matches);
// Do we have entries?
if (isset($matches[0][0])) {