[pLog-svn] r1705 - plog/branches/plog-1.1-ben/class/locale
ork at devel.plogworld.net
ork at devel.plogworld.net
Mon Apr 4 17:35:53 GMT 2005
Author: ork
Date: 2005-04-04 17:35:52 +0000 (Mon, 04 Apr 2005)
New Revision: 1705
Modified:
plog/branches/plog-1.1-ben/class/locale/locale.class.php
Log:
use caching.. :)
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-04 17:34:47 UTC (rev 1704)
+++ plog/branches/plog-1.1-ben/class/locale/locale.class.php 2005-04-04 17:35:52 UTC (rev 1705)
@@ -72,6 +72,7 @@
var $_defaultFolder;
var $_code; // our ISO locale code, eg. es_ES, en_UK, etc
+ var $_cache;
var $_messages;
var $_charset;
var $_description;
@@ -89,18 +90,15 @@
*/
function Locale( $code )
{
- $this->Object();
+ $this->Object();
- $config =& Config::getConfig();
+ $this->_code = $code;
- $this->_defaultFolder = $this->getLocaleFolder();
+ $this->_loadLocaleInfo();
- $this->_code = $code;
+ if( $this->_charset == "" )
+ $this->_charset = DEFAULT_ENCODING;
- $this->_loadLocaleInfo();
-
- if( $this->_charset == "" )
- $this->_charset = DEFAULT_ENCODING;
}
/**
@@ -108,15 +106,29 @@
*/
function _loadLocaleFile()
{
- $fileName = $this->_defaultFolder."/locale_".$this->_code.".php";
+ $this->_cache =& CacheManager::getCache();
- if( File::isReadable( $fileName ))
- include( $fileName );
+ $cachedData = $this->_cache->getData( $this->_code, CACHE_LOCALES );
- $this->_messages = $messages;
+ if ($cachedData) {
+ // load cached version
+ $this->_messages = $cachedData;
+ } else {
+ $this->_defaultFolder = $this->getLocaleFolder();
+
+ $fileName = $this->_defaultFolder."/locale_".$this->_code.".php";
+
+ if( File::isReadable( $fileName ))
+ include( $fileName );
+
+ $this->_messages = $messages;
+
+ $this->_cache->setData( $this->_code, CACHE_LOCALES, $this->_messages );
+ }
+
unset($messages);
-
+
/*if( function_exists('memory_get_usage'))
$this->log->debug('Memory used after loading locale ' . $this->_code . ': ' . memory_get_usage());*/
}
@@ -127,8 +139,11 @@
*/
function _loadLocaleInfo()
{
- // load the locale into $this->_messages
- $this->_loadLocaleFile();
+
+ if( !is_array($this->_messages) ) {
+ // load the locale into $this->_messages
+ $this->_loadLocaleFile();
+ }
// get the info that we need
$this->_description = isset($this->_messages["locale_description"]) ? $this->_messages["locale_description"] : "no description for " . $this->_code;
More information about the pLog-svn
mailing list