]> git.andy128k.dev Git - ipf.git/commitdiff
app level templates
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 7 Jul 2013 06:44:33 +0000 (09:44 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 7 Jul 2013 06:44:33 +0000 (09:44 +0300)
doc/template.org
ipf.php
ipf/template/environment.php

index 4ce9d2817c93f1bf04a1838433434cd4eba74742..3a599c9382ad46fc49c0e4e4dad5a5de7990b9ff 100644 (file)
@@ -2,6 +2,8 @@
 
   This document describes template language of IPF framework.
 
+  Templates are placed in 'templates' directories of project or application.
+
   =[ ]?= -- optional code
 
   =[ ]*= -- code can be repeated zero or more times.
    + =template_tags= -- additional template tags
    + =template_modifiers= -- additional template modifiers
    + =template_context_processors= -- list of context processors
-   + =template_dirs= -- list of directories to look for template files. By default it contains 'templates' folder in project directory and 'templates' folder in IPF_Admin application (when it is enabled).
    + =debug= -- forces to recompile template before each rendering
 
diff --git a/ipf.php b/ipf.php
index 6123db765c3f0040d35f6e58b0e8250c954ce0a9..79789a33d09d6e69cc99ef83161b6d2acb1455b1 100644 (file)
--- a/ipf.php
+++ b/ipf.php
@@ -53,13 +53,6 @@ final class IPF
         if (!is_array(IPF::$settings['applications']))
             throw new IPF_Exception_Settings('applications must be array of string');
 
-        if (!isset(IPF::$settings['template_dirs'])){
-            IPF::$settings['template_dirs'] = array();
-            IPF::$settings['template_dirs'][] = IPF::$settings['project_path'].DIRECTORY_SEPARATOR.'templates';
-            if (array_search('IPF_Admin',IPF::$settings['applications']))
-                IPF::$settings['template_dirs'][] = IPF::$settings['ipf_path'].DIRECTORY_SEPARATOR.'ipf'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'templates';
-        }
-
         if (!isset(IPF::$settings['admin_title'])){
             IPF::$settings['admin_title'] = 'IPF Administration';
         }
index 7d3d79a7a03450807e5f2cbf140ee0b10703c561..0ea8b8e475a8f1aa60a50167b6e88ace31c0c139 100644 (file)
@@ -10,8 +10,21 @@ abstract class IPF_Template_Environment
 
     public static function getDefault()
     {
-        if (!self::$defaultEnvironment)
-            self::$defaultEnvironment = new IPF_Template_Environment_FileSystem(IPF::get('template_dirs'), IPF::get('tmp'));
+        if (!self::$defaultEnvironment) {
+            $dirs = array();
+
+            $projectTemplates = IPF::get('project_path') . '/templates';
+            if (is_dir($projectTemplates))
+                $dirs[] = $projectTemplates;
+
+            foreach (IPF_Project::getInstance()->appList() as $app) {
+                $applicationTemplates = $app->getPath() . 'templates';
+                if (is_dir($applicationTemplates))
+                    $dirs[] = $applicationTemplates;
+            }
+
+            self::$defaultEnvironment = new IPF_Template_Environment_FileSystem($dirs, IPF::get('tmp'));
+        }
         return self::$defaultEnvironment;
     }
 }