TYPO3 CMS  TYPO3_6-2
TranslationConfigurationProvider.php
Go to the documentation of this file.
1 <?php
3 
19 
26 
40  public function getSystemLanguages($page_id = 0, $backPath = '') {
41  $modSharedTSconfig = BackendUtility::getModTSconfig($page_id, 'mod.SHARED');
42  $languageIconTitles = array();
43  // fallback "old iconstyles"
44  if (preg_match('/\\.gif$/', $modSharedTSconfig['properties']['defaultLanguageFlag'])) {
45  $modSharedTSconfig['properties']['defaultLanguageFlag'] = str_replace('.gif', '', $modSharedTSconfig['properties']['defaultLanguageFlag']);
46  }
47  $languageIconTitles[0] = array(
48  'uid' => 0,
49  'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage') . ')' : $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'),
50  'ISOcode' => 'DEF',
51  'flagIcon' => strlen($modSharedTSconfig['properties']['defaultLanguageFlag']) ? 'flags-' . $modSharedTSconfig['properties']['defaultLanguageFlag'] : 'empty-empty'
52  );
53  // Set "All" language:
54  $languageIconTitles[-1] = array(
55  'uid' => -1,
56  'title' => $GLOBALS['LANG']->getLL('multipleLanguages'),
57  'ISOcode' => 'DEF',
58  'flagIcon' => 'flags-multiple'
59  );
60  // Find all system languages:
61  $sys_languages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_language', '');
62  foreach ($sys_languages as $row) {
63  $languageIconTitles[$row['uid']] = $row;
64  if ($row['static_lang_isocode'] && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
65  $staticLangRow = BackendUtility::getRecord('static_languages', $row['static_lang_isocode'], 'lg_iso_2');
66  if ($staticLangRow['lg_iso_2']) {
67  $languageIconTitles[$row['uid']]['ISOcode'] = $staticLangRow['lg_iso_2'];
68  }
69  }
70  if (strlen($row['flag'])) {
71  $languageIconTitles[$row['uid']]['flagIcon'] = IconUtility::mapRecordTypeToSpriteIconName('sys_language', $row);
72  }
73  }
74  return $languageIconTitles;
75  }
76 
89  public function translationInfo($table, $uid, $sys_language_uid = 0, $row = NULL, $selFieldList = '') {
90  if ($GLOBALS['TCA'][$table] && $uid) {
91  if ($row === NULL) {
92  $row = BackendUtility::getRecordWSOL($table, $uid);
93  }
94  if (is_array($row)) {
95  $trTable = $this->getTranslationTable($table);
96  if ($trTable) {
97  if ($trTable !== $table || $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) {
98  if ($trTable !== $table || $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] == 0) {
99  // Look for translations of this record, index by language field value:
100  $translationsTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($selFieldList ? $selFieldList : 'uid,' . $GLOBALS['TCA'][$trTable]['ctrl']['languageField'], $trTable, $GLOBALS['TCA'][$trTable]['ctrl']['transOrigPointerField'] . '=' . (int)$uid . ' AND pid=' . (int)($table === 'pages' ? $row['uid'] : $row['pid']) . ' AND ' . $GLOBALS['TCA'][$trTable]['ctrl']['languageField'] . (!$sys_language_uid ? '>0' : '=' . (int)$sys_language_uid) . BackendUtility::deleteClause($trTable) . BackendUtility::versioningPlaceholderClause($trTable));
101  $translations = array();
102  $translations_errors = array();
103  foreach ($translationsTemp as $r) {
104  if (!isset($translations[$r[$GLOBALS['TCA'][$trTable]['ctrl']['languageField']]])) {
105  $translations[$r[$GLOBALS['TCA'][$trTable]['ctrl']['languageField']]] = $r;
106  } else {
107  $translations_errors[$r[$GLOBALS['TCA'][$trTable]['ctrl']['languageField']]][] = $r;
108  }
109  }
110  return array(
111  'table' => $table,
112  'uid' => $uid,
113  'CType' => $row['CType'],
114  'sys_language_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']],
115  'translation_table' => $trTable,
116  'translations' => $translations,
117  'excessive_translations' => $translations_errors
118  );
119  } else {
120  return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")';
121  }
122  } else {
123  return 'Record "' . $table . '_' . $uid . '" seems to be a translation already (has a language value "' . $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] . '", relation to record "' . $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] . '")';
124  }
125  } else {
126  return 'Translation is not supported for this table!';
127  }
128  } else {
129  return 'Record "' . $table . '_' . $uid . '" was not found';
130  }
131  } else {
132  return 'No table "' . $table . '" or no UID value';
133  }
134  }
135 
143  public function getTranslationTable($table) {
144  return $this->isTranslationInOwnTable($table) ? $table : $this->foreignTranslationTable($table);
145  }
146 
154  public function isTranslationInOwnTable($table) {
155  return $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
156  }
157 
165  public function foreignTranslationTable($table) {
166  $trTable = $GLOBALS['TCA'][$table]['ctrl']['transForeignTable'];
167  if ($trTable && $GLOBALS['TCA'][$trTable] && $GLOBALS['TCA'][$trTable]['ctrl']['languageField'] && $GLOBALS['TCA'][$trTable]['ctrl']['transOrigPointerField'] && $GLOBALS['TCA'][$trTable]['ctrl']['transOrigPointerTable'] === $table) {
168  return $trTable;
169  }
170  }
171 
172 }
static getRecordWSOL($table, $uid, $fields=' *', $where='', $useDeleteClause=TRUE, $unsetMovePointers=FALSE)
static mapRecordTypeToSpriteIconName($table, array $row)
$uid
Definition: server.php:36
translationInfo($table, $uid, $sys_language_uid=0, $row=NULL, $selFieldList='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static deleteClause($table, $tableAlias='')