[pLog-svn] r1759 - plog/branches/plog-1.1-ben/class/locale

ork at devel.plogworld.net ork at devel.plogworld.net
Tue Apr 5 21:53:48 GMT 2005


Author: ork
Date: 2005-04-05 21:53:48 +0000 (Tue, 05 Apr 2005)
New Revision: 1759

Modified:
   plog/branches/plog-1.1-ben/class/locale/locale.class.php
   plog/branches/plog-1.1-ben/class/locale/locales.class.php
Log:
what was i thinking implementing the cache in _loadLocaleFile()? well it was the 1st cache usage, so i might be forgiven .. :)


Modified: plog/branches/plog-1.1-ben/class/locale/locale.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/locale/locale.class.php	2005-04-05 21:19:28 UTC (rev 1758)
+++ plog/branches/plog-1.1-ben/class/locale/locale.class.php	2005-04-05 21:53:48 UTC (rev 1759)
@@ -106,27 +106,15 @@
          */
 		function _loadLocaleFile()
 		{
-            $this->_cache =& CacheManager::getCache();
-
-            $cachedData = $this->_cache->getData( $this->_code, CACHE_LOCALES );
-
-            if ($cachedData) {
-                // load cached version
-                $this->_messages = $cachedData;
-            } else {
-
-                $this->_defaultFolder = $this->getLocaleFolder();
+            $this->_defaultFolder = $this->getLocaleFolder();
   
-                $fileName = $this->_defaultFolder."/locale_".$this->_code.".php";
+            $fileName = $this->_defaultFolder."/locale_".$this->_code.".php";
 
-                if( File::isReadable( $fileName ))
-                    include( $fileName );
+            if( File::isReadable( $fileName ))
+                include( $fileName );
 
-                $this->_messages = $messages;
+            $this->_messages = $messages;
 
-                $this->_cache->setData( $this->_code, CACHE_LOCALES, $this->_messages );
-            }
-
             unset($messages);
 
 			/*if( function_exists('memory_get_usage'))

Modified: plog/branches/plog-1.1-ben/class/locale/locales.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/locale/locales.class.php	2005-04-05 21:19:28 UTC (rev 1758)
+++ plog/branches/plog-1.1-ben/class/locale/locales.class.php	2005-04-05 21:53:48 UTC (rev 1759)
@@ -3,7 +3,6 @@
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
 	include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
 	include_once( PLOG_CLASS_PATH."class/locale/locale.class.php" );
-	include_once( PLOG_CLASS_PATH."class/locale/pluginlocale.class.php" );
 
     define("DEFAULT_LOCALE", "en_UK");
 
@@ -26,7 +25,7 @@
 
     	function Locales()
         {
-        	$this->Object();
+            $this->Object();
         }
 
         /**
@@ -61,20 +60,26 @@
 
             // check if we have already loaded that locale or else, load it from
             // disk and keep it for later, just in case anybody asks again
-            if( isset($loadedLocales[$localeCode] )) {
+            if( isset($loadedLocales[$localeCode]) ) {
             	$locale = $loadedLocales[$localeCode];
+            } else {
+                require_once( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
+                $cache =& CacheManager::getCache();
+                $locale = $cache->getData( $localeCode, CACHE_LOCALES );
+                if ( !$locale ) {
+                    $locale = new Locale( $localeCode );
+                    $cache->setData( $localeCode, CACHE_LOCALES, $locale );
+                }
             }
-            else {
-            	$locale = new Locale( $localeCode );
 
 			// check if we have any plugin locales loaded for this language
 			global $_plugins_loadedLocales;
+
 			if( is_array( $_plugins_loadedLocales["$localeCode"] )) {
 				foreach( $_plugins_loadedLocales["$localeCode"] as $pluginLocale ) {
 					$locale->mergeLocale( $pluginLocale );
 				}
-			}
-			elseif( is_array( $_plugins_loadedLocales["en_UK"] )) {
+			} elseif( is_array( $_plugins_loadedLocales["en_UK"] )) {
 				// if not, we can always use english as the default... hoping that the plugin will
 				// provide a translation!
 				foreach( $_plugins_loadedLocales["en_UK"] as $pluginLocale ) {
@@ -82,8 +87,7 @@
 				}
 			}
 
-                $loadedLocales[$localeCode] = $locale;
-            }
+           $loadedLocales[$localeCode] = $locale;
 			
             return $locale;
         }
@@ -113,6 +117,8 @@
             	$locale = $_plugins_loadedLocales[$localeCode][$pluginLocaleKey];
             }
             else {
+	            include_once( PLOG_CLASS_PATH."class/locale/pluginlocale.class.php" );
+
             	$locale = new PluginLocale( $pluginId, $localeCode );
                 $_plugins_loadedLocales[$localeCode][$pluginLocaleKey] = $locale;
             }




More information about the pLog-svn mailing list