Commit eee94489 by seldaek

merging r309-311 from 1.1

git-svn-id: http://svn.dwoo.org/trunk@312 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent d3270dde
......@@ -26,6 +26,9 @@
* Fixed a Dwoo_Data bug in the append method when the index didn't exist
yet it threw a notice
* Fixed a bug when accessing global vars from a sub-template
* Fixed a bug in the {dynamic} plugin
* Cached templates now check the source template for modification before
outputting the cached version
* Removed a couple of @-operator calls to file_get_contents
[2009-07-18] 1.1.0
......
......@@ -408,9 +408,8 @@ class Dwoo
// output
if ($_output === true) {
echo $out;
} else {
return $out;
}
return $out;
}
}
}
......
......@@ -263,7 +263,7 @@ class Dwoo_Template_String implements Dwoo_ITemplate
if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) {
// already checked, return cache file
return $cachedFile;
} elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength))) {
} elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($dwoo))) {
// cache is still valid and can be loaded
self::$cache['cached'][$this->cacheId] = true;
return $cachedFile;
......
......@@ -27,9 +27,9 @@ class Dwoo_Plugin_dynamic extends Dwoo_Block_Plugin implements Dwoo_ICompilable_
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
{
$output = Dwoo_Compiler::PHP_OPEN .
$output = Dwoo_Compiler::PHP_OPEN .
'if($doCache) {'."\n\t".
'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'.
'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'.
str_replace('\'', '\\\'', $content) .
'</dwoo:dynamic_\'.$dynamicId.\'>\';'.
"\n} else {\n\t";
......@@ -42,19 +42,19 @@ class Dwoo_Plugin_dynamic extends Dwoo_Block_Plugin implements Dwoo_ICompilable_
$output = substr($output, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
} else {
$output .= Dwoo_Compiler::PHP_OPEN;
}
}
$output .= "\n}". Dwoo_Compiler::PHP_CLOSE;
return $output;
}
public static function unescape($output, $dynamicId)
{
return preg_replace_callback('/<dwoo:dynamic_('.$dynamicId.')>(.+?)<\/dwoo:dynamic_'.$dynamicId.'>/', array('self', 'unescapePhp'), $output);
return preg_replace_callback('/<dwoo:dynamic_('.$dynamicId.')>(.+?)<\/dwoo:dynamic_'.$dynamicId.'>/s', array('self', 'unescapePhp'), $output);
}
public static function unescapePhp($match)
{
return preg_replace('{<\?php /\*'.$match[1].'\*/ echo \'(.+?)\'; \?>}', '$1', $match[2]);
return preg_replace('{<\?php /\*'.$match[1].'\*/ echo \'(.+?)\'; \?>}s', '$1', $match[2]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment