TYPO3 CMS  TYPO3_6-2
BackendConfigurationManager.php
Go to the documentation of this file.
1 <?php
3 
20 
27  protected $queryGenerator;
28 
32  protected $typoScriptSetupCache = array();
33 
38  protected $currentPageId;
39 
45  public function getTypoScriptSetup() {
46  $pageId = $this->getCurrentPageId();
47 
48  if (!array_key_exists($pageId, $this->typoScriptSetupCache)) {
50  $template = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\TemplateService');
51  // do not log time-performance information
52  $template->tt_track = 0;
53  // Explicitly trigger processing of extension static files
54  $template->setProcessExtensionStatics(TRUE);
55  $template->init();
56  // Get the root line
57  $rootline = array();
58  if ($pageId > 0) {
60  $sysPage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
61  // Get the rootline for the current page
62  $rootline = $sysPage->getRootLine($pageId, '', TRUE);
63  }
64  // This generates the constants/config + hierarchy info for the template.
65  $template->runThroughTemplates($rootline, 0);
66  $template->generateConfig();
67  $this->typoScriptSetupCache[$pageId] = $template->setup;
68  }
69  return $this->typoScriptSetupCache[$pageId];
70  }
71 
80  protected function getPluginConfiguration($extensionName, $pluginName = NULL) {
81  $setup = $this->getTypoScriptSetup();
82  $pluginConfiguration = array();
83  if (is_array($setup['module.']['tx_' . strtolower($extensionName) . '.'])) {
84  $pluginConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . strtolower($extensionName) . '.']);
85  }
86  if ($pluginName !== NULL) {
87  $pluginSignature = strtolower($extensionName . '_' . $pluginName);
88  if (is_array($setup['module.']['tx_' . $pluginSignature . '.'])) {
89  $overruleConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . $pluginSignature . '.']);
90  \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($pluginConfiguration, $overruleConfiguration);
91  }
92  }
93  return $pluginConfiguration;
94  }
95 
108  $switchableControllerActions = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'];
109  if (!is_array($switchableControllerActions)) {
110  $switchableControllerActions = array();
111  }
112  return $switchableControllerActions;
113  }
114 
121  protected function getCurrentPageId() {
122  if ($this->currentPageId !== NULL) {
123  return $this->currentPageId;
124  }
125 
126  $this->currentPageId = $this->getCurrentPageIdFromGetPostData() ?: $this->getCurrentPageIdFromCurrentSiteRoot();
127  $this->currentPageId = $this->currentPageId ?: $this->getCurrentPageIdFromRootTemplate();
128  $this->currentPageId = $this->currentPageId ?: self::DEFAULT_BACKEND_STORAGE_PID;
129 
130  return $this->currentPageId;
131  }
132 
138  protected function getCurrentPageIdFromGetPostData() {
140  }
141 
147  protected function getCurrentPageIdFromCurrentSiteRoot() {
148  $rootPage = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
149  'uid', 'pages', 'deleted=0 AND hidden=0 AND is_siteroot=1', '', 'sorting'
150  );
151  if (empty($rootPage)) {
152  return 0;
153  }
154 
155  return (int)$rootPage['uid'];
156  }
157 
163  protected function getCurrentPageIdFromRootTemplate() {
164  $rootTemplate = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
165  'pid', 'sys_template', 'deleted=0 AND hidden=0 AND root=1', '', 'crdate'
166  );
167  if (empty($rootTemplate)) {
168  return 0;
169  }
170 
171  return (int)$rootTemplate['pid'];
172  }
173 
179  public function getDefaultBackendStoragePid() {
180  return $this->getCurrentPageId();
181  }
182 
191  protected function getContextSpecificFrameworkConfiguration(array $frameworkConfiguration) {
192  if (!isset($frameworkConfiguration['mvc']['requestHandlers'])) {
193  $frameworkConfiguration['mvc']['requestHandlers'] = array(
194  'TYPO3\\CMS\\Extbase\\Mvc\\Web\\FrontendRequestHandler' => 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\FrontendRequestHandler',
195  'TYPO3\\CMS\\Extbase\\Mvc\\Web\\BackendRequestHandler' => 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\BackendRequestHandler'
196  );
197  }
198  return $frameworkConfiguration;
199  }
200 
201 
209  protected function getRecursiveStoragePids($storagePid, $recursionDepth = 0) {
210  if ($recursionDepth <= 0) {
211  return $storagePid;
212  }
213 
214  $recursiveStoragePids = '';
215  $storagePids = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $storagePid);
216  foreach ($storagePids as $startPid) {
217  $pids = $this->queryGenerator->getTreeList($startPid, $recursionDepth, 0, 1);
218  if (strlen($pids) > 0) {
219  $recursiveStoragePids .= $pids . ',';
220  }
221  }
222 
223  return rtrim($recursiveStoragePids, ',');
224  }
225 
226 }
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=TRUE, $includeEmptyValues=TRUE, $enableUnsetFeature=TRUE)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]