Code Duplication    Length = 44-46 lines in 3 locations

typo3/sysext/backend/Classes/View/PageLayoutView.php 1 location

@@ 3853-3896 (lines=44) @@
3850
     *
3851
     * @param string $justLocalized String with table, orig uid and language separated by ":
3852
     */
3853
    public function localizationRedirect($justLocalized)
3854
    {
3855
        list($table, $orig_uid, $language) = explode(':', $justLocalized);
3856
        if ($GLOBALS['TCA'][$table]
3857
            && $GLOBALS['TCA'][$table]['ctrl']['languageField']
3858
            && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
3859
        ) {
3860
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
3861
            $queryBuilder->getRestrictions()
3862
                ->removeAll()
3863
                ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
3864
                ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
3865
3866
            $localizedRecordUid = $queryBuilder->select('uid')
3867
                ->from($table)
3868
                ->where(
3869
                    $queryBuilder->expr()->eq(
3870
                        $GLOBALS['TCA'][$table]['ctrl']['languageField'],
3871
                        $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)
3872
                    ),
3873
                    $queryBuilder->expr()->eq(
3874
                        $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'],
3875
                        $queryBuilder->createNamedParameter($orig_uid, \PDO::PARAM_INT)
3876
                    )
3877
                )
3878
                ->setMaxResults(1)
3879
                ->execute()
3880
                ->fetchColumn();
3881
3882
            if ($localizedRecordUid !== false) {
3883
                // Create parameters and finally run the classic page module for creating a new page translation
3884
                $url = $this->listURL();
3885
                $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
3886
                $editUserAccountUrl = (string)$uriBuilder->buildUriFromRoute(
3887
                    'record_edit',
3888
                    [
3889
                        'edit[' . $table . '][' . $localizedRecordUid . ']' => 'edit',
3890
                        'returnUrl' => $url
3891
                    ]
3892
                );
3893
                HttpUtility::redirect($editUserAccountUrl);
3894
            }
3895
        }
3896
    }
3897
3898
    /**
3899
     * Set URL parameters to override or add in the listUrl() method.

typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php 1 location

@@ 1301-1345 (lines=45) @@
1298
     * @param string $justLocalized String with table, orig uid and language separated by ":
1299
     * @deprecated since TYPO3 v9, will be removed in TYPO3 v10
1300
     */
1301
    public function localizationRedirect($justLocalized)
1302
    {
1303
        list($table, $orig_uid, $language) = explode(':', $justLocalized);
1304
        if ($GLOBALS['TCA'][$table]
1305
            && $GLOBALS['TCA'][$table]['ctrl']['languageField']
1306
            && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
1307
        ) {
1308
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
1309
            $queryBuilder->getRestrictions()
1310
                ->removeAll()
1311
                ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
1312
                ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
1313
1314
            $localizedRecordUid = $queryBuilder->select('uid')
1315
                ->from($table)
1316
                ->where(
1317
                    $queryBuilder->expr()->eq(
1318
                        $GLOBALS['TCA'][$table]['ctrl']['languageField'],
1319
                        $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)
1320
                    ),
1321
                    $queryBuilder->expr()->eq(
1322
                        $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'],
1323
                        $queryBuilder->createNamedParameter($orig_uid, \PDO::PARAM_INT)
1324
                    )
1325
                )
1326
                ->setMaxResults(1)
1327
                ->execute()
1328
                ->fetchColumn();
1329
1330
            if ($localizedRecordUid !== false) {
1331
                // Create parameters and finally run the classic page module for creating a new page translation
1332
                $url = $this->listURL();
1333
                /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
1334
                $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
1335
                $editUserAccountUrl = (string)$uriBuilder->buildUriFromRoute(
1336
                    'record_edit',
1337
                    [
1338
                        'edit[' . $table . '][' . $localizedRecordUid . ']' => 'edit',
1339
                        'returnUrl' => $url
1340
                    ]
1341
                );
1342
                HttpUtility::redirect($editUserAccountUrl);
1343
            }
1344
        }
1345
    }
1346
1347
    /**
1348
     * Set URL parameters to override or add in the listUrl() method.

typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php 1 location

@@ 3726-3771 (lines=46) @@
3723
     *
3724
     * @param string $justLocalized String with table, orig uid and language separated by ":
3725
     */
3726
    public function localizationRedirect($justLocalized)
3727
    {
3728
        list($table, $orig_uid, $language) = explode(':', $justLocalized);
3729
        if ($GLOBALS['TCA'][$table]
3730
            && $GLOBALS['TCA'][$table]['ctrl']['languageField']
3731
            && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
3732
        ) {
3733
            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
3734
            $queryBuilder->getRestrictions()
3735
                ->removeAll()
3736
                ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
3737
                ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
3738
3739
            $localizedRecordUid = $queryBuilder->select('uid')
3740
                ->from($table)
3741
                ->where(
3742
                    $queryBuilder->expr()->eq(
3743
                        $GLOBALS['TCA'][$table]['ctrl']['languageField'],
3744
                        $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)
3745
                    ),
3746
                    $queryBuilder->expr()->eq(
3747
                        $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'],
3748
                        $queryBuilder->createNamedParameter($orig_uid, \PDO::PARAM_INT)
3749
                    )
3750
                )
3751
                ->setMaxResults(1)
3752
                ->execute()
3753
                ->fetchColumn();
3754
3755
            if ($localizedRecordUid !== false) {
3756
                // Create parameters and finally run the classic page module for creating a new page translation
3757
                $url = $this->listURL();
3758
                /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
3759
                $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
3760
3761
                $editUserAccountUrl = (string)$uriBuilder->buildUriFromRoute(
3762
                    'record_edit',
3763
                    [
3764
                        'edit[' . $table . '][' . $localizedRecordUid . ']' => 'edit',
3765
                        'returnUrl' => $url
3766
                    ]
3767
                );
3768
                HttpUtility::redirect($editUserAccountUrl);
3769
            }
3770
        }
3771
    }
3772
3773
    /**
3774
     * Set URL parameters to override or add in the listUrl() method.