Commit 7093aa38 by seldaek

Dwoo_Template::$chmod is now enforced for directories as well

fixes #18 git-svn-id: svn://dwoo.org/dwoo/trunk@244 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 19287dec
......@@ -10,6 +10,7 @@
* Fixed assignments not handling multi-line values correctly
* Fixed parameter parsing issue when a plugin name was all uppercased
* Fixes assignments failing with autoEscape enabled
* Dwoo_Template::$chmod is now enforced for directories as well (#18)
[2008-12-24] 1.0.1
* Direct assignments like {$foo = 5} now allow spaces around the operator
......
......@@ -299,7 +299,7 @@ class Dwoo_Template_String implements Dwoo_ITemplate
fwrite($file, $output);
fclose($file);
$this->makeDirectory(dirname($cachedFile));
$this->makeDirectory(dirname($cachedFile), $cacheDir);
if (!@rename($temp, $cachedFile)) {
@unlink($cachedFile);
@rename($temp, $cachedFile);
......@@ -365,7 +365,7 @@ class Dwoo_Template_String implements Dwoo_ITemplate
$compiler->setCustomPlugins($dwoo->getCustomPlugins());
$compiler->setSecurityPolicy($dwoo->getSecurityPolicy());
$this->makeDirectory(dirname($compiledFile));
$this->makeDirectory(dirname($compiledFile), $dwoo->getCompileDir());
file_put_contents($compiledFile, $compiler->compile($dwoo, $this));
if ($this->chmod !== null) {
chmod($compiledFile, $this->chmod);
......@@ -455,17 +455,31 @@ 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
* is only used for unix permissions)
*/
protected function makeDirectory($path)
protected function makeDirectory($path, $baseDir = null)
{
if (is_dir($path) === true) {
return;
}
if ($this->chmod !== null) {
mkdir($path, $this->chmod, true);
if ($this->chmod === null) {
$chmod = 0777;
} else {
mkdir($path, 0777, true);
$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), '\\', '/');
$folders = explode('/', $path);
foreach ($folders as $folder) {
$baseDir .= $folder . DIRECTORY_SEPARATOR;
chmod($baseDir, $chmod);
}
}
}
}
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