[limb-svn] r6526 - 3.x/trunk/limb/macro/src

svn at limb-project.com svn at limb-project.com
Mon Nov 19 00:21:06 MSK 2007


Author: lifer
Date: 2007-11-19 00:21:06 +0300 (Mon, 19 Nov 2007)
New Revision: 6526
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6526

Modified:
   3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
Log:
added forceCompile = 'auto' mode.
In this mode, cache will be automatically updated if source template will be changed.


Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php	2007-11-17 15:38:05 UTC (rev 6525)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php	2007-11-18 21:21:06 UTC (rev 6526)
@@ -63,9 +63,26 @@
     {
       $this->compiled_file = $this->locator->locateCompiledTemplate($this->file);
 
-      if($this->config->isForceCompile() || !file_exists($this->compiled_file))
+      $need_compile = false;	
+
+      if (true === $this->config->isForceCompile()) {
+
+		$need_compile = true;
+		$source_file = $this->locator->locateSourceTemplate($this->file);
+
+      } else if ('auto' == $this->config->isForceCompile()) {
+
+ 		if (filemtime($source_file = $this->locator->locateSourceTemplate($this->file)) > filemtime($this->compiled_file)) {
+
+			$need_compile = true;
+
+		}
+
+      }
+
+      if($need_compile || !file_exists($this->compiled_file))
       {
-        if(!$source_file = $this->locator->locateSourceTemplate($this->file))
+        if(!$source_file)
           throw new lmbMacroException('Template source file not found', array('file_name' => $this->file));
 
         $macro_executor_class = 'MacroTemplateExecutor' . uniqid();//think about evaling this instance



More information about the limb-svn mailing list