Пример #1
0
 /**
  * Function to set the colPos of an element depending on
  * whether it is a child of a parent container or not
  * will set colPos according to availability of the current grid column of an element
  * 0 = no column at all
  * -1 = grid element column
  * -2 = non used elements column
  * changes are applied to the field array of the parent object by reference
  *
  * @param                                             $status
  * @param    string                                   $table      : The name of the table the data should be saved to
  * @param    int                                      $id         : The uid of the page we are currently working on
  * @param    array                                    $fieldArray : The array of fields and values that have been saved to the datamap
  * @param    \TYPO3\CMS\Core\DataHandling\DataHandler $parentObj  : The parent object that triggered this hook
  *
  * @return   void
  */
 public function processDatamap_postProcessFieldArray($status, $table, $id, array &$fieldArray, \TYPO3\CMS\Core\DataHandling\DataHandler $parentObj)
 {
     $cmd = GeneralUtility::_GET('cmd');
     if (count($cmd) && key($cmd) === 'tt_content' && $status === 'new' && strpos($cmd['tt_content'][key($cmd['tt_content'])]['copy'], 'x') !== FALSE && !$parentObj->isImporting) {
         $positionArray = explode('x', $cmd['tt_content'][key($cmd['tt_content'])]['copy']);
         if ($positionArray[0] < 0) {
             $parentPage = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('pid', 'tt_content', 'uid = ' . abs($positionArray[0]));
             if ($parentPage['pid']) {
                 $pid = $parentPage['pid'];
             }
         } else {
             $pid = (int) $positionArray[0];
         }
         $sortNumber = $parentObj->getSortNumber('tt_content', 0, abs($pid));
         $fieldArray['sorting'] = $sortNumber;
     }
 }
Пример #2
0
 /**
  * Move the content element depending on various request/row parameters.
  *
  * @param array $row The row which may, may not, trigger moving.
  * @param string $relativeTo If not-zero moves record to after this UID (negative) or top of this colPos (positive)
  * @param array $parameters List of parameters defining the move operation target
  * @param DataHandler $tceMain
  * @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;
         } 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);
             // neither change fields tx_flux_column nor tx_flux_parent here!
         } 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);
 }