[ Index ] |
|
Code source de Typo3 4.1.3 |
1 <?php 2 /*************************************************************** 3 * Copyright notice 4 * 5 * (c) 2006 Kasper Skaarhoj (kasperYYYY@typo3.com) 6 * All rights reserved 7 * 8 * This script is part of the TYPO3 project. The TYPO3 project is 9 * free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * The GNU General Public License can be found at 15 * http://www.gnu.org/copyleft/gpl.html. 16 * A copy is found in the textfile GPL.txt and important notices to the license 17 * from the author is found in LICENSE.txt distributed with these scripts. 18 * 19 * 20 * This script is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * GNU General Public License for more details. 24 * 25 * This copyright notice MUST APPEAR in all copies of the script! 26 ***************************************************************/ 27 /** 28 * Contains translation tools 29 * 30 * $Id: class.t3lib_loaddbgroup.php 1816 2006-11-26 00:43:24Z mundaun $ 31 * 32 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 33 */ 34 /** 35 * [CLASS/FUNCTION INDEX of SCRIPT] 36 * 37 */ 38 39 40 41 42 43 44 45 46 47 48 /** 49 * Contains translation tools 50 * 51 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 52 * @package TYPO3 53 * @subpackage t3lib 54 */ 55 class t3lib_transl8tools { 56 57 /** 58 * 59 */ 60 function getSystemLanguages($page_id=0,$backPath='') { 61 global $TCA,$LANG; 62 63 // Icons and language titles: 64 t3lib_div::loadTCA('sys_language'); 65 $flagAbsPath = t3lib_div::getFileAbsFileName($TCA['sys_language']['columns']['flag']['config']['fileFolder']); 66 $flagIconPath = $backPath.'../'.substr($flagAbsPath, strlen(PATH_site)); 67 68 $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($page_id, 'mod.SHARED'); 69 $languageIconTitles = array(); 70 71 // Set default: 72 $languageIconTitles[0] = array( 73 'uid' => 0, 74 'title' => strlen ($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'].' ('.$LANG->getLL('defaultLanguage').')' : $LANG->getLL('defaultLanguage'), 75 'ISOcode' => 'DEF', 76 'flagIcon' => strlen($modSharedTSconfig['properties']['defaultLanguageFlag']) && @is_file($flagAbsPath.$modSharedTSconfig['properties']['defaultLanguageFlag']) ? $flagIconPath.$modSharedTSconfig['properties']['defaultLanguageFlag'] : null, 77 ); 78 79 // Set "All" language: 80 $languageIconTitles[-1]=array( 81 'uid' => -1, 82 'title' => $LANG->getLL('multipleLanguages'), 83 'ISOcode' => 'DEF', 84 'flagIcon' => $flagIconPath.'multi-language.gif', 85 ); 86 87 // Find all system languages: 88 $sys_languages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 89 '*', 90 'sys_language', 91 '' 92 ); 93 foreach($sys_languages as $row) { 94 $languageIconTitles[$row['uid']] = $row; 95 96 if ($row['static_lang_isocode'] && t3lib_extMgm::isLoaded('static_info_tables')) { 97 $staticLangRow = t3lib_BEfunc::getRecord('static_languages',$row['static_lang_isocode'],'lg_iso_2'); 98 if ($staticLangRow['lg_iso_2']) { 99 $languageIconTitles[$row['uid']]['ISOcode'] = $staticLangRow['lg_iso_2']; 100 } 101 } 102 if (strlen ($row['flag'])) { 103 $languageIconTitles[$row['uid']]['flagIcon'] = @is_file($flagAbsPath.$row['flag']) ? $flagIconPath.$row['flag'] : ''; 104 } 105 } 106 107 return $languageIconTitles; 108 } 109 110 /** 111 * Initialization of the class. 112 */ 113 function translationInfo($table,$uid,$sys_language_uid=0) { 114 global $TCA; 115 116 if ($TCA[$table] && $uid) { 117 t3lib_div::loadTCA($table); 118 119 $row = t3lib_BEfunc::getRecordWSOL($table,$uid); 120 if (is_array($row)) { 121 $trTable = $this->getTranslationTable($table); 122 if ($trTable) { 123 if ($trTable!==$table || $row[$TCA[$table]['ctrl']['languageField']] <= 0) { 124 if ($trTable!==$table || $row[$TCA[$table]['ctrl']['transOrigPointerField']] == 0) { 125 126 // Look for translations of this record, index by language field value: 127 $translationsTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 128 'uid,'.$TCA[$trTable]['ctrl']['languageField'], 129 $trTable, 130 'pid='.intval($table==='pages' ? $row['uid'] : $row['pid']). // Making exception for pages of course where the translations will always be ON the page, not on the level above... 131 ' AND '.$TCA[$trTable]['ctrl']['languageField'].(!$sys_language_uid ? '>0' : '='.intval($sys_language_uid)). 132 ' AND '.$TCA[$trTable]['ctrl']['transOrigPointerField'].'='.intval($uid). 133 t3lib_BEfunc::deleteClause($trTable). 134 t3lib_BEfunc::versioningPlaceholderClause($trTable) 135 ); 136 137 $translations = array(); 138 $translations_errors = array(); 139 foreach($translationsTemp as $r) { 140 if (!isset($translations[$r[$TCA[$trTable]['ctrl']['languageField']]])) { 141 $translations[$r[$TCA[$trTable]['ctrl']['languageField']]] = $r; 142 } else { 143 $translations_errors[$r[$TCA[$trTable]['ctrl']['languageField']]][] = $r; 144 } 145 } 146 147 return array( 148 'table' => $table, 149 'uid' => $uid, 150 'sys_language_uid' => $row[$TCA[$table]['ctrl']['languageField']], 151 'translation_table' => $trTable, 152 'translations' => $translations, 153 'excessive_translations' => $translations_errors 154 ); 155 } else return 'Record "'.$table.'_'.$uid.'" seems to be a translation already (has a relation to record "'.$row[$TCA[$table]['ctrl']['transOrigPointerField']].'")'; 156 } else return 'Record "'.$table.'_'.$uid.'" seems to be a translation already (has a language value "'.$row[$TCA[$table]['ctrl']['languageField']].'", relation to record "'.$row[$TCA[$table]['ctrl']['transOrigPointerField']].'")'; 157 } else return 'Translation is not supported for this table!'; 158 } else return 'Record "'.$table.'_'.$uid.'" was not found'; 159 } else return 'No table "'.$table.'" or no UID value'; 160 } 161 162 /** 163 * Returns the table in which translations for input table is found. 164 */ 165 function getTranslationTable($table) { 166 return $this->isTranslationInOwnTable($table) ? $table : $this->foreignTranslationTable($table); 167 } 168 169 /** 170 * Returns true, if the input table has localization enabled and done so with records from the same table 171 */ 172 function isTranslationInOwnTable($table) { 173 global $TCA; 174 175 return $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable']; 176 } 177 178 /** 179 * Returns foreign translation table, if any 180 */ 181 function foreignTranslationTable($table) { 182 global $TCA; 183 184 $trTable = $TCA[$table]['ctrl']['transForeignTable']; 185 186 if ($trTable && $TCA[$trTable] && $TCA[$trTable]['ctrl']['languageField'] && $TCA[$trTable]['ctrl']['transOrigPointerField'] && $TCA[$trTable]['ctrl']['transOrigPointerTable']===$table) { 187 return $trTable; 188 } 189 } 190 } 191 192 193 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transl8tools.php']) { 194 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_transl8tools.php']); 195 } 196 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Nov 25 17:13:16 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |