Commit 37bde099 authored by Philip Liebel's avatar Philip Liebel

fix getHref, fix use of mod.SHARED.defaultLanguageFlag, simplify function call for img tag

parent 55d402c6
......@@ -29,8 +29,20 @@ use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
class IconUtility {
public static function skinImg ($basePath ,$path, $style= '') {
$absoluteFilePath = $basePath . $path;
/**
*
* @param string $lang
* @param string $style
* @return string
*/
public static function flagImg ($lang, $style= '') {
$flagIconsPath = PATH_typo3 . 'sysext/core/Resources/Public/Icons/Flags/PNG/';
if(!$lang) {
$lang = 'de';
}
$absoluteFilePath = $flagIconsPath . strtoupper($lang) . '.png';
return ' src="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($absoluteFilePath)) . '"'
. ' alt="" title="" ' . $style
. ' ';
......
......@@ -64,7 +64,7 @@ final class LanglinkBrowseLinksUtility
// get default language flag for that page
$defaultFlag = BackendUtility::getModTSconfig($uid, 'mod.SHARED.defaultLanguageFlag');
$defaultFlag = ($defaultFlag['value'] == '') ? 'DE.png' : strtoupper($defaultFlag['value']) . '.png';
$defaultFlag = $defaultFlag['value'] ?? 'DE';
if (!preg_match('/\.[a-z]+$/', $defaultFlag)) {
// version 4.5.0 only saves 'gb' for 'gb.gif'
//$defaultFlag .= '.svg';
......@@ -84,7 +84,7 @@ final class LanglinkBrowseLinksUtility
<span class="list-tree-title">
<a href="'
. self::getHref($uid, $langRecord['sys_language_uid']) .'" style="' . $internalStyle . '" class="t3js-pageLink ' . trim($classAttr) . '" >'
. '<img'.IconUtility::skinImg(PATH_typo3, 'sysext/core/Resources/Public/Icons/Flags/PNG/'.$defaultFlag, 'width="20" height="12"').' alt="" />
. '<img'.IconUtility::flagImg($defaultFlag, 'width="20" height="12"').' alt="" />
</a>
</span>';
......@@ -104,7 +104,7 @@ final class LanglinkBrowseLinksUtility
<span class="list-tree-title">
<a href="'. self::getHref($uid, $langRecord['sys_language_uid']) . '" style="' . $internalStyle . '" class="t3js-pageLink ' . trim($classAttr) . '"'
. ' data-l="' . $langRecord['sys_language_uid'] . '" >'
. '<img'. IconUtility::skinImg(PATH_typo3, 'sysext/core/Resources/Public/Icons/Flags/PNG/'.strtoupper($langRecord['lang_flag']) . '.png', 'width="20" height="12"').' alt="" />
. '<img'. IconUtility::flagImg($langRecord['lang_flag'], 'width="20" height="12"').' alt="" />
</a>
</span>';
}
......@@ -129,6 +129,6 @@ final class LanglinkBrowseLinksUtility
* @return string
*/
protected static function getHref($pid, $lang) {
return 't3://page?uid=' . int($pid);
return 't3://page?uid=' . intval($pid);
}
}
......@@ -23,7 +23,7 @@ If you haven't set a flag for your default language in the backend you will se a
```
mod.SHARED {
defaultLanguageFlag = de.gif
defaultLanguageFlag = de
}
```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment