Пример #1
0
 /**
  * Copies all records from tables in $copyTablesArray from page with $old_pid to page with $new_pid
  * Uses raw-copy for the operation (meant for versioning!)
  *
  * @param int $oldPageId Current page id.
  * @param int $newPageId New page id
  * @param array $copyTablesArray Array of tables from which to copy
  * @param DataHandler $tcemainObj TCEmain object
  * @return void
  * @see versionizePages()
  */
 protected function rawCopyPageContent($oldPageId, $newPageId, array $copyTablesArray, DataHandler $tcemainObj)
 {
     if (!$newPageId) {
         return;
     }
     foreach ($copyTablesArray as $table) {
         // all records under the page is copied.
         if ($table && is_array($GLOBALS['TCA'][$table]) && $table !== 'pages') {
             $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, 'pid=' . (int) $oldPageId . $tcemainObj->deleteClause($table));
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
                 // Check, if this record has already been copied by a parent record as relation:
                 if (!$tcemainObj->copyMappingArray[$table][$row['uid']]) {
                     // Copying each of the underlying records (method RAW)
                     $tcemainObj->copyRecord_raw($table, $row['uid'], $newPageId);
                 }
             }
             $GLOBALS['TYPO3_DB']->sql_free_result($mres);
         }
     }
 }
Пример #2
0
 /**
  * Returning uid of previous localized record, if any, for tables with a "sortby" column
  * Used when new localized records are created so that localized records are sorted in the same order as the default language records
  *
  * This is a port from DataHandler::getPreviousLocalizedRecordUid that respects tx_flux_parent and tx_flux_column!
  *
  * @param integer $uid Uid of default language record
  * @param integer $language Language of localization
  * @param TYPO3\CMS\Core\DataHandling\DataHandler $datahandler
  * @return integer uid of record after which the localized record should be inserted
  */
 protected function getPreviousLocalizedRecordUid($uid, $language, DataHandler $reference)
 {
     $table = 'tt_content';
     $previousLocalizedRecordUid = $uid;
     $sortRow = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
     $select = $sortRow . ',pid,uid,colPos,tx_flux_parent,tx_flux_column';
     // Get the sort value of the default language record
     $row = BackendUtility::getRecord($table, $uid, $select);
     if (is_array($row)) {
         // Find the previous record in default language on the same page
         $where = sprintf('pid=%d AND sys_language_uid=0 AND %s < %d', (int) $row['pid'], $sortRow, (int) $row[$sortRow]);
         // Respect the colPos for content elements
         if ($table === 'tt_content') {
             $where .= sprintf(' AND colPos=%d AND tx_flux_column=\'%s\' AND tx_flux_parent=%d', (int) $row['colPos'], $row['tx_flux_column'], (int) $row['tx_flux_parent']);
         }
         $where .= $reference->deleteClause($table);
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, '', $sortRow . ' DESC', '1');
         // If there is an element, find its localized record in specified localization language
         if ($previousRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $previousLocalizedRecord = BackendUtility::getRecordLocalization($table, $previousRow['uid'], $language);
             if (is_array($previousLocalizedRecord[0])) {
                 $previousLocalizedRecordUid = $previousLocalizedRecord[0]['uid'];
             }
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
     }
     return $previousLocalizedRecordUid;
 }