44 public function getPaths($namespace = self::MAIN_NAMESPACE)
46 return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array();
58 return array_keys($this->paths);
73 $this->paths[$namespace] = array();
74 foreach (
$paths as $path) {
75 $this->
addPath($path, $namespace);
87 public function addPath($path, $namespace = self::MAIN_NAMESPACE)
90 $this->cache = array();
93 throw new Twig_Error_Loader(sprintf(
'The "%s" directory does not exist.', $path));
96 $this->paths[$namespace][] = rtrim($path,
'/\\');
107 public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
110 $this->cache = array();
112 if (!is_dir($path)) {
113 throw new Twig_Error_Loader(sprintf(
'The "%s" directory does not exist.', $path));
116 $path = rtrim($path,
'/\\');
118 if (!isset($this->paths[$namespace])) {
119 $this->paths[$namespace][] = $path;
121 array_unshift($this->paths[$namespace], $path);
146 $name = (string) $name;
147 if (isset($this->cache[$name])) {
170 $name = (string) $name;
173 $name = preg_replace(
'#/{2,}#',
'/', strtr($name,
'\\',
'/'));
175 if (isset($this->cache[$name])) {
176 return $this->cache[$name];
181 $namespace = self::MAIN_NAMESPACE;
182 if (isset($name[0]) &&
'@' == $name[0]) {
183 if (
false === $pos = strpos($name,
'/')) {
184 throw new Twig_Error_Loader(sprintf(
'Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
187 $namespace = substr($name, 1, $pos - 1);
189 $name = substr($name, $pos + 1);
192 if (!isset($this->paths[$namespace])) {
193 throw new Twig_Error_Loader(sprintf(
'There are no registered paths for namespace "%s".', $namespace));
196 foreach ($this->paths[$namespace] as $path) {
197 if (is_file($path.
'/'.$name)) {
198 return $this->cache[$name] = $path.
'/'.$name;
202 throw new Twig_Error_Loader(sprintf(
'Unable to find template "%s" (looked into: %s).', $name, implode(
', ', $this->paths[$namespace])));
207 if (
false !== strpos($name,
"\0")) {
211 $name = ltrim($name,
'/');
212 $parts = explode(
'/', $name);
214 foreach ($parts as $part) {
215 if (
'..' === $part) {
217 }
elseif (
'.' !== $part) {
222 throw new Twig_Error_Loader(sprintf(
'Looks like you try to load a template outside configured directories (%s).', $name));
Loads template from the filesystem.
prependPath($path, $namespace=self::MAIN_NAMESPACE)
Prepends a path where templates are stored.
getNamespaces()
Returns the path namespaces.
getSource($name)
{Gets the source code of a template, given its name.The name of the template to loadstring The templa...
Adds an exists() method for loaders.
isFresh($name, $time)
{Returns true if the template is still fresh.The template name The last modification time of the cach...
__construct($paths=array())
Constructor.
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
setPaths($paths, $namespace=self::MAIN_NAMESPACE)
Sets the paths where templates are stored.
getCacheKey($name)
{Gets the cache key to use for the cache for a given template name.The name of the template to loadst...
getPaths($namespace=self::MAIN_NAMESPACE)
Returns the paths to the templates.
addPath($path, $namespace=self::MAIN_NAMESPACE)
Adds a path where templates are stored.
Interface all loaders must implement.
const MAIN_NAMESPACE
Identifier of the main namespace.
Exception thrown when an error occurs during template loading.
exists($name)
{Check if we have the source code of a template, given its name.The name of the template to check if ...