FluidTYPO3\Flux\Service\ContentService::moveRecord PHP Method

moveRecord() public method

Move the content element depending on various request/row parameters.
public moveRecord ( array &$row, string &$relativeTo, array $parameters, TYPO3\CMS\Core\DataHandling\DataHandler $tceMain ) : void
$row array The row which may, may not, trigger moving.
$relativeTo string If not-zero moves record to after this UID (negative) or top of this colPos (positive)
$parameters array List of parameters defining the move operation target
$tceMain TYPO3\CMS\Core\DataHandling\DataHandler
return void
    public function moveRecord(array &$row, &$relativeTo, $parameters, DataHandler $tceMain)
    {
        // Note: this condition is here in order to NOT perform any actions if
        // the $relativeTo variable was passed by EXT:gridelements in which case
        // it is invalid (not a negative/positive integer but a string).
        if (FALSE === strpos($relativeTo, 'x')) {
            if (0 - MiscellaneousUtility::UNIQUE_INTEGER_OVERHEAD > $relativeTo) {
                // Fake relative to value - we can get the target from a session variable
                list($parent, $column) = $this->getTargetAreaStoredInSession($relativeTo);
                $row['tx_flux_parent'] = $parent;
                $row['tx_flux_column'] = $column;
                $row['sorting'] = $tceMain->getSortNumber('tt_content', 0, $row['pid']);
            } elseif (0 <= (int) $relativeTo && FALSE === empty($parameters[1])) {
                list($prefix, $column, $prefix2, , , $relativePosition, $relativeUid, $area) = GeneralUtility::trimExplode('-', $parameters[1]);
                $relativeUid = (int) $relativeUid;
                if ('colpos' === $prefix && 'page' === $prefix2) {
                    $row['colPos'] = $column;
                    $row['tx_flux_parent'] = $relativeUid;
                    $row['tx_flux_column'] = $area;
                }
            } elseif (0 > (int) $relativeTo) {
                // inserting a new element after another element. Check column position of that element.
                $relativeToRecord = $this->loadRecordFromDatabase(abs($relativeTo));
                $row['tx_flux_parent'] = $relativeToRecord['tx_flux_parent'];
                $row['tx_flux_column'] = $relativeToRecord['tx_flux_column'];
                $row['colPos'] = $relativeToRecord['colPos'];
                $row['sorting'] = $tceMain->resorting('tt_content', $relativeToRecord['pid'], 'sorting', abs($relativeTo));
            } elseif (0 < (int) $relativeTo) {
                // moving to first position in colPos, means that $relativeTo is the pid of the containing page
                $row['sorting'] = $tceMain->getSortNumber('tt_content', 0, $relativeTo);
                $row['tx_flux_parent'] = NULL;
                $row['tx_flux_column'] = NULL;
            } else {
                $row['tx_flux_parent'] = NULL;
                $row['tx_flux_column'] = NULL;
            }
        } else {
            // $relativeTo variable was passed by EXT:gridelements
            $row['tx_flux_parent'] = NULL;
            $row['tx_flux_column'] = NULL;
        }
        if (0 < $row['tx_flux_parent']) {
            $row['colPos'] = self::COLPOS_FLUXCONTENT;
        }
        $this->updateRecordInDatabase($row);
        $this->updateMovePlaceholder($row);
    }

Usage Example

Beispiel #1
0
 /**
  * Post-process a command executed on a record form the table this ConfigurationProvider
  * is attached to.
  *
  * @param string $command
  * @param integer $id
  * @param array $row
  * @param integer $relativeTo
  * @param DataHandler $reference
  * @return void
  */
 public function postProcessCommand($command, $id, array &$row, &$relativeTo, DataHandler $reference)
 {
     if (TRUE === self::shouldCallWithClassName(__CLASS__, __FUNCTION__, $id)) {
         parent::postProcessCommand($command, $id, $row, $relativeTo, $reference);
         $pasteCommands = array('copy', 'move');
         if (TRUE === in_array($command, $pasteCommands)) {
             $callback = $this->getCallbackCommand();
             if (TRUE === isset($callback['paste'])) {
                 $pasteCommand = $callback['paste'];
                 $parameters = explode('|', $pasteCommand);
                 $this->contentService->pasteAfter($command, $row, $parameters, $reference);
             } else {
                 $moveData = $this->getMoveData();
                 $this->contentService->moveRecord($row, $relativeTo, $moveData, $reference);
             }
         }
         self::trackMethodCallWithClassName(__CLASS__, __FUNCTION__, $id);
     }
 }
All Usage Examples Of FluidTYPO3\Flux\Service\ContentService::moveRecord