Skip to content

Commit

Permalink
Mise à jour sav_library_plus
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent FOULLOY committed Oct 5, 2023
1 parent e667717 commit 0ae7aaa
Show file tree
Hide file tree
Showing 46 changed files with 301 additions and 275 deletions.
10 changes: 7 additions & 3 deletions Classes/Compatibility/Database/DatabaseConnection.php
Expand Up @@ -1122,8 +1122,8 @@ protected function checkConnectionCharset()
]);
throw new \RuntimeException('TYPO3 Fatal Error: Could not determine the value of the database session variable: ' . $variableName, 1381847779);
}

if ($charsetVariables[$variableName] !== $this->connectionCharset) {
if (! preg_match('/^' . $this->connectionCharset . '/', $charsetVariables[$variableName])) {
// if ($charsetVariables[$variableName] !== $this->connectionCharset) {
$hasValidCharset = false;
break;
}
Expand Down Expand Up @@ -1192,7 +1192,11 @@ public function debug_check_recordset($res)
}
$trace = debug_backtrace(0);
array_shift($trace);
$msg = 'Invalid database result detected: function TYPO3\\CMS\\Typo3DbLegacy\\Database\\DatabaseConnection->' . $trace[0]['function'] . ' called from file ' . substr($trace[0]['file'], (strlen(Environment::getPublicPath() . '/') + 2)) . ' in line ' . $trace[0]['line'] . '.';
$msg = 'Invalid database result detected: function TYPO3\\CMS\\Typo3DbLegacy\\Database\\DatabaseConnection->' . $trace[0]['function'] . ' called from file ' . substr($trace[0]['file'], (strlen(Environment::getPublicPath() . '/') + 2)) . ' in line ' . $trace[0]['line'] . '.' . chr(10);
for ($i=1; $i<10; $i++) {
array_shift($trace);
$msg .= 'function ' . $trace[0]['function'] . ' called from file ' . substr($trace[0]['file'], (strlen(Environment::getPublicPath() . '/') + 2)) . ' in line ' . $trace[0]['line'] . '.' . chr(10);
}
self::getLogger()->log(LogLevel::ERROR, $msg . ' Use a devLog extension to get more details.', [
'extension' => 'core'
]);
Expand Down
Expand Up @@ -94,7 +94,7 @@ public static function doLanguageAndWorkspaceOverlay(string $tableName, array $r
if ($tableName === 'pages') {
$row = $pageRepository->getPageOverlay($row, self::getLanguageUid());
} elseif (isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField']) && $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] !== '') {
if (in_array($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']], [
if (in_array($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']] ?? null, [
- 1,
0
])) {
Expand Down
12 changes: 6 additions & 6 deletions Classes/Controller/AbstractController.php
Expand Up @@ -632,7 +632,7 @@ public static function compressParameters($parameters)
public static function uncompressParameters($compressedString, $formName = null)
{
// Checks if there is a fragment in the link
$fragmentPosition = strpos($compressedString, '#');
$fragmentPosition = strpos($compressedString ?? '', '#');
if ($fragmentPosition !== false) {
$compressedString = substr($compressedString, 0, $fragmentPosition);
}
Expand Down Expand Up @@ -736,15 +736,15 @@ public static function getExtensionWebPath($extension)
public function buildLinkToPage($str, $formParameters, $cache = 0, $additionalParameters = [])
{
// Gets the page id
$pageId = $formParameters['pageId'];
$pageId = $formParameters['pageId'] ?? null;
if (! empty($pageId)) {
unset($formParameters['pageId']);
} else {
$pageId = $this->getPageId();
}

// Gets the form name
$formName = ($formParameters['formName'] ? $formParameters['formName'] : self::getFormName());
$formName = (($formParameters['formName'] ?? false) ? $formParameters['formName'] : self::getFormName());

// Builds the form parameters
$formParameters = array_merge([
Expand All @@ -766,19 +766,19 @@ public function buildLinkToPage($str, $formParameters, $cache = 0, $additionalPa

// Adds the page Id as parameter
$conf['parameter'] = $pageId;
if ($formParameters['target']) {
if ($formParameters['target'] ?? false) {
$conf['target'] = $formParameters['target'];
unset($formParameters['target']);
}

// Adds the linkAccessRestrictedPages attribute
if ($formParameters['linkAccessRestrictedPages']) {
if ($formParameters['linkAccessRestrictedPages'] ?? false) {
$conf['linkAccessRestrictedPages'] = true;
unset($formParameters['linkAccessRestrictedPages']);
}

// Adds the forceAbsoluteUrl attribute
if (isset($formParameters['forceAbsoluteUrl'])) {
if ($formParameters['forceAbsoluteUrl'] ?? false) {
$conf['forceAbsoluteUrl'] = $formParameters['forceAbsoluteUrl'];
unset($formParameters['forceAbsoluteUrl']);
if (isset($formParameters['forceAbsoluteUrl.'])) {
Expand Down
16 changes: 8 additions & 8 deletions Classes/DatePicker/DatePicker.php
Expand Up @@ -90,8 +90,8 @@ protected static function addCascadingStyleSheet()
$extensionKey = AbstractController::LIBRARY_NAME;
$key = self::KEY . '.';
$extensionTypoScriptConfiguration = ExtensionConfigurationManager::getTypoScriptConfiguration();
$datePickerTypoScriptConfiguration = $extensionTypoScriptConfiguration[$key];
if (empty($datePickerTypoScriptConfiguration['stylesheet']) === false) {
$datePickerTypoScriptConfiguration = $extensionTypoScriptConfiguration[$key] ?? null;
if (! empty($datePickerTypoScriptConfiguration['stylesheet'] ?? null)) {
// The style sheet is given by the extension TypoScript
$cascadingStyleSheetAbsoluteFileName = GeneralUtility::getFileAbsFileName($datePickerTypoScriptConfiguration['stylesheet']);
if (is_file($cascadingStyleSheetAbsoluteFileName)) {
Expand All @@ -104,8 +104,8 @@ protected static function addCascadingStyleSheet()
}
} else {
$libraryTypoScriptConfiguration = LibraryConfigurationManager::getTypoScriptConfiguration();
$datePickerTypoScriptConfiguration = $libraryTypoScriptConfiguration[$key];
if (empty($datePickerTypoScriptConfiguration['stylesheet']) === false) {
$datePickerTypoScriptConfiguration = $libraryTypoScriptConfiguration[$key] ?? null;
if (! empty($datePickerTypoScriptConfiguration['stylesheet'] ?? null)) {
// The style sheet is given by the library TypoScript
$cascadingStyleSheetAbsoluteFileName = GeneralUtility::getFileAbsFileName($datePickerTypoScriptConfiguration['stylesheet']);
if (is_file($cascadingStyleSheetAbsoluteFileName)) {
Expand Down Expand Up @@ -148,13 +148,13 @@ protected static function getDatePickerFormat()
{
$key = self::KEY . '.';
$extensionTypoScriptConfiguration = ExtensionConfigurationManager::getTypoScriptConfiguration();
$datePickerTypoScriptConfiguration = $extensionTypoScriptConfiguration[$key];
if (is_array($datePickerTypoScriptConfiguration['format.'])) {
$datePickerTypoScriptConfiguration = $extensionTypoScriptConfiguration[$key] ?? null;
if (is_array($datePickerTypoScriptConfiguration['format.'] ?? null)) {
return $datePickerTypoScriptConfiguration['format.'];
} else {
$libraryTypoScriptConfiguration = LibraryConfigurationManager::getTypoScriptConfiguration();
$datePickerTypoScriptConfiguration = $libraryTypoScriptConfiguration[$key];
if (is_array($datePickerTypoScriptConfiguration['format.'])) {
$datePickerTypoScriptConfiguration = $libraryTypoScriptConfiguration[$key] ?? null;
if (is_array($datePickerTypoScriptConfiguration['format.'] ?? null)) {
return $datePickerTypoScriptConfiguration['format.'];
}
}
Expand Down
1 change: 0 additions & 1 deletion Classes/Form/Element/Help.php
Expand Up @@ -49,7 +49,6 @@ public function render()

$result = $this->initializeResultArray();
$result['html'] = '<a target="_blank" href="' . $documentationUrl . '">' . $message . '</a>';

return $result;
}

Expand Down
3 changes: 2 additions & 1 deletion Classes/ItemViewers/Edit/DateItemViewer.php
Expand Up @@ -43,7 +43,8 @@ protected function renderItem()
if ($this->getItemConfiguration('error')) {
$value = $this->getItemConfiguration('value');
} else {
$value = ($this->getItemConfiguration('value') ? strftime($format, $this->getItemConfiguration('value')) : ($this->getItemConfiguration('nodefault') ? '' : strftime($format)));
// @todo Replace deprecated strftime in php 8.1. Suppress warning in v11.
$value = ($this->getItemConfiguration('value') ? @strftime($format, $this->getItemConfiguration('value')) : ($this->getItemConfiguration('nodefault') ? '' : @strftime($format)));
}

$htmlArray[] = HtmlElements::htmlInputTextElement([
Expand Down
3 changes: 2 additions & 1 deletion Classes/ItemViewers/Edit/DateTimeItemViewer.php
Expand Up @@ -43,7 +43,8 @@ protected function renderItem()
if ($this->getItemConfiguration('error')) {
$value = $this->getItemConfiguration('value');
} else {
$value = ($this->getItemConfiguration('value') ? strftime($format, $this->getItemConfiguration('value')) : ($this->getItemConfiguration('nodefault') ? '' : strftime($format)));
// @todo Replace deprecated strftime in php 8.1. Suppress warning in v11.
$value = ($this->getItemConfiguration('value') ? @strftime($format, $this->getItemConfiguration('value')) : ($this->getItemConfiguration('nodefault') ? '' : @strftime($format)));
}

$htmlArray[] = HtmlElements::htmlInputTextElement([
Expand Down
2 changes: 1 addition & 1 deletion Classes/ItemViewers/Edit/FilesItemViewer.php
Expand Up @@ -59,7 +59,7 @@ protected function renderItem()
for ($counter = 0; $counter < $this->getItemConfiguration('maxitems'); $counter ++) {

// Sets the file name
$fileName = ($fileNames[$counter] ? $fileNames[$counter] : '');
$fileName = (($fileNames[$counter] ?? false) ? $fileNames[$counter] : '');
if ($fileName instanceof FileReference) {
$fileName = $fileName->getIdentifier();
}
Expand Down
Expand Up @@ -40,7 +40,7 @@ protected function renderItem()
$labelSelect = $this->getItemConfiguration('labelselect');
if (empty($labelSelect) === false) {
// Checks if this label comes from an aliasSelect attribute
$aliasSelect = $this->getItemConfiguration('aliasselect');
$aliasSelect = $this->getItemConfiguration('aliasselect') ?? '';
if (preg_match('/(?:AS|as) ' . $labelSelect . '/', $aliasSelect)) {
// Uses the alias
$label = $labelSelect;
Expand Down
30 changes: 27 additions & 3 deletions Classes/ItemViewers/Edit/RichTextEditorItemViewer.php
Expand Up @@ -16,10 +16,10 @@
namespace YolfTypo3\SavLibraryPlus\ItemViewers\Edit;

use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Configuration\Richtext;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;

/**
* Edit rich text editor item Viewer.
Expand All @@ -38,6 +38,8 @@ protected function renderItem()
{
$GLOBALS['BE_USER'] = GeneralUtility::makeInstance(BackendUserAuthentication::class);
$GLOBALS['BE_USER']->uc['edit_RTE'] = true;
$GLOBALS['BE_USER']->user['lang'] = null;
$GLOBALS['LANG'] = null;

$richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
$richtextConfiguration = $richtextConfigurationProvider->getConfiguration('', '', $this->getPageId(), '', [
Expand All @@ -49,24 +51,44 @@ protected function renderItem()
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
$formData = [
'renderType' => 'text',
'fieldName' => $this->getItemConfiguration('itemName'),
'processedTca' => [
'columns' => [
$this->getItemConfiguration('itemName') => [
'config' => [
'type' => 'text',
]
]
]
],
'databaseRow' => [
'uid' => ''
],
'tableName' => '',
'defaultLanguageDiffRow' => [
],
'recordTypeValue' => null,
'effectivePid' => null,
'inlineStructure' => [],
'row' => [
'pid' => $this->getPageId()
'pid' => $this->getPageId(),
],
'parameterArray' => [
'fieldConf' => [
'config' => [
'cols' => $this->getItemConfiguration('cols'),
'rows' => $this->getItemConfiguration('rows'),
'enableRichtext' => true,
'richtextConfiguration' => $richtextConfiguration
'richtextConfiguration' => $richtextConfiguration,
'richtextConfigurationName' => null,
],
'defaultExtras' => 'richtext[]:rte_transform[mode=ts_css]'
],
'itemFormElName' => $this->getItemConfiguration('itemName'),
'itemFormElValue' => html_entity_decode($this->getItemConfiguration('value'), ENT_QUOTES)
]
];

$formResult = $nodeFactory->create($formData)->render();

// Loads the ckeditor javascript file
Expand Down Expand Up @@ -117,4 +139,6 @@ protected function sanitizeFieldId(string $itemFormElementName): string
$fieldId = (string)preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $itemFormElementName);
return htmlspecialchars((string)preg_replace('/^[^a-zA-Z]/', 'x', $fieldId));
}

}

2 changes: 1 addition & 1 deletion Classes/ItemViewers/Edit/SelectorboxItemViewer.php
Expand Up @@ -59,7 +59,7 @@ protected function renderItem()
HtmlElements::htmlAddAttributeIfNotNull('selected', $selected),
HtmlElements::htmlAddAttribute('value', $item[1])
],
stripslashes(FlashMessages::translate($item[0]))
stripslashes(FlashMessages::translate($item[0]) ?? '')
);
}

Expand Down
8 changes: 4 additions & 4 deletions Classes/ItemViewers/General/AbstractItemViewer.php
Expand Up @@ -158,7 +158,7 @@ public function isEditItemViewer()
*/
public function getItemConfiguration($key)
{
return $this->itemConfiguration[$key];
return $this->itemConfiguration[$key] ?? null;
}

/**
Expand Down Expand Up @@ -688,7 +688,7 @@ protected function makeNewWindowLink($value)
->parseFieldTags($windowUrl);

// Returns the message if the window url is not a file
if (is_file($windowUrl) === false) {
if (is_file($windowUrl ?? '') === false) {
return $message;
}

Expand Down Expand Up @@ -824,8 +824,8 @@ protected function makeDateFormat($timeStamp)
if (empty($format) === true) {
$format = ($this->getItemConfiguration('eval' . $special) == 'datetime' ? $this->getController()->getDefaultDateTimeFormat() : $this->getController()->getDefaultDateFormat());
}

return strftime($format, (int) $timeStamp);
// @todo Replace deprecated strftime in php 8.1. Suppress warning in v11.
return @strftime($format, (int) $timeStamp);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Classes/ItemViewers/General/CheckboxItemViewer.php
Expand Up @@ -97,8 +97,8 @@ protected function renderCheckedAsImage()
$content = HtmlElements::htmlImgElement([
HtmlElements::htmlAddAttribute('class', 'checkboxSelected'),
HtmlElements::htmlAddAttribute('src', LibraryConfigurationManager::getIconPath($imageFileName)),
HtmlElements::htmlAddAttribute('title',FlashMessages::translate($imageTitleKey)),
HtmlElements::htmlAddAttribute('alt', FlashMessages::translate($imageTitleKey))
HtmlElements::htmlAddAttribute('title',FlashMessages::translate($imageTitleKey)),
HtmlElements::htmlAddAttribute('alt', FlashMessages::translate($imageTitleKey))
]
);

Expand Down Expand Up @@ -146,8 +146,8 @@ protected function renderNotCheckedAsImage()
$content = HtmlElements::htmlImgElement([
HtmlElements::htmlAddAttribute('class', 'checkboxNotSelected'),
HtmlElements::htmlAddAttribute('src', LibraryConfigurationManager::getIconPath($imageFileName)),
HtmlElements::htmlAddAttribute('title', FlashMessages::translate($imageTitleKey)),
HtmlElements::htmlAddAttribute('alt', FlashMessages::translate($imageTitleKey))
HtmlElements::htmlAddAttribute('title', FlashMessages::translate($imageTitleKey)),
HtmlElements::htmlAddAttribute('alt', FlashMessages::translate($imageTitleKey))
]
);

Expand Down
2 changes: 1 addition & 1 deletion Classes/ItemViewers/General/FilesItemViewer.php
Expand Up @@ -56,7 +56,7 @@ protected function renderItem()
$fileNames = $fileRepository->findByRelation($this->getItemConfiguration('tableName'), $this->getItemConfiguration('fieldName'), $this->getItemConfiguration('uid'));
} else {
// For old style extension
$fileNames = explode(',', $this->getItemConfiguration('value'));
$fileNames = explode(',', $this->getItemConfiguration('value') ?? '');
}

foreach ($fileNames as $fileNameKey => $this->fileName) {
Expand Down
9 changes: 6 additions & 3 deletions Classes/ItemViewers/General/GraphItemViewer.php
Expand Up @@ -21,7 +21,6 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use YolfTypo3\SavCharts\Controller\DefaultController;
use YolfTypo3\SavCharts\XmlParser\XmlParser;
use YolfTypo3\SavLibraryPlus\Controller\AbstractController;
Expand Down Expand Up @@ -71,8 +70,12 @@ protected function renderItem()
} else {
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
}
/** @var ContentObjectRenderer $contentObject */
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);

// Gets the content object
$contentObject = $this->getController()
->getExtensionConfigurationManager()
->getExtensionContentObject();

$configurationManager->setContentObject($contentObject);
$configurationManager->setConfiguration([
'extensionName' => 'SavCharts',
Expand Down
2 changes: 2 additions & 0 deletions Classes/ItemViewers/General/LinkItemViewer.php
Expand Up @@ -29,6 +29,8 @@ class LinkItemViewer extends AbstractItemViewer
*/
protected function renderItem()
{
$content = '';

// Gets the value
$value = $this->getItemConfiguration('value');

Expand Down
Expand Up @@ -36,7 +36,7 @@ protected function renderItem()
$labelSelect = $this->getItemConfiguration('labelselect');
if (empty($labelSelect) === false) {
// Checks if this label comes from an aliasSelect attribute
$aliasSelect = $this->getItemConfiguration('aliasselect');
$aliasSelect = $this->getItemConfiguration('aliasselect') ?? '';
if (preg_match('/(?:AS|as) ' . $labelSelect . '/', $aliasSelect)) {
// Uses the alias
$label = $labelSelect;
Expand Down Expand Up @@ -65,8 +65,8 @@ protected function renderItem()
$rows = $querier->getRows();

// Processes the row
$row = $rows[0];
$specialFields = str_replace(' ', '', $this->getItemConfiguration('specialfields'));
$row = $rows[0] ?? null;
$specialFields = str_replace(' ', '', $this->getItemConfiguration('specialfields') ?? '');
if (! empty($row)) {
// Injects the special markers
$specialFieldsArray = explode(',', $specialFields);
Expand Down
2 changes: 1 addition & 1 deletion Classes/ItemViewers/General/SelectorboxItemViewer.php
Expand Up @@ -46,7 +46,7 @@ protected function renderItem()

// Gets the selected element
if ($itemFound === true) {
$content = stripslashes(FlashMessages::translate($item[0]));
$content = stripslashes(FlashMessages::translate($item[0]) ?? '');
} else {
return '';
}
Expand Down

0 comments on commit 0ae7aaa

Please sign in to comment.