CVS: phpweather phpweather.php,1.29,1.30
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-08-26 13:13:01
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv7529 Modified Files: phpweather.php Log Message: A little cache to prevent rereading the directory. Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- phpweather.php 12 Aug 2002 23:52:03 -0000 1.29 +++ phpweather.php 26 Aug 2002 13:12:58 -0000 1.30 @@ -71,16 +71,23 @@ * @access public */ function get_languages($type) { - require(PHPWEATHER_BASE_DIR . '/languages.php'); - $this->debug("Finding language for $type"); - $dir = opendir(PHPWEATHER_BASE_DIR . '/output'); - while($file = readdir($dir)) { - if (ereg("^pw_${type}_([a-z][a-z])\.php$", $file, $regs)) { - $output[$regs[1]] = $languages[$regs[1]]; + static $output = array(); + + if (empty($output)) { + + require(PHPWEATHER_BASE_DIR . '/languages.php'); + $this->debug("Finding language for $type"); + + $dir = opendir(PHPWEATHER_BASE_DIR . '/output'); + while($file = readdir($dir)) { + if (ereg("^pw_${type}_([a-z][a-z])\.php$", $file, $regs)) { + $output[$regs[1]] = $languages[$regs[1]]; + } } + closedir($dir); } - closedir($dir); + return $output; } |