Added feature #15668: TYPO3 Backend should display flags for translations as sprite...
authorErnesto Baschny <ernst@cron-it.de>
Tue, 16 Nov 2010 13:31:17 +0000 (13:31 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Tue, 16 Nov 2010 13:31:17 +0000 (13:31 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9397 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_recordlist.php
t3lib/class.t3lib_transl8tools.php
typo3/alt_doc.php
typo3/class.db_list_extra.inc
typo3/sysext/beuser/mod/index.php

index 97bb6a0..88925aa 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-11-16  Ernesto Baschny  <ernst@cron-it.de>
+
+       * Added feature #15668: TYPO3 Backend should display flags for translations as sprite icons (Thanks to Steffen Ritter)
+
 2010-11-16  Sebastian Kurfuerst  <sebastian@typo3.org>
 
        * Updated Extbase and Fluid to 1.3.0beta1. See their ChangeLog for details.
index 32cebab..45550d7 100644 (file)
@@ -858,24 +858,25 @@ final class t3lib_BEfunc {
        /**
         * Returns an array with system languages:
         *
-        * @return      array           Array with languages
+        * Since TYPO3 4.5 the flagIcon is not returned as a filename in "gfx/flags/*" anymore,
+        * but as a string <flags-xx>. The calling party should call
+        * t3lib_iconWorks::getSpriteIcon(<flags-xx>) to get an HTML which will represent
+        * the flag of this language.
+        *
+        * @return      array           Array with languages (title, uid, flagIcon)
         */
        public static function getSystemLanguages()     {
-
-                       // Initialize, add default language:
+               $languages = t3lib_div::makeInstance('t3lib_transl8tools')->getSystemLanguages();
                $sysLanguages = array();
-               $sysLanguages[] = array('Default language', 0);
-
-                       // Traverse languages
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,title,flag', 'sys_language', 'pid=0' . self::deleteClause('sys_language'));
-               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                       $sysLanguages[] = array(
-                               htmlspecialchars($row['title']) . ' [' . $row['uid'] . ']',
-                               $row['uid'],
-                               ($row['flag'] ? 'flags/' . $row['flag'] : '')
-                       );
+               foreach ($languages as $language) {
+                       if($language['uid'] !== -1) {
+                               $sysLanguages[] = array(
+                                       0 => htmlspecialchars($language['title']) . ' [' . $language['uid'] . ']',
+                                       1 => $language['uid'],
+                                       2 => $language['flagIcon']
+                               );
+                       }
                }
-               $GLOBALS['TYPO3_DB']->sql_free_result($res);
 
                return $sysLanguages;
        }
index c514cae..af7083c 100644 (file)
@@ -374,8 +374,13 @@ class t3lib_recordList {
         * @return      string          Language icon
         */
        function languageFlag($sys_language_uid)        {
-               return ($this->languageIconTitles[$sys_language_uid]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$sys_language_uid]['flagIcon'].'" class="absmiddle" alt="" />&nbsp;' : '').
-                               htmlspecialchars($this->languageIconTitles[$sys_language_uid]['title']);
+               $out = '';
+               if ($this->languageIconTitles[$sys_language_uid]['flagIcon']) {
+                       $out .= t3lib_iconWorks::getSpriteIcon($this->languageIconTitles[$sys_language_uid]['flagIcon']);
+                       $out .= '&nbsp;';
+               }
+               $out .= htmlspecialchars($this->languageIconTitles[$sys_language_uid]['title']);
+               return $out;
        }
 
        /**
index e14d1b0..c4587cd 100644 (file)
@@ -68,27 +68,32 @@ class t3lib_transl8tools    {
 
        /**
         * Returns array of system languages
+        *
+        * Since TYPO3 4.5 the flagIcon is not returned as a filename in "gfx/flags/*" anymore,
+        * but as a string <flags-xx>. The calling party should call
+        * t3lib_iconWorks::getSpriteIcon(<flags-xx>) to get an HTML which will represent
+        * the flag of this language.
+        *
         * @param       integer         page id (only used to get TSconfig configuration setting flag and label for default language)
         * @param       string          Backpath for flags
-        * @return      array
+        * @return      array           Array with languages (title, uid, flagIcon)
         */
        function getSystemLanguages($page_id=0,$backPath='')    {
                global $TCA,$LANG;
 
-                       // Icons and language titles:
-               t3lib_div::loadTCA('sys_language');
-               $flagAbsPath = t3lib_div::getFileAbsFileName($TCA['sys_language']['columns']['flag']['config']['fileFolder']);
-               $flagIconPath = $backPath.'../'.substr($flagAbsPath, strlen(PATH_site));
-
                $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($page_id, 'mod.SHARED');
                $languageIconTitles = array();
 
-                       // Set default:
+                       // fallback "old iconstyles"
+               if (preg_match('/\.gif$/', $modSharedTSconfig['properties']['defaultLanguageFlag'])) {
+                       $modSharedTSconfig['properties']['defaultLanguageFlag'] = str_replace('.gif', '', $modSharedTSconfig['properties']['defaultLanguageFlag']);
+               }
+
                $languageIconTitles[0] = array(
                        'uid' => 0,
-                       'title' => strlen ($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'].' ('.$LANG->getLL('defaultLanguage').')' : $LANG->getLL('defaultLanguage'),
+                       'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'].' ('.$GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xml:defaultLanguage').')' : $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xml:defaultLanguage'),
                        'ISOcode' => 'DEF',
-                       'flagIcon' => strlen($modSharedTSconfig['properties']['defaultLanguageFlag']) && @is_file($flagAbsPath.$modSharedTSconfig['properties']['defaultLanguageFlag']) ? $flagIconPath.$modSharedTSconfig['properties']['defaultLanguageFlag'] : null,
+                       'flagIcon' => strlen($modSharedTSconfig['properties']['defaultLanguageFlag']) ? 'flags-' . $modSharedTSconfig['properties']['defaultLanguageFlag'] : 'empty-empty',
                );
 
                        // Set "All" language:
@@ -96,7 +101,7 @@ class t3lib_transl8tools     {
                        'uid' => -1,
                        'title' => $LANG->getLL('multipleLanguages'),
                        'ISOcode' => 'DEF',
-                       'flagIcon' => $flagIconPath.'multi-language.gif',
+                       'flagIcon' => 'flags-multiple',
                );
 
                        // Find all system languages:
@@ -115,7 +120,7 @@ class t3lib_transl8tools    {
                                }
                        }
                        if (strlen ($row['flag'])) {
-                               $languageIconTitles[$row['uid']]['flagIcon'] = @is_file($flagAbsPath.$row['flag']) ? $flagIconPath.$row['flag'] : '';
+                               $languageIconTitles[$row['uid']]['flagIcon'] = t3lib_iconWorks::mapRecordTypeToSpriteIconName('sys_language', $row);
                        }
                }
 
index 81ac9bc..3582773 100644 (file)
@@ -1209,6 +1209,11 @@ class SC_alt_doc {
                global $LANG;
 
                $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($id, 'mod.SHARED');
+               
+                       // fallback non sprite-configuration
+               if (preg_match('/\.gif$/', $modSharedTSconfig['properties']['defaultLanguageFlag'])) {
+                       $modSharedTSconfig['properties']['defaultLanguageFlag'] = str_replace('.gif', '', $modSharedTSconfig['properties']['defaultLanguageFlag']);
+               }
 
                $languages = array(
                        0 => array(
index 2bec6de..ac88d0f 100644 (file)
@@ -1561,7 +1561,11 @@ class localRecordList extends recordList {
                                                $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
                                        );
                                        $language = t3lib_BEfunc::getRecord('sys_language', $lUid_OnPage, 'title');
-                                       $lC = ($this->languageIconTitles[$lUid_OnPage]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$lUid_OnPage]['flagIcon'].'" class="absmiddle" alt="" />' : $this->languageIconTitles[$lUid_OnPage]['title']);
+                                       if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
+                                               $lC = t3lib_iconWorks::getSpriteIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon']);;
+                                       } else {
+                                               $lC = $this->languageIconTitles[$lUid_OnPage]['title'];
+                                       }
                                        $lC = '<a href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($language['title']) . '">' . $lC . '</a> ';
 
                                        $lNew.=$lC;
index 12a0011..95df778 100755 (executable)
@@ -774,7 +774,9 @@ class local_beUserAuth extends t3lib_beUserAuth {
                                                foreach ($items as $iCfg)       {
                                                        if (isset($nef[$iCfg[1]]))      {
                                                                unset($nef[$iCfg[1]]);
-                                                               if (strlen($iCfg[2]))   {
+                                                               if (strpos($iCfg[2], '.gif') === FALSE) {
+                                                                       $icon = t3lib_iconWorks::getSpriteIcon($iCfg[2]) . '&nbsp;';
+                                                               } elseif (strlen($iCfg[2]))     {
                                                                        $icon = '<img '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$iCfg[2]).' class="absmiddle" style="margin-right: 5px;" alt="" />';
                                                                } else {
                                                                        $icon = '';