Commit ce2fb905 by Seldaek

No more double-slashes in template paths since this seemed to cause slight performance issues

git-svn-id: svn://dwoo.org/dwoo/trunk@268 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent dd288f0c
[2009--] 1.1.0
! BC Break: Dwoo::initGlobals() is only called once during the Dwoo object
construction. If you had overriden it and need to update global data
before each template is executed you should instead override
construction. If you had overriden it and need to update global data
before each template is executed you should instead override
Dwoo::initRuntimeVars() and push stuff in the globals array there. Also
be aware that this means captured data, foreach values and so-on will
persist from a parent template to an included one (but the include's
changes will not be reflected on the parent), and from a template
be aware that this means captured data, foreach values and so-on will
persist from a parent template to an included one (but the include's
changes will not be reflected on the parent), and from a template
to the next if you render several in series.
+ Added {template} plugin that allows you to define sub-templates and then
call them (works recursively too, good for menus and lists)
+ Added {load_templates} to load external sub-templates into your file
+ Allowed string concatenation assignments with {$foo.="bar"}
+ Allowed access of static properties as {Foo::$bar}
+ Plugins/Helpers that use a dynamic number of arguments through
func_get_args are now working since the compiler lets any arguments in
+ Plugins/Helpers that use a dynamic number of arguments through
func_get_args are now working since the compiler lets any arguments in
excess pass through
+ Adapters: CodeIgniter: the adapter by Stefan Verstege has been added to
core and he will be its maintainer from now on
......@@ -24,22 +24,24 @@
* The include_path isn't altered anymore, hopefully saving some stat calls
* User classes extending Dwoo_Template_File are now supported better with
regard to includes - Thanks to the Kayako.com team for the patch
* Objects now act like arrays when you access non-existing properties on
* Objects now act like arrays when you access non-existing properties on
them (i.e. it outputs a notice only if it's output straight, and none
when passed to a function)
* For can now iterate backwards if you input numbers, it won't work with
* For can now iterate backwards if you input numbers, it won't work with
variables though
* Slight performance improvement with big inheritance trees
* No more double-slashes in template paths since this seemed to cause
slight performance issues
* Fixed a bug with parsing AND/OR keywords in conditionals when they were
followed by round brackets
* Fixed assignments not handling multi-line values correctly
* Fixed parameter parsing issue when a plugin name was all uppercased
* Fixed assignments failing with autoEscape enabled
* Fixed parsing of vars with string keys that was too greedy
* Fixed parsing of comments that were on top of the file when there are
* Fixed parsing of comments that were on top of the file when there are
spaces at the end of it
* Dwoo_Template::$chmod is now enforced for directories as well (#18)
* Many new unit tests to improve code coverage and a bunch of bug fixes
* Many new unit tests to improve code coverage and a bunch of bug fixes
that resulted, but I didn't really keep track of them
[2008-12-24] 1.0.1
......
......@@ -45,7 +45,7 @@ class Dwoo_Loader implements Dwoo_ILoader
public function __construct($cacheDir)
{
$this->corePluginDir = DWOO_DIRECTORY . 'plugins';
$this->cacheDir = $cacheDir . DIRECTORY_SEPARATOR;
$this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
// include class paths or rebuild paths if the cache file isn't there
$foo = @file_get_contents($this->cacheDir.'classpath.cache.d'.Dwoo::RELEASE_TAG.'.php');
......@@ -70,7 +70,7 @@ class Dwoo_Loader implements Dwoo_ILoader
}
// iterates over all files/folders
$list = glob($path.DIRECTORY_SEPARATOR.'*');
$list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*');
if (is_array($list)) {
foreach ($list as $f) {
if (is_dir($f)) {
......
......@@ -98,13 +98,11 @@ class Dwoo_Template_File extends Dwoo_Template_String
{
return $this->includePath;
}
/**
* Checks if compiled file is valid (exists and it's the modification is greater or
* Checks if compiled file is valid (exists and it's the modification is greater or
* equal to the modification time of the template file)
*
*
* @param string file
* @return boolean True cache file existance and it's modification time
*/
......@@ -145,6 +143,7 @@ class Dwoo_Template_File extends Dwoo_Template_String
return $this->file;
} else {
foreach ($this->includePath as $path) {
$path = rtrim($path, DIRECTORY_SEPARATOR);
if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) {
$this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file;
return $this->resolvedPath;
......@@ -259,9 +258,9 @@ class Dwoo_Template_File extends Dwoo_Template_String
/**
* returns some php code that will check if this template has been modified or not
*
*
* if the function returns null, the template will be instanciated and then the Uid checked
*
*
* @return string
*/
public function getIsModifiedCode()
......
......@@ -289,7 +289,7 @@ class Dwoo_Template_String implements Dwoo_ITemplate
// thanks for his help on avoiding concurency issues
$temp = tempnam($cacheDir, 'temp');
if (!($file = @fopen($temp, 'wb'))) {
$temp = $cacheDir . DIRECTORY_SEPARATOR . uniqid('temp');
$temp = $cacheDir . uniqid('temp');
if (!($file = @fopen($temp, 'wb'))) {
trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING);
return false;
......@@ -376,15 +376,15 @@ class Dwoo_Template_String implements Dwoo_ITemplate
return $compiledFile;
}
/**
* Checks if compiled file is valid (it exists)
*
*
* @param string file
* @return boolean True cache file existance
*/
protected function isValidCompiledFile($file) {
return file_exists($file);
return file_exists($file);
}
/**
......@@ -453,9 +453,9 @@ class Dwoo_Template_String implements Dwoo_ITemplate
/**
* returns some php code that will check if this template has been modified or not
*
*
* if the function returns null, the template will be instanciated and then the Uid checked
*
*
* @return string
*/
public function getIsModifiedCode()
......@@ -467,8 +467,8 @@ class Dwoo_Template_String implements Dwoo_ITemplate
* ensures the given path exists
*
* @param string $path any path
* @param string $baseDir the base directory where the directory is created
* ($path must still contain the full path, $baseDir
* @param string $baseDir the base directory where the directory is created
* ($path must still contain the full path, $baseDir
* is only used for unix permissions)
*/
protected function makeDirectory($path, $baseDir = null)
......@@ -476,14 +476,14 @@ class Dwoo_Template_String implements Dwoo_ITemplate
if (is_dir($path) === true) {
return;
}
if ($this->chmod === null) {
$chmod = 0777;
} else {
$chmod = $this->chmod;
}
mkdir($path, $chmod, true);
// enforce the correct mode for all directories created
if (strpos(PHP_OS, 'WIN') !== 0 && $baseDir !== null) {
$path = strtr(str_replace($baseDir, '', $path), '\\', '/');
......
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