language : Add a working cache management. Change structure of cache as the previous one remove the fonctionnality

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2935 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-07-20 14:51:46 +00:00
parent abf8b4336a
commit b98adaf6af

View File

@@ -214,9 +214,9 @@ class language
$category = $this->languageCategoryText ($category);
$temporaries = glob ("$repLocale/$languageCode.$codeset/$category/*-*.mo");
$moFile = "$repLocale/$languageCode.$codeset/$category/$package.mo";
$linkBase = $this->cacheDir."/$languageCode.$codeset/$category/".
"$package-";
$link = $linkBase.filemtime($moFile).".mo";
$linkBase = $this->cacheDir."/".filemtime($moFile)."/";
$linkEnd = "$languageCode.$codeset/$category/$package.mo";
$link = $linkBase.$linkEnd;
if (! file_exists ($moFile))
{
return "";
@@ -235,8 +235,15 @@ class language
if (! file_exists ($link) || ! is_readable ($link) ||
filemtime ($moFile) > filemtime ($link))
{
$files = glob ("$linkBase*");
array_map ("unlink", $files);
$files = glob ($this->cacheDir."/*/".$linkEnd);
foreach ($files as $file)
{
unlink ($file);
// Remove the empty dirs. If not empty, do not display an error
@rmdir (dirname ($file));
@rmdir (dirname (dirname ($file)));
@rmdir (dirname (dirname (dirname ($file))));
}
copy ($moFile, $link);
chmod ($link, 0666);
}