TYPO3 CMS  TYPO3_7-6
WizardController.php
Go to the documentation of this file.
1 <?php
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 
21 
26 {
30  public function __construct()
31  {
32  $this->getLanguageService()->includeLLFile('EXT:form/Resources/Private/Language/locallang_wizard.xlf');
33  }
34 
44  public function indexAction(ServerRequestInterface $request, ResponseInterface $response)
45  {
47  $view = GeneralUtility::makeInstance(\TYPO3\CMS\Form\View\Wizard\WizardView::class, $this->getRepository());
48  $content = $view->render();
49  $response->getBody()->write($content);
50  return $response;
51  }
52 
62  public function saveAction(ServerRequestInterface $request, ResponseInterface $response)
63  {
64  $repository = $this->getRepository();
65  $success = false;
66  // Check if the referenced record is available
67  if ($repository->hasRecord()) {
68  // Save the data
69  $success = $repository->save();
70  }
71 
72  if (!$success) {
73  $response = $response->withStatus(500);
74  $message = $this->getLanguageService()->getLL('action_save_message_failed', false);
75  } else {
76  $message = $this->getLanguageService()->getLL('action_save_message_saved', false);
77  }
78  $response->getBody()->write(json_encode(['message' => $message]));
79  return $response
80  ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
81  ->withHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT')
82  ->withHeader('Cache-Control', 'no-cache, must-revalidate')
83  ->withHeader('Pragma', 'no-cache');
84  }
85 
95  public function loadAction(ServerRequestInterface $request, ResponseInterface $response)
96  {
97  $result = $this->getRepository()->getRecordAsJson();
98  if (!$result) {
99  $response = $response->withStatus(500);
100  $result = ['message' => $this->getLanguageService()->getLL('action_load_message_failed', false)];
101  } else {
102  $result = ['configuration' => $result];
103  }
104  $response->getBody()->write(json_encode($result));
105  return $response
106  ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
107  ->withHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT')
108  ->withHeader('Cache-Control', 'no-cache, must-revalidate')
109  ->withHeader('Pragma', 'no-cache');
110  }
111 
117  protected function getRepository()
118  {
119  return GeneralUtility::makeInstance(ContentRepository::class);
120  }
121 
127  protected function getLanguageService()
128  {
129  return $GLOBALS['LANG'];
130  }
131 }
saveAction(ServerRequestInterface $request, ResponseInterface $response)
loadAction(ServerRequestInterface $request, ResponseInterface $response)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']