コード例 #1
0
 /**
  * If the select field is build by a foreign_table the related UIDs
  * will be returned.
  *
  * Otherwise the label of the currently selected value will be written
  * to the alternativeFieldValue class property.
  *
  * @param array $fieldConfig The "config" section of the TCA for the current select field.
  * @param string $fieldName The name of the select field.
  * @param string $value The current value in the local record, usually a comma separated list of selected values.
  * @return array Array of related UIDs.
  */
 protected function getRelatedSelectFieldUids(array $fieldConfig, $fieldName, $value)
 {
     $relatedUids = array();
     $isTraversable = FALSE;
     if (isset($fieldConfig['foreign_table'])) {
         $isTraversable = TRUE;
         // if a foreign_table is used we pre-filter the records for performance
         $fieldConfig['foreign_table_where'] .= ' AND ' . $fieldConfig['foreign_table'] . '.uid IN (' . $value . ')';
     }
     $PA = array();
     $PA['fieldConf']['config'] = $fieldConfig;
     $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type'];
     $PA['fieldTSConfig'] = $this->formEngine->setTSconfig($this->currentTable, $this->currentRow, $fieldName);
     $PA['fieldConf']['config'] = $this->formEngine->overrideFieldConf($PA['fieldConf']['config'], $PA['fieldTSConfig']);
     $selectItemArray = $this->formEngine->getSelectItems($this->currentTable, $fieldName, $this->currentRow, $PA);
     if ($isTraversable && count($selectItemArray)) {
         $this->currentTable = $fieldConfig['foreign_table'];
         $relatedUids = $this->getSelectedValuesFromSelectItemArray($selectItemArray, $value);
     } else {
         $selectedLabels = $this->getSelectedValuesFromSelectItemArray($selectItemArray, $value, 1, TRUE);
         if (count($selectedLabels) === 1) {
             $this->alternativeFieldValue = $selectedLabels[0];
             $this->forceAlternativeFieldValueUse = TRUE;
         }
     }
     return $relatedUids;
 }
コード例 #2
0
 /**
  * Convert the DOM object-id of an inline container to an array.
  * The object-id could look like 'data-parentPageId-tx_mmftest_company-1-employees'.
  * The result is written to $this->inlineStructure.
  * There are two keys:
  * - 'stable': Containing full qualified identifiers (table, uid and field)
  * - 'unstable': Containting partly filled data (e.g. only table and possibly field)
  *
  * @param string $domObjectId The DOM object-id
  * @param boolean $loadConfig Load the TCA configuration for that level (default: TRUE)
  * @return void
  * @todo Define visibility
  */
 public function parseStructureString($string, $loadConfig = TRUE)
 {
     $unstable = array();
     $vector = array('table', 'uid', 'field');
     $pattern = '/^' . $this->prependNaming . self::Structure_Separator . '(.+?)' . self::Structure_Separator . '(.+)$/';
     if (preg_match($pattern, $string, $match)) {
         $this->inlineFirstPid = $match[1];
         $parts = explode(self::Structure_Separator, $match[2]);
         $partsCnt = count($parts);
         for ($i = 0; $i < $partsCnt; $i++) {
             if ($i > 0 && $i % 3 == 0) {
                 // Load the TCA configuration of the table field and store it in the stack
                 if ($loadConfig) {
                     \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($unstable['table']);
                     $unstable['config'] = $GLOBALS['TCA'][$unstable['table']]['columns'][$unstable['field']]['config'];
                     // Fetch TSconfig:
                     $TSconfig = $this->fObj->setTSconfig($unstable['table'], array('uid' => $unstable['uid'], 'pid' => $this->inlineFirstPid), $unstable['field']);
                     // Override TCA field config by TSconfig:
                     if (!$TSconfig['disabled']) {
                         $unstable['config'] = $this->fObj->overrideFieldConf($unstable['config'], $TSconfig);
                     }
                     $unstable['localizationMode'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getInlineLocalizationMode($unstable['table'], $unstable['config']);
                 }
                 $this->inlineStructure['stable'][] = $unstable;
                 $unstable = array();
             }
             $unstable[$vector[$i % 3]] = $parts[$i];
         }
         $this->updateStructureNames();
         if (count($unstable)) {
             $this->inlineStructure['unstable'] = $unstable;
         }
     }
 }
コード例 #3
0
 /**
  * Convert the DOM object-id of an inline container to an array.
  * The object-id could look like 'data-parentPageId-tx_mmftest_company-1-employees'.
  * The result is written to $this->inlineStructure.
  * There are two keys:
  * - 'stable': Containing full qualified identifiers (table, uid and field)
  * - 'unstable': Containting partly filled data (e.g. only table and possibly field)
  *
  * @param string $domObjectId The DOM object-id
  * @param boolean $loadConfig Load the TCA configuration for that level (default: TRUE)
  * @return void
  * @todo Define visibility
  */
 public function parseStructureString($string, $loadConfig = TRUE)
 {
     $unstable = array();
     $vector = array('table', 'uid', 'field');
     // Substitute FlexForm additon and make parsing a bit easier
     $string = str_replace(self::FlexForm_Separator, self::FlexForm_Substitute, $string);
     // The starting pattern of an object identifer (e.g. "data-<firstPidValue>-<anything>)
     $pattern = '/^' . $this->prependNaming . self::Structure_Separator . '(.+?)' . self::Structure_Separator . '(.+)$/';
     if (preg_match($pattern, $string, $match)) {
         $this->inlineFirstPid = $match[1];
         $parts = explode(self::Structure_Separator, $match[2]);
         $partsCnt = count($parts);
         for ($i = 0; $i < $partsCnt; $i++) {
             if ($i > 0 && $i % 3 == 0) {
                 // Load the TCA configuration of the table field and store it in the stack
                 if ($loadConfig) {
                     \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($unstable['table']);
                     $unstable['config'] = $GLOBALS['TCA'][$unstable['table']]['columns'][$unstable['field']]['config'];
                     // Fetch TSconfig:
                     $TSconfig = $this->fObj->setTSconfig($unstable['table'], array('uid' => $unstable['uid'], 'pid' => $this->inlineFirstPid), $unstable['field']);
                     // Override TCA field config by TSconfig:
                     if (!$TSconfig['disabled']) {
                         $unstable['config'] = $this->fObj->overrideFieldConf($unstable['config'], $TSconfig);
                     }
                     $unstable['localizationMode'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getInlineLocalizationMode($unstable['table'], $unstable['config']);
                 }
                 // Extract FlexForm from field part (if any)
                 if (strpos($unstable['field'], self::FlexForm_Substitute) !== FALSE) {
                     $fieldParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(self::FlexForm_Substitute, $unstable['field']);
                     $unstable['field'] = array_shift($fieldParts);
                     // FlexForm parts start with data:
                     if (count($fieldParts) > 0 && $fieldParts[0] === 'data') {
                         $unstable['flexform'] = $fieldParts;
                     }
                 }
                 $this->inlineStructure['stable'][] = $unstable;
                 $unstable = array();
             }
             $unstable[$vector[$i % 3]] = $parts[$i];
         }
         $this->updateStructureNames();
         if (count($unstable)) {
             $this->inlineStructure['unstable'] = $unstable;
         }
     }
 }