‪TYPO3CMS  9.5
TypoScriptTemplateInformationModuleFunctionController.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 
25 
31 {
34 
39  'pObj' => 'Using TypoScriptTemplateInformationModuleFunctionController::$pObj is deprecated and will not be possible anymore in TYPO3 v10.0.',
40  'function_key' => 'Using TypoScriptTemplateInformationModuleFunctionController::$function_key is deprecated, property will be removed in TYPO3 v10.0.',
41  'extClassConf' => 'Using TypoScriptTemplateInformationModuleFunctionController::$extClassConf is deprecated, property will be removed in TYPO3 v10.0.',
42  'localLangFile' => 'Using TypoScriptTemplateInformationModuleFunctionController::$localLangFile is deprecated, property will be removed in TYPO3 v10.0.',
43  'tce_processed' => 'Using TypoScriptTemplateInformationModuleFunctionController::$tce_processed is deprecated, property will be removed in TYPO3 v10.0.',
44  ];
45 
49  private ‪$deprecatedPublicMethods = [
50  'initialize_editor' => 'Using TypoScriptTemplateInformationModuleFunctionController::initialize_editor() is deprecated and will not be possible anymore in TYPO3 v10.0.',
51  'tableRowData' => 'Using TypoScriptTemplateInformationModuleFunctionController::tableRowData() is deprecated and will not be possible anymore in TYPO3 v10.0.',
52  'handleExternalFunctionValue' => 'Using TypoScriptTemplateInformationModuleFunctionController::handleExternalFunctionValue() is deprecated, method will be removed in TYPO3 v10.0.',
53  ];
54 
61  protected ‪$tce_processed = false;
62 
66  protected ‪$pObj;
67 
72  protected ‪$templateRow;
73 
77  protected ‪$templateService;
78 
82  protected ‪$id;
83 
92  protected ‪$localLangFile = '';
93 
101  protected ‪$extClassConf;
102 
111  protected ‪$function_key = '';
112 
118  public function ‪init(‪$pObj)
119  {
120  $this->pObj = ‪$pObj;
121  // Local lang:
122  if (!empty($this->localLangFile)) {
123  // @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
124  $this->‪getLanguageService()->‪includeLLFile($this->localLangFile);
125  }
126  $this->id = (int)GeneralUtility::_GP('id');
127  }
128 
138  protected function ‪tableRowData($label, $data, $field, ‪$id)
139  {
140  $urlParameters = [
141  'id' => ‪$this->id,
142  'edit' => [
143  'sys_template' => [
144  ‪$id => 'edit'
145  ]
146  ],
147  'columnsOnly' => $field,
148  'createExtension' => 0,
149  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
150  ];
152  $uriBuilder = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\UriBuilder::class);
153  $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
154 
155  return [
156  'url' => $url,
157  'data' => $data,
158  'label' => $label
159  ];
160  }
161 
173  protected function ‪initialize_editor($pageId, $template_uid = 0)
174  {
175  $this->templateService = GeneralUtility::makeInstance(ExtendedTemplateService::class);
176 
177  // Get the row of the first VISIBLE template of the page. where clause like the frontend.
178  $this->templateRow = $this->templateService->ext_getFirstTemplate($pageId, $template_uid);
179  if (is_array($this->templateRow)) {
180  return true;
181  }
182  return false;
183  }
184 
190  public function ‪main()
191  {
192  // Checking for more than one template an if, set a menu...
193  $manyTemplatesMenu = $this->pObj->templateMenu();
194  $template_uid = 0;
195  if ($manyTemplatesMenu) {
196  $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
197  }
198  // Initialize
199  $existTemplate = $this->‪initialize_editor($this->id, $template_uid);
200  $saveId = 0;
201  if ($existTemplate) {
202  $saveId = $this->templateRow['_ORIG_uid'] ?: $this->templateRow['uid'];
203  }
205  $uriBuilder = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\UriBuilder::class);
206  // Create extension template
207  $newId = $this->pObj->createTemplate($this->id, $saveId);
208  if ($newId) {
209  // Switch to new template
210  $urlParameters = [
211  'id' => ‪$this->id,
212  'SET[templatesOnPage]' => $newId
213  ];
214  $url = (string)$uriBuilder->buildUriFromRoute('web_ts', $urlParameters);
216  }
217  $tce = null;
218  if ($existTemplate) {
219  $lang = $this->‪getLanguageService();
220  $lang->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang_info.xlf');
221  $assigns = [];
222  $assigns['LLPrefix'] = 'LLL:EXT:tstemplate/Resources/Private/Language/locallang_info.xlf:';
223 
224  $assigns['title'] = trim($this->templateRow['title']);
225  $assigns['siteTitle'] = trim($this->templateRow['sitetitle']);
226  $assigns['templateRecord'] = ‪$this->templateRow;
227  if ($manyTemplatesMenu) {
228  $assigns['manyTemplatesMenu'] = $manyTemplatesMenu;
229  }
230 
231  // Processing:
232  $tableRows = [];
233  $tableRows[] = $this->‪tableRowData($lang->getLL('title'), $this->templateRow['title'], 'title', $this->templateRow['uid']);
234  $tableRows[] = $this->‪tableRowData($lang->getLL('sitetitle'), $this->templateRow['sitetitle'], 'sitetitle', $this->templateRow['uid']);
235  $tableRows[] = $this->‪tableRowData($lang->getLL('description'), $this->templateRow['description'], 'description', $this->templateRow['uid']);
236  $tableRows[] = $this->‪tableRowData($lang->getLL('constants'), sprintf($lang->getLL('editToView'), trim($this->templateRow['constants']) ? count(explode(LF, $this->templateRow['constants'])) : 0), 'constants', $this->templateRow['uid']);
237  $tableRows[] = $this->‪tableRowData($lang->getLL('setup'), sprintf($lang->getLL('editToView'), trim($this->templateRow['config']) ? count(explode(LF, $this->templateRow['config'])) : 0), 'config', $this->templateRow['uid']);
238  $assigns['tableRows'] = $tableRows;
239 
240  // Edit all icon:
241  $urlParameters = [
242  'edit' => [
243  'sys_template' => [
244  $this->templateRow['uid'] => 'edit'
245  ]
246  ],
247  'createExtension' => 0,
248  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
249  ];
250  $assigns['editAllUrl'] = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
251 
252  // Rendering of the output via fluid
253  $view = GeneralUtility::makeInstance(StandaloneView::class);
254  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
255  'EXT:tstemplate/Resources/Private/Templates/InformationModule.html'
256  ));
257  $view->assignMultiple($assigns);
258  $theOutput = $view->render();
259  } else {
260  $theOutput = $this->pObj->noTemplate(1);
261  }
262  return $theOutput;
263  }
264 
271  protected function ‪handleExternalFunctionValue()
272  {
273  // Must clean first to make sure the correct key is set...
274  $this->pObj->MOD_SETTINGS = ‪BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), 'web_ts');
275  if ($this->function_key) {
276  $this->extClassConf = $this->pObj->getExternalItemConfig('web_ts', $this->function_key, $this->pObj->MOD_SETTINGS[$this->function_key]);
277  }
278  }
279 
283  protected function ‪getLanguageService(): ‪LanguageService
284  {
285  return ‪$GLOBALS['LANG'];
286  }
287 }
‪TYPO3\CMS\Core\Localization\LanguageService\includeLLFile
‪mixed includeLLFile($fileRef, $setGlobal=true, $mergeLocalOntoDefault=false)
Definition: LanguageService.php:260
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$tce_processed
‪bool $tce_processed
Definition: TypoScriptTemplateInformationModuleFunctionController.php:56
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\getLanguageService
‪LanguageService getLanguageService()
Definition: TypoScriptTemplateInformationModuleFunctionController.php:272
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$templateRow
‪array $templateRow
Definition: TypoScriptTemplateInformationModuleFunctionController.php:65
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\tableRowData
‪array tableRowData($label, $data, $field, $id)
Definition: TypoScriptTemplateInformationModuleFunctionController.php:127
‪TYPO3
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$pObj
‪TypoScriptTemplateModuleController $pObj
Definition: TypoScriptTemplateInformationModuleFunctionController.php:60
‪TYPO3\CMS\Tstemplate\Controller
Definition: TemplateAnalyzerModuleFunctionController.php:2
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\initialize_editor
‪bool initialize_editor($pageId, $template_uid=0)
Definition: TypoScriptTemplateInformationModuleFunctionController.php:162
‪TYPO3\CMS\Core\TypoScript\ExtendedTemplateService
Definition: ExtendedTemplateService.php:39
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\handleExternalFunctionValue
‪handleExternalFunctionValue()
Definition: TypoScriptTemplateInformationModuleFunctionController.php:260
‪TYPO3\CMS\Backend\Utility\BackendUtility\getModuleData
‪static array getModuleData( $MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
Definition: BackendUtility.php:3259
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateModuleController
Definition: TypoScriptTemplateModuleController.php:50
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$extClassConf
‪array $extClassConf
Definition: TypoScriptTemplateInformationModuleFunctionController.php:91
‪TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait
Definition: PublicMethodDeprecationTrait.php:68
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$id
‪$id
Definition: TypoScriptTemplateInformationModuleFunctionController.php:74
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$function_key
‪string $function_key
Definition: TypoScriptTemplateInformationModuleFunctionController.php:100
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\main
‪string main()
Definition: TypoScriptTemplateInformationModuleFunctionController.php:179
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$deprecatedPublicMethods
‪array $deprecatedPublicMethods
Definition: TypoScriptTemplateInformationModuleFunctionController.php:45
‪TYPO3\CMS\Core\Utility\HttpUtility
Definition: HttpUtility.php:21
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait
Definition: PublicPropertyDeprecationTrait.php:66
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\init
‪init($pObj)
Definition: TypoScriptTemplateInformationModuleFunctionController.php:107
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$localLangFile
‪string $localLangFile
Definition: TypoScriptTemplateInformationModuleFunctionController.php:83
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController
Definition: TypoScriptTemplateInformationModuleFunctionController.php:31
‪TYPO3\CMS\Core\Utility\HttpUtility\redirect
‪static redirect($url, $httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:103
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$templateService
‪ExtendedTemplateService $templateService
Definition: TypoScriptTemplateInformationModuleFunctionController.php:69
‪TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\$deprecatedPublicProperties
‪array $deprecatedPublicProperties
Definition: TypoScriptTemplateInformationModuleFunctionController.php:35