2 /***************************************************************
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
26 * A general purpose configuration manager used in backend mode.
29 * @subpackage Configuration
32 class Tx_Extbase_Configuration_BackendConfigurationManager
extends Tx_Extbase_Configuration_AbstractConfigurationManager
{
37 protected $typoScriptSetupCache = NULL;
40 * Returns TypoScript Setup array from current Environment.
42 * @return array the raw TypoScript setup
44 public function getTypoScriptSetup() {
45 if ($this->typoScriptSetupCache
=== NULL) {
46 $template = t3lib_div
::makeInstance('t3lib_TStemplate');
47 // do not log time-performance information
48 $template->tt_track
= 0;
51 $sysPage = t3lib_div
::makeInstance('t3lib_pageSelect');
52 // get the rootline for the current page
53 $rootline = $sysPage->getRootLine($this->getCurrentPageId());
54 // This generates the constants/config + hierarchy info for the template.
55 $template->runThroughTemplates($rootline, 0);
56 $template->generateConfig();
57 $this->typoScriptSetupCache
= $template->setup
;
59 return $this->typoScriptSetupCache
;
63 * Returns the TypoScript configuration found in module.tx_yourextension_yourmodule
64 * merged with the global configuration of your extension from module.tx_yourextension
66 * @param string $extensionName
67 * @param string $pluginName in BE mode this is actually the module signature. But we're using it just like the plugin name in FE
70 protected function getPluginConfiguration($extensionName, $pluginName) {
71 $setup = $this->getTypoScriptSetup();
72 $pluginConfiguration = array();
73 if (is_array($setup['module.']['tx_' . strtolower($extensionName) . '.'])) {
74 $pluginConfiguration = Tx_Extbase_Utility_TypoScript
::convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . strtolower($extensionName) . '.']);
76 $pluginSignature = strtolower($extensionName . '_' . $pluginName);
77 if (is_array($setup['module.']['tx_' . $pluginSignature . '.'])) {
78 $pluginConfiguration = t3lib_div
::array_merge_recursive_overrule($pluginConfiguration, Tx_Extbase_Utility_TypoScript
::convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . $pluginSignature . '.']));
80 return $pluginConfiguration;
84 * Returns the configured controller/action pairs of the specified module in the format
86 * 'Controller1' => array('action1', 'action2'),
87 * 'Controller2' => array('action3', 'action4')
90 * @param string $extensionName
91 * @param string $pluginName in BE mode this is actually the module signature. But we're using it just like the plugin name in FE
94 protected function getSwitchableControllerActions($extensionName, $pluginName) {
95 $switchableControllerActions = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'];
96 if (!is_array($switchableControllerActions)) {
97 $switchableControllerActions = array();
99 return $switchableControllerActions;
103 * Returns the page uid of the current page.
104 * If no page is selected, we'll return the uid of the first root page.
106 * @return integer current page id. If no page is selected current root page id is returned
108 protected function getCurrentPageId() {
109 $pageId = (integer)t3lib_div
::_GP('id');
115 $rootTemplates = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pid', 'sys_template', 'deleted=0 AND hidden=0 AND root=1', '', '', '1');
116 if (count($rootTemplates) > 0) {
117 return $rootTemplates[0]['pid'];
120 // get current site root
121 $rootPages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages', 'deleted=0 AND hidden=0 AND is_siteroot=1', '', '', '1');
122 if (count($rootPages) > 0) {
123 return $rootPages[0]['uid'];
127 return self
::DEFAULT_BACKEND_STORAGE_PID
;
131 * We do not want to override anything in the backend.
134 protected function getContextSpecificFrameworkConfiguration(array $frameworkConfiguration) {
135 return $frameworkConfiguration;