2 namespace TYPO3\CMS\Backend\Controller\Page;
54 if (!isset($params[
'pageId'], $params[
'colPos'], $params[
'languageId'])) {
59 $pageId = (int)$params[
'pageId'];
60 $colPos = (int)$params[
'colPos'];
61 $languageId = (int)$params[
'languageId'];
67 $systemLanguages = $translationProvider->getSystemLanguages($pageId);
69 $availableLanguages = [];
70 $availableLanguages[0] = $systemLanguages[0];
76 $elementsInColumnCount = $databaseConnection->exec_SELECTcountRows(
79 'tt_content.sys_language_uid=' . (
int)$languageId
80 .
' AND tt_content.colPos = ' . (
int)$colPos
81 .
' AND tt_content.pid=' . (
int)$pageId
84 $additionalWhere =
'';
85 if (!$backendUser->isAdmin()) {
86 $additionalWhere .=
' AND sys_language.hidden=0';
88 if (!empty($backendUser->user[
'allowed_languages'])) {
89 $additionalWhere .=
' AND sys_language.uid IN(' . $databaseConnection->cleanIntList($backendUser->user[
'allowed_languages']) .
')';
92 if ($elementsInColumnCount === 0) {
93 $res = $databaseConnection->exec_SELECTquery(
95 'tt_content,sys_language',
96 'tt_content.sys_language_uid=sys_language.uid'
97 .
' AND tt_content.colPos = ' . (
int)$colPos
98 .
' AND tt_content.pid=' . (
int)$pageId
99 .
' AND sys_language.uid <> ' . (
int)$languageId
102 'tt_content.sys_language_uid',
105 while ($row = $databaseConnection->sql_fetch_assoc($res)) {
106 if (isset($systemLanguages[$row[
'uid']])) {
107 $availableLanguages[] = $systemLanguages[$row[
'uid']];
110 $databaseConnection->sql_free_result($res);
114 foreach ($availableLanguages as &$language) {
115 if ($language[
'flagIcon'] ===
'empty-empty') {
116 $language[
'flagIcon'] =
'';
118 $language[
'flagIcon'] = $this->iconFactory->getIcon($language[
'flagIcon'],
Icon::SIZE_SMALL)->render();
122 $response->
getBody()->write(json_encode($availableLanguages));
136 if (!isset($params[
'pageId'], $params[
'colPos'], $params[
'languageId'])) {
144 while ($row = $databaseConnection->sql_fetch_assoc($res)) {
146 'icon' => $this->iconFactory->getIconForRecord(
'tt_content', $row,
Icon::SIZE_SMALL)->render(),
147 'title' => $row[
$GLOBALS[
'TCA'][
'tt_content'][
'ctrl'][
'label']],
151 $databaseConnection->sql_free_result($res);
153 $response->
getBody()->write(json_encode($records));
165 if (!isset($params[
'pageId'], $params[
'colPos'], $params[
'languageId'])) {
170 $pageId = (int)$params[
'pageId'];
171 $colPos = (int)$params[
'colPos'];
172 $languageId = (int)$params[
'languageId'];
177 while ($row = $databaseConnection->sql_fetch_assoc($res)) {
178 $uids[] = (int)$row[
'uid'];
180 $databaseConnection->sql_free_result($res);
182 $response->
getBody()->write(json_encode($uids));
194 if (!isset($params[
'pageId'], $params[
'srcLanguageId'], $params[
'destLanguageId'], $params[
'action'], $params[
'uidList'])) {
199 if ($params[
'action'] !==
'copyFromLanguage' && $params[
'action'] !==
'localize') {
200 $response->
getBody()->write(
'Invalid action "' . $params[
'action'] .
'" called.');
205 $pageId = (int)$params[
'pageId'];
206 $srcLanguageId = (int)$params[
'srcLanguageId'];
207 $destLanguageId = (int)$params[
'destLanguageId'];
208 $params[
'uidList'] = array_reverse($params[
'uidList']);
215 for ($i = 0, $count = count($params[
'uidList']); $i < $count; ++$i) {
216 $currentUid = $params[
'uidList'][$i];
218 if ($params[
'action'] ===
'localize') {
219 if ($srcLanguageId === 0) {
220 $cmd[
'tt_content'][$currentUid] = [
221 'localize' => $destLanguageId
224 $cmd[
'tt_content'][$currentUid] = [
229 'sys_language_uid' => $destLanguageId
235 $cmd[
'tt_content'][$currentUid] = [
240 'sys_language_uid' => $destLanguageId,
250 $dataHandler->start([], $cmd);
251 $dataHandler->process_cmdmap();
253 $response->
getBody()->write(json_encode([]));
271 'tt_content.sys_language_uid=' . (
int)$languageId
272 .
' AND tt_content.colPos = ' . (
int)$colPos
273 .
' AND tt_content.pid=' . (
int)$pageId