ormStyle: Fix icon URL including the app. root in the MetaModel to ease usage with load balancers

This commit is contained in:
Molkobain
2021-09-25 14:38:10 +02:00
parent 4d8ac5fee5
commit ca7f6362bf
4 changed files with 172 additions and 21 deletions

View File

@@ -445,10 +445,10 @@ abstract class MetaModel
/**
* @param string $sClass
* @param bool $bImgTag
* @param string $sMoreStyles
* @param bool $bImgTag Whether to surround the icon URL with an HTML IMG tag or not
* @param string $sMoreStyles Additional inline CSS style to add to the IMG tag. Only used if $bImgTag is set to true
*
* @return string
* @return string Absolute URL the class icon
* @throws \CoreException
*/
final public static function GetClassIcon($sClass, $bImgTag = true, $sMoreStyles = '')
@@ -459,7 +459,7 @@ abstract class MetaModel
if (array_key_exists('style', self::$m_aClassParams[$sClass])) {
/** @var ormStyle $oStyle */
$oStyle = self::$m_aClassParams[$sClass]['style'];
$sIcon = $oStyle->GetIcon();
$sIcon = $oStyle->GetIconAsAbsUrl();
}
if (strlen($sIcon) == 0) {
$sParentClass = self::GetParentPersistentClass($sClass);
@@ -494,7 +494,7 @@ abstract class MetaModel
$oStyle = new ormStyle("ibo-class-style--$sClass", "ibo-class-style-alt--$sClass");
}
if ((strlen($oStyle->GetMainColor()) > 0) && (strlen($oStyle->GetComplementaryColor()) > 0) && (strlen($oStyle->GetIcon()) > 0)) {
if ((strlen($oStyle->GetMainColor()) > 0) && (strlen($oStyle->GetComplementaryColor()) > 0) && (strlen($oStyle->GetIconAsRelPath()) > 0)) {
// all the parameters are set, no need to search in the parent classes
return $oStyle;
}
@@ -512,10 +512,10 @@ abstract class MetaModel
$oStyle->SetComplementaryColor($oParentStyle->GetComplementaryColor());
$oStyle->SetAltStyleClass($oParentStyle->GetAltStyleClass());
}
if (strlen($oStyle->GetIcon()) == 0) {
$oStyle->SetIcon($oParentStyle->GetIcon());
if (strlen($oStyle->GetIconAsRelPath()) == 0) {
$oStyle->SetIcon($oParentStyle->GetIconAsRelPath());
}
if ((strlen($oStyle->GetMainColor()) > 0) && (strlen($oStyle->GetComplementaryColor()) > 0) && (strlen($oStyle->GetIcon()) > 0)) {
if ((strlen($oStyle->GetMainColor()) > 0) && (strlen($oStyle->GetComplementaryColor()) > 0) && (strlen($oStyle->GetIconAsRelPath()) > 0)) {
// all the parameters are set, no need to search in the parent classes
return $oStyle;
}
@@ -523,7 +523,7 @@ abstract class MetaModel
$sParentClass = self::GetParentPersistentClass($sParentClass);
}
if ((strlen($oStyle->GetMainColor()) == 0) && (strlen($oStyle->GetComplementaryColor()) == 0) && (strlen($oStyle->GetIcon()) == 0)) {
if ((strlen($oStyle->GetMainColor()) == 0) && (strlen($oStyle->GetComplementaryColor()) == 0) && (strlen($oStyle->GetIconAsRelPath()) == 0)) {
return null;
}