revert some unneeded normalization of compiled_dir, cache_dir and plugins_dir

This commit is contained in:
Uwe Tews
2015-01-04 23:42:22 +01:00
parent 3463fae2a1
commit 7cc981e6a6

View File

@@ -2,7 +2,6 @@
/** /**
* Project: Smarty: the PHP compiling template engine * Project: Smarty: the PHP compiling template engine
* File: Smarty.class.php * File: Smarty.class.php
*
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
@@ -71,7 +70,6 @@ if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
/** /**
* Try loading the Smmarty_Internal_Data class * Try loading the Smmarty_Internal_Data class
*
* If we fail we must load Smarty's autoloader. * If we fail we must load Smarty's autoloader.
* Otherwise we may have a global autoloader like Composer * Otherwise we may have a global autoloader like Composer
*/ */
@@ -272,7 +270,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* *
* @var string * @var string
*/ */
private $cache_dir = './templates_c/'; private $cache_dir = './cache/';
/** /**
* config directory * config directory
* *
@@ -953,9 +951,9 @@ class Smarty extends Smarty_Internal_TemplateBase
{ {
$this->plugins_dir = array(); $this->plugins_dir = array();
foreach ((array) $plugins_dir as $k => $v) { foreach ((array) $plugins_dir as $k => $v) {
$this->plugins_dir[$k] = preg_replace(array('#\\\\#', '#([^\/]+)(/)*#', '#([^\/]+)$#'), array('/', '$1/'), $v); $this->plugins_dir[$k] = rtrim($v, '/\\') . DS;
} }
$this->_is_file_cache = array();
return $this; return $this;
} }
@@ -968,9 +966,26 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public function addPluginsDir($plugins_dir) public function addPluginsDir($plugins_dir)
{ {
$this->_addDir('plugins_dir', $plugins_dir); // make sure we're dealing with an array
$this->plugins_dir = (array) $this->plugins_dir;
if (is_array($plugins_dir)) {
foreach ($plugins_dir as $k => $v) {
if (is_int($k)) {
// indexes are not merged but appended
$this->plugins_dir[] = rtrim($v, '/\\') . DS;
} else {
// string indexes are overridden
$this->plugins_dir[$k] = rtrim($v, '/\\') . DS;
}
}
} else {
// append new directory
$this->plugins_dir[] = rtrim($plugins_dir, '/\\') . DS;
}
$this->plugins_dir = array_unique($this->plugins_dir); $this->plugins_dir = array_unique($this->plugins_dir);
$this->_is_file_cache = array();
return $this; return $this;
} }
@@ -993,10 +1008,11 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public function setCompileDir($compile_dir) public function setCompileDir($compile_dir)
{ {
$this->compile_dir = preg_replace(array('#\\\\#', '#([^\/]+)(/)*#', '#([^\/]+)$#'), array('/', '$1/'), $compile_dir); $this->compile_dir = rtrim($compile_dir, '/\\') . DS;
if (!isset(Smarty::$_muted_directories[$this->compile_dir])) { if (!isset(Smarty::$_muted_directories[$this->compile_dir])) {
Smarty::$_muted_directories[$this->compile_dir] = null; Smarty::$_muted_directories[$this->compile_dir] = null;
} }
return $this; return $this;
} }
@@ -1019,7 +1035,7 @@ class Smarty extends Smarty_Internal_TemplateBase
*/ */
public function setCacheDir($cache_dir) public function setCacheDir($cache_dir)
{ {
$this->cache_dir = preg_replace(array('#\\\\#', '#([^\/]+)(/)*#', '#([^\/]+)$#'), array('/', '$1/'), $cache_dir); $this->cache_dir = rtrim($cache_dir, '/\\') . DS;
if (!isset(Smarty::$_muted_directories[$this->cache_dir])) { if (!isset(Smarty::$_muted_directories[$this->cache_dir])) {
Smarty::$_muted_directories[$this->cache_dir] = null; Smarty::$_muted_directories[$this->cache_dir] = null;
} }