TYPO3 CMS  TYPO3_6-2
TranslationStatusController.php
Go to the documentation of this file.
1 <?php
3 
19 
26 
33  public function modMenu() {
34  global $LANG;
35  $menuArray = array(
36  'depth' => array(
37  0 => $LANG->getLL('depth_0'),
38  1 => $LANG->getLL('depth_1'),
39  2 => $LANG->getLL('depth_2'),
40  3 => $LANG->getLL('depth_3'),
41  999 => $LANG->sL('LLL:EXT:lang/locallang_core.xlf:labels.depth_infi')
42  )
43  );
44  // Languages:
45  $lang = $this->getSystemLanguages();
46  $menuArray['lang'] = array(
47  0 => '[All]'
48  );
49  foreach ($lang as $langRec) {
50  $menuArray['lang'][$langRec['uid']] = $langRec['title'];
51  }
52  return $menuArray;
53  }
54 
61  public function main() {
62  global $BACK_PATH, $LANG, $SOBE;
63  $theOutput = $this->pObj->doc->header($LANG->sL('LLL:EXT:cms/web_info/locallang.xlf:lang_title'));
64  if ($this->pObj->id) {
65  // Depth selector:
66  $h_func = BackendUtility::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
67  $h_func .= BackendUtility::getFuncMenu($this->pObj->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang']);
68  $theOutput .= $h_func;
69  // Add CSH:
70  $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'lang', $GLOBALS['BACK_PATH'], '|<br />');
71  // Showing the tree:
72  // Initialize starting point of page tree:
73  $treeStartingPoint = (int)$this->pObj->id;
74  $treeStartingRecord = BackendUtility::getRecordWSOL('pages', $treeStartingPoint);
75  $depth = $this->pObj->MOD_SETTINGS['depth'];
76  // Initialize tree object:
77  $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
78  $tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
79  $tree->addField('l18n_cfg');
80  // Creating top icon; the current page
81  $HTML = IconUtility::getSpriteIconForRecord('pages', $treeStartingRecord);
82  $tree->tree[] = array(
83  'row' => $treeStartingRecord,
84  'HTML' => $HTML
85  );
86  // Create the tree from starting point:
87  if ($depth) {
88  $tree->getTree($treeStartingPoint, $depth, '');
89  }
90  // Render information table:
91  $theOutput .= $this->renderL10nTable($tree);
92  }
93  return $theOutput;
94  }
95 
103  public function renderL10nTable(&$tree) {
104  global $LANG;
105  // System languages retrieved:
106  $languages = $this->getSystemLanguages();
107  // Title length:
108  $titleLen = $GLOBALS['BE_USER']->uc['titleLen'];
109  // Put together the TREE:
110  $output = '';
111  $newOL_js = array();
112  $langRecUids = array();
113  foreach ($tree->tree as $data) {
114  $tCells = array();
115  $langRecUids[0][] = $data['row']['uid'];
116  // Page icons / titles etc.
117  $tCells[] = '<td' . ($data['row']['_CSSCLASS'] ? ' class="' . $data['row']['_CSSCLASS'] . '"' : '') . '>' . $data['HTML'] . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($data['row']['title'], $titleLen)) . ((string)$data['row']['nav_title'] !== '' ? ' [Nav: <em>' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($data['row']['nav_title'], $titleLen)) . '</em>]' : '') . '</td>';
118  // DEFAULT language:
119  // "View page" link is created:
120  $viewPageLink = '<a href="#" onclick="' . htmlspecialchars(BackendUtility::viewOnClick(
121  $data['row']['uid'], $GLOBALS['BACK_PATH'], '', '', '', '&L=###LANG_UID###')
122  ) . '" title="' . $LANG->sL('LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_viewPage') . '">' .
123  IconUtility::getSpriteIcon('actions-document-view') . '</a>';
124  $status = \TYPO3\CMS\Core\Utility\GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'c-blocked' : 'c-ok';
125  // Create links:
126  $info = '';
127  $editUid = $data['row']['uid'];
128  $params = '&edit[pages][' . $editUid . ']=edit';
129  $info .= '<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick(
130  $params, $GLOBALS['BACK_PATH'])
131  ) . '" title="' . $LANG->sL(
132  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_editDefaultLanguagePage'
133  ) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
134  $info .= '<a href="#" onclick="' . htmlspecialchars(
135  'top.loadEditId(' . (int)$data['row']['uid'] . ',"&SET[language]=0"); return false;'
136  ) . '" title="' . $LANG->sL('LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_editPage') . '">' .
137  IconUtility::getSpriteIcon('actions-page-open') . '</a>';
138  $info .= str_replace('###LANG_UID###', '0', $viewPageLink);
139  $info .= '&nbsp;';
140  $info .= \TYPO3\CMS\Core\Utility\GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? '<span title="' . $LANG->sL('LLL:EXT:cms/locallang_tca.xlf:pages.l18n_cfg.I.1', TRUE) . '">D</span>' : '&nbsp;';
141  $info .= \TYPO3\CMS\Core\Utility\GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) ? '<span title="' . $LANG->sL('LLL:EXT:cms/locallang_tca.xlf:pages.l18n_cfg.I.2', TRUE) . '">N</span>' : '&nbsp;';
142  // Put into cell:
143  $tCells[] = '<td class="' . $status . ' c-leftLine">' . $info . '</td>';
144  $tCells[] = '<td class="' . $status . '" title="' . $LANG->sL(
145  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_CEcount'
146  ) . '" align="center">' . $this->getContentElementCount($data['row']['uid'], 0) . '</td>';
147  $modSharedTSconfig = BackendUtility::getModTSconfig($data['row']['uid'], 'mod.SHARED');
148  $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages']) ? \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], TRUE) : array();
149  // Traverse system languages:
150  foreach ($languages as $langRow) {
151  if ($this->pObj->MOD_SETTINGS['lang'] == 0 || (int)$this->pObj->MOD_SETTINGS['lang'] === (int)$langRow['uid']) {
152  $row = $this->getLangStatus($data['row']['uid'], $langRow['uid']);
153  $info = '';
154  if (is_array($row)) {
155  $langRecUids[$langRow['uid']][] = $row['uid'];
156  $status = $row['_HIDDEN'] ? (\TYPO3\CMS\Core\Utility\GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) || \TYPO3\CMS\Core\Utility\GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'c-blocked' : 'c-fallback') : 'c-ok';
158  'pages_language_overlay',
159  $row,
160  array('class' => 'c-recIcon')
161  );
162  $info = $icon . htmlspecialchars(
163  \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['title'], $titleLen)
164  ) . ((string)$row['nav_title'] !== '' ? ' [Nav: <em>' . htmlspecialchars(
165  \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen)
166  ) . '</em>]' : '') . ($row['_COUNT'] > 1 ? '<div>' . $LANG->sL(
167  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_badThingThereAre'
168  ) . '</div>' : '');
169  $tCells[] = '<td class="' . $status . ' c-leftLine">' . $info . '</td>';
170  // Edit whole record:
171  $info = '';
172  $editUid = $row['uid'];
173  $params = '&edit[pages_language_overlay][' . $editUid . ']=edit';
174  $info .= '<a href="#" onclick="' . htmlspecialchars(
175  BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])
176  ) . '" title="' . $LANG->sL(
177  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_editLanguageOverlayRecord'
178  ) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
179  $info .= '<a href="#" onclick="' . htmlspecialchars(
180  'top.loadEditId(' . (int)$data['row']['uid'] . ',"&SET[language]=' . $langRow['uid'] . '"); return false;'
181  ) . '" title="' . $LANG->sL(
182  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_editPageLang'
183  ) . '">' . IconUtility::getSpriteIcon('actions-page-open') . '</a>';
184  $info .= str_replace('###LANG_UID###', $langRow['uid'], $viewPageLink);
185  $tCells[] = '<td class="' . $status . '">' . $info . '</td>';
186  $tCells[] = '<td class="' . $status . '" title="' . $LANG->sL(
187  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_CEcount'
188  ) . '" align="center">' . $this->getContentElementCount($data['row']['uid'], $langRow['uid']) . '</td>';
189  } else {
190  if (in_array($langRow['uid'], $disableLanguages)) {
191  // Language has been disabled for this page
192  $status = 'c-blocked';
193  $info = '';
194  } else {
195  $status = \TYPO3\CMS\Core\Utility\GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) || \TYPO3\CMS\Core\Utility\GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'c-blocked' : 'c-fallback';
196  $info = '<input type="checkbox" name="newOL[' . $langRow['uid'] . '][' . $data['row']['uid'] . ']" value="1" />';
197  $newOL_js[$langRow['uid']] .= '
198  +(document.webinfoForm[\'newOL[' . $langRow['uid'] . '][' . $data['row']['uid'] . ']\'].checked ? \'&edit[pages_language_overlay][' . $data['row']['uid'] . ']=new\' : \'\')
199  ';
200  }
201  $tCells[] = '<td class="' . $status . ' c-leftLine">&nbsp;</td>';
202  $tCells[] = '<td class="' . $status . '">&nbsp;</td>';
203  $tCells[] = '<td class="' . $status . '">' . $info . '</td>';
204  }
205  }
206  }
207  $output .= '
208  <tr class="bgColor4">
209  ' . implode('
210  ', $tCells) . '
211  </tr>';
212  }
213  // Put together HEADER:
214  $tCells = array();
215  $tCells[] = '<td>' . $LANG->sL('LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_page') . ':</td>';
216  if (is_array($langRecUids[0])) {
217  $params = '&edit[pages][' . implode(',', $langRecUids[0]) . ']=edit&columnsOnly=title,nav_title,l18n_cfg,hidden';
218  $editIco = '<a href="#" onclick="' . htmlspecialchars(
219  BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])
220  ) . '" title="' . $LANG->sL(
221  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_editPageProperties'
222  ) . '">' . IconUtility::getSpriteIcon('actions-document-new') . '</a>';
223  } else {
224  $editIco = '';
225  }
226  $tCells[] = '<td class="c-leftLine" colspan="2">' . $LANG->sL(
227  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_default'
228  ) . ':' . $editIco . '</td>';
229  foreach ($languages as $langRow) {
230  if ($this->pObj->MOD_SETTINGS['lang'] == 0 || (int)$this->pObj->MOD_SETTINGS['lang'] === (int)$langRow['uid']) {
231  // Title:
232  $tCells[] = '<td class="c-leftLine">' . htmlspecialchars($langRow['title']) . '</td>';
233  // Edit language overlay records:
234  if (is_array($langRecUids[$langRow['uid']])) {
235  $params = '&edit[pages_language_overlay][' .
236  implode(',', $langRecUids[$langRow['uid']]) .
237  ']=edit&columnsOnly=title,nav_title,hidden';
238  $tCells[] = '<td><a href="#" onclick="' . htmlspecialchars(
239  BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])
240  ) . '" title="' . $LANG->sL(
241  'LLL:EXT:cms/web_info/locallang.xlf:lang_renderl10n_editLangOverlays'
242  ) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a></td>';
243  } else {
244  $tCells[] = '<td>&nbsp;</td>';
245  }
246  // Create new overlay records:
247  $params = '\'' .
248  $newOL_js[$langRow['uid']] .
249  '+\'&columnsOnly=title,hidden,sys_language_uid&defVals[pages_language_overlay][sys_language_uid]=' .
250  $langRow['uid'];
251  $tCells[] = '<td><a href="#" onclick="' . htmlspecialchars(
252  BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])
253  ) . '" title="' . $LANG->sL(
254  'LLL:EXT:cms/web_info/locallang.xlf:lang_getlangsta_createNewTranslationHeaders'
255  ) . '">' . IconUtility::getSpriteIcon('actions-document-new') . '</a></td>';
256  }
257  }
258  $output = '
259  <tr class="t3-row-header">
260  ' . implode('
261  ', $tCells) . '
262  </tr>' . $output;
263  $output = '
264 
265  <table border="0" cellspacing="0" cellpadding="0" id="langTable" class="typo3-dblist">' . $output . '
266  </table>';
267  return $output;
268  }
269 
276  public function getSystemLanguages() {
277  if (!$GLOBALS['BE_USER']->user['admin'] && strlen($GLOBALS['BE_USER']->groupData['allowed_languages'])) {
278  $allowed_languages = array_flip(explode(',', $GLOBALS['BE_USER']->groupData['allowed_languages']));
279  }
280  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_language', '1=1' . BackendUtility::deleteClause('sys_language'));
281  $outputArray = array();
282  while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
283  if (is_array($allowed_languages) && count($allowed_languages)) {
284  if (isset($allowed_languages[$row['uid']])) {
285  $outputArray[] = $row;
286  }
287  } else {
288  $outputArray[] = $row;
289  }
290  }
291  return $outputArray;
292  }
293 
302  public function getLangStatus($pageId, $langId) {
303  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
304  '*',
305  'pages_language_overlay',
306  'pid=' . (int)$pageId .
307  ' AND sys_language_uid=' . (int)$langId .
308  BackendUtility::deleteClause('pages_language_overlay') .
309  BackendUtility::versioningPlaceholderClause('pages_language_overlay')
310  );
311  $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
312  BackendUtility::workspaceOL('pages_language_overlay', $row);
313  if (is_array($row)) {
314  $row['_COUNT'] = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
315  $row['_HIDDEN'] = $row['hidden'] || (int)$row['endtime'] > 0 && (int)$row['endtime'] < $GLOBALS['EXEC_TIME'] || $GLOBALS['EXEC_TIME'] < (int)$row['starttime'];
316  }
317  return $row;
318  }
319 
328  public function getContentElementCount($pageId, $sysLang) {
329  $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'tt_content', 'pid=' . (int)$pageId . ' AND sys_language_uid=' . (int)$sysLang . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content'));
330  return $count ?: '-';
331  }
332 
333 }
static getRecordWSOL($table, $uid, $fields=' *', $where='', $useDeleteClause=TRUE, $unsetMovePointers=FALSE)
static editOnClick($params, $backPath='', $requestUri='')
static workspaceOL($table, &$row, $wsid=-99, $unsetMovePointers=FALSE)
static cshItem($table, $field, $BACK_PATH, $wrap='', $onlyIconMode=FALSE, $styleAttrib='')
static hideIfDefaultLanguage($localizationConfiguration)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static hideIfNotTranslated($l18n_cfg_fieldValue)
static viewOnClick($pageUid, $backPath='', $rootLine='', $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=TRUE)
static getSpriteIconForRecord($table, array $row, array $options=array())
$BACK_PATH
Definition: conf.php:3
static getSpriteIcon($iconName, array $options=array(), array $overlays=array())
static getFuncMenu($mainParams, $elementName, $currentValue, $menuItems, $script='', $addparams='')
static fixed_lgd_cs($string, $chars, $appendString='...')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
$SOBE
Definition: db_layout.php:121
static deleteClause($table, $tableAlias='')