[FEATURE] Add autofocus attribute to BE login
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / InstallToolModuleController.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2013 Steffen Gebert <steffen.gebert@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Backend module of the 'install' extension, which automatically enables the
29 * Install Tool, if it's accessed by an authenticated Backend user.
30 *
31 * @author Steffen Gebert <steffen.gebert@typo3.org>
32 */
33 class InstallToolModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
34
35 /**
36 * Entry point for the backend module
37 *
38 * @return void
39 */
40 public function main() {
41 /** @var $installToolService \TYPO3\CMS\Install\EnableFileService */
42 $installToolService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\EnableFileService');
43 if ($installToolService->checkInstallToolEnableFile()) {
44 // Install Tool is already enabled
45 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('install/');
46 } elseif ($this->isValidEnableRequest()) {
47 // Install Tool should be enabled
48 $installToolService->createInstallToolEnableFile();
49 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('install/');
50 } else {
51 // ask the user to enable the Install Tool
52 $this->showInstallToolEnableRequest();
53 }
54 }
55
56 /**
57 * Checks if enabling install tool is requested and form token is correct
58 *
59 * @return bool
60 */
61 protected function isValidEnableRequest() {
62 return \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('enableInstallTool') && \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get()->validateToken(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('formToken'), 'installToolEnableToken');
63 }
64
65 /**
66 * Shows warning message about ENABLE_INSTALL_TOOL file and a button to create this file
67 *
68 * @return void
69 */
70 protected function showInstallToolEnableRequest() {
71 // Create instance of object for output of data
72 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
73 $this->doc->setModuleTemplate(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('install') . 'mod/mod_template.html');
74 $this->doc->form = '<form method="post" id="t3-install-form-unlock" action="">';
75 $this->doc->addStyleSheet('install', 'stylesheets/install/install.css');
76 $this->doc->addStyleSheet('mod-install', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('install') . 'mod/mod_styles.css');
77 $markers = ($buttons = array());
78 $markers['CONTENT'] = $this->renderMessage();
79 $content = $this->doc->moduleBody('', $buttons, $markers);
80 $this->doc->postCode = '<input type="hidden" name="enableInstallTool" value="1" />' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('installToolEnableToken');
81 echo $this->doc->render('', $content);
82 }
83
84 /**
85 * Renders the message and the activation button
86 *
87 * @return string
88 */
89 protected function renderMessage() {
90 /** @var $message \TYPO3\CMS\Core\Messaging\ErrorpageMessage */
91 $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\ErrorpageMessage');
92 $message->setTitle($GLOBALS['LANG']->sL('LLL:EXT:install/mod/locallang_mod.xlf:confirmUnlockInstallToolTitle'));
93 $message->setSeverity(\TYPO3\CMS\Core\Messaging\ErrorpageMessage::WARNING);
94 $message->setHtmlTemplate('/typo3/sysext/install/Resources/Private/Templates/Notice.html');
95 $content = $GLOBALS['LANG']->sL('LLL:EXT:install/mod/locallang_mod.xlf:confirmUnlockInstallToolMessage') . '<button type="submit">' . $GLOBALS['LANG']->sL('LLL:EXT:install/mod/locallang_mod.xlf:confirmUnlockInstallToolButton') . '<span class="t3-install-form-button-icon-positive">&nbsp;</span></button>';
96 $messageMarkers = array();
97 $messageMarkers['###CONTENT###'] = $content;
98 $message->setMarkers($messageMarkers);
99 return $message->render();
100 }
101
102 }
103
104
105 ?>