TYPO3 CMS  TYPO3_8-7
UserStorageCapabilityService.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 
24 
29 {
39  public function renderIsPublic(array $propertyArray)
40  {
41  $isPublic = $GLOBALS['TCA']['sys_file_storage']['columns']['is_public']['config']['default'];
42  $fileRecord = $propertyArray['row'];
43 
44  // Makes sure the storage object can be retrieved which is not the case when new storage.
45  if ((int)$propertyArray['row']['uid'] > 0) {
47  $lang = $GLOBALS['LANG'];
49  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
51  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
52  try {
53  $storage = ResourceFactory::getInstance()->getStorageObject($fileRecord['uid']);
54  $storageRecord = $storage->getStorageRecord();
55  $isPublic = $storage->isPublic() && $storageRecord['is_public'];
56  } catch (InvalidPathException $e) {
58  FlashMessage::class,
59  $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:filestorage.invalidpathexception.message'),
60  $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:filestorage.invalidpathexception.title'),
62  );
63  $defaultFlashMessageQueue->enqueue($message);
64  }
65 
66  // Display a warning to the BE User in case settings is not inline with storage capability.
67  if ($storageRecord['is_public'] && !$storage->isPublic()) {
69  FlashMessage::class,
70  $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.message.storage_is_no_public'),
71  $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.header.storage_is_no_public'),
73  );
74  $defaultFlashMessageQueue->enqueue($message);
75  }
76  }
77 
78  return $this->renderFileInformationContent($fileRecord, $isPublic);
79  }
80 
88  protected function renderFileInformationContent(array $fileRecord, $isPublic)
89  {
90  $template = '
91  <div class="t3-form-field-item">
92  <div class="checkbox">
93  <label>
94  <input name="data[sys_file_storage][{uid}][is_public]" value="0" type="hidden">
95  <input class="checkbox" value="1" name="data[sys_file_storage][{uid}][is_public]_0" type="checkbox" %s>
96  </label>
97  </div>
98  </div>';
99 
100  $content = sprintf(
101  $template,
102  $isPublic ? 'checked="checked"' : ''
103  );
104 
105  return str_replace('{uid}', $fileRecord['uid'], $content);
106  }
107 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']