[pLog-svn] r2658 - in plog/trunk: class/summary/view class/template locale templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Nov 27 20:30:05 GMT 2005


Author: oscar
Date: 2005-11-27 20:30:04 +0000 (Sun, 27 Nov 2005)
New Revision: 2658

Modified:
   plog/trunk/class/summary/view/summarycachedview.class.php
   plog/trunk/class/template/cachecontrol.class.php
   plog/trunk/locale/locale_en_UK.php
   plog/trunk/templates/admin/globalsettings_templates.template
Log:
Added a feature that allows the summary templates to have different timeout values for the cache. There is a new configuration key called summary_template_cache_lifetime that when set to a value greater than 0, it will tell Smarty to keep that template around for as long as many seconds as indicated by this key. The implementation is actually quite easy because Smarty has built-in support for this sort of things.

I've also modified CacheControl::resetSummaryCache so that it doesn't do anything if the aforementioned key has a value greater than 0 (meaning that we shouldn't remove it now but instead, let smarty take care of it)

Modified: plog/trunk/class/summary/view/summarycachedview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarycachedview.class.php	2005-11-27 20:25:46 UTC (rev 2657)
+++ plog/trunk/class/summary/view/summarycachedview.class.php	2005-11-27 20:30:04 UTC (rev 2658)
@@ -31,6 +31,16 @@
 
             $templateService = new TemplateService();
             $this->_template = $templateService->customTemplate( $this->_templateName, "summary", true );
+			
+			// set the summary custom time
+			include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+			$config =& Config::getConfig();
+			// set the summary cache lifetime, or zero if none
+			$summaryTemplateLifetime = $config->getValue( "summary_template_cache_lifetime", 0 );
+			if( $summaryTemplateLifetime > 0 ) {
+				print("summary cache lifetime = $summaryTemplateLifetime<br/>");
+				$this->_template->cache_lifetime = $summaryTemplateLifetime;
+			}
         }
 
 		/**

Modified: plog/trunk/class/template/cachecontrol.class.php
===================================================================
--- plog/trunk/class/template/cachecontrol.class.php	2005-11-27 20:25:46 UTC (rev 2657)
+++ plog/trunk/class/template/cachecontrol.class.php	2005-11-27 20:30:04 UTC (rev 2658)
@@ -1,8 +1,6 @@
 <?php
-
 	
-	include_once( PLOG_CLASS_PATH."class/template/cachedtemplate.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+	include_once( PLOG_CLASS_PATH."class/object/loggable.class.php" );
 
 	/**
 	 * \ingroup Template
@@ -11,7 +9,7 @@
 	 * whenever you need to clear the contents of the whole site, the summary or just a single
 	 * blog.
 	 */
-	class CacheControl 
+	class CacheControl extends Loggable
 	{
 
 		/**
@@ -22,6 +20,7 @@
 		function resetAllCaches()
 		{
 			// get a list of all the blogs
+			include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
 			$blogs = new Blogs();
 			$siteBlogs = $blogs->getAllBlogIds();
 			
@@ -45,11 +44,19 @@
 		 */
 		function clearSummaryCache()
 		{
-	            $config =& Config::getConfig();
+            $config =& Config::getConfig();
 			// nothing to do if caching is not enabled...
 			if( !$config->getValue( "template_cache_enabled" ))
 				return false;			
 				
+			// nothing to do either if the summary page lifetime is greater than 0,
+			// since smarty will take care of resetting it when needed
+			$summaryTemplateLifetime = $config->getValue( "summary_template_cache_lifetime" );
+			if( $summaryTemplateLifetime > 0 )
+				return true;
+				
+			// if not then continue...
+			include_once( PLOG_CLASS_PATH."class/template/cachedtemplate.class.php" );			
 			$t = new CachedTemplate( null );			
 			$tmpFolder = $config->getValue( "temp_folder" );
 			$summaryTmpFolder = $tmpFolder."/summary";
@@ -85,11 +92,9 @@
 			if( !$config->getValue( "template_cache_enabled" ))
 				return false;
 		
-			//$t = new CachedTemplate( null );
 			$tmpFolder = $config->getValue( "temp_folder" );
 			$blogTmpFolder = $tmpFolder."/".$blogId;
-            //$t->cache_dir    = $blogTmpFolder;
-            //$t->compile_dir  = $blogTmpFolder;
+
 			// recursively delete the contents of the folder, but not its structure or subfolders            
 			File::deleteDir( $blogTmpFolder, true, true );
 			

Modified: plog/trunk/locale/locale_en_UK.php
===================================================================
--- plog/trunk/locale/locale_en_UK.php	2005-11-27 20:25:46 UTC (rev 2657)
+++ plog/trunk/locale/locale_en_UK.php	2005-11-27 20:30:04 UTC (rev 2658)
@@ -964,5 +964,6 @@
 $messages['view'] = 'View';
 $messages['editUser'] = 'Edit User';
 $messages['help_urlize_word_separator'] = 'Character that will be used as the word separator when generating URLs pointing to LifeType pages. This will also be used when generating hostnames from blog names if support for subdomains is activated. [Default = _]';
+$messages['help_summary_template_cache_lifetime'] = 'Life time in seconds of the summary cached pages. If set to something else than \'0\' the summary pages will be kept for as long as indicated here insted of being refreshed every time data changes. [Default = 0]';
 
 ?>
\ No newline at end of file

Modified: plog/trunk/templates/admin/globalsettings_templates.template
===================================================================
--- plog/trunk/templates/admin/globalsettings_templates.template	2005-11-27 20:25:46 UTC (rev 2657)
+++ plog/trunk/templates/admin/globalsettings_templates.template	2005-11-27 20:30:04 UTC (rev 2658)
@@ -49,6 +49,12 @@
     <div class="formHelp">{$locale->tr("help_template_cache_lifetime")}</div>
     <input style="width:100%" type="text" id="config[template_cache_lifetime]" name="config[template_cache_lifetime]" value="{$template_cache_lifetime}"/>
    </div>
+   <!-- summary_template_cache_lifetime -->
+   <div class="field">
+    <label for="config[summary_template_cache_lifetime]">summary_template_cache_lifetime</label>
+    <div class="formHelp">{$locale->tr("help_summary_template_cache_lifetime")}</div>
+    <input style="width:100%" type="text" id="config[summary_template_cache_lifetime]" name="config[summary_template_cache_lifetime]" value="{$summary_template_cache_lifetime}"/>
+   </div>   
    <!-- template_http_cache_enabled -->
    <div class="field">
     <label for="config[template_http_cache_enabled]">template_http_cache_enabled</label>




More information about the pLog-svn mailing list