diff --git a/Classes/Backend/EventListener/PreviewEventListener.php b/Classes/Backend/EventListener/PreviewEventListener.php index 904649e..3d8a265 100644 --- a/Classes/Backend/EventListener/PreviewEventListener.php +++ b/Classes/Backend/EventListener/PreviewEventListener.php @@ -18,19 +18,19 @@ final class PreviewEventListener * * @var string */ - const KEY = 'camaliga'; + public const KEY = 'camaliga'; /** * Path to the locallang file * * @var string */ - const LLPATH = 'LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:'; + public const LLPATH = 'LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:'; /** * Max shown settings */ - const SETTINGS_IN_PREVIEW = 10; + public const SETTINGS_IN_PREVIEW = 10; protected $recordMapping = [ 'listId' => [ @@ -84,8 +84,8 @@ public function __invoke(PageContentPreviewRenderingEvent $event): void return; } if ($event->getRecord()['CType'] === 'list' && in_array($event->getRecord()['list_type'], $this->pis)) { - $pi = substr($event->getRecord()['list_type'], strpos($event->getRecord()['list_type'], '_')+1); - $header = '' . htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'template.' . $pi)) . ''; + $pi = substr((string) $event->getRecord()['list_type'], strpos((string) $event->getRecord()['list_type'], '_')+1); + $header = '' . htmlspecialchars((string) $this->getLanguageService()->sL(self::LLPATH . 'template.' . $pi)) . ''; $this->flexformData = GeneralUtility::xml2array($event->getRecord()['pi_flexform']); $this->getStartingPoint($event->getRecord()['pages']); diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index f177e98..fb346da 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -1,6 +1,8 @@ contentRepository = $contentRepository; } @@ -113,7 +113,7 @@ public function thumbAction(): ResponseInterface } } // Elemente sortiert holen - $contents = $this->contentRepository->findAll('sorting', 'asc', false, array($pid)); + $contents = $this->contentRepository->findAll('sorting', 'asc', false, [$pid]); $this->view->assign('pid', $pid); $this->view->assign('saved', $saved); diff --git a/Classes/Controller/ContentController.php b/Classes/Controller/ContentController.php index fa46221..5c724b9 100644 --- a/Classes/Controller/ContentController.php +++ b/Classes/Controller/ContentController.php @@ -1,6 +1,20 @@ configurationManager->getConfiguration( - \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT + ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT ); for ($i=10; $i>0; $i--) { if (isset($tsSettings['plugin.']['tx_camaliga.']['view.']['templateRootPaths.'][$i])) { @@ -88,7 +102,7 @@ public function initializeAction() } $tsSettings = $tsSettings['plugin.']['tx_camaliga.']['settings.']; $originalSettings = $this->configurationManager->getConfiguration( - \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS + ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS ); // start override @@ -157,20 +171,16 @@ public function initializeAction() /** * Injects the content-Repository - * - * @param \Quizpalme\Camaliga\Domain\Repository\ContentRepository $contentRepository */ - public function injectContentRepository(\Quizpalme\Camaliga\Domain\Repository\ContentRepository $contentRepository) + public function injectContentRepository(ContentRepository $contentRepository) { $this->contentRepository = $contentRepository; } /** * Injects the helpers utility - * - * @param \Quizpalme\Camaliga\Utility\HelpersUtility $helpersUtility */ - public function injectHelpersUtility(\Quizpalme\Camaliga\Utility\HelpersUtility $helpersUtility) + public function injectHelpersUtility(HelpersUtility $helpersUtility) { $this->helpersUtility = $helpersUtility; } @@ -197,14 +207,14 @@ public function listAction(): ResponseInterface if (!$storagePidsComma) { // nix ausgewählt => aktuelle PID nehmen $storagePidsComma = intval($content_pid); - $storagePidsArray = array($storagePidsComma); - $storagePidsOnly = array($storagePidsComma); + $storagePidsArray = [$storagePidsComma]; + $storagePidsOnly = [$storagePidsComma]; } else { $storagePidsOnly = []; } $categoryUids = []; if ($this->settings['defaultCatIDs']) { - $defaultCats = explode(',', $this->settings['defaultCatIDs']); + $defaultCats = explode(',', (string) $this->settings['defaultCatIDs']); foreach ($defaultCats as $defCat) { $selected = intval(trim($defCat)); $categoryUids[$selected] = $selected; @@ -267,7 +277,6 @@ public function listAction(): ResponseInterface /** * action listExtended * - * @param int $currentPage * @return ResponseInterface */ public function listExtendedAction(int $currentPage = 1): ResponseInterface @@ -285,7 +294,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface $search = true; } } - $languageAspect = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class)->getAspect('language'); + $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); $sys_language_uid = $languageAspect->getId(); // @extensionScannerIgnoreLine @@ -309,7 +318,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface // es kommt eben auf die Reihenfolge der Einspeisung an! $storagePidsData[$value] = $storagePidsData_tmp[$value]; } - $defPids = ',' . str_replace(' ', '', $this->settings['defaultStoragePids']) . ','; + $defPids = ',' . str_replace(' ', '', (string) $this->settings['defaultStoragePids']) . ','; foreach ($storagePidsArray as $aPID) { // Prüfen, ob nur bestimmte Ordner ausgewählt sind if ($this->request->hasArgument('search')) { @@ -322,7 +331,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface } } else if ($this->settings['defaultStoragePids']) { // Default-PID vorhanden? - if (strpos($defPids, ',' . $aPID . ',') !== false) { + if (str_contains($defPids, ',' . $aPID . ',')) { $storagePidsData[$aPID]['selected'] = $aPID; $storagePidsOnly[] = intval($aPID); } @@ -331,16 +340,16 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface } else if (!$storagePidsComma) { // nix ausgewählt => aktuelle PID nehmen $storagePidsComma = intval($content_pid); - $storagePidsArray = array($storagePidsComma); - $storagePidsOnly = array($storagePidsComma); + $storagePidsArray = [$storagePidsComma]; + $storagePidsOnly = [$storagePidsComma]; } // gets all categories, which we want for the options - $categoryRepository = GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Repository\\CategoryRepository'); + $categoryRepository = GeneralUtility::makeInstance(CategoryRepository::class); if (isset($this->settings['category']['storagePids']) && $this->settings['category']['storagePids']) { if ($this->settings['category']['storagePids'] == -1) { $catStoragePids = []; // alle kategorien } else { - $catStoragePids = explode(',', $this->settings['category']['storagePids']); // category-folder + $catStoragePids = explode(',', (string) $this->settings['category']['storagePids']); // category-folder } } else { $catStoragePids = $storagePidsArray; // camaliga-folder(s) @@ -406,7 +415,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface $storagePidsData[$aPID]['selected'] = $aPID; } foreach ($categoryUids as $defCat) { - foreach (explode(',', $defCat) as $selected) { + foreach (explode(',', (string) $defCat) as $selected) { $uid = intval(trim($selected)); $parent = $all_cats[$uid]['parent']; if ($cats[$parent]['description'] == 'checkbox') { @@ -419,7 +428,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface } } else if (!$search && $this->settings['defaultCatIDs']) { // keine Suche, keine Cookies => default cats auswählen - $defaultCats = explode(',', $this->settings['defaultCatIDs']); + $defaultCats = explode(',', (string) $this->settings['defaultCatIDs']); foreach ($defaultCats as $defCat) { $uid = $selected = intval(trim($defCat)); $parent = $all_cats[$uid]['parent']; @@ -435,7 +444,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface // Suche if (!$search && $this->settings['extended']['onlySearchForm'] == 1) { - $contents = array(); + $contents = []; $this->view->assign('onlySearchForm', 1); } else { if (isset($cUid) && $cUid > 0) { @@ -443,7 +452,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface if ($this->settings['debug']) { $debug .= 'findByUids(array(' . $cUid . "))\n"; } - $contents = $this->contentRepository->findByUids(array($cUid)); + $contents = $this->contentRepository->findByUids([$cUid]); } else if (!empty($categoryUids)) { if (count($storagePidsOnly)==0 && count($storagePidsArray)>0) { $storagePidsOnly = $storagePidsArray; @@ -461,7 +470,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface if ($this->settings['debug']) { $debug .= 'findComplex( ,' . $sword . ',' . $place . ',' . $radius . ',' . $sortBy . ',' . $sortOrder . ',' . $this->settings['onlyDistinct'] . ',' . implode(',', $storagePidsOnly) . ',' . $this->settings['limit'] . ")\n"; } - $contents = $this->contentRepository->findComplex(array(), $sword, $place, $radius, $sortBy, $sortOrder, $this->settings['onlyDistinct'], $storagePidsOnly, $this->settings['limit']); + $contents = $this->contentRepository->findComplex([], $sword, $place, $radius, $sortBy, $sortOrder, $this->settings['onlyDistinct'], $storagePidsOnly, $this->settings['limit']); } else { // Simple Suche if ($this->settings['debug']) { @@ -494,7 +503,7 @@ public function listExtendedAction(int $currentPage = 1): ResponseInterface if ($this->settings['extended']['radiusValues']) { $radiusArray = []; - $radiusTemp = explode(',', $this->settings['extended']['radiusValues']); + $radiusTemp = explode(',', (string) $this->settings['extended']['radiusValues']); foreach ($radiusTemp as $aRadius) { $radiusArray[$aRadius] = $aRadius . ' km'; } @@ -571,7 +580,7 @@ public function teaserAction(): ResponseInterface $debug = ''; if (isset($this->settings['teaserIDs'])) { - $ids = explode(',', $this->settings['teaserIDs']); + $ids = explode(',', (string) $this->settings['teaserIDs']); $contents = $this->contentRepository->findByUids($ids, $this->settings['sortBy'], $this->settings['sortOrder']); if ($this->settings['debug']) { $debug = 'findByUids(array(' . $this->settings['teaserIDs'] . '),' . $this->settings['sortBy'] . ',' . $this->settings['sortOrder'] . ")\n"; @@ -1095,7 +1104,7 @@ public function randomAction(): ResponseInterface */ public function newAction(): ResponseInterface { - $content = GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Model\\Content'); + $content = GeneralUtility::makeInstance(Content::class); // gets all categories, which we want $cats = $this->getCategoriesAndParents(); @@ -1108,7 +1117,6 @@ public function newAction(): ResponseInterface /** * action create * - * @param Content $content * @return ResponseInterface */ public function createAction(Content $content): ResponseInterface @@ -1116,7 +1124,7 @@ public function createAction(Content $content): ResponseInterface $debug = ''; $mediaFolder = $this->settings['img']['folderForNewEntries']; - $persistenceManager = GeneralUtility::makeInstance("TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager"); + $persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); //$content->setHidden(1); if ($content->getUid() > 0) { $this->contentRepository->update($content); @@ -1136,8 +1144,8 @@ public function createAction(Content $content): ResponseInterface // https://stackoverflow.com/questions/57828620/how-to-access-uploaded-files-in-frontend-in-the-controller-in-typo3 // https://www.ophidia.net/typo3-8-filereference-aus-bild-erzeugen/ $uploadedFileData = $this->request->getArgument('image'); //$_FILES['image']; - if (substr($uploadedFileData['type'], 0, 5) == 'image') { - $resourceFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceFactory::class); + if (str_starts_with((string) $uploadedFileData['type'], 'image')) { + $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); $storage = $resourceFactory->getDefaultStorage(); $delete1 = ''; $delete2 = ''; @@ -1153,16 +1161,13 @@ public function createAction(Content $content): ResponseInterface } # add uploaded file - $imageFile = $targetFolder->addUploadedFile($uploadedFileData, \TYPO3\CMS\Core\Resource\DuplicationBehavior::RENAME); + $imageFile = $targetFolder->addUploadedFile($uploadedFileData, DuplicationBehavior::RENAME); $infos = $imageFile->getProperties(); if (($infos['width'] > $this->settings['img']['width']) || ($infos['height'] > $this->settings['img']['height'])) { # resize uploaded image //$image = $imageService->getImage($imgPath); - $imageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\ImageService'); - $processingInstructions = array( - 'maxWidth' => $this->settings['img']['width'], - 'maxHeight' => $this->settings['img']['height'], - ); + $imageService = GeneralUtility::makeInstance(ImageService::class); + $processingInstructions = ['maxWidth' => $this->settings['img']['width'], 'maxHeight' => $this->settings['img']['height']]; $imageFileResized = $imageService->applyProcessingInstructions($imageFile, $processingInstructions); $persistenceManager->persistAll(); // aufräumen, geht hier aber noch nicht: $imageFile->delete(); und $imageFileResized->delete(); @@ -1185,7 +1190,7 @@ public function createAction(Content $content): ResponseInterface 'crop' => null, ] ); - $imageFileReference = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference'); + $imageFileReference = GeneralUtility::makeInstance(FileReference::class); $imageFileReference->setOriginalResource($falFileReference); # set reference and position in Camaliga @@ -1228,10 +1233,10 @@ public function createAction(Content $content): ResponseInterface # Slug bilden! Achtung: uniqueInSite funktioniert hier nicht! $fieldConfig = $GLOBALS['TCA']['tx_camaliga_domain_model_content']['columns']['slug']['config']; - $slugHelper = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\SlugHelper::class, 'tx_camaliga_domain_model_content', 'slug', $fieldConfig); - $connection = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getConnectionForTable('tx_camaliga_domain_model_content'); + $slugHelper = GeneralUtility::makeInstance(SlugHelper::class, 'tx_camaliga_domain_model_content', 'slug', $fieldConfig); + $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_camaliga_domain_model_content'); $queryBuilder = $connection->createQueryBuilder(); - $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction::class)); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); $statement = $queryBuilder->select('*')->from('tx_camaliga_domain_model_content')->where( $queryBuilder->expr()->eq('uid', $uid) )->executeQuery(); @@ -1266,7 +1271,7 @@ public function createAction(Content $content): ResponseInterface } } } - $categoryRepository = GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Repository\\CategoryRepository'); + $categoryRepository = GeneralUtility::makeInstance(CategoryRepository::class); foreach ($categoryUids as $key => $value) { $category = $categoryRepository->findOneByUid($key); $content->addCategory($category); @@ -1332,18 +1337,18 @@ private function getLatLon(&$objects) */ private function getCategoriesAndParents() { - $categoryRepository = GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Repository\\CategoryRepository'); + $categoryRepository = GeneralUtility::makeInstance(CategoryRepository::class); if ($this->settings['category']['storagePids']) { if ($this->settings['category']['storagePids'] == -1) { $catStoragePids = []; // alle kategorien } else { - $catStoragePids = explode(',', $this->settings['category']['storagePids']); // category-folder + $catStoragePids = explode(',', (string) $this->settings['category']['storagePids']); // category-folder } } else { $storagePidsArray = $this->contentRepository->getStoragePids(); if (empty($storagePidsArray)) { // nix ausgewählt => aktuelle PID nehmen - $storagePidsArray = array(intval($GLOBALS["TSFE"]->id)); + $storagePidsArray = [intval($GLOBALS["TSFE"]->id)]; } $catStoragePids = $storagePidsArray; // camaliga-folder(s) } diff --git a/Classes/Domain/Model/Category.php b/Classes/Domain/Model/Category.php index 29caf8d..3b028bf 100644 --- a/Classes/Domain/Model/Category.php +++ b/Classes/Domain/Model/Category.php @@ -1,33 +1,35 @@ - */ - protected $categories; + * categories + * + * @var ObjectStorage<\Quizpalme\Camaliga\Domain\Model\Category> + */ + #[Lazy] + protected $categories; /** - * Get categories - * - * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Quizpalme\Camaliga\Domain\Model\Category> - */ - public function getCategories() + * Get categories + * + * @return ObjectStorage<\Quizpalme\Camaliga\Domain\Model\Category> + */ + public function getCategories() { return $this->categories; } /** - * Set categories - * - * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $categories - * @return void - */ - public function setCategories($categories) + * Set categories + * + * @param ObjectStorage $categories + * @return void + */ + public function setCategories($categories) { $this->categories = $categories; } diff --git a/Classes/Domain/Model/Content.php b/Classes/Domain/Model/Content.php index 7bac370..5088e37 100644 --- a/Classes/Domain/Model/Content.php +++ b/Classes/Domain/Model/Content.php @@ -1,6 +1,16 @@ 'NotEmpty'])] + protected $title; /** * Short description @@ -90,44 +100,44 @@ class Content extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject protected $slug; /** - * Image 1 - * - * @Extbase\ORM\Cascade("remove") - * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference - */ - protected $falimage = null; + * Image 1 + * + * @var FileReference + */ + #[Extbase\ORM\Cascade(['value' => 'remove'])] + protected $falimage = null; /** - * Image 2 - * - * @Extbase\ORM\Cascade("remove") - * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference - */ - protected $falimage2 = null; + * Image 2 + * + * @var FileReference + */ + #[Extbase\ORM\Cascade(['value' => 'remove'])] + protected $falimage2 = null; /** - * Image 3 - * - * @Extbase\ORM\Cascade("remove") - * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference - */ - protected $falimage3 = null; + * Image 3 + * + * @var FileReference + */ + #[Extbase\ORM\Cascade(['value' => 'remove'])] + protected $falimage3 = null; /** - * Image 4 - * - * @Extbase\ORM\Cascade("remove") - * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference - */ - protected $falimage4 = null; + * Image 4 + * + * @var FileReference + */ + #[Extbase\ORM\Cascade(['value' => 'remove'])] + protected $falimage4 = null; /** - * Image 5 - * - * @Extbase\ORM\Cascade("remove") - * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference - */ - protected $falimage5 = null; + * Image 5 + * + * @var FileReference + */ + #[Extbase\ORM\Cascade(['value' => 'remove'])] + protected $falimage5 = null; /** * Street @@ -228,19 +238,19 @@ class Content extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject protected $custom3; /** - * Mutter-Element: Quizpalme\Camaliga\Domain\Model\Content. Früher integer - * - * @Extbase\ORM\Lazy - * @var \Quizpalme\Camaliga\Domain\Model\Content - */ - protected $mother; + * Mutter-Element: Quizpalme\Camaliga\Domain\Model\Content. Früher integer + * + * @var \Quizpalme\Camaliga\Domain\Model\Content + */ + #[Extbase\ORM\Lazy] + protected $mother; /** - * Categories. Früher: integer - * - * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> - */ - protected $categories; + * Categories. Früher: integer + * + * @var ObjectStorage + */ + protected $categories; /** * Modulo begin @@ -264,7 +274,7 @@ public function __construct() { //Do not remove the next line: It would break the functionality $this->initStorageObjects(); - $this->categories = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->categories = new ObjectStorage(); } /** @@ -326,8 +336,8 @@ public function setSorting($sorting) { * @return string $title */ public function getTitleNl2br() { - $title = str_replace(array("'"), "\'", $this->title); - return str_replace(array("\r\n", "\r", "\n"), "
", $title); + $title = str_replace(["'"], "\'", $this->title); + return str_replace(["\r\n", "\r", "\n"], "
", $title); } /** @@ -355,8 +365,8 @@ public function setTitle($title) { * @return string $shortdesc */ public function getShortdescNl2br() { - $tmp = str_replace(array("'"), "\'", $this->shortdesc); - return str_replace(array("\r\n", "\r", "\n"), "
", $tmp); + $tmp = str_replace(["'"], "\'", $this->shortdesc); + return str_replace(["\r\n", "\r", "\n"], "
", $tmp); } /** @@ -384,8 +394,8 @@ public function setShortdesc($shortdesc) { * @return string $longdesc */ public function getLongdescNl2br() { - $tmp = str_replace(array("'"), "\'", $this->longdesc); - return str_replace(array("\r\n", "\r", "\n"), "
", $tmp); + $tmp = str_replace(["'"], "\'", $this->longdesc); + return str_replace(["\r\n", "\r", "\n"], "
", $tmp); } /** @@ -413,7 +423,7 @@ public function setLongdesc($longdesc) { * @return string $link */ public function getLinkResolved() { - $contentRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Repository\\ContentRepository'); + $contentRepository = GeneralUtility::makeInstance(ContentRepository::class); $output = ''; $linkArray = explode('?', $this->link); if ($linkArray[0] == 't3://file') { @@ -430,16 +440,16 @@ public function getLinkResolved() { */ public function getLinks() { $links_tmp = explode(' ', $this->link); - $links = array(); + $links = []; $i = 0; foreach ($links_tmp as $link) { - $links[$i] = array(); + $links[$i] = []; $links[$i]['link'] = $link; - if ((substr(trim($link), 0, 3) == 'www') || (substr(trim($link), 0, 4) == 'http')) { + if ((str_starts_with(trim($link), 'www')) || (str_starts_with(trim($link), 'http'))) { $links[$i]['type'] = 2; - } elseif (substr(trim($link), 0, 5) == 'file:') { + } elseif (str_starts_with(trim($link), 'file:')) { $links[$i]['type'] = 3; - } elseif (substr(trim($link), 0, 7) == 'mailto:') { + } elseif (str_starts_with(trim($link), 'mailto:')) { $links[$i]['type'] = 4; } else if (is_numeric(trim($link))) { $links[$i]['type'] = 1; @@ -490,106 +500,101 @@ public function setSlug($slug) { } /** - * Returns the image - * - * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage - */ - public function getFalimage() + * Returns the image + * + * @return FileReference $falimage + */ + public function getFalimage() { return $this->falimage; } /** - * Sets the falimage - * - * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage - * @return void - */ - public function setFalimage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage) + * Sets the falimage + * + * @return void + */ + public function setFalimage(FileReference $falimage) { $this->falimage = $falimage; } /** - * Returns the image - * - * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage2 - */ - public function getFalimage2() + * Returns the image + * + * @return FileReference $falimage2 + */ + public function getFalimage2() { return $this->falimage2; } /** - * Sets the falimage2 - * - * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage2 - * @return void - */ - public function setFalimage2(\TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage2) + * Sets the falimage2 + * + * @return void + */ + public function setFalimage2(FileReference $falimage2) { $this->falimage2 = $falimage2; } /** - * Returns the image - * - * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage3 - */ - public function getFalimage3() + * Returns the image + * + * @return FileReference $falimage3 + */ + public function getFalimage3() { return $this->falimage3; } /** - * Sets the falimage3 - * - * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage3 - * @return void - */ - public function setFalimage3(\TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage3) + * Sets the falimage3 + * + * @return void + */ + public function setFalimage3(FileReference $falimage3) { $this->falimage3 = $falimage3; } /** - * Returns the image - * - * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage4 - */ - public function getFalimage4() + * Returns the image + * + * @return FileReference $falimage4 + */ + public function getFalimage4() { return $this->falimage4; } /** - * Sets the falimage4 - * - * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage4 - * @return void - */ - public function setFalimage4(\TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage4) + * Sets the falimage4 + * + * @return void + */ + public function setFalimage4(FileReference $falimage4) { $this->falimage4 = $falimage4; } /** - * Returns the image - * - * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimag5 - */ - public function getFalimage5() + * Returns the image + * + * @return FileReference $falimag5 + */ + public function getFalimage5() { return $this->falimage5; } /** - * Sets the falimage5 - * - * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage5 - * @return void - */ - public function setFalimage5(\TYPO3\CMS\Extbase\Domain\Model\FileReference $falimage5) + * Sets the falimage5 + * + * @return void + */ + public function setFalimage5(FileReference $falimage5) { $this->falimage5 = $falimage5; } @@ -609,8 +614,8 @@ public function getStreet() { * @return string $street */ public function getStreetNl2br() { - $tmp = str_replace(array("'"), "\'", $this->street); - return str_replace(array("\r\n", "\r", "\n"), "
", $tmp); + $tmp = str_replace(["'"], "\'", $this->street); + return str_replace(["\r\n", "\r", "\n"], "
", $tmp); } /** @@ -880,51 +885,49 @@ public function getMother() { } /** - * Sets the mother - * - * @param \Quizpalme\Camaliga\Domain\Model\Content $mother - * @return void - */ - public function setMother(\Quizpalme\Camaliga\Domain\Model\Content $mother) { + * Sets the mother + * + * @return void + */ + public function setMother(\Quizpalme\Camaliga\Domain\Model\Content $mother) { $this->mother = $mother; } /** - * Adds a Category - * - * @param \TYPO3\CMS\Extbase\Domain\Model\Category $category - * @return void - */ - public function addCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category) { + * Adds a Category + * + * @return void + */ + public function addCategory(Category $category) { $this->categories->attach($category); } /** - * Removes a Category - * - * @param \TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove The Category to be removed - * @return void - */ - public function removeCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove) { + * Removes a Category + * + * @param Category $categoryToRemove The Category to be removed + * @return void + */ + public function removeCategory(Category $categoryToRemove) { $this->categories->detach($categoryToRemove); } /** - * Sets the categories - * - * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> $categories - * @return void - */ - public function setCategories(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $categories) { + * Sets the categories + * + * @param ObjectStorage $categories + * @return void + */ + public function setCategories(ObjectStorage $categories) { $this->categories = $categories; } /** - * Returns the categories - * - * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> $categories - */ - public function getCategories() { + * Returns the categories + * + * @return ObjectStorage $categories + */ + public function getCategories() { return $this->categories; } @@ -934,22 +937,22 @@ public function getCategories() { * @return array categories */ public function getCategoriesAndParents() { - $configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface'); + $configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class); $settings = $configurationManager->getConfiguration( - \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT + ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT ); $categorySettings = $settings['plugin.']['tx_camaliga.']['settings.']['category.']; if ($categorySettings['storagePids']) { if ($categorySettings['storagePids'] == -1) { $catStoragePids = []; } else { - $catStoragePids = explode(',', $categorySettings['storagePids']); + $catStoragePids = explode(',', (string) $categorySettings['storagePids']); } } else { - $contentRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Repository\\ContentRepository'); + $contentRepository = GeneralUtility::makeInstance(ContentRepository::class); $catStoragePids = $contentRepository->getStoragePids(); } - $categoryRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Repository\\CategoryRepository'); + $categoryRepository = GeneralUtility::makeInstance(CategoryRepository::class); $all_cats = $categoryRepository->getAllCats($categorySettings['sortBy'], $categorySettings['orderBy'], $catStoragePids); $used_cats = []; foreach ($this->getCategories() as $category) { @@ -1010,14 +1013,14 @@ public function setModuloEnd($moduloEnd) { */ public function getExtended() { $extended = []; - $extendedFields = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('camaliga', 'extendedFields'); + $extendedFields = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('camaliga', 'extendedFields'); if ($extendedFields) { $orig_uid = intval($this->getUid()); // ist immer die original uid (nicht vom übersetzten Element!) - $fieldsArray = explode(' ', trim($extendedFields)); + $fieldsArray = explode(' ', trim((string) $extendedFields)); //$search = implode(',', $fieldsArray); if (!empty($fieldsArray)) { foreach ($fieldsArray as $field) { - $queryBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable('tx_camaliga_domain_model_content'); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_camaliga_domain_model_content'); $statement = $queryBuilder ->select($field) ->from('tx_camaliga_domain_model_content') @@ -1041,7 +1044,7 @@ public function getExtended() { * @param integer $uid UID */ public function repairFALreference($uid) { - $queryBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference'); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference'); $queryBuilder ->update('sys_file_reference') ->where( diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index 36c0156..dc91607 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -1,10 +1,11 @@ createQuery(); if (!empty($pids)) { $query->getQuerySettings()->setRespectStoragePage(FALSE); @@ -111,13 +113,13 @@ public function findAll($sortBy = 'sorting', $sortOrder = 'asc', $onlyDistinct = } // ->setOffset($page * $limit) $result = $query - ->setOrderings( array($sortBy => $order) ) + ->setOrderings( [$sortBy => $order] ) ->execute(); if ($onlyDistinct) { // bessere Idee: - $resUids = array(); - $delKeys = array(); + $resUids = []; + $delKeys = []; foreach ($result as $element) { $resUids[$element->getUid()] = 1; } @@ -149,10 +151,10 @@ public function findAll($sortBy = 'sorting', $sortOrder = 'asc', $onlyDistinct = * @param array $pids Storage PIDs * @param integer $limit Limit */ - public function findComplex($uids, $sword, $place, $radius, $sortBy = 'sorting', $sortOrder = 'asc', $onlyDistinct = FALSE, $pids = array(), $limit = 0) + public function findComplex($uids, $sword, $place, $radius, $sortBy = 'sorting', $sortOrder = 'asc', $onlyDistinct = FALSE, $pids = [], $limit = 0) { - $order = ($sortOrder == 'desc') ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : - \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING; + $order = ($sortOrder == 'desc') ? QueryInterface::ORDER_DESCENDING : + QueryInterface::ORDER_ASCENDING; if ($sortBy=='sorting' || $sortBy=='tstamp' || $sortBy=='title' || $sortBy=='zip' || $sortBy=='city' || $sortBy=='country' || $sortBy=='custom1' || $sortBy=='custom2' || $sortBy=='custom3') { // OK @@ -169,7 +171,7 @@ public function findComplex($uids, $sword, $place, $radius, $sortBy = 'sorting', $uids = []; } $noMatch = FALSE; - $this->distanceArray = array(); + $this->distanceArray = []; // Umkreissuche von hier: http://opengeodb.org/wiki/OpenGeoDB_-_Umkreissuche if ($place && $radius) { @@ -250,7 +252,7 @@ public function findComplex($uids, $sword, $place, $radius, $sortBy = 'sorting', if (!$noMatch) { //var_dump($uids); - $constraints = array(); + $constraints = []; $query = $this->createQuery(); if (!empty($pids)) { $query->getQuerySettings()->setRespectStoragePage(false); @@ -299,7 +301,7 @@ public function findComplex($uids, $sword, $place, $radius, $sortBy = 'sorting', $query->setLimit(intval($limit)); } return $query - ->setOrderings(array($sortBy => $order)) + ->setOrderings([$sortBy => $order]) ->execute(); } } @@ -312,8 +314,8 @@ public function findComplex($uids, $sword, $place, $radius, $sortBy = 'sorting', */ public function findByUids($uids, $sortBy = 'sorting', $sortOrder = 'asc') { - $order = ($sortOrder == 'desc') ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : - \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING; + $order = ($sortOrder == 'desc') ? QueryInterface::ORDER_DESCENDING : + QueryInterface::ORDER_ASCENDING; if ($sortBy=='sorting' || $sortBy=='tstamp' || $sortBy=='title' || $sortBy=='zip' || $sortBy=='city' || $sortBy=='country' || $sortBy=='custom1' || $sortBy=='custom2' || $sortBy=='custom3') { // OK @@ -325,7 +327,7 @@ public function findByUids($uids, $sortBy = 'sorting', $sortOrder = 'asc') // nicht nötig: if ($onlyDistinct) $query->matching($query->logicalAnd($query->equals('mother', 0), $query->in('uid', $uids))); else $query->matching($query->in('uid', $uids)); return $query - ->setOrderings( array($sortBy => $order) ) + ->setOrderings( [$sortBy => $order] ) ->execute(); } @@ -373,7 +375,7 @@ public function findByCategories($cat_uids, $sword, $place, $radius, $sortBy = ' ->where( $queryBuilder->expr()->eq('categoryMM.tablenames', $queryBuilder->createNamedParameter($table)), $queryBuilder->expr()->eq('categoryMM.fieldname', $queryBuilder->createNamedParameter('categories')), - $queryBuilder->expr()->in('categoryMM.uid_local', explode(',', $uidsChilds)) + $queryBuilder->expr()->in('categoryMM.uid_local', explode(',', (string) $uidsChilds)) ); if (!empty($pids)) { $queryBuilder->andWhere( $queryBuilder->expr()->in('tx_camaliga_domain_model_content.pid', $pids) ); @@ -553,7 +555,7 @@ public function getRelevantCategories($pids = []) */ public function getStoragePidsData() { - $storagePidsData_tmp = array(); + $storagePidsData_tmp = []; $pids = $this->getStoragePids(); $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); $statement = $queryBuilder diff --git a/Classes/Hooks/DataHandlerHook.php b/Classes/Hooks/DataHandlerHook.php index 2acf00f..3713af4 100644 --- a/Classes/Hooks/DataHandlerHook.php +++ b/Classes/Hooks/DataHandlerHook.php @@ -12,6 +12,8 @@ * * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use Quizpalme\Camaliga\Utility\HelpersUtility; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -23,19 +25,16 @@ class DataHandlerHook { /** * Pre command map hook * - * @param array $incomingFieldArray - * @param string $table * @param string|int $id (id could be string, for this reason no type hint) - * @param DataHandler $dataHandler */ public function processDatamap_preProcessFieldArray(array &$incomingFieldArray, string $table, $id, DataHandler $dataHandler): void { if ($table == 'tx_camaliga_domain_model_content' && $incomingFieldArray['city'] && !floatval($incomingFieldArray['latitude']) && !floatval($incomingFieldArray['longitude'])) { // dies hier greift bei neuen Einträgen - $configurationUtility = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('camaliga'); + $configurationUtility = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('camaliga'); if ((bool)$configurationUtility['searchCoordinatesInBE']) { - $coordinates = GeneralUtility::makeInstance(\Quizpalme\Camaliga\Utility\HelpersUtility::class)->getLatLonOfAddress($incomingFieldArray['street'], $incomingFieldArray['zip'], $incomingFieldArray['city'], $incomingFieldArray['country'], 2, ''); + $coordinates = GeneralUtility::makeInstance(HelpersUtility::class)->getLatLonOfAddress($incomingFieldArray['street'], $incomingFieldArray['zip'], $incomingFieldArray['city'], $incomingFieldArray['country'], 2, ''); if ($coordinates['latitude'] || $coordinates['longitude']) { $incomingFieldArray['latitude'] = sprintf('%01.9f', $coordinates['latitude']); $incomingFieldArray['longitude'] = sprintf('%01.9f', $coordinates['longitude']); @@ -51,7 +50,7 @@ public function processDatamap_preProcessFieldArray(array &$incomingFieldArray, public function processDatamap_postProcessFieldArray(string $status, string $table, $id, array $fieldArray, DataHandler $dataHandler): void { if ($table == 'tx_camaliga_domain_model_content' && is_numeric($id)) { - $configurationUtility = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('camaliga'); + $configurationUtility = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('camaliga'); if ((bool)$configurationUtility['searchCoordinatesInBE']) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); $city = ''; @@ -82,7 +81,7 @@ public function processDatamap_postProcessFieldArray(string $status, string $tab } if ($city && !$latitude && !$longitude) { //$helpersUtility = GeneralUtility::makeInstance("Quizpalme\\Camaliga\\Utility\\HelpersUtility"); - $coordinates = GeneralUtility::makeInstance(\Quizpalme\Camaliga\Utility\HelpersUtility::class)->getLatLonOfAddress($street, $zip, $city, $country, 2, ''); + $coordinates = GeneralUtility::makeInstance(HelpersUtility::class)->getLatLonOfAddress($street, $zip, $city, $country, 2, ''); if ($coordinates['latitude'] || $coordinates['longitude']) { $queryBuilder ->update($table) diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index 87edc29..86d2246 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -26,6 +26,8 @@ */ namespace Quizpalme\Camaliga\Hooks; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use Quizpalme\Camaliga\Utility\TemplateLayout; use TYPO3\CMS\Backend\Utility\BackendUtility as BackendUtilityCore; /** @@ -49,11 +51,11 @@ public function user_templateLayout(array &$config) { } else { $pid = 0; } - $templateLayoutsUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Utility\\TemplateLayout'); + $templateLayoutsUtility = GeneralUtility::makeInstance(TemplateLayout::class); $templateLayouts = $templateLayoutsUtility->getAvailableTemplateLayouts($pid); foreach ($templateLayouts as $layout) { $additionalLayout = [ - htmlspecialchars($this->getLanguageService()->sL($layout[0])), + htmlspecialchars((string) $this->getLanguageService()->sL($layout[0])), $layout[1] ]; array_push($config['items'], $additionalLayout); diff --git a/Classes/Hooks/KeSearchIndexer.php b/Classes/Hooks/KeSearchIndexer.php index b60d782..5ab3c70 100644 --- a/Classes/Hooks/KeSearchIndexer.php +++ b/Classes/Hooks/KeSearchIndexer.php @@ -15,7 +15,7 @@ class KeSearchIndexer extends IndexerBase { // Set a key for your indexer configuration. // Add this in Configuration/TCA/Overrides/tx_kesearch_indexerconfig.php, too! - const KEY = 'camaliga'; + public const KEY = 'camaliga'; /** * Adds the custom indexer to the TCA of indexer configurations, so that @@ -28,11 +28,11 @@ class KeSearchIndexer extends IndexerBase public function registerIndexerConfiguration(&$params, $pObj) { // Set a name and an icon for your indexer. - $customIndexer = array( + $customIndexer = [ 'Camaliga elements (ext:camaliga)', KeSearchIndexer::KEY, - 'EXT:camaliga/Resources/Public/Icons/Extension.gif' - ); + 'EXT:camaliga/Resources/Public/Icons/Extension.gif' + ]; $params['items'][] = $customIndexer; } @@ -79,7 +79,7 @@ public function customIndexer(array &$indexerConfig, IndexerRunner &$indexerObje ->add(GeneralUtility::makeInstance(DeletedRestriction::class)) ->add(GeneralUtility::makeInstance(HiddenRestriction::class)); - $folders = GeneralUtility::trimExplode(',', htmlentities($indexerConfig['sysfolder'])); + $folders = GeneralUtility::trimExplode(',', htmlentities((string) $indexerConfig['sysfolder'])); $statement = $queryBuilder ->select('*') ->from($table) @@ -90,12 +90,12 @@ public function customIndexer(array &$indexerConfig, IndexerRunner &$indexerObje while ($record = $statement->fetchAssociative()) { // compile the information which should go into the index // the field names depend on the table you want to index! - $title = strip_tags($record['title']); - $abstract = strip_tags($record['shortdesc']); - $content = strip_tags($record['longdesc']); - $place = strip_tags($record['city']); - $place .= ($record['city'] && $record['country']) ? ', ' . strip_tags($record['country']) - : ' ' . strip_tags($record['country']); + $title = strip_tags((string) $record['title']); + $abstract = strip_tags((string) $record['shortdesc']); + $content = strip_tags((string) $record['longdesc']); + $place = strip_tags((string) $record['city']); + $place .= ($record['city'] && $record['country']) ? ', ' . strip_tags((string) $record['country']) + : ' ' . strip_tags((string) $record['country']); $fullContent = $title . "\n" . $abstract . "\n" . $content . "\n" .$place; $tags = ''; // oder '#camaliga#'; $params = '&tx_camaliga_' . $pluginForLinks . '[content]=' . $record['uid']; @@ -104,11 +104,7 @@ public function customIndexer(array &$indexerConfig, IndexerRunner &$indexerObje } // Additional information - $additionalFields = array( - 'sortdate' => $record['crdate'], - 'orig_uid' => $record['uid'], - 'orig_pid' => $record['pid'], - ); + $additionalFields = ['sortdate' => $record['crdate'], 'orig_uid' => $record['uid'], 'orig_pid' => $record['pid']]; // add something to the title, just to identify the entries // in the frontend diff --git a/Classes/PageTitle/PageTitleProvider.php b/Classes/PageTitle/PageTitleProvider.php index 1c4bdb7..0e8e1b4 100644 --- a/Classes/PageTitle/PageTitleProvider.php +++ b/Classes/PageTitle/PageTitleProvider.php @@ -5,9 +5,6 @@ class PageTitleProvider extends AbstractPageTitleProvider { - /** - * @param string $title - */ public function setTitle(string $title) { $this->title = $title; diff --git a/Classes/Task/CsvExportAdditionalFieldProvider.php b/Classes/Task/CsvExportAdditionalFieldProvider.php index 0e0f69f..704ed22 100644 --- a/Classes/Task/CsvExportAdditionalFieldProvider.php +++ b/Classes/Task/CsvExportAdditionalFieldProvider.php @@ -1,6 +1,7 @@ getCurrentAction(); if (empty($taskInfo['csvfile'])) { if ($currentSchedulerModuleAction->equals(Action::ADD)) { @@ -93,77 +94,50 @@ public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleCont // Ordner $fieldId = 'task_page'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.page'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // Kategorien $fieldId = 'task_cats'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.cats'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // path to csv file $fieldId = 'task_csvfile'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.csvfile'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // header of the csv file $fieldId = 'task_header'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.header'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // fields to export into the csv file $fieldId = 'task_fields'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.fields'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // separator $fieldId = 'task_separator'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.separator'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // delimiter $fieldId = 'task_delimiter'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.delimiter'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // catdelimiter $fieldId = 'task_catdelimiter'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.catdelimiter'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // convert $fieldId = 'task_convert'; $checked = ($taskInfo['convert']) ? ' checked="checked"' : ''; $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.convert'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; return $additionalFields; } @@ -193,21 +167,21 @@ public function validateAdditionalFields(array &$submittedData, SchedulerModuleC $isValid = FALSE; $this->addMessage( $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.invalidPage'), - FlashMessage::ERROR + ContextualFeedbackSeverity::ERROR ); } } else { $isValid = FALSE; $this->addMessage( $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.invalidPage'), - FlashMessage::ERROR + ContextualFeedbackSeverity::ERROR ); } - if (substr($submittedData['camaliga']['csvfile'],0,10) != 'fileadmin/') { + if (!str_starts_with((string) $submittedData['camaliga']['csvfile'], 'fileadmin/')) { $isValid = FALSE; $this->addMessage( $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.invalidCsvfile'), - FlashMessage::ERROR + ContextualFeedbackSeverity::ERROR ); } return $isValid; diff --git a/Classes/Task/CsvExportTask.php b/Classes/Task/CsvExportTask.php index 35f1d3d..450dcc0 100644 --- a/Classes/Task/CsvExportTask.php +++ b/Classes/Task/CsvExportTask.php @@ -1,6 +1,11 @@ getHeader(); if ($convert) $text = iconv('utf-8', 'iso-8859-1', $text); $content = $text . $ln; // header of the csv file - $cat_keys = array(); // uids of category names - $cat_parents = array(); // parent of the categories - $cat_rel = array(); // camaliga-category-relations - $cat_counts = array(); // count $cats categories + $cat_keys = []; // uids of category names + $cat_parents = []; // parent of the categories + $cat_rel = []; // camaliga-category-relations + $cat_counts = []; // count $cats categories $i = 0; // Counter // Step 0: init @@ -277,7 +282,7 @@ public function execute() { 'persistence' => [ 'storagePid' => '', 'classes' => [ - 'Quizpalme\Camaliga\Domain\Model\Category' => [ + Category::class => [ 'mapping' => [ 'recordType' => 0, 'tableName' => 'sys_category' @@ -286,11 +291,11 @@ public function execute() { ] ] ]; - $this->configurationManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); + $this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); $this->configurationManager->setConfiguration($configurationArray); // Step 1: select all categories of the current language - $categoryRepository = GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Repository\\CategoryRepository'); + $categoryRepository = GeneralUtility::makeInstance(CategoryRepository::class); $all_cats = $categoryRepository->getAllCats('sorting', 'asc', []); // Step 2: store more category datas in arrays @@ -361,13 +366,13 @@ public function execute() { foreach ($fieldArry as $field) { if ($j>0) $content .= $delimiter; - if (substr(trim($field), 0, 10) != '"category:') { - $text = preg_replace( "/\r|\n/", " ", $row[trim($field)]); + if (!str_starts_with(trim($field), '"category:')) { + $text = preg_replace( "/\r|\n/", " ", (string) $row[trim($field)]); if ($convert) $text = iconv('utf-8', 'iso-8859-1', $text); $content .= $separator . $text . $separator; } else { $cat = trim(substr(trim($field), 10, -1)); // Name der parent kategorie - $text = ($convert) ? iconv('utf-8', 'iso-8859-1', $cat_rel[$uid][$cat_keys[$cat]]) : $cat_rel[$uid][$cat_keys[$cat]]; + $text = ($convert) ? iconv('utf-8', 'iso-8859-1', (string) $cat_rel[$uid][$cat_keys[$cat]]) : $cat_rel[$uid][$cat_keys[$cat]]; $content .= $separator . $text . $separator; // Kinder einer gesuchten Kategorie } $j++; @@ -376,7 +381,7 @@ public function execute() { } } - $fp = fopen(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/' . $this->getCsvfile(), 'w'); + $fp = fopen(Environment::getPublicPath() . '/' . $this->getCsvfile(), 'w'); $ergebnis = fwrite($fp, $content); fclose($fp); if (!$ergebnis) diff --git a/Classes/Task/CsvImportAdditionalFieldProvider.php b/Classes/Task/CsvImportAdditionalFieldProvider.php index b53718c..854223c 100644 --- a/Classes/Task/CsvImportAdditionalFieldProvider.php +++ b/Classes/Task/CsvImportAdditionalFieldProvider.php @@ -1,6 +1,7 @@ getCurrentAction(); if (empty($taskInfo['page'])) { @@ -108,96 +109,63 @@ public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleCont // Ordner $fieldId = 'task_page'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.page'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // cat-folder $fieldId = 'task_catpage'; $checked = ($taskInfo['catpage']) ? ' checked="checked"' : ''; $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:itasks.validate.catpage'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // Sprache $fieldId = 'task_language'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.language'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // path to csv file $fieldId = 'task_csvfile'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:itasks.validate.csvfile'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // fields in the DB $fieldId = 'task_fields'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:itasks.validate.fields'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // separator $fieldId = 'task_separator'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.separator'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // delimiter $fieldId = 'task_delimiter'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.delimiter'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // catdelimiter $fieldId = 'task_catdelimiter'; - $fieldCode = ''; + $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.catdelimiter'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // convert $fieldId = 'task_convert'; $checked = ($taskInfo['convert']) ? ' checked="checked"' : ''; $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:itasks.validate.convert'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // delete $fieldId = 'task_delete'; $checked = ($taskInfo['delete']) ? ' checked="checked"' : ''; $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:itasks.validate.delete'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; // simulate $fieldId = 'task_simulate'; $checked = ($taskInfo['simulate']) ? ' checked="checked"' : ''; $fieldCode = ''; $label = $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:itasks.validate.simulate'); - $additionalFields[$fieldId] = array( - 'code' => $fieldCode, - 'label' => $label - ); + $additionalFields[$fieldId] = ['code' => $fieldCode, 'label' => $label]; return $additionalFields; } @@ -226,14 +194,14 @@ public function validateAdditionalFields(array &$submittedData, SchedulerModuleC $isValid = FALSE; $this->addMessage( $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.invalidPage'), - FlashMessage::ERROR + ContextualFeedbackSeverity::ERROR ); } } else { $isValid = FALSE; $this->addMessage( $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.invalidPage'), - FlashMessage::ERROR + ContextualFeedbackSeverity::ERROR ); } $lang = (int)$submittedData['camaliga']['language']; @@ -251,15 +219,15 @@ public function validateAdditionalFields(array &$submittedData, SchedulerModuleC $isValid = FALSE; $this->addMessage( $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.invalidLanguage'), - FlashMessage::ERROR + ContextualFeedbackSeverity::ERROR ); } } - if (substr($submittedData['camaliga']['csvfile'],0,10) != 'fileadmin/') { + if (!str_starts_with((string) $submittedData['camaliga']['csvfile'], 'fileadmin/')) { $isValid = FALSE; $this->addMessage( $GLOBALS['LANG']->sL('LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.validate.invalidCsvfile'), - FlashMessage::ERROR + ContextualFeedbackSeverity::ERROR ); } return $isValid; diff --git a/Classes/Task/CsvImportTask.php b/Classes/Task/CsvImportTask.php index 36a97e4..e01aa91 100644 --- a/Classes/Task/CsvImportTask.php +++ b/Classes/Task/CsvImportTask.php @@ -1,6 +1,15 @@ getPage(); // folder with camaliga elements $syslanguid = (int) $this->getLanguage(); // sys_language_uid ID @@ -345,7 +354,7 @@ public function execute() { $fields_names = explode(',', $fields); // field-array // files sortiert nach Name, dann umkehren - $path = \TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/' . $this->getCsvfile(); + $path = Environment::getPublicPath() . '/' . $this->getCsvfile(); $files = array_filter(glob($path), 'is_file'); $total = count($files); if ($total > 1) $files = array_reverse($files); @@ -399,7 +408,7 @@ public function execute() { 'persistence' => [ 'storagePid' => '', 'classes' => [ - 'Quizpalme\Camaliga\Domain\Model\Category' => [ + Category::class => [ 'mapping' => [ 'recordType' => 0, 'tableName' => 'sys_category' @@ -408,7 +417,7 @@ public function execute() { ] ] ]; - $this->configurationManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); + $this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); $this->configurationManager->setConfiguration($configurationArray); // Step 1: search all categories @@ -418,7 +427,7 @@ public function execute() { if ($catpage) { $cat_pids[] = $pid; } - $categoryRepository = GeneralUtility::makeInstance('Quizpalme\\Camaliga\\Domain\\Repository\\CategoryRepository'); + $categoryRepository = GeneralUtility::makeInstance(CategoryRepository::class); $all_cats = $categoryRepository->getAllCats('uid', 'asc', $cat_pids); foreach ($all_cats as $row) { $catArray[$row['title']] = $row['uid']; @@ -450,13 +459,13 @@ public function execute() { } // Step 3: Import - $lines = array(); + $lines = []; if ($newestFile) { $lines = file($newestFile); } if ( count($lines) > 1 ) { $nr = 0; - $fields_values = array(); + $fields_values = []; $fields_values['pid'] = $pid; $fields_values['tstamp'] = time(); $fields_values['crdate'] = time(); @@ -512,13 +521,13 @@ public function execute() { if ($simulate && count($insert)>0) { $output = $this->build_table($insert); // vielleicht so: https://readthedocs.org/projects/bartacus-bundle/downloads/pdf/stable/ - $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', + $message = GeneralUtility::makeInstance(FlashMessage::class, $output, 'Simulation:', // the header is optional - \TYPO3\CMS\Core\Messaging\FlashMessage::INFO, + ContextualFeedbackSeverity::INFO, FALSE ); - $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); + $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $messageQueue = $flashMessageService->getMessageQueueByIdentifier(); $messageQueue->addMessage($message); } @@ -537,15 +546,15 @@ function insertLine($names, $values, $fields, $simulate, $convert, $catArray, $c $success_global = TRUE; $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_camaliga_domain_model_content'); $fieldConfig = $GLOBALS['TCA']['tx_camaliga_domain_model_content']['columns']['slug']['config']; - $slugHelper = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\SlugHelper::class, 'tx_camaliga_domain_model_content', 'slug', $fieldConfig); + $slugHelper = GeneralUtility::makeInstance(SlugHelper::class, 'tx_camaliga_domain_model_content', 'slug', $fieldConfig); for ($i=0; $i 0) || $simulate) { // Kategorie-Relationen einfügen? Kategorien müssen vorhanden sein! $cats = 0; - $catIDs = array(); + $catIDs = []; for ($i=0; $i 'tx_camaliga_domain_model_content', 'fieldname' => 'categories'); + $mmInsertArray = ['tablenames' => 'tx_camaliga_domain_model_content', 'fieldname' => 'categories']; $mmInsertArray['uid_local'] = $catID; // Die Kategorie $mmInsertArray['uid_foreign'] = $values['uid']; // Das Camaliga-Element $mmInsertArray['sorting'] = ($cats+1)*10; @@ -684,7 +693,7 @@ function build_table($array){ // data rows foreach( $array as $key=>$value){ foreach($value as $key2=>$value2){ - $html .= strip_tags($value2) . '; '; + $html .= strip_tags((string) $value2) . '; '; } $html .= "###\n\r"; } diff --git a/Classes/Updates/SwitchableControllerActionsPluginUpdater.php b/Classes/Updates/SwitchableControllerActionsPluginUpdater.php index c707bf4..5950c2a 100644 --- a/Classes/Updates/SwitchableControllerActionsPluginUpdater.php +++ b/Classes/Updates/SwitchableControllerActionsPluginUpdater.php @@ -339,7 +339,7 @@ protected function getAllowedSettingsFromFlexForm(string $listType): array $settings = []; $flexFormFile = $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'][$listType . ',list']; if ($flexFormFile) { - $flexFormContent = file_get_contents(GeneralUtility::getFileAbsFileName(substr(trim($flexFormFile), 5))); + $flexFormContent = file_get_contents(GeneralUtility::getFileAbsFileName(substr(trim((string) $flexFormFile), 5))); $flexFormData = GeneralUtility::xml2array($flexFormContent); // Iterate each sheet and extract all settings @@ -354,10 +354,6 @@ protected function getAllowedSettingsFromFlexForm(string $listType): array /** * Updates list_type and pi_flexform of the given content element UID - * - * @param int $uid - * @param string $newListType - * @param string $flexform */ protected function updateContentElement(int $uid, string $newListType, string $flexform): void { @@ -377,7 +373,6 @@ protected function updateContentElement(int $uid, string $newListType, string $f /** * Transforms the given array to FlexForm XML * - * @param array $input * @return string */ protected function array2xml(array $input = []): string diff --git a/Classes/Utility/HelpersUtility.php b/Classes/Utility/HelpersUtility.php index 7375e76..6842a19 100644 --- a/Classes/Utility/HelpersUtility.php +++ b/Classes/Utility/HelpersUtility.php @@ -2,6 +2,10 @@ namespace Quizpalme\Camaliga\Utility; +use Quizpalme\Camaliga\Domain\Model\Content; +use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry; +use Quizpalme\Camaliga\PageTitle\PageTitleProvider; +use TYPO3\CMS\Core\Resource\FileRepository; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -25,7 +29,7 @@ public function sortObjects($objects) * zuerst holen wir uns alle gewünschten Objekte, welche später in Fuid in zufälliger Reihenfolge ausgegeben werden sollen * und erstellen ein zusätzelichen Array, in welches mittels array_push() die UIDs der Objekte geschrieben werden */ - $uidArray = array(); + $uidArray = []; foreach($objects as $object) { array_push($uidArray, $object->getUid()); } @@ -34,7 +38,7 @@ public function sortObjects($objects) * außerdem erstellen wir ein neues Array, welches später von der Funktion zurückgegeben wird */ shuffle($uidArray); - $objectArray = array(); + $objectArray = []; /** * für jeden Eintrag im UID Array gehen wir durch die vorhandenen Objekte * und wenn die aktuelle uid im Array = der Uid des aktuellen Objektes ist, @@ -53,18 +57,16 @@ public function sortObjects($objects) /** * set SEO head? * - * @param \Quizpalme\Camaliga\Domain\Model\Content $content - * @param array $settings * @return void */ - public function setSeo(\Quizpalme\Camaliga\Domain\Model\Content $content, array $settings) + public function setSeo(Content $content, array $settings) { $title = $content->getTitle(); $desc = preg_replace("/[\n\r]/"," - ", $content->getShortdesc()); - $MetaTagManagerRegistry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry::class); + $MetaTagManagerRegistry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class); if ($settings['seo']['setTitle'] == 1) { //$GLOBALS['TSFE']->page['title'] = $title; - $titleProvider = GeneralUtility::makeInstance(\Quizpalme\Camaliga\PageTitle\PageTitleProvider::class); + $titleProvider = GeneralUtility::makeInstance(PageTitleProvider::class); $titleProvider->setTitle($title); } if (($settings['seo']['setDescription'] == 1) && $desc) { @@ -91,7 +93,7 @@ public function setSeo(\Quizpalme\Camaliga\Domain\Model\Content $content, array $image = ''; if ($content->getFalimage() && $content->getFalimage()->getUid()) { //$typo3FALRepository = $this->objectManager->get("TYPO3\\CMS\\Core\\Resource\\FileRepository"); - $typo3FALRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class); + $typo3FALRepository = GeneralUtility::makeInstance(FileRepository::class); $fileObject = $typo3FALRepository->findFileReferenceByUid($content->getFalimage()->getUid()); $fileObjectData = $fileObject->toArray(); $image = $server . '/' . $fileObjectData['url']; @@ -127,7 +129,7 @@ public function getLatLonOfAddress($street, $zip, $city, $country, $getLatLon, $ if ($country) { $address .= ($address) ? ', ' . $country : $country; } - $address = urlencode($address); + $address = urlencode((string) $address); $httpOptions = [ "http" => [ "method" => "GET", @@ -155,8 +157,8 @@ public function getLatLonOfAddress($street, $zip, $city, $country, $getLatLon, $ } else { if ($resp['status']=='OK'){ // get the important data - $result['latitude'] = isset($resp['results'][0]['geometry']['location']['lat']) ? $resp['results'][0]['geometry']['location']['lat'] : ""; - $result['longitude'] = isset($resp['results'][0]['geometry']['location']['lng']) ? $resp['results'][0]['geometry']['location']['lng'] : ""; + $result['latitude'] = $resp['results'][0]['geometry']['location']['lat'] ?? ""; + $result['longitude'] = $resp['results'][0]['geometry']['location']['lng'] ?? ""; //$formatted_address = isset($resp['results'][0]['formatted_address']) ? $resp['results'][0]['formatted_address'] : ""; } else { $result['debug'] = 'google geocode response to address "' . $address . '": ' . $resp['status'] . "\n"; @@ -197,9 +199,9 @@ public function getLatLonOfImage($fileName) //convert strings to numbers foreach($gps as $key => $value){ - $pos = strpos($value, '/'); + $pos = strpos((string) $value, '/'); if($pos !== false){ - $temp = explode('/',$value); + $temp = explode('/',(string) $value); $gps[$key] = $temp[0] / $temp[1]; } } diff --git a/Classes/Utility/TemplateLayout.php b/Classes/Utility/TemplateLayout.php index 700e0e5..c2e72b4 100644 --- a/Classes/Utility/TemplateLayout.php +++ b/Classes/Utility/TemplateLayout.php @@ -26,6 +26,8 @@ */ namespace Quizpalme\Camaliga\Utility; +use TYPO3\CMS\Core\SingletonInterface; +use TYPO3\CMS\Backend\Utility\BackendUtility; /** * TemplateLayout: Template-Layout per TSconfig * @@ -33,7 +35,7 @@ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later * */ -class TemplateLayout implements \TYPO3\CMS\Core\SingletonInterface { +class TemplateLayout implements SingletonInterface { /** * Get available template layouts for a page @@ -42,9 +44,9 @@ class TemplateLayout implements \TYPO3\CMS\Core\SingletonInterface { * @return array */ public function getAvailableTemplateLayouts($pageUid) { - $templateLayouts = array(); + $templateLayouts = []; foreach($this->getTemplateLayoutsFromTsConfig($pageUid) as $templateKey => $title) { - $templateLayouts[] = array($title, $templateKey); + $templateLayouts[] = [$title, $templateKey]; } return $templateLayouts; } @@ -56,8 +58,8 @@ public function getAvailableTemplateLayouts($pageUid) { * @return array */ protected function getTemplateLayoutsFromTsConfig($pageUid) { - $templateLayouts = array(); - $pagesTsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($pageUid); + $templateLayouts = []; + $pagesTsConfig = BackendUtility::getPagesTSconfig($pageUid); if (isset($pagesTsConfig['tx_camaliga.']['templateLayouts.']) && is_array($pagesTsConfig['tx_camaliga.']['templateLayouts.'])) { $templateLayouts = $pagesTsConfig['tx_camaliga.']['templateLayouts.']; } diff --git a/Classes/ViewHelpers/ContentViewHelper.php b/Classes/ViewHelpers/ContentViewHelper.php index 67d8173..5b3c76b 100644 --- a/Classes/ViewHelpers/ContentViewHelper.php +++ b/Classes/ViewHelpers/ContentViewHelper.php @@ -1,6 +1,7 @@ contentRepository = $contentRepository; } @@ -92,7 +91,7 @@ public function render() return str_replace( array_keys($row), array_values($row), - $this->arguments['param'] + (string) $this->arguments['param'] ); } } \ No newline at end of file diff --git a/Configuration/TCA/tx_camaliga_domain_model_content.php b/Configuration/TCA/tx_camaliga_domain_model_content.php index a27b7f2..564df18 100644 --- a/Configuration/TCA/tx_camaliga_domain_model_content.php +++ b/Configuration/TCA/tx_camaliga_domain_model_content.php @@ -11,7 +11,7 @@ $pre = 'fal'; $slugFields = []; if ($slugField1) { - $fieldsArray = explode(' ', trim($slugField1)); + $fieldsArray = explode(' ', trim((string) $slugField1)); if (count($fieldsArray) > 1) { $slugField1a = []; foreach ($fieldsArray as $field) { @@ -25,7 +25,7 @@ } $slugFields[] = $slugField1a; if ($slugField2) { - $fieldsArray = explode(' ', trim($slugField2)); + $fieldsArray = explode(' ', trim((string) $slugField2)); if (count($fieldsArray) > 1) { $slugField2a = []; foreach ($fieldsArray as $field) { @@ -37,13 +37,12 @@ $slugFields[] = $slugField2a; } -$tcaArray = array( - 'ctrl' => array( +$tcaArray = [ + 'ctrl' => [ 'title' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content', 'label' => 'title', 'tstamp' => 'tstamp', 'crdate' => 'crdate', - 'cruser_id' => 'cruser_id', 'sortby' => 'sorting', 'versioningWS' => true, 'origUid' => 't3_origuid', @@ -51,38 +50,26 @@ 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', - 'enablecolumns' => array( + 'enablecolumns' => [ 'disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime', - ), + ], 'security' => [ 'ignorePageTypeRestriction' => true, ], 'searchFields' => 'title,shortdesc,longdesc,street,zip,city,country,person,custom1', 'iconfile' => 'EXT:camaliga/Resources/Public/Icons/tx_camaliga_domain_model_content.gif' - ), - 'types' => array( - '1' => array('showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, slug, shortdesc, longdesc, link, '.$pre.'image'), - ), - 'columns' => array( - 'sys_language_uid' => [ - 'exclude' => true, - 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', - 'config' => [ - 'type' => 'select', - 'renderType' => 'selectSingle', - 'special' => 'languages', - 'items' => [ - [ - 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', - -1, - 'flags-multiple' - ] - ], - 'default' => 0, - ], - ], + ], + 'types' => [ + '1' => ['showitem' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, slug, shortdesc, longdesc, link, '.$pre.'image'], + ], + 'columns' => [ + 'sys_language_uid' => [ + 'exclude' => true, + 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', + 'config' => ['type' => 'language'], + ], 'l10n_parent' => [ 'displayCond' => 'FIELD:sys_language_uid:>:0', 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent', @@ -91,7 +78,7 @@ 'renderType' => 'selectSingle', 'default' => 0, 'items' => [ - ['', 0], + ['label' => '', 'value' => 0], ], 'foreign_table' => 'tx_camaliga_domain_model_content', 'foreign_table_where' => 'AND {#tx_camaliga_domain_model_content}.{#pid}=###CURRENT_PID### AND {#tx_camaliga_domain_model_content}.{#sys_language_uid} IN (-1,0)', @@ -118,8 +105,7 @@ 'renderType' => 'checkboxToggle', 'items' => [ [ - 0 => '', - 1 => '', + 'label' => '', 'invertStateDisplay' => true ] ], @@ -129,9 +115,7 @@ 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', - 'eval' => 'datetime,int', + 'type' => 'datetime', 'default' => 0, 'behaviour' => [ 'allowLanguageSynchronization' => true @@ -142,9 +126,7 @@ 'exclude' => true, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', - 'eval' => 'datetime,int', + 'type' => 'datetime', 'default' => 0, 'range' => [ 'upper' => mktime(0, 0, 0, 1, 1, 2038) @@ -175,7 +157,8 @@ 'config' => [ 'type' => 'input', 'size' => 30, - 'eval' => 'trim,required' + 'eval' => 'trim', + 'required' => true ], ], 'slug' => [ @@ -223,8 +206,7 @@ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.link', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputLink', + 'type' => 'link', ], ], $pre.'image' => [ @@ -240,186 +222,170 @@ 'config' => [ 'type' => 'category', ], - ], - ), -); + ] + ] +]; if (!$disableFurtherImages) { - $tcaArray['columns'][$pre.'image2'] = array( - 'exclude' => true, - 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.image2', - 'config' => [ - 'type' => 'file', - 'maxitems' => 1, - 'allowed' => 'common-image-types' - ], - ); - $tcaArray['columns'][$pre.'image3'] = array( - 'exclude' => true, - 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.image3', - 'config' => [ - 'type' => 'file', - 'maxitems' => 1, - 'allowed' => 'common-image-types' - ], - ); - $tcaArray['columns'][$pre.'image4'] = array( - 'exclude' => true, - 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.image4', - 'config' => [ - 'type' => 'file', - 'maxitems' => 1, - 'allowed' => 'common-image-types' - ], - ); - $tcaArray['columns'][$pre.'image5'] = array( - 'exclude' => true, - 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.image5', - 'config' => [ - 'type' => 'file', - 'maxitems' => 1, - 'allowed' => 'common-image-types' - ], - ); + $tcaArray['columns'][$pre.'image2'] = ['exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.image2', 'config' => [ + 'type' => 'file', + 'maxitems' => 1, + 'allowed' => 'common-image-types' + ]]; + $tcaArray['columns'][$pre.'image3'] = ['exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.image3', 'config' => [ + 'type' => 'file', + 'maxitems' => 1, + 'allowed' => 'common-image-types' + ]]; + $tcaArray['columns'][$pre.'image4'] = ['exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.image4', 'config' => [ + 'type' => 'file', + 'maxitems' => 1, + 'allowed' => 'common-image-types' + ]]; + $tcaArray['columns'][$pre.'image5'] = ['exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.image5', 'config' => [ + 'type' => 'file', + 'maxitems' => 1, + 'allowed' => 'common-image-types' + ]]; $tcaArray['types']['1']['showitem'] .= ',falimage2,--linebreak--, falimage3,--linebreak--, falimage4,--linebreak--, falimage5'; } if (!$disableAddress) { - $tcaArray['columns']['street'] = array( + $tcaArray['columns']['street'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.street', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 30, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['zip'] = array( + ] + ]; + $tcaArray['columns']['zip'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.zip', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 10, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['city'] = array( + ] + ]; + $tcaArray['columns']['city'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.city', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 30, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['country'] = array( + ] + ]; + $tcaArray['columns']['country'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.country', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 30, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['latitude'] = array( + ] + ]; + $tcaArray['columns']['latitude'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.latitude', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 15, 'eval' => 'trim,Quizpalme\\Camaliga\\Evaluation\\Double9Evaluation', 'default' => '0.000000000' - ), - ); - $tcaArray['columns']['longitude'] = array( + ] + ]; + $tcaArray['columns']['longitude'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.longitude', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 15, 'eval' => 'trim,Quizpalme\\Camaliga\\Evaluation\\Double9Evaluation', 'default' => '0.000000000' - ), - ); + ] + ]; $tcaArray['types']['1']['showitem'] .= ',street,--linebreak--,zip, city,--linebreak--, country,--linebreak--, latitude, longitude'; } if (!$disableContact) { - $tcaArray['columns']['person'] = array( + $tcaArray['columns']['person'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.person', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 25, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['phone'] = array( + ] + ]; + $tcaArray['columns']['phone'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.phone', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 25, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['mobile'] = array( + ] + ]; + $tcaArray['columns']['mobile'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.mobile', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 25, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['email'] = array( + ] + ]; + $tcaArray['columns']['email'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.email', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 30, 'eval' => 'trim' - ), - ); + ] + ]; $tcaArray['types']['1']['showitem'] .= ', person,--linebreak--,phone, mobile,--linebreak--, email'; } if (!$disableCustom) { - $tcaArray['columns']['custom1'] = array( + $tcaArray['columns']['custom1'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.custom1', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 25, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['custom2'] = array( + ] + ]; + $tcaArray['columns']['custom2'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.custom2', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 25, 'eval' => 'trim' - ), - ); - $tcaArray['columns']['custom3'] = array( + ] + ]; + $tcaArray['columns']['custom3'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.custom3', - 'config' => array( + 'config' => [ 'type' => 'input', 'size' => 30, 'eval' => 'trim' - ), - ); + ] + ]; $tcaArray['types']['1']['showitem'] .= ',custom1, custom2, custom3'; } if (!$disableMother) { - $tcaArray['columns']['mother'] = array( + $tcaArray['columns']['mother'] = [ 'exclude' => true, 'label' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_db.xlf:tx_camaliga_domain_model_content.mother', - 'config' => array( + 'config' => [ 'type' => 'group', 'internal_type' => 'db', 'allowed' => 'tx_camaliga_domain_model_content', @@ -427,8 +393,8 @@ 'maxitems' => '1', 'minitems' => '0', 'default' => 0 - ), - ); + ] + ]; $tcaArray['types']['1']['showitem'] .= ',mother'; } diff --git a/Configuration/TypoScript/setup.txt b/Configuration/TypoScript/setup.txt index ec5b733..e4f8c09 100644 --- a/Configuration/TypoScript/setup.txt +++ b/Configuration/TypoScript/setup.txt @@ -135,7 +135,7 @@ plugin.tx_camaliga { # plugin.tx_camaliga._CSS_DEFAULT_STYLE ( ) # Icon für die Suche. -plugin.tx_kesearch_pi2.additionalPathForTypeIcons = typo3conf/ext/camaliga/ +plugin.tx_kesearch_pi2.additionalPathForTypeIcons = EXT:camaliga/ module.tx_camaliga < plugin.tx_camaliga diff --git a/Documentation/Changelog/Index.rst b/Documentation/Changelog/Index.rst index c350d22..051fc89 100644 --- a/Documentation/Changelog/Index.rst +++ b/Documentation/Changelog/Index.rst @@ -298,7 +298,9 @@ Version Changes 12.1.0 Important change: the Bootstrap templates supports now Bootstrap 5 instead of Bootstrap 4. -13.0.0 Setting errorId added: if no uid given, a redirect to an error page can be configured. +13.0.0 Refactored with the rector tool. + + Setting errorId added: if no uid given, a redirect to an error page can be configured. Ignore validation in show and showExtended action removed! ========== ============================================================================================================================== \ No newline at end of file diff --git a/Documentation/Localization.de_DE/Nderungen/Index.rst b/Documentation/Localization.de_DE/Nderungen/Index.rst index 58c6bb2..c1ea370 100644 --- a/Documentation/Localization.de_DE/Nderungen/Index.rst +++ b/Documentation/Localization.de_DE/Nderungen/Index.rst @@ -305,7 +305,9 @@ Version Änderungen 12.1.0 Wichtige Änderung: die Bootstrap-Templates unterstützen nun Bootstrap 5 statt Bootstrap 4. -13.0.0 Setting errorId ist neu: wenn keine uid angegeben ist, kann eine Weiterleitung eingerichtet werden. +13.0.0 Refactored mit dem rector-Tool. + + Setting errorId ist neu: wenn keine uid angegeben ist, kann eine Weiterleitung eingerichtet werden. Ignore validation in der show- und showExtended-action entfernt! ========== ===================================================================================================================== \ No newline at end of file diff --git a/README.md b/README.md index 8781b97..fc45589 100644 --- a/README.md +++ b/README.md @@ -28,5 +28,6 @@ Version 12.1: - Important change: the Bootstrap templates supports now Bootstrap 5 instead of Bootstrap 4. Version 13.0: +- Refactored with the rector tool. - Setting errorId added: if no uid given, a redirect to an error page can be configured. - Ignore validation in show and showExtended action removed! \ No newline at end of file diff --git a/composer.json b/composer.json index 44befd4..67af587 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,8 @@ "name" : "quizpalme/camaliga", "type" : "typo3-cms-extension", "description" : "A carousel/gallery/map/list extension that can use the TYPO3 categories and different jQuery-plugins like Slick or Isotope. Bootstrap 5 support. Indexer for ke_search.", - "authors" : [{ + "authors" : [ + { "name" : "Kurt Gusbeth", "role" : "Developer" } diff --git a/ext_localconf.php b/ext_localconf.php index 5868e3c..604d080 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -251,23 +251,23 @@ // Add CSV-export task (sheduler) - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['Quizpalme\\Camaliga\\Task\\CsvExportTask'] = [ + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\Quizpalme\Camaliga\Task\CsvExportTask::class] = [ 'extension' => 'camaliga', 'title' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.title', 'description' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:tasks.description', - 'additionalFields' => 'Quizpalme\\Camaliga\\Task\\CsvExportAdditionalFieldProvider' + 'additionalFields' => \Quizpalme\Camaliga\Task\CsvExportAdditionalFieldProvider::class ]; // Add CSV-import task (sheduler) - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['Quizpalme\\Camaliga\\Task\\CsvImportTask'] = [ + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\Quizpalme\Camaliga\Task\CsvImportTask::class] = [ 'extension' => 'camaliga', 'title' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:itasks.title', 'description' => 'LLL:EXT:camaliga/Resources/Private/Language/locallang_be.xlf:itasks.description', - 'additionalFields' => 'Quizpalme\\Camaliga\\Task\\CsvImportAdditionalFieldProvider' + 'additionalFields' => \Quizpalme\Camaliga\Task\CsvImportAdditionalFieldProvider::class ]; // TCA-Validator - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals']['Quizpalme\\Camaliga\\Evaluation\\Double9Evaluation'] = ''; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][\Quizpalme\Camaliga\Evaluation\Double9Evaluation::class] = ''; // Register switchableControllerActions plugin migrator