[pLog-svn] r493 - in plog/trunk/class: summary/view template

oscar at devel.plogworld.net oscar at devel.plogworld.net
Tue Dec 14 14:09:50 GMT 2004


Author: oscar
Date: 2004-12-14 14:09:50 +0000 (Tue, 14 Dec 2004)
New Revision: 493

Modified:
   plog/trunk/class/summary/view/summarycachedview.class.php
   plog/trunk/class/summary/view/summaryview.class.php
   plog/trunk/class/template/cachecontrol.class.php
   plog/trunk/class/template/templateservice.class.php
Log:
now the cache folders are handled and cleaned by plog instead of by Smarty. It is more effective and we also save
a few stupid messages (such as when the folder does not existed because it has already been cleaned up, etc) Also
the summary now saves its compiled/cached templates to the tmp/summary folder instead of just tmp/ as it was before. CacheControl::resetSummaryCache has been modified accordingly, and a new TemplateService::customTemplate method has been added.


Modified: plog/trunk/class/summary/view/summarycachedview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarycachedview.class.php	2004-12-14 13:30:32 UTC (rev 492)
+++ plog/trunk/class/summary/view/summarycachedview.class.php	2004-12-14 14:09:50 UTC (rev 493)
@@ -6,6 +6,11 @@
 	include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
 	include_once( PLOG_CLASS_PATH."class/net/http/httpcache.class.php" );	
 
+	/**
+	 * This class should extended SmartyView but SmartyView was designed to work with BlogInfo
+	 * objects while the summary does not so we had to reimplement part of the functionality... This is
+	 * ideal or optimal but it works so we will let it be for a while.
+	 */
     class SummaryCachedView extends View 
 	{
 
@@ -27,7 +32,7 @@
         function generateTemplate()
         {
             $templateService = new TemplateService();
-            $this->_template = $templateService->CachedTemplate( $this->_templateName, "summary" );        
+            $this->_template = $templateService->customTemplate( $this->_templateName, "summary", true );
         }
 
 		/**
@@ -100,4 +105,4 @@
 			}
         }
     }
-?>
+?>
\ No newline at end of file

Modified: plog/trunk/class/summary/view/summaryview.class.php
===================================================================
--- plog/trunk/class/summary/view/summaryview.class.php	2004-12-14 13:30:32 UTC (rev 492)
+++ plog/trunk/class/summary/view/summaryview.class.php	2004-12-14 14:09:50 UTC (rev 493)
@@ -18,10 +18,10 @@
 
         function render()
         {
-			View::render();
+			parent::render();
 		
             $templateService = new TemplateService();
-            $template = $templateService->Template( $this->_templateName, "summary" );
+            $template = $templateService->customTemplate( $this->_templateName, "summary" );
 
             $config =& Config::getConfig();
             $this->_locale =& Locales::getLocale( $config->getValue("default_locale" ));

Modified: plog/trunk/class/template/cachecontrol.class.php
===================================================================
--- plog/trunk/class/template/cachecontrol.class.php	2004-12-14 13:30:32 UTC (rev 492)
+++ plog/trunk/class/template/cachecontrol.class.php	2004-12-14 14:09:50 UTC (rev 493)
@@ -47,18 +47,16 @@
 		 */
 		function clearSummaryCache()
 		{
-            $config =& Config::getConfig();
+	            $config =& Config::getConfig();
 			// nothing to do if caching is not enabled...
 			if( !$config->getValue( "template_cache_enabled" ))
 				return false;			
 				
 			$t = new CachedTemplate( null );			
 			$tmpFolder = $config->getValue( "temp_folder" );
-			$summaryTmpFolder = $tmpFolder;
-            $t->cache_dir    = $summaryTmpFolder;
-            $t->compile_dir  = $summaryTmpFolder;
+			$summaryTmpFolder = $tmpFolder."/summary";
 			
-			$t->clear_cache( null );
+			File::deleteDir( $summaryTmpFolder );
 			
 			$this->log->debug( "SUMMARY CACHE EMPTIED!" );
 			

Modified: plog/trunk/class/template/templateservice.class.php
===================================================================
--- plog/trunk/class/template/templateservice.class.php	2004-12-14 13:30:32 UTC (rev 492)
+++ plog/trunk/class/template/templateservice.class.php	2004-12-14 14:09:50 UTC (rev 493)
@@ -74,6 +74,39 @@
 
             return $t;
         }
+
+		/**
+		 * @param templateName
+		 * @param layout
+		 * @param cached
+		 * @return a Template or CachedTemplate object, depending on whether
+		 * $cached is 'true' or 'false'
+		 */
+		function customTemplate( $templateName, $layout, $cached = false )
+		{
+			// get a nice Template object
+			$config =& Config::getConfig();
+			if( $cached )
+				$t = $this->CachedTemplate( $templateName, $layout );
+			else
+				$t = $this->Template( $templateName, $layout );
+
+			$tmpFolder = $config->getValue( "temp_folder" );
+			$templateTmpFolder = $tmpFolder.'/'.$layout;
+			$t->cache_dir = $templateTmpFolder;
+			$t->compile_dir = $templateTmpFolder;
+
+			// and now make sure that there is a folder where we can save
+			// our rendered templates
+			if( !File::isDir( $templateTmpFolder )) {
+				$this->log->debug( "creating temporary folder $templateTmpFolder" );
+				File::createDir( $templateTmpFolder );
+			}
+
+			$t->compile_check = $config->getValue( 'template_compile_check' );
+
+			return $t;
+		}
 		
 		/**
 		 * returns a template from the admin folder. It still uses TemplateService::Template but




More information about the pLog-svn mailing list