TYPO3 CMS  TYPO3_6-2
FrontendConfigurationManager.php
Go to the documentation of this file.
1 <?php
3 
22 
27  protected $flexFormService;
28 
34  public function getTypoScriptSetup() {
35  return $GLOBALS['TSFE']->tmpl->setup;
36  }
37 
46  protected function getPluginConfiguration($extensionName, $pluginName = NULL) {
47  $setup = $this->getTypoScriptSetup();
48  $pluginConfiguration = array();
49  if (is_array($setup['plugin.']['tx_' . strtolower($extensionName) . '.'])) {
50  $pluginConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_' . strtolower($extensionName) . '.']);
51  }
52  if ($pluginName !== NULL) {
53  $pluginSignature = strtolower($extensionName . '_' . $pluginName);
54  if (is_array($setup['plugin.']['tx_' . $pluginSignature . '.'])) {
56  $pluginConfiguration,
57  $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_' . $pluginSignature . '.'])
58  );
59  }
60  }
61  return $pluginConfiguration;
62  }
63 
76  $switchableControllerActions = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['plugins'][$pluginName]['controllers'];
77  if (!is_array($switchableControllerActions)) {
78  $switchableControllerActions = array();
79  }
80  return $switchableControllerActions;
81  }
82 
91  protected function getContextSpecificFrameworkConfiguration(array $frameworkConfiguration) {
92  $frameworkConfiguration = $this->overrideStoragePidIfStartingPointIsSet($frameworkConfiguration);
93  $frameworkConfiguration = $this->overrideConfigurationFromPlugin($frameworkConfiguration);
94  $frameworkConfiguration = $this->overrideConfigurationFromFlexForm($frameworkConfiguration);
95  return $frameworkConfiguration;
96  }
97 
105  protected function overrideStoragePidIfStartingPointIsSet(array $frameworkConfiguration) {
106  $pages = $this->contentObject->data['pages'];
107  if (is_string($pages) && strlen($pages) > 0) {
108  $list = array();
109  if ($this->contentObject->data['recursive'] > 0) {
110  $explodedPages = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $pages);
111  foreach ($explodedPages as $pid) {
112  $list[] = $this->contentObject->getTreeList($pid, $this->contentObject->data['recursive']);
113  }
114  }
115  if (count($list) > 0) {
116  $pages = $pages . ',' . implode(',', $list);
117  }
119  'persistence' => array(
120  'storagePid' => $pages
121  )
122  ));
123  }
124  return $frameworkConfiguration;
125  }
126 
133  protected function overrideConfigurationFromPlugin(array $frameworkConfiguration) {
134  $setup = $this->getTypoScriptSetup();
135  $pluginSignature = strtolower($frameworkConfiguration['extensionName'] . '_' . $frameworkConfiguration['pluginName']);
136  $pluginConfiguration = $setup['plugin.']['tx_' . $pluginSignature . '.'];
137  if (is_array($pluginConfiguration)) {
138  $pluginConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($pluginConfiguration);
139  $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $pluginConfiguration, 'settings');
140  $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $pluginConfiguration, 'persistence');
141  $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $pluginConfiguration, 'view');
142  }
143  return $frameworkConfiguration;
144  }
145 
153  protected function overrideConfigurationFromFlexForm(array $frameworkConfiguration) {
154  $flexFormConfiguration = $this->contentObject->data['pi_flexform'];
155  if (is_string($flexFormConfiguration)) {
156  if (strlen($flexFormConfiguration) > 0) {
157  $flexFormConfiguration = $this->flexFormService->convertFlexFormContentToArray($flexFormConfiguration);
158  } else {
159  $flexFormConfiguration = array();
160  }
161  }
162  if (is_array($flexFormConfiguration) && count($flexFormConfiguration)) {
163  $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $flexFormConfiguration, 'settings');
164  $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $flexFormConfiguration, 'persistence');
165  $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $flexFormConfiguration, 'view');
166  $frameworkConfiguration = $this->overrideSwitchableControllerActionsFromFlexForm($frameworkConfiguration, $flexFormConfiguration);
167  }
168  return $frameworkConfiguration;
169  }
170 
179  protected function mergeConfigurationIntoFrameworkConfiguration(array $frameworkConfiguration, array $configuration, $configurationPartName) {
180  if (is_array($configuration[$configurationPartName])) {
181  if (is_array($frameworkConfiguration[$configurationPartName])) {
182  \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($frameworkConfiguration[$configurationPartName], $configuration[$configurationPartName]);
183  } else {
184  $frameworkConfiguration[$configurationPartName] = $configuration[$configurationPartName];
185  }
186  }
187  return $frameworkConfiguration;
188  }
189 
198  protected function overrideSwitchableControllerActionsFromFlexForm(array $frameworkConfiguration, array $flexFormConfiguration) {
199  if (!isset($flexFormConfiguration['switchableControllerActions']) || is_array($flexFormConfiguration['switchableControllerActions'])) {
200  return $frameworkConfiguration;
201  }
202  // As "," is the flexForm field value delimiter, we need to use ";" as in-field delimiter. That's why we need to replace ; by , first.
203  // The expected format is: "Controller1->action2;Controller2->action3;Controller2->action1"
204  $switchableControllerActionPartsFromFlexForm = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', str_replace(';', ',', $flexFormConfiguration['switchableControllerActions']), TRUE);
205  $newSwitchableControllerActionsFromFlexForm = array();
206  foreach ($switchableControllerActionPartsFromFlexForm as $switchableControllerActionPartFromFlexForm) {
207  list($controller, $action) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('->', $switchableControllerActionPartFromFlexForm);
208  if (empty($controller) || empty($action)) {
209  throw new \TYPO3\CMS\Extbase\Configuration\Exception\ParseErrorException('Controller or action were empty when overriding switchableControllerActions from flexForm.', 1257146403);
210  }
211  $newSwitchableControllerActionsFromFlexForm[$controller][] = $action;
212  }
213  if (count($newSwitchableControllerActionsFromFlexForm) > 0) {
214  $this->overrideSwitchableControllerActions($frameworkConfiguration, $newSwitchableControllerActionsFromFlexForm);
215  }
216  return $frameworkConfiguration;
217  }
218 
226  protected function getRecursiveStoragePids($storagePid, $recursionDepth = 0) {
227  if ($recursionDepth <= 0) {
228  return $storagePid;
229  }
230 
231  $recursiveStoragePids = '';
232  $storagePids = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $storagePid);
233  foreach ($storagePids as $startPid) {
234  $pids = $this->getContentObject()->getTreeList($startPid, $recursionDepth, 0);
235  if (strlen($pids) > 0) {
236  $recursiveStoragePids .= $pids . ',';
237  }
238  }
239  return rtrim($recursiveStoragePids, ',');
240  }
241 }
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
overrideSwitchableControllerActionsFromFlexForm(array $frameworkConfiguration, array $flexFormConfiguration)
mergeConfigurationIntoFrameworkConfiguration(array $frameworkConfiguration, array $configuration, $configurationPartName)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
overrideSwitchableControllerActions(array &$frameworkConfiguration, array $switchableControllerActions)