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); $category = $this->languageCategoryText ($category);
$temporaries = glob ("$repLocale/$languageCode.$codeset/$category/*-*.mo"); $temporaries = glob ("$repLocale/$languageCode.$codeset/$category/*-*.mo");
$moFile = "$repLocale/$languageCode.$codeset/$category/$package.mo"; $moFile = "$repLocale/$languageCode.$codeset/$category/$package.mo";
$linkBase = $this->cacheDir."/$languageCode.$codeset/$category/". $linkBase = $this->cacheDir."/".filemtime($moFile)."/";
"$package-"; $linkEnd = "$languageCode.$codeset/$category/$package.mo";
$link = $linkBase.filemtime($moFile).".mo"; $link = $linkBase.$linkEnd;
if (! file_exists ($moFile)) if (! file_exists ($moFile))
{ {
return ""; return "";
@@ -235,8 +235,15 @@ class language
if (! file_exists ($link) || ! is_readable ($link) || if (! file_exists ($link) || ! is_readable ($link) ||
filemtime ($moFile) > filemtime ($link)) filemtime ($moFile) > filemtime ($link))
{ {
$files = glob ("$linkBase*"); $files = glob ($this->cacheDir."/*/".$linkEnd);
array_map ("unlink", $files); 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); copy ($moFile, $link);
chmod ($link, 0666); chmod ($link, 0666);
} }