TYPO3 CMS  TYPO3_6-2
EditController.php
Go to the documentation of this file.
1 <?php
3 
20 
27 
28  // Internal, static: GPvars
29  // Wizard parameters, coming from TCEforms linking to the wizard.
33  public $P;
34 
35  // Boolean; if set, the window will be closed by JavaScript
39  public $doClose;
40 
44  public function __construct() {
45  $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xlf');
46  $GLOBALS['SOBE'] = $this;
47 
48  $this->init();
49  }
50 
56  protected function init() {
57  $this->P = GeneralUtility::_GP('P');
58  // Used for the return URL to alt_doc.php so that we can close the window.
59  $this->doClose = GeneralUtility::_GP('doClose');
60  }
61 
68  public function main() {
69  if ($this->doClose) {
70  $this->closeWindow();
71  } else {
72  // Initialize:
73  $table = $this->P['table'];
74  $field = $this->P['field'];
75  $config = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
76  $fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table'];
77  // Detecting the various allowed field type setups and acting accordingly.
78  if (is_array($config) && $config['type'] == 'select' && !$config['MM'] && $config['maxitems'] <= 1 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->P['currentValue']) && $this->P['currentValue'] && $fTable) {
79  // SINGLE value:
80  $redirectUrl = 'alt_doc.php?returnUrl=' . rawurlencode(BackendUtility::getModuleUrl('wizard_edit', array('doClose' => 1))) . '&edit[' . $fTable . '][' . $this->P['currentValue'] . ']=edit';
81  HttpUtility::redirect($redirectUrl);
82  } elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] == 'select' && $config['foreign_table'] || $config['type'] == 'group' && $config['internal_type'] == 'db')) {
83  // MULTIPLE VALUES:
84  // Init settings:
85  $allowedTables = $config['type'] == 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table'];
86  $prependName = 1;
87  $params = '';
88  // Selecting selected values into an array:
89  $dbAnalysis = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
90  $dbAnalysis->start($this->P['currentSelectedValues'], $allowedTables);
91  $value = $dbAnalysis->getValueArray($prependName);
92  // Traverse that array and make parameters for alt_doc.php:
93  foreach ($value as $rec) {
94  $recTableUidParts = GeneralUtility::revExplode('_', $rec, 2);
95  $params .= '&edit[' . $recTableUidParts[0] . '][' . $recTableUidParts[1] . ']=edit';
96  }
97  // Redirect to alt_doc.php:
98  HttpUtility::redirect('alt_doc.php?returnUrl=' . rawurlencode(BackendUtility::getModuleUrl('wizard_edit', array('doClose' => 1))) . $params);
99  } else {
100  $this->closeWindow();
101  }
102  }
103  }
104 
111  public function closeWindow() {
112  echo '<script language="javascript" type="text/javascript">close();</script>';
113  die;
114  }
115 
116 }
die
Definition: index.php:6
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:76
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static revExplode($delimiter, $string, $count=0)