|
From: Lo?c C. <lo...@us...> - 2001-12-01 10:50:48
|
Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/localization
In directory usw-pr-cvs1:/tmp/cvs-serv11899/chat/localization
Modified Files:
tutorial.lib.php3 admin.lib.php3
Log Message:
extended the cache feature added by Nicolas to administration and tutorial translations
Index: tutorial.lib.php3
===================================================================
RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/localization/tutorial.lib.php3,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** tutorial.lib.php3 2001/11/26 22:50:54 1.9
--- tutorial.lib.php3 2001/12/01 10:50:45 1.10
***************
*** 46,53 ****
global $lang;
- $notFound = true;
reset($availableTutorials);
! while ($notFound && list($key, $name) = each($availableTutorials))
{
// $envType = 0 for a simple variable,
--- 46,52 ----
global $lang;
reset($availableTutorials);
! while (list($key, $name) = each($availableTutorials))
{
// $envType = 0 for a simple variable,
***************
*** 59,63 ****
{
$lang = $availableTutorials[$key];
! $notFound = false;
}
}
--- 58,62 ----
{
$lang = $availableTutorials[$key];
! break;
}
}
***************
*** 68,91 ****
* Creates the array containing available languages
*/
! // Defines available languages
! $availableTutorials = array();
! $languageDirectories = dir('./localization/');
! while ($name = $languageDirectories->read())
{
! if (is_dir('./localization/' . $name)
! && file_exists('./localization/' . $name . '/tutorial.loc'))
{
! list($key) = file('./localization/' . $name . '/regex.txt');
! $availableTutorials[$key] = $name;
}
! }
! $languageDirectories->close();
! // Sorts the $availableTutorials array in a convenient order
! if (!@function_exists('krsort'))
! {
! include('./localization/sort_languages.lib.' . C_EXTENSION);
}
- krsort($availableTutorials);
--- 67,108 ----
* Creates the array containing available languages
*/
! // Tries to get this array from the cache
! $tutorialCacheFile = (defined('_CHAT_PATH') ? _CHAT_PATH : '') . 'cache/availableTutorialLanguages.cache';
! if (file_exists($tutorialCacheFile) && (filemtime($tutorialCacheFile) + 60*60 - time()) > 0)
{
! // Cache is up to date, we use it
! $availableTutorials = unserialize(implode('', file($tutorialCacheFile)));
! }
! // Else defines available languages
! else
! {
! // Defines available languages
! $availableTutorials = array();
! $languageDirectories = dir('./localization/');
! while ($name = $languageDirectories->read())
{
! if (is_dir('./localization/' . $name)
! && file_exists('./localization/' . $name . '/tutorial.loc'))
! {
! list($key) = file('./localization/' . $name . '/regex.txt');
! $availableTutorials[$key] = $name;
! }
}
! $languageDirectories->close();
! // Sorts the $availableTutorials array in a convenient order
! if (!@function_exists('krsort'))
! {
! include('./localization/sort_languages.lib.' . C_EXTENSION);
! }
! krsort($availableTutorials);
!
! // Store the result in a cache file to limit server load
! if ($cacheFile = @fopen($tutorialCacheFile, 'w'))
! {
! fwrite($cacheFile, serialize($availableTutorials));
! fclose($cacheFile);
! }
}
Index: admin.lib.php3
===================================================================
RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/localization/admin.lib.php3,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** admin.lib.php3 2001/11/26 22:50:54 1.9
--- admin.lib.php3 2001/12/01 10:50:45 1.10
***************
*** 46,53 ****
global $dbSessionVars;
- $notFound = true;
reset($availableAdmins);
! while ($notFound && list($key, $name) = each($availableAdmins))
{
// $envType = 0 for a simple cookie value,
--- 46,52 ----
global $dbSessionVars;
reset($availableAdmins);
! while (list($key, $name) = each($availableAdmins))
{
// $envType = 0 for a simple cookie value,
***************
*** 59,63 ****
{
$dbSessionVars['adminLang'] = $availableAdmins[$key];
! $notFound = false;
}
}
--- 58,62 ----
{
$dbSessionVars['adminLang'] = $availableAdmins[$key];
! break;
}
}
***************
*** 69,92 ****
* Creates the array containing available languages
*/
! // Defines available languages
! $availableAdmins = array();
! $languageDirectories = dir('./localization/');
! while ($name = $languageDirectories->read())
{
! if (is_dir('./localization/' . $name)
! && file_exists('./localization/' . $name . '/admin.loc')
{
! list($key) = file('./localization/' . $name . '/regex.txt');
! $availableAdmins[$key] = $name;
}
! }
! $languageDirectories->close();
! // Sorts the $availableAdmins array in a convenient order
! if (!@function_exists('krsort'))
! {
! include('./localization/sort_languages.lib.' . C_EXTENSION);
}
- krsort($availableAdmins);
--- 68,108 ----
* Creates the array containing available languages
*/
! // Tries to get this array from the cache
! $adminCacheFile = (defined('_CHAT_PATH') ? _CHAT_PATH : '') . 'cache/availableAdminLanguages.cache';
! if (file_exists($adminCacheFile) && (filemtime($adminCacheFile) + 60*60 - time()) > 0)
{
! // Cache is up to date, we use it
! $availableAdmins = unserialize(implode('', file($adminCacheFile)));
! }
! // Else defines available languages
! else
! {
! $availableAdmins = array();
! $languageDirectories = dir('./localization/');
! while ($name = $languageDirectories->read())
{
! if (is_dir('./localization/' . $name)
! && file_exists('./localization/' . $name . '/admin.loc')
! {
! list($key) = file('./localization/' . $name . '/regex.txt');
! $availableAdmins[$key] = $name;
! }
}
! $languageDirectories->close();
! // Sorts the $availableAdmins array in a convenient order
! if (!@function_exists('krsort'))
! {
! include('./localization/sort_languages.lib.' . C_EXTENSION);
! }
! krsort($availableAdmins);
!
! // Store the result in a cache file to limit server load
! if ($cacheFile = @fopen($adminCacheFile, 'w'))
! {
! fwrite($cacheFile, serialize($availableAdmins));
! fclose($cacheFile);
! }
}
|