[FEATURE] Introduce .typoscript file extension
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Step / DefaultConfiguration.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Step;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Core\Bootstrap;
18 use TYPO3\CMS\Core\Database\ConnectionPool;
19 use TYPO3\CMS\Core\Registry;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21 use TYPO3\CMS\Install\Service\EnableFileService;
22
23 /**
24 * Set production defaults
25 */
26 class DefaultConfiguration extends AbstractStepAction
27 {
28 /**
29 * Set defaults of auto configuration, mark installation as completed
30 *
31 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
32 */
33 public function execute()
34 {
35 /** @var \TYPO3\CMS\Install\Configuration\FeatureManager $featureManager */
36 $featureManager = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Configuration\FeatureManager::class);
37 // Get best matching configuration presets
38 $configurationValues = $featureManager->getBestMatchingConfigurationForAllFeatures();
39 $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
40
41 // let the admin user redirect to the distributions page on first login
42 switch ($this->postValues['values']['sitesetup']) {
43 // Update the admin backend user to show the distribution management on login
44 case 'loaddistribution':
45 $adminUserFirstLogin = [
46 'startModuleOnFirstLogin' => 'tools_ExtensionmanagerExtensionmanager->tx_extensionmanager_tools_extensionmanagerextensionmanager%5Baction%5D=distributions&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bcontroller%5D=List',
47 'ucSetByInstallTool' => '1',
48 ];
49 $connectionPool->getConnectionForTable('be_users')->update(
50 'be_users',
51 ['uc' => serialize($adminUserFirstLogin)],
52 ['admin' => 1]
53 );
54 break;
55
56 // Create a page with UID 1 and PID1 and fluid_styled_content for page TS config, respect ownership
57 case 'createsite':
58 $databaseConnectionForPages = $connectionPool->getConnectionForTable('pages');
59 $databaseConnectionForPages->insert(
60 'pages',
61 [
62 'pid' => 0,
63 'crdate' => time(),
64 'cruser_id' => 1,
65 'tstamp' => time(),
66 'title' => 'Home',
67 'doktype' => 1,
68 'is_siteroot' => 1,
69 'perms_userid' => 1,
70 'perms_groupid' => 1,
71 'perms_user' => 32,
72 'perms_group' => 32,
73 'perms_everybody' => 1
74 ]
75 );
76 $pageUid = $databaseConnectionForPages->lastInsertId('pages');
77
78 // add a root sys_template with fluid_styled_content and a default PAGE typoscript snippet
79 $connectionPool->getConnectionForTable('sys_template')->insert(
80 'sys_template',
81 [
82 'pid' => $pageUid,
83 'crdate' => time(),
84 'cruser_id' => 1,
85 'tstamp' => time(),
86 'title' => 'Main TypoScript Rendering',
87 'sitetitle' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
88 'root' => 1,
89 'clear' => 1,
90 'include_static_file' => 'EXT:fluid_styled_content/Configuration/TypoScript/,EXT:fluid_styled_content/Configuration/TypoScript/Styling/',
91 'constants' => '',
92 'config' => 'page = PAGE
93 page.10 = TEXT
94 page.10.value (
95 <div style="width: 800px; margin: 15% auto;">
96 <div style="width: 300px;">
97 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 42"><path d="M60.2 14.4v27h-3.8v-27h-6.7v-3.3h17.1v3.3h-6.6zm20.2 12.9v14h-3.9v-14l-7.7-16.2h4.1l5.7 12.2 5.7-12.2h3.9l-7.8 16.2zm19.5 2.6h-3.6v11.4h-3.8V11.1s3.7-.3 7.3-.3c6.6 0 8.5 4.1 8.5 9.4 0 6.5-2.3 9.7-8.4 9.7m.4-16c-2.4 0-4.1.3-4.1.3v12.6h4.1c2.4 0 4.1-1.6 4.1-6.3 0-4.4-1-6.6-4.1-6.6m21.5 27.7c-7.1 0-9-5.2-9-15.8 0-10.2 1.9-15.1 9-15.1s9 4.9 9 15.1c.1 10.6-1.8 15.8-9 15.8m0-27.7c-3.9 0-5.2 2.6-5.2 12.1 0 9.3 1.3 12.4 5.2 12.4 3.9 0 5.2-3.1 5.2-12.4 0-9.4-1.3-12.1-5.2-12.1m19.9 27.7c-2.1 0-5.3-.6-5.7-.7v-3.1c1 .2 3.7.7 5.6.7 2.2 0 3.6-1.9 3.6-5.2 0-3.9-.6-6-3.7-6H138V24h3.1c3.5 0 3.7-3.6 3.7-5.3 0-3.4-1.1-4.8-3.2-4.8-1.9 0-4.1.5-5.3.7v-3.2c.5-.1 3-.7 5.2-.7 4.4 0 7 1.9 7 8.3 0 2.9-1 5.5-3.3 6.3 2.6.2 3.8 3.1 3.8 7.3 0 6.6-2.5 9-7.3 9"/><path fill="#FF8700" d="M31.7 28.8c-.6.2-1.1.2-1.7.2-5.2 0-12.9-18.2-12.9-24.3 0-2.2.5-3 1.3-3.6C12 1.9 4.3 4.2 1.9 7.2 1.3 8 1 9.1 1 10.6c0 9.5 10.1 31 17.3 31 3.3 0 8.8-5.4 13.4-12.8M28.4.5c6.6 0 13.2 1.1 13.2 4.8 0 7.6-4.8 16.7-7.2 16.7-4.4 0-9.9-12.1-9.9-18.2C24.5 1 25.6.5 28.4.5"/></svg>
98 </div>
99 <h4 style="font-family: sans-serif;">Welcome to a default website made with <a href="https://typo3.org">TYPO3</a></h4>
100 </div>
101 )
102 page.100 =< styles.content.get',
103 'description' => 'This is an Empty Site Package TypoScript template.
104
105 For each website you need a TypoScript template on the main page of your website (on the top level). For better maintenance all TypoScript should be extracted into external files via <INCLUDE_TYPOSCRIPT: source="FILE:EXT:site_myproject/Configuration/TypoScript/setup.typoscript">.'
106 ]
107 );
108 break;
109 }
110
111 // Setting SYS/isInitialInstallationInProgress to FALSE marks this instance installation as complete
112 $configurationValues['SYS/isInitialInstallationInProgress'] = false;
113
114 // Mark upgrade wizards as done
115 $this->loadExtLocalconfDatabaseAndExtTables();
116 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'])) {
117 $registry = GeneralUtility::makeInstance(Registry::class);
118 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $updateClassName) {
119 $registry->set('installUpdate', $updateClassName, 1);
120 }
121 }
122
123 /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
124 $configurationManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
125 $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationValues);
126
127 /** @var \TYPO3\CMS\Install\Service\SessionService $session */
128 $session = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Service\SessionService::class);
129 $session->destroySession();
130
131 /** @var $formProtection \TYPO3\CMS\Core\FormProtection\InstallToolFormProtection */
132 $formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get(
133 \TYPO3\CMS\Core\FormProtection\InstallToolFormProtection::class
134 );
135 $formProtection->clean();
136
137 if (EnableFileService::installToolEnableFileExists() && !EnableFileService::isInstallToolEnableFilePermanent()) {
138 EnableFileService::removeInstallToolEnableFile();
139 }
140
141 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('../../../index.php', \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
142 }
143
144 /**
145 * Step needs to be executed if 'isInitialInstallationInProgress' is set to TRUE in LocalConfiguration
146 *
147 * @return bool
148 */
149 public function needsExecution()
150 {
151 $result = false;
152 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'])
153 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'] === true
154 ) {
155 $result = true;
156 }
157 return $result;
158 }
159
160 /**
161 * Executes the step
162 *
163 * @return string Rendered content
164 */
165 protected function executeAction()
166 {
167 $this->assignSteps();
168 $this->view->assign('composerMode', Bootstrap::usesComposerClassLoading());
169 return $this->view->render();
170 }
171 }