mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
PR#39 Fix support of expressions (friendlyname) in different language contexts
This commit is contained in:
@@ -1595,7 +1595,7 @@ class DBObjectSearch extends DBSearch
|
|||||||
}
|
}
|
||||||
$aContextData['sModifierProperties'] = $sModifierProperties;
|
$aContextData['sModifierProperties'] = $sModifierProperties;
|
||||||
|
|
||||||
$sRawId = $sOqlQuery.$sModifierProperties;
|
$sRawId = Dict::GetUserLanguage().'-'.$sOqlQuery.$sModifierProperties;
|
||||||
if (!is_null($aAttToLoad))
|
if (!is_null($aAttToLoad))
|
||||||
{
|
{
|
||||||
$sRawId .= json_encode($aAttToLoad);
|
$sRawId .= json_encode($aAttToLoad);
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
class ExpressionCache
|
class ExpressionCache
|
||||||
{
|
{
|
||||||
static private $aCache = array();
|
|
||||||
|
|
||||||
static public function GetCachedExpression($sClass, $sAttCode)
|
static public function GetCachedExpression($sClass, $sAttCode)
|
||||||
{
|
{
|
||||||
@@ -28,20 +27,12 @@ class ExpressionCache
|
|||||||
|
|
||||||
$oExpr = null;
|
$oExpr = null;
|
||||||
$sKey = static::GetKey($sClass, $sAttCode);
|
$sKey = static::GetKey($sClass, $sAttCode);
|
||||||
if (array_key_exists($sKey, static::$aCache))
|
if (class_exists('ExpressionCacheData'))
|
||||||
{
|
{
|
||||||
$oExpr = static::$aCache[$sKey];
|
if (array_key_exists($sKey, ExpressionCacheData::$aCache))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (class_exists('ExpressionCacheData'))
|
|
||||||
{
|
{
|
||||||
if (array_key_exists($sKey, ExpressionCacheData::$aCache))
|
$sVal = ExpressionCacheData::$aCache[$sKey];
|
||||||
{
|
$oExpr = unserialize($sVal);
|
||||||
$sVal = ExpressionCacheData::$aCache[$sKey];
|
|
||||||
$oExpr = unserialize($sVal);
|
|
||||||
static::$aCache[$sKey] = $oExpr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $oExpr;
|
return $oExpr;
|
||||||
@@ -50,36 +41,45 @@ class ExpressionCache
|
|||||||
|
|
||||||
static public function Warmup()
|
static public function Warmup()
|
||||||
{
|
{
|
||||||
$sFilePath = static::GetCacheFileName();
|
// Store current language
|
||||||
|
$sUserLang = Dict::GetUserLanguage();
|
||||||
if (!is_file($sFilePath))
|
$aLanguages = Dict::GetLanguages();
|
||||||
|
foreach($aLanguages as $sLang => $aLang)
|
||||||
{
|
{
|
||||||
$content = <<<EOF
|
Dict::SetUserLanguage($sLang);
|
||||||
|
$sFilePath = static::GetCacheFileName();
|
||||||
|
|
||||||
|
if (!is_file($sFilePath))
|
||||||
|
{
|
||||||
|
$content = <<<EOF
|
||||||
<?php
|
<?php
|
||||||
// Copyright (c) 2010-2017 Combodo SARL
|
// Copyright (c) 2010-2019 Combodo SARL
|
||||||
// Generated Expression Cache file
|
// Generated Expression Cache file for $sLang
|
||||||
|
|
||||||
class ExpressionCacheData
|
class ExpressionCacheData
|
||||||
{
|
{
|
||||||
static \$aCache = array(
|
static \$aCache = array(
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
foreach(MetaModel::GetClasses() as $sClass)
|
foreach (MetaModel::GetClasses() as $sClass)
|
||||||
{
|
|
||||||
$content .= static::GetSerializedExpression($sClass, 'friendlyname');
|
|
||||||
if (MetaModel::IsObsoletable($sClass))
|
|
||||||
{
|
{
|
||||||
$content .= static::GetSerializedExpression($sClass, 'obsolescence_flag');
|
$content .= static::GetSerializedExpression($sClass, 'friendlyname');
|
||||||
|
if (MetaModel::IsObsoletable($sClass))
|
||||||
|
{
|
||||||
|
$content .= static::GetSerializedExpression($sClass, 'obsolescence_flag');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$content .= <<<EOF
|
$content .= <<<EOF
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
file_put_contents($sFilePath, $content);
|
file_put_contents($sFilePath, $content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Restore original user language
|
||||||
|
Dict::SetUserLanguage($sUserLang);
|
||||||
}
|
}
|
||||||
|
|
||||||
static private function GetSerializedExpression($sClass, $sAttCode)
|
static private function GetSerializedExpression($sClass, $sAttCode)
|
||||||
@@ -101,9 +101,10 @@ EOF;
|
|||||||
|
|
||||||
public static function GetCacheFileName()
|
public static function GetCacheFileName()
|
||||||
{
|
{
|
||||||
return utils::GetCachePath().'expressioncache.php';
|
$sLang = Dict::GetUserLanguage();
|
||||||
|
$sLang = str_replace(" ", "", $sLang);
|
||||||
|
return utils::GetCachePath().'expressioncache-' . $sLang . '.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user