diff --git a/Classes/Command/MigrateNewsCommandController.php b/Classes/Command/MigrateNewsCommandController.php index 5e502eb4754bb8424c3b022282bdb12f40c260f9..4aec4af5b1bc6839e17ead1614a45920c6e90bc0 100644 --- a/Classes/Command/MigrateNewsCommandController.php +++ b/Classes/Command/MigrateNewsCommandController.php @@ -27,17 +27,20 @@ namespace SGalinski\SgNews\Command; ***************************************************************/ use SGalinski\SgNews\Domain\Model\News; -use SGalinski\SgNews\Domain\Model\Tag; +use SGalinski\SgNews\Domain\Repository\FileReferenceRepository; +use SGalinski\SgNews\Domain\Repository\NewsRepository; use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; -use TYPO3\CMS\Core\Database\DatabaseConnection; +use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\FileInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Domain\Model\FileReference; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Mvc\Controller\CommandController; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; +use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; /** @@ -50,29 +53,41 @@ class MigrateNewsCommandController extends CommandController { protected $requestAdminPermissions = TRUE; /** - * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager - * @inject + * @var PersistenceManager */ protected $persistenceManager; /** - * @var \SGalinski\SgNews\Domain\Repository\NewsRepository - * @inject + * @param PersistenceManager $persistenceManager + */ + public function injectPersistenceManager(PersistenceManager $persistenceManager) { + $this->persistenceManager = $persistenceManager; + } + + /** + * @var NewsRepository */ protected $newsRepository; /** - * @var \SGalinski\SgNews\Domain\Repository\TagRepository - * @inject + * @param NewsRepository $newsRepository */ - private $tagRepository; + public function injectNewsRepository(NewsRepository $newsRepository) { + $this->newsRepository = $newsRepository; + } /** - * @var \SGalinski\SgNews\Domain\Repository\FileReferenceRepository - * @inject + * @var FileReferenceRepository */ private $fileReferenceRepository; + /** + * @param FileReferenceRepository $fileReferenceRepository + */ + public function injectFileReferenceRepository(FileReferenceRepository $fileReferenceRepository) { + $this->fileReferenceRepository = $fileReferenceRepository; + } + /** * this array maps new pages to their original entry in the tx_news table * @@ -117,8 +132,7 @@ class MigrateNewsCommandController extends CommandController { ) { // fix repair translation bug where tsfe is missing from command controller, can be removed when v1.5 is released if (!$GLOBALS['TSFE']) { - /** @var TypoScriptFrontendController $typoScriptController */ - $GLOBALS['TSFE'] = $typoScriptController = $this->objectManager->get( + $GLOBALS['TSFE'] = $this->objectManager->get( TypoScriptFrontendController::class, $GLOBALS['TYPO3_CONF_VARS'], 0, 0 ); } @@ -126,13 +140,14 @@ class MigrateNewsCommandController extends CommandController { $this->languageMap = json_decode($languageMapAsJson, TRUE); $this->categoryMap = json_decode($categoryMapAsJson, TRUE); - /** @var DatabaseConnection $db */ - $db = $GLOBALS['TYPO3_DB']; - $where = 'hidden = 0 and deleted = 0 and endtime = 0 and pid = ' . (int) $pId; - - /** @var \mysqli_result $result */ - $result = $db->exec_SELECTquery('*', 'tx_news_domain_model_news', $where); - + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_news_domain_model_news'); + $queryBuilder->getRestrictions()->removeByType(StartTimeRestriction::class); + $rows = $queryBuilder->select('*') + ->from('tx_news_domain_model_news') + ->where( + $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pId, \PDO::PARAM_INT)) + ) + ->execute()->fetchAll(); $localDataHandler = GeneralUtility::makeInstance(DataHandler::class); $beUser = $this->simulateBackendUser(); $localCommandMap = [ @@ -143,13 +158,11 @@ class MigrateNewsCommandController extends CommandController { ] ]; - $resultArray = []; - while ($row = $result->fetch_assoc()) { + foreach ($rows as $row) { // ignore the entry if its not within the given year if ((int) date('Y', $row['datetime']) !== $year) { continue; } - $resultArray[] = $row; // if no l10n_parent exists, create a copy of the page if ((int) $row['l10n_parent'] === 0) { @@ -199,8 +212,17 @@ class MigrateNewsCommandController extends CommandController { $this->persistenceManager->persistAll(); // update content element from the new page - $where = 'pid = ' . $newPageId . ' AND sys_language_uid = ' . $this->languageMap[(int) $row['sys_language_uid']]; - $db->exec_UPDATEquery('tt_content', $where, ['bodytext' => $row['bodytext']]); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); + $queryBuilder->getRestrictions()->removeAll(); + $queryBuilder->update('tt_content') + ->where( + $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($newPageId, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($this->languageMap[(int) $row['sys_language_uid']], \PDO::PARAM_INT)) + ) + ) + ->set('bodytext', $row['bodytext'], TRUE) + ->execute(); } } else { // this row is a translation and should simply update the content accordingly $this->updateTranslation($row); @@ -217,20 +239,30 @@ class MigrateNewsCommandController extends CommandController { */ private function getMatchingFile(array $row) { // match old page id with old file reference id - /** @var DatabaseConnection $db */ - $db = $GLOBALS['TYPO3_DB']; - $where = 'tablenames = "tx_news_domain_model_news" AND fieldname = "fal_media" AND uid_foreign = ' . $row['uid']; - /** @var \mysqli_result $result */ - $fileReferenceResult = $db->exec_SELECTgetSingleRow( - 'uid, uid_local', 'sys_file_reference_news_migration', $where - ); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference_news_migration'); + $queryBuilder->getRestrictions()->removeAll(); + $fileReferenceResult = $queryBuilder->select('uid', 'uid_local') + ->from('sys_file_reference_news_migration') + ->where( + $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq('tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news')), + $queryBuilder->expr()->eq('fieldname', $queryBuilder->createNamedParameter('fal_media')), + $queryBuilder->expr()->eq('uid_foreign', $queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)) + ) + ) + ->execute()->fetch(); if (!$fileReferenceResult) { return NULL; } - $where = 'uid = ' . $fileReferenceResult['uid_local']; - /** @var \mysqli_result $result */ - $fileResult = $db->exec_SELECTgetSingleRow('identifier', 'sys_file_news_migration', $where); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_news_migration'); + $queryBuilder->getRestrictions()->removeAll(); + $fileResult = $queryBuilder->select('identifier') + ->from('sys_file_news_migration') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($fileReferenceResult['uid_local'], \PDO::PARAM_INT)) + ) + ->execute()->fetch(); if (!$fileResult) { return NULL; } @@ -249,17 +281,17 @@ class MigrateNewsCommandController extends CommandController { * Get the tag / category, matching the news * * @param array $row - * @return News */ private function setMatchingTag(array $row) { - /** @var DatabaseConnection $db */ - $db = $GLOBALS['TYPO3_DB']; - $where = 'uid_foreign = ' . (int) $row['uid']; - - /** @var \mysqli_result $result */ - $result = $db->exec_SELECTquery('uid_local, sorting_foreign', 'sys_category_record_mm_news_migration', $where); - - while ($mmRow = $result->fetch_assoc()) { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_category_record_mm_news_migration'); + $queryBuilder->getRestrictions()->removeAll(); + $mmRows = $queryBuilder->select('uid_local', 'sorting_foreign') + ->from('sys_category_record_mm_news_migration') + ->where( + $queryBuilder->expr()->eq('uid_foreign', $queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)) + ) + ->execute()->fetchAll(); + foreach ($mmRows as $mmRow) { $values = [ 'uid_local' => $this->categoryMap[(int) $mmRow['uid_local']], 'uid_foreign' => $this->newsPagesMap[(int) $row['uid']], @@ -267,7 +299,8 @@ class MigrateNewsCommandController extends CommandController { 'fieldname' => 'tx_sgnews_tags', 'sorting_foreign' => (int) $mmRow['sorting_foreign'] ]; - $db->exec_INSERTquery('sys_category_record_mm', $values); + $queryBuilder->insert('sys_category_record_mm') + ->values($values); } } @@ -277,68 +310,111 @@ class MigrateNewsCommandController extends CommandController { * @param array $row */ private function updateTranslation(array $row) { - /** @var DatabaseConnection $db */ - $db = $GLOBALS['TYPO3_DB']; - // get entry in news map $parentId = $this->newsPagesMap[$row['l10n_parent']]; - // get content element from the original page - $where = 'pid = ' . (int) $parentId; - - /** @var \mysqli_result $result */ - $result = $db->exec_SELECTquery('l18n_parent', 'tt_content', $where); - $originalContentElement = $result->fetch_row(); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content'); + $queryBuilder->getRestrictions()->removeAll(); + $originalContentElement = $queryBuilder->select('l18n_parent') + ->from('tt_content') + ->where( + $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($parentId, \PDO::PARAM_INT)) + ) + ->execute()->fetch(); + $queryBuilder->update('tt_content'); // if its the new default, there is no l18n_parent if ((int) $this->languageMap[(int) $row['sys_language_uid'] === 0]) { - $where = 'uid = ' . (int) $originalContentElement[0]; + $queryBuilder->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($originalContentElement[0], \PDO::PARAM_INT)) + ); } else { - $where = 'l18n_parent = ' . (int) $originalContentElement[0]; + $queryBuilder->where( + $queryBuilder->expr()->eq('l18n_parent', $queryBuilder->createNamedParameter($originalContentElement[0], \PDO::PARAM_INT)) + ); } // look up the correct language id, if they have changed if (isset($this->languageMap[(int) $row['sys_language_uid']])) { - $where .= ' AND sys_language_uid = ' . $this->languageMap[(int) $row['sys_language_uid']]; + $queryBuilder->andWhere( + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($this->languageMap[(int) $row['sys_language_uid']], \PDO::PARAM_INT)) + ); } else { - $where .= ' AND sys_language_uid = ' . (int) $row['sys_language_uid']; + $queryBuilder->andWhere( + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($row['sys_language_uid'], \PDO::PARAM_INT)) + ); } - - $db->exec_UPDATEquery('tt_content', $where, ['bodytext' => $row['bodytext']]); + $queryBuilder->set('bodytext', $row['bodytext'], TRUE) + ->execute(); // possibly the default language needs to be overwritten and the old default translation needs to be preserved if (isset($this->languageMap[(int) $row['sys_language_uid']]) && $this->languageMap[(int) $row['sys_language_uid']] === 0) { - $where = 'uid = ' . (int) $parentId; - /** @var \mysqli_result $result */ - $result = $db->exec_SELECTgetSingleRow('title, subtitle', 'pages', $where); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); + $queryBuilder->getRestrictions()->removeAll(); + $result = $queryBuilder->select('title', 'subtitle') + ->from('pages') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($parentId, \PDO::PARAM_INT)) + ) + ->execute()->fetch(); if ($result) { - $where = 'pid = ' . (int) $parentId . ' AND sys_language_uid = ' . $this->languageMap[0]; - $db->exec_UPDATEquery( - 'pages_language_overlay', $where, - ['title' => $result['title'], 'subtitle' => $result['subtitle'], 'navtitle' => ''] + $queryBuilder->where( + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($this->languageMap[0], \PDO::PARAM_INT)) ); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $queryBuilder->update('pages_language_overlay') + ->andWhere( + $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($parentId, \PDO::PARAM_INT)) + ); + } else { + $queryBuilder->update('pages') + ->andWhere( + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($this->languageMap[0], \PDO::PARAM_INT)) + ); + } + $queryBuilder->set('title', $result['title'], TRUE) + ->set('subtitle', $result['subtitle'], TRUE) + ->set('navtitle', '', TRUE) + ->execute(); } - $where = 'uid = ' . (int) $parentId; - $db->exec_UPDATEquery( - 'pages', $where, ['title' => date( - 'Y-m-d', $row['datetime'] - ) . ' - ' . $row['title'], 'subtitle' => $row['title'], 'lastUpdated' => $row['datetime'], 'navtitle' => ''] - ); + $newTitle = date('Y-m-d', $row['datetime']) . ' - ' . $row['title']; + $queryBuilder->update('pages') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($parentId, \PDO::PARAM_INT)) + ) + ->set('title', $newTitle, TRUE) + ->set('subtitle', $row['title'], TRUE) + ->set('lastUpdated', $row['datetime'], TRUE) + ->set('navtitle', '', TRUE) + ->execute(); } else { + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $queryBuilder->update('pages_language_overlay') + ->where( + $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($parentId, \PDO::PARAM_INT)) + ); + } else { + $queryBuilder->update('pages') + ->where( + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($parentId, \PDO::PARAM_INT)) + ); + } + // finally translate the page title if necessary - /** @noinspection NotOptimalIfConditionsInspection */ if (isset($this->languageMap[(int) $row['sys_language_uid']]) && $this->languageMap[(int) $row['sys_language_uid']] > 0) { - $where = 'pid = ' . (int) $parentId . ' AND sys_language_uid = ' . $this->languageMap[(int) $row['sys_language_uid']]; + $queryBuilder->andWhere( + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($this->languageMap[(int) $row['sys_language_uid']], \PDO::PARAM_INT)) + ); } else { - $where = 'pid = ' . (int) $parentId . ' AND sys_language_uid = ' . (int) $row['sys_language_uid']; + $queryBuilder->andWhere( + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($row['sys_language_uid'], \PDO::PARAM_INT)) + ); } + $queryBuilder->set('title', date('Y-m-d', $row['datetime']) . ' - ' . $row['title'], TRUE) + ->execute(); } - - $db->exec_UPDATEquery( - 'pages_language_overlay', $where, ['title' => date('Y-m-d', $row['datetime']) . ' - ' . $row['title']] - ); } /** diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index af31b713b91a5be78f9761730581cec42dc328b1..95dbdf5436248466734c1f14f46505dc77eb23f7 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -29,6 +29,7 @@ namespace SGalinski\SgNews\Controller; use RuntimeException; use SGalinski\SgNews\Domain\Model\Category; use SGalinski\SgNews\Domain\Model\News; +use SGalinski\SgNews\Utility\ExtensionUtility; use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -59,8 +60,7 @@ abstract class AbstractController extends ActionController { */ public function initializeAction() { $extensionKey = $this->request->getControllerExtensionKey(); - $serializedConfiguration = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]; - $this->extensionConfiguration = unserialize($serializedConfiguration, [FALSE]); + $this->extensionConfiguration = ExtensionUtility::getExtensionConfiguration($extensionKey); parent::initializeAction(); } diff --git a/Classes/Controller/Ajax/LikeController.php b/Classes/Controller/Ajax/LikeController.php index 1b465c37ae160494706c6af985ce378d3295964a..d2060167e9b959e03bcbc53d1c55a4e3920b3682 100644 --- a/Classes/Controller/Ajax/LikeController.php +++ b/Classes/Controller/Ajax/LikeController.php @@ -27,9 +27,8 @@ namespace SGalinski\SgNews\Controller\Ajax; ***************************************************************/ use SGalinski\SgAjax\Controller\Ajax\AbstractAjaxController; -use TYPO3\CMS\Core\Database\DatabaseConnection; +use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Frontend\Page\PageRepository; /** * The LikeController handles the Ajax-Actions related to the like feature @@ -46,13 +45,17 @@ class LikeController extends AbstractAjaxController { */ public function addLikeAction($newsPid) { try { - /** @var DatabaseConnection $database */ - $database = $GLOBALS['TYPO3_DB']; - /** @var PageRepository $pageRepository */ - $pageRepository = GeneralUtility::makeInstance(PageRepository::class); - - $database->sql_query('UPDATE pages SET tx_sgnews_likes = tx_sgnews_likes ' . '+ 1 WHERE uid=' . (int) $newsPid . - $pageRepository->enableFields('pages')); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); + $queryBuilder->update('pages') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsPid, \PDO::PARAM_INT)) + ) + ->set( + 'tx_sgnews_likes', + '`tx_sgnews_likes` + 1', + FALSE + ) + ->execute(); } catch (\Exception $exception) { $this->returnData(['success' => false]); } diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 2ce6d9d586da743a7324ab528599b07ef5a6ae44..35a4d0483339b65793a639554bd82d8f876b64c4 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -35,6 +35,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -121,11 +122,7 @@ class BackendController extends ActionController { * @api */ protected function initializeView(ViewInterface $view) { - if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { - $GLOBALS['LANG']->includeLLFile('EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf'); - } else { - $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_mod_web_list.xlf'); - } + $GLOBALS['LANG']->includeLLFile('EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf'); // create doc header component $this->pageUid = (int) GeneralUtility::_GP('id'); /** @var BackendUserAuthentication $backendUser */ @@ -157,6 +154,14 @@ class BackendController extends ActionController { $currentLanguageInfo = $languageOptions[$this->language] ?? NULL; } + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); + $pageRenderer->addJsInlineCode('typo3_version', 'TYPO3.version=' + . VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version()) + . ';'); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $pageRenderer->loadExtJS(); + } + $this->docHeaderComponent->setMetaInformation($this->pageInfo); $this->makeButtons(); $this->makeLanguageMenu(); @@ -223,11 +228,21 @@ class BackendController extends ActionController { /** @var IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(IconFactory::class); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $locallangPath = 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:'; + } else { + $locallangPath = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:'; + } + // Refresh $refreshButton = $buttonBar->makeLinkButton() ->setHref(GeneralUtility::getIndpEnv('REQUEST_URI')) - ->setTitle(LocalizationUtility::translate('LLL:EXT:lang/locallang_core.xlf:labels.reload', '')) - ->setIcon($iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)); + ->setTitle( + LocalizationUtility::translate( + $locallangPath . 'labels.reload' + ) + ) + ->setIcon($iconFactory->getIcon('actions-edit-undo', Icon::SIZE_SMALL)); $buttonBar->addButton($refreshButton, ButtonBar::BUTTON_POSITION_RIGHT); // shortcut button diff --git a/Classes/Domain/Repository/FileReferenceRepository.php b/Classes/Domain/Repository/FileReferenceRepository.php index ef1cc95067da284064af6ca3b74b18642e4451ea..b26ff56edfb84d559a68e8a4f1c3e06694411f37 100644 --- a/Classes/Domain/Repository/FileReferenceRepository.php +++ b/Classes/Domain/Repository/FileReferenceRepository.php @@ -26,8 +26,9 @@ namespace SGalinski\SgNews\Domain\Repository; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Utility\GeneralUtility; use SGalinski\SgNews\Domain\Model\FileReference; -use TYPO3\CMS\Core\Database\DatabaseConnection; use TYPO3\CMS\Core\Resource\File; /** @@ -78,23 +79,23 @@ class FileReferenceRepository extends AbstractRepository { * @throws \Exception */ public function addFileReferenceFromFileId($fileId, array $reference, $tablename, $fieldname) { - /** @var DatabaseConnection $db */ - $db = $GLOBALS['TYPO3_DB']; - $arguments = [ - 'crdate' => $GLOBALS['EXEC_TIME'], - 'tstamp' => $GLOBALS['EXEC_TIME'], - 'pid' => (int) $reference['pid'], - 'table_local' => 'sys_file', - 'uid_local' => $fileId, - 'uid_foreign' => (int) $reference['uid'], - 'tablenames' => $tablename, - 'fieldname' => $fieldname, - ]; + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference'); + $success = $queryBuilder->insert('sys_file_reference') + ->values([ + 'crdate' => $GLOBALS['EXEC_TIME'], + 'tstamp' => $GLOBALS['EXEC_TIME'], + 'pid' => (int) $reference['pid'], + 'table_local' => 'sys_file', + 'uid_local' => $fileId, + 'uid_foreign' => (int) $reference['uid'], + 'tablenames' => $tablename, + 'fieldname' => $fieldname + ]); - if (!$db->exec_INSERTquery('sys_file_reference', $arguments)) { + if (!$success) { throw new \Exception('An error occurred while adding a file reference record.', 1452590219); } - return (int) $db->sql_insert_id(); + return (int) $queryBuilder->getConnection()->lastInsertId(); } } diff --git a/Classes/Hooks/PageLayoutController.php b/Classes/Hooks/PageLayoutController.php index 3c961badf217c7f11e5a2f1eac5df03afd46fa2c..0daa0ec5151ae3a11dcaa520aa54319f198e71ee 100644 --- a/Classes/Hooks/PageLayoutController.php +++ b/Classes/Hooks/PageLayoutController.php @@ -30,7 +30,9 @@ use SGalinski\SgNews\Utility\BackendNewsUtility; use TYPO3\CMS\Backend\Controller\PageLayoutController as CorePageLayoutController; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** @@ -68,29 +70,10 @@ class PageLayoutController { ) { return $out; } - $moduleTemplate = $controller->getModuleTemplate(); - $moduleTemplate->addJavaScriptCode( - 'newsModuleLink', ' - function newsModuleLinkGotToPageCallbackNoFollow(path){ - var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree); - callback.apply(this, arguments); - } - - function sgNewsGoToNewsModule(uid, path) { - if (top.nav) { - top.nav.invokePageId(uid, newsModuleLinkGotToPageCallbackNoFollow); - } else { - var tree = top.Ext.getCmp(\'typo3-pagetree\'); - if (tree) { - tree.activeTree.selectPath(path); - } - } - parent.fsMod.recentIds[\'web\'] = uid; - parent.TYPO3.ModuleMenu.App.showModule(\'web_SgNewsNews\'); - return false; - } - ' - ); + + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); + $pageRenderer->loadRequireJsModule('TYPO3/CMS/SgNews/Backend'); + /** @var IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $icon = $iconFactory->getIcon('sg_news-module-transparent'); @@ -98,14 +81,22 @@ class PageLayoutController { $buttonLabel = LocalizationUtility::translate('backend.button.goToNewsModule', 'SgNews'); $buttonLabel = '<span style="vertical-align: middle;">' . $buttonLabel . '</span>'; - $rootline = BackendUtility::BEgetRootLine($categoryRow['uid'], '', TRUE); - ksort($rootline); - $path = '/root'; - foreach ($rootline as $page) { - $path .= '/p' . dechex($page['uid']); + $path = ''; + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $pageRenderer->addJsInlineCode('typo3_version', 'TYPO3.version=' + . VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getCurrentTypo3Version()) + . ';'); + $rootline = BackendUtility::BEgetRootLine($categoryRow['uid'], '', TRUE); + ksort($rootline); + $path = '/root'; + foreach ($rootline as $page) { + $path .= '/p' . dechex($page['uid']); + } + + $path = ', \'' . $path . '\''; } - $onclick = 'return sgNewsGoToNewsModule(' . $categoryRow['uid'] . ', \'' . $path . '\');'; + $onclick = 'TYPO3.SgNewsModule.sgNewsGoToNewsModule(' . $categoryRow['uid'] . $path . '); return false;'; $wrap = ' <div class="btn-group" role="group">%s</div>'; $link = '<a href="#" onclick="' . $onclick . '" class="btn btn-primary">%s</a>'; $link = sprintf($link, $icon . ' ' . $buttonLabel); diff --git a/Classes/Service/ConfigurationService.php b/Classes/Service/ConfigurationService.php index 6d97ba2e7e918db947c94714b286133f15c2b4bf..4ee488f46b88b3388009592d9128ddf413d3125c 100644 --- a/Classes/Service/ConfigurationService.php +++ b/Classes/Service/ConfigurationService.php @@ -49,9 +49,9 @@ class ConfigurationService implements SingletonInterface { * @param string $key * @param array $settings * @throws InvalidConfigurationTypeException - * @return string + * @return array|string|NULL */ - public function getConfiguration($key, array $settings): string { + public function getConfiguration($key, array $settings) { if (!$this->tsConfig) { $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); $this->tsConfig = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); diff --git a/Classes/Service/LicensingService.php b/Classes/Service/LicensingService.php index 92b72fefd8732f818548eb7f8bd1ec29fc60bae6..73a0f340e0671f677b465515722eb2fa5c721980 100644 --- a/Classes/Service/LicensingService.php +++ b/Classes/Service/LicensingService.php @@ -28,7 +28,9 @@ namespace SGalinski\SgNews\Service; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use SGalinski\SgNews\Utility\ExtensionUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Http\NullResponse; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -54,7 +56,7 @@ class LicensingService { public static function checkKey(): bool { if (static::$isLicenseKeyValid === NULL) { static::$isLicenseKeyValid = FALSE; - $configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::EXTENSION_KEY], [FALSE]); + $configuration = ExtensionUtility::getExtensionConfiguration(self::EXTENSION_KEY); if (isset($configuration['key']) && $key = trim($configuration['key'])) { static::$isLicenseKeyValid = (bool) preg_match('/^([A-Z\d]{6}-?){4}$/', $key); } @@ -71,7 +73,7 @@ class LicensingService { */ public static function ping($returnUrl = FALSE): string { try { - $configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::EXTENSION_KEY], [FALSE]); + $configuration = ExtensionUtility::getExtensionConfiguration(self::EXTENSION_KEY); $key = ''; if (isset($configuration['key'])) { $key = trim($configuration['key']); @@ -103,13 +105,14 @@ class LicensingService { * @return ResponseInterface * @throws \InvalidArgumentException */ - public function ajaxPing(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface { + public function ajaxPing(ServerRequestInterface $request, ResponseInterface $response = NULL): ResponseInterface { /** @var BackendUserAuthentication $backendUser */ $backendUser = $GLOBALS['BE_USER']; if ($backendUser && !$backendUser->getModuleData('tools_beuser/index.php/web_SgNewsNews_pinged', 'ses')) { $backendUser->pushModuleData('tools_beuser/index.php/web_SgNewsNews_pinged', TRUE); self::ping(); } - return $response; + + return $response ?? new NullResponse(); } } diff --git a/Classes/TCA/TcaProvider.php b/Classes/TCA/TcaProvider.php index d6cf5f9245022cab4e290fea446b42b8e840f7a3..b467e5c3c14f73481f876cc98420f1a5c2f351f5 100644 --- a/Classes/TCA/TcaProvider.php +++ b/Classes/TCA/TcaProvider.php @@ -25,7 +25,7 @@ namespace SGalinski\SgNews\TCA; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use TYPO3\CMS\Core\Database\DatabaseConnection; +use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -57,9 +57,6 @@ class TcaProvider implements SingletonInterface { * @return void */ public function processDatamap_afterAllOperations(DataHandler $tceMain) { - /** @var DatabaseConnection $database */ - $database = $GLOBALS['TYPO3_DB']; - /** @var array $tablesData */ foreach ($tceMain->datamap as $table => $tablesData) { if (!in_array($table, ['pages', 'pages_language_overlay'], TRUE)) { @@ -75,31 +72,42 @@ class TcaProvider implements SingletonInterface { $translationRow = []; $pagesIdentity = (int) $identity; if ($table === 'pages_language_overlay') { - $translationRow = $database->exec_SELECTgetSingleRow( - 'pid, subtitle, t3ver_oid', 'pages_language_overlay', 'uid = ' . (int) $identity - ); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages_language_overlay'); + $queryBuilder->getRestrictions()->removeAll(); + $translationRow = $queryBuilder->select('pid', 'subtitle', 't3ver_oid') + ->from('pages_language_overlay') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($identity, \PDO::PARAM_INT)) + ) + ->execute()->fetch(); $workspaceOriginalId = (int) $translationRow['t3ver_oid']; if ($workspaceOriginalId > 0) { - $translationRow = $database->exec_SELECTgetSingleRow( - 'pid, subtitle, t3ver_oid', 'pages_language_overlay', 'uid = ' . $workspaceOriginalId - ); + $translationRow = $queryBuilder->select('pid', 'subtitle', 't3ver_oid') + ->from('pages_language_overlay') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($workspaceOriginalId, \PDO::PARAM_INT)) + ) + ->execute()->fetch(); } $pagesIdentity = (int) $translationRow['pid']; } - $row = $database->exec_SELECTgetSingleRow( - 'doktype, subtitle, lastUpdated, tx_sgnews_highlighted, t3ver_oid', 'pages', 'uid = ' . - $pagesIdentity - ); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); + $queryBuilder->getRestrictions()->removeAll(); + $row = $queryBuilder->select('doktype', 'subtitle', 'lastUpdated', 'tx_sgnews_highlighted', 't3ver_oid') + ->from('pages') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($pagesIdentity, \PDO::PARAM_INT)) + ) + ->execute()->fetch(); $workspaceOriginalId = (int) $row['t3ver_oid']; if ($workspaceOriginalId > 0) { - $row = $database->exec_SELECTgetSingleRow( - 'doktype, subtitle, lastUpdated, tx_sgnews_highlighted, t3ver_oid', 'pages', 'uid = ' . - $workspaceOriginalId - ); + $row = $queryBuilder->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($workspaceOriginalId, \PDO::PARAM_INT)) + )->execute()->fetch(); } // only articles @@ -119,8 +127,14 @@ class TcaProvider implements SingletonInterface { } $calculatedTitle = $prefix . strftime('%Y-%m-%d', $row['lastUpdated']) . ' - ' . $subtitle; - $updateFields = ['nav_title' => $subtitle, 'title' => trim($calculatedTitle)]; - $database->exec_UPDATEquery($table, 'uid = ' . $identity, $updateFields); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table); + $queryBuilder->update($table) + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($identity, \PDO::PARAM_INT)) + ) + ->set('nav_title', $subtitle, TRUE) + ->set('title', trim($calculatedTitle), TRUE) + ->execute(); } } } diff --git a/Classes/Utility/BackendNewsUtility.php b/Classes/Utility/BackendNewsUtility.php index 8b677e5f271bc87d4435cffedab47acdbf1a375f..26692db39235900117f84adbebf5dd4c6052427e 100644 --- a/Classes/Utility/BackendNewsUtility.php +++ b/Classes/Utility/BackendNewsUtility.php @@ -32,8 +32,15 @@ use SGalinski\SgNews\Domain\Repository\NewsRepository; use SGalinski\SgNews\Domain\Repository\TagRepository; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; -use TYPO3\CMS\Core\Database\DatabaseConnection; +use TYPO3\CMS\Core\Database\Connection; +use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Database\Query\QueryHelper; +use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction; +use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Database\QueryGenerator; +use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider; +use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider; +use TYPO3\CMS\Core\Imaging\IconRegistry; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; @@ -83,14 +90,21 @@ class BackendNewsUtility { */ public static function getAlternativePageOptions(): array { $options = []; + $andWhere = ' AND sys_language_uid IN (0,-1)'; + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $andWhere = ''; + } /** @var array $rootOptionRows */ - $rootOptionRows = self::getRecordsByField('pages', 'is_siteroot', 1, '', '', 'sorting'); + $rootOptionRows = self::getRecordsByField( + 'pages', 'is_siteroot', 1, $andWhere, '', 'sorting' + ); if ($rootOptionRows) { foreach ($rootOptionRows as $row) { $pageInfo = BackendUtility::readPageAccess($row['uid'], $GLOBALS['BE_USER']->getPagePermsClause(1)); if ($pageInfo) { $options[] = self::getOptionPageInfo($pageInfo); } + $categories = self::getCategoriesForSiteRoot((int) $row['uid']); /** @var int $categoryUid */ foreach ($categories as $categoryUid => $categoryTitle) { @@ -105,6 +119,7 @@ class BackendNewsUtility { } } } + return $options; } @@ -122,10 +137,12 @@ class BackendNewsUtility { foreach ($rootline as $page) { $path .= '/p' . dechex($page['uid']); } + $pageInfo['path'] = $path; $pageInfo['_thePathFull'] = substr($pageInfo['_thePathFull'], 1); $pageInfo['_thePathFull'] = substr($pageInfo['_thePathFull'], 0, -1); } + return $pageInfo; } @@ -144,14 +161,18 @@ class BackendNewsUtility { $siteRootUid, PHP_INT_MAX, 0, $GLOBALS['BE_USER']->getPagePermsClause(1) ); - // if doktype = 117 (category) then get the category name (page title) - /** @var DatabaseConnection $databaseConnection */ - $databaseConnection = $GLOBALS['TYPO3_DB']; - - $where = 'deleted = 0 AND doktype = ' . self::CATEGORY_DOKTYPE . ' AND uid in (' . $childPids . ')'; - $result = $databaseConnection->exec_SELECTgetRows('uid, title', 'pages', $where); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + $result = $queryBuilder->select('uid', 'title') + ->from('pages') + ->where( + $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq('doktype', $queryBuilder->createNamedParameter(self::CATEGORY_DOKTYPE, \PDO::PARAM_INT)), + $queryBuilder->expr()->in('uid', $queryBuilder->createNamedParameter(explode(',', $childPids), Connection::PARAM_INT_ARRAY)) + ) + ) + ->execute()->fetchAll(); $categories = []; - /** @var array $result */ foreach ($result as $page) { $categoryPageInfo = BackendUtility::readPageAccess( (int) $page['uid'], $GLOBALS['BE_USER']->getPagePermsClause(1) @@ -180,6 +201,7 @@ class BackendNewsUtility { $GLOBALS['TSFE'] = new \stdClass(); $GLOBALS['TSFE']->gr_list = ''; } + $pageUid = (int) $pageUid; $languageUid = (int) $languageUid; $tags = []; @@ -199,18 +221,22 @@ class BackendNewsUtility { if (isset($pageTS['TCEFORM.']['pages.']['tx_sgnews_tags.']['PAGE_TSCONFIG_ID'])) { $tagsPid = (int) $pageTS['TCEFORM.']['pages.']['tx_sgnews_tags.']['PAGE_TSCONFIG_ID']; } + if ($tagsPid) { $query->matching($query->equals('pid', $tagsPid)); } } + $query->setOrderings(['title' => QueryInterface::ORDER_ASCENDING]); $resultTags = $query->execute(TRUE); if ($temporaryTSFEInstance) { unset($GLOBALS['TSFE']); } + foreach ($resultTags as $tag) { $tags[(int) $tag['uid']] = trim($tag['title']); } + return $tags; } @@ -230,6 +256,7 @@ class BackendNewsUtility { $GLOBALS['TSFE'] = new \stdClass(); $GLOBALS['TSFE']->gr_list = ''; } + $newsItemUid = (int) $newsItemUid; $languageUid = (int) $languageUid; $tags = []; @@ -244,17 +271,20 @@ class BackendNewsUtility { if ($newsItemUid) { $query->matching($query->equals('uid', $newsItemUid)); } + /** @var News $newsItem */ $newsItem = $query->execute()->getFirst(); if ($temporaryTSFEInstance) { unset($GLOBALS['TSFE']); } + if ($newsItem) { /** @var Tag $tag */ foreach ($newsItem->getTags() as $tag) { $tags[(int) $tag->getUid()] = trim($tag->getTitle()); } } + return $tags; } @@ -274,6 +304,7 @@ class BackendNewsUtility { if (!$rootPageUid) { return $out; } + $categories = []; if (!isset($filters['categories']) || !is_array($filters['categories']) || !count($filters['categories'])) { $rootCategories = self::getCategoriesForSiteRoot($rootPageUid); @@ -292,9 +323,11 @@ class BackendNewsUtility { } } } + if (!count($categories)) { return $out; } + $queryGenerator = GeneralUtility::makeInstance(QueryGenerator::class); $allowedUids = []; foreach ($categories as $categoryUid) { @@ -305,119 +338,79 @@ class BackendNewsUtility { ); $allowedUids = array_unique(array_merge($allowedUids, $allowedUidsTemp)); } - if (!count($allowedUids)) { - return $out; - } - list($select, $tables, $where) = self::getNewsQueryParts($allowedUids, $filters, $languageUid); - if ($tables === '') { + if (!count($allowedUids)) { return $out; } - /** @var DatabaseConnection $databaseConnection */ - $databaseConnection = $GLOBALS['TYPO3_DB']; - $result = $databaseConnection->exec_SELECTquery($select, $tables, $where, '`pages`.`uid`', '`pages`.`sorting`'); - while ($row = $result->fetch_assoc()) { - $out[] = $row; - } - $databaseConnection->sql_free_result($result); - return $out; - } - - /** - * Creates news query parts - * - * @param array $allowedUids - * @param array $filters - * @param int $languageUid - * @return array - */ - private static function getNewsQueryParts(array $allowedUids, array $filters = [], $languageUid = 0): array { - $out = [0 => ' - `pages`.`uid` AS uid, - `pages`.`pid` AS pid, - `pages`.`hidden` AS hidden, - `pages`.`sorting` AS sorting, - `pages`.`doktype` AS doktype, - `pages`.`title` AS title - ', 1 => '', 2 => '']; - $out[1] = '`pages`'; - $out[2] = '`pages`.`uid` IN(' . implode(',', $allowedUids) . ') ' . BackendUtility::deleteClause('pages') . - ' AND `pages`.`doktype` = ' . self::NEWS_DOKTYPE; + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages'); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + $queryBuilder->select('p.uid', + 'p.pid', + 'p.hidden', + 'p.sorting', + 'p.doktype', + 'p.title' + )->from('pages', 'p') + ->where( + $queryBuilder->expr()->andX( + $queryBuilder->expr()->in('p.uid', $queryBuilder->createNamedParameter($allowedUids, Connection::PARAM_INT_ARRAY)), + $queryBuilder->expr()->eq('p.doktype', $queryBuilder->createNamedParameter(self::NEWS_DOKTYPE, \PDO::PARAM_INT)) + ) + ) + ->groupBy('p.uid') + ->orderBy('p.sorting'); if ($languageUid) { - $out[0] .= ', `translation`.`title` AS translation_title'; - $out[0] .= ', `translation`.`uid` AS translation_uid'; - $out[1] .= ' LEFT JOIN `pages_language_overlay` AS `translation` ON `translation`.`pid` = `pages`.`uid` ' . - BackendUtility::deleteClause('pages_language_overlay', 'translation') . - ' AND `translation`.`sys_language_uid` = ' . $languageUid; - } - if (isset($filters['tags']) && is_array($filters['tags']) && count($filters['tags'])) { - $tagUids = []; - /** @var array $filterTags */ - $filterTags = $filters['tags']; - foreach ($filterTags as $tagUid) { - if ((int) $tagUid && !in_array((int) $tagUid, $tagUids, TRUE)) { - $tagUids[] = (int) $tagUid; - } - } - if (count($tagUids)) { - $out[1] .= ' INNER JOIN `sys_category_record_mm` AS `tag` ON `tag`.`tablenames` = \'pages\'' . - ' AND `tag`.`fieldname` = \'tx_sgnews_tags\' AND `tag`.`uid_foreign` = `pages`.`uid`' . - ' AND `tag`.`uid_local` IN (' . implode(',', $filters['tags']) . ')'; + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $queryBuilder->leftJoin('p', 'pages_language_overlay', 'translation', + $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq('translation.pid', 'p.uid'), + $queryBuilder->expr()->eq('translation.sys_language_uid', $queryBuilder->createNamedParameter($languageUid, \PDO::PARAM_INT)) + ) + ); + } else { + $queryBuilder->leftJoin('p', 'pages', 'translation', + $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq('translation.l10n_parent', 'p.uid'), + $queryBuilder->expr()->eq('translation.sys_language_uid', $queryBuilder->createNamedParameter($languageUid, \PDO::PARAM_INT)) + ) + ); } } - if (isset($filters['search']) && trim($filters['search'])) { - $out[2] .= self::getNewsSearchClause(trim($filters['search']), $languageUid); - } - return $out; - } - - /** - * Creates constraints of query for searching news by search-word - * - * @param string $searchString - * @param int $languageUid - * @return string - */ - private static function getNewsSearchClause($searchString = '', $languageUid = 0): string { - $out = ''; - $searchString = strtolower(trim($searchString)); - $languageUid = (int) $languageUid; - if (!$searchString) { - return $out; - } - $out = ' AND ('; - /** @var DatabaseConnection $databaseConnection */ - $databaseConnection = $GLOBALS['TYPO3_DB']; - $likeString = 'LIKE \'%' . $databaseConnection->escapeStrForLike($searchString, 'pages') . '%\''; - $constraints = []; - $pageFields = [ - 'title' => TRUE, - 'description' => TRUE, - 'author' => TRUE, - 'abstract' => TRUE, - ]; - foreach ($pageFields as $fieldName => $isCommonField) { - if ($isCommonField) { - $constraints[] = 'LOWER(`pages`.`' . $fieldName . '`) ' . $likeString; - } + if (isset($filters['tags']) && is_array($filters['tags']) && count($filters['tags'])) { + $queryBuilder->innerJoin('p', 'sys_category_record_mm', 'tag', + $queryBuilder->expr()->andX( + $queryBuilder->expr()->eq('tag.tablenames', $queryBuilder->createNamedParameter('pages')), + $queryBuilder->expr()->eq('tag.fieldname', $queryBuilder->createNamedParameter('tx_sgnews_tags')), + $queryBuilder->expr()->eq('tag.uid_foreign', 'p.uid'), + $queryBuilder->expr()->in('tag.uid_local', $queryBuilder->createNamedParameter(\array_unique($filters['tags']), Connection::PARAM_INT_ARRAY)) + ) + ); } - if (!$languageUid) { - foreach ($pageFields as $fieldName => $isCommonField) { - if (!$isCommonField) { - $constraints[] = 'LOWER(`pages`.`' . $fieldName . '`) ' . $likeString; - } - } - } else { - foreach ($pageFields as $fieldName => $isCommonField) { - if ($isCommonField) { - $constraints[] = 'LOWER(`translation`.`' . $fieldName . '`) ' . $likeString; - } + + if (isset($filters['search']) && trim($filters['search'])) { + $expressions = [ + $queryBuilder->expr()->like('p.title', $queryBuilder->createNamedParameter('%' . trim($filters['search']) . '%')), + $queryBuilder->expr()->like('p.description', $queryBuilder->createNamedParameter('%' . trim($filters['search']) . '%')), + $queryBuilder->expr()->like('p.author', $queryBuilder->createNamedParameter('%' . trim($filters['search']) . '%')), + $queryBuilder->expr()->like('p.abstract', $queryBuilder->createNamedParameter('%' . trim($filters['search']) . '%')), + ]; + if ($languageUid) { + $expressions[] = $queryBuilder->expr()->like('translation.title', $queryBuilder->createNamedParameter('%' . trim($filters['search']) . '%')); + $expressions[] = $queryBuilder->expr()->like('translation.description', $queryBuilder->createNamedParameter('%' . trim($filters['search']) . '%')); + $expressions[] = $queryBuilder->expr()->like('translation.author', $queryBuilder->createNamedParameter('%' . trim($filters['search']) . '%')); + $expressions[] = $queryBuilder->expr()->like('translation.abstract', $queryBuilder->createNamedParameter('%' . trim($filters['search']) . '%')); } + + $queryBuilder->andWhere( + $queryBuilder->expr()->orX( + ...$expressions + ) + ); } - $out .= implode(' OR ', $constraints) . ')'; - return $out; + + return $queryBuilder->execute()->fetchAll(); } /** @@ -435,22 +428,20 @@ class BackendNewsUtility { if (isset($pageTS['mod.']['SHARED.']['defaultLanguageLabel'])) { $defaultLanguage = $pageTS['mod.']['SHARED.']['defaultLanguageLabel'] . ' (' . $defaultLanguage . ')'; } + $defaultLanguageFlag = 'empty-empty'; if (isset($pageTS['mod.']['SHARED.']['defaultLanguageFlag'])) { $defaultLanguageFlag = 'flags-' . $pageTS['mod.']['SHARED.']['defaultLanguageFlag']; } + $languages = [ 0 => ['title' => $defaultLanguage, 'flag' => $defaultLanguageFlag] ]; - /** @var DatabaseConnection $databaseConnection */ - $databaseConnection = $GLOBALS['TYPO3_DB']; - $orderBy = ''; - if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) { - $orderBy = 'sorting'; - } - $languageRows = $databaseConnection->exec_SELECTgetRows( - 'uid, title, flag', 'sys_language', 'hidden = 0', '', $orderBy - ); + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language'); + $languageRows = $queryBuilder->select('uid', 'title', 'flag') + ->from('sys_language') + ->orderBy('sorting') + ->execute()->fetchAll(); if ($languageRows) { /** @var BackendUserAuthentication $backendUser */ $backendUser = $GLOBALS['BE_USER']; @@ -463,6 +454,7 @@ class BackendNewsUtility { } } } + return $languages; } @@ -486,28 +478,83 @@ class BackendNewsUtility { $useDeleteClause = TRUE ) { if (is_array($GLOBALS['TCA'][$theTable])) { - /** @var DatabaseConnection $databaseConnection */ - $databaseConnection = $GLOBALS['TYPO3_DB']; - $result = $databaseConnection->exec_SELECTquery( - '*', - $theTable, - $theField . '=' . $databaseConnection->fullQuoteStr($theValue, $theTable) . - ($useDeleteClause ? BackendUtility::deleteClause($theTable) . ' ' : '') . - BackendUtility::versioningPlaceholderClause($theTable) . ' ' . - $whereClause, - $groupBy, - $orderBy, - $limit - ); - $rows = []; - while ($row = $databaseConnection->sql_fetch_assoc($result)) { - $rows[] = $row; + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($theTable); + $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));; + if ($useDeleteClause) { + $queryBuilder->getRestrictions() + ->add(GeneralUtility::makeInstance(DeletedRestriction::class)); + } + + $queryBuilder->select('*') + ->from($theTable) + ->where( + $queryBuilder->expr()->eq($theField, $queryBuilder->createNamedParameter($theValue)) + ); + // additional where + if ($whereClause) { + $queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($whereClause)); + } + + // group by + if ($groupBy !== '') { + $queryBuilder->groupBy(QueryHelper::parseGroupBy($groupBy)); } - $databaseConnection->sql_free_result($result); - if (!empty($rows)) { - return $rows; + + // order by + if ($orderBy !== '') { + foreach (QueryHelper::parseOrderBy($orderBy) as $orderPair) { + list($fieldName, $order) = $orderPair; + $queryBuilder->addOrderBy($fieldName, $order); + } + } + + // limit + if ($limit !== '') { + if (strpos($limit, ',')) { + $limitOffsetAndMax = GeneralUtility::intExplode(',', $limit); + $queryBuilder->setFirstResult((int)$limitOffsetAndMax[0]); + $queryBuilder->setMaxResults((int)$limitOffsetAndMax[1]); + } else { + $queryBuilder->setMaxResults((int)$limit); + } } + + return $queryBuilder->execute()->fetchAll(); } + return NULL; } + + /** + * Register the extension icons + * For use in ext_localconf.php + */ + public static function registerIcons() { + $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); + $iconRegistry->registerIcon( + 'actions-document-open-white', + SvgIconProvider::class, + ['source' => 'EXT:sg_news/Resources/Public/Icons/actions-document-open-white.svg'] + ); + $iconRegistry->registerIcon( + 'sg_news-module', + SvgIconProvider::class, + ['source' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg'] + ); + $iconRegistry->registerIcon( + 'sg_news-module-transparent', + SvgIconProvider::class, + ['source' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews-transparent.svg'] + ); + $iconRegistry->registerIcon( + 'tcarecords-pages-' . self::CATEGORY_DOKTYPE, + BitmapIconProvider::class, + ['source' => 'EXT:sg_news/Resources/Public/Images/Category.png'] + ); + $iconRegistry->registerIcon( + 'tcarecords-pages-' . self::NEWS_DOKTYPE, + BitmapIconProvider::class, + ['source' => 'EXT:sg_news/Resources/Public/Images/News.png'] + ); + } } diff --git a/Classes/Utility/ExtensionUtility.php b/Classes/Utility/ExtensionUtility.php new file mode 100644 index 0000000000000000000000000000000000000000..65cf527ef8ecea6ca50d5026f4a97099089e3298 --- /dev/null +++ b/Classes/Utility/ExtensionUtility.php @@ -0,0 +1,55 @@ +<?php + +namespace SGalinski\SgNews\Utility; + +/** + * + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ + +use TYPO3\CMS\Core\Utility\VersionNumberUtility; + +/** + * Class ExtensionUtility + * + * @package SGalinski\SgMail\Utility + * @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de> + */ +class ExtensionUtility { + /** + * Get the extension configuration + * + * @param string $extKey + * @return array + */ + public static function getExtensionConfiguration(string $extKey = 'sg_news'): array { + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $extConf = \unserialize( + $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extKey], ['allowed_classes' => FALSE] + ); + return is_array($extConf) ? $extConf : []; + } + + return $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS'][$extKey] ?? []; + } +} diff --git a/Classes/Utility/VersionUtility.php b/Classes/Utility/VersionUtility.php deleted file mode 100644 index e7714457675b04cff7632a796ad203425f1299da..0000000000000000000000000000000000000000 --- a/Classes/Utility/VersionUtility.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php - -namespace SGalinski\SgNews\Utility; - -/*************************************************************** - * Copyright notice - * - * (c) sgalinski Internet Services (https://www.sgalinski.de) - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use TYPO3\CMS\Core\Utility\VersionNumberUtility; - -/** - * Helper class to detect the used TYPO3 version. - */ -class VersionUtility { - /** - * Returns true if the current version ts TYPO3 6.2. - * - * @return bool - */ - public static function isVersion62(): bool { - $versionNumber = self::getVersion(); - return ($versionNumber >= 6002000 && $versionNumber < 7000000); - } - - /** - * Returns true if the current version ts TYPO3 7.6 and less version 8 - * - * @return bool - */ - public static function isVersion76(): bool { - $versionNumber = self::getVersion(); - return ($versionNumber >= 7006000 && $versionNumber < 8000000); - } - - /** - * Returns true if the current version ts TYPO3 7.6 or later - * - * @return bool - */ - public static function isVersion76OOrHigher(): bool { - return (self::getVersion() >= 7006000); - } - - /** - * Returns true if the current version ts TYPO3 8.7 or later - * - * @return bool - */ - public static function isVersion870OrHigher(): bool { - return (self::getVersion() >= 8007000); - } - - /** - * Returns the current version as an integer. - * - * @return int - */ - protected static function getVersion(): int { - return VersionNumberUtility::convertVersionNumberToInteger( - VersionNumberUtility::getNumericTypo3Version() - ); - } -} diff --git a/Classes/ViewHelpers/Backend/ControlViewHelper.php b/Classes/ViewHelpers/Backend/ControlViewHelper.php index d25c74ad542c9110e581ef3a01c43bad71f9c665..f1aedda2430b977f668d936e6ca1ed12b0f7d370 100644 --- a/Classes/ViewHelpers/Backend/ControlViewHelper.php +++ b/Classes/ViewHelpers/Backend/ControlViewHelper.php @@ -30,10 +30,11 @@ use SGalinski\SgNews\Service\LicensingService; use SGalinski\SgNews\ViewHelpers\AbstractViewHelper; use TYPO3\CMS\Backend\Clipboard\Clipboard; use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; @@ -41,31 +42,54 @@ use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; * Class ControlViewHelper **/ class ControlViewHelper extends AbstractViewHelper { + + /** + * Initialize the ViewHelper arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('table', 'string', 'The table to control', TRUE); + $this->registerArgument('row', 'mixed', 'The row of the record', TRUE); + $this->registerArgument('sortingData', 'array', 'The sorting data', FALSE, []); + $this->registerArgument('clipboard', 'bool', 'Use the clipboard', FALSE, FALSE); + } + /** * Renders the control buttons for the specified record * - * @param string $table - * @param mixed $row - * @param array $sortingData - * @param boolean $clipboard * @return string * @throws \InvalidArgumentException * @throws \UnexpectedValueException */ - public function render($table, $row, array $sortingData = [], $clipboard = FALSE): string { + public function render(): string { + $table = $this->arguments['table']; + $row = $this->arguments['row']; + $sortingData = $this->arguments['sortingData']; + $clipboard = $this->arguments['clipboard']; if (!is_array($row)) { $row = BackendUtility::getRecord($table, $row->getUid()); } - /** @var DatabaseRecordList $databaseRecordList */ + $databaseRecordList = GeneralUtility::makeInstance(DatabaseRecordList::class); - /** @var BackendUserAuthentication $backendUser */ $backendUser = $GLOBALS['BE_USER']; $pageInfo = BackendUtility::readPageAccess($row['pid'], $backendUser->getPagePermsClause(1)); $databaseRecordList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo); + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/AjaxDataHandler'); + $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf'); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Lang\LanguageService::class); + } else { + $languageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class); + } + + $languageService->includeLLFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf'); + $databaseRecordList->currentTable = $sortingData; if ($table === 'pages') { $databaseRecordList->searchLevels = 1; } + $out = $databaseRecordList->makeControl($table, $row); if ($clipboard) { $databaseRecordList->MOD_SETTINGS['clipBoard'] = TRUE; @@ -74,24 +98,30 @@ class ControlViewHelper extends AbstractViewHelper { $GLOBALS['SOBE'] = $databaseRecordList; $out .= $databaseRecordList->makeClip($table, $row); } - if ($table === 'pages' && LicensingService::checkKey()) { - $rootline = BackendUtility::BEgetRootLine($row['uid'], '', TRUE); - ksort($rootline); - $path = '/root'; - foreach ($rootline as $page) { - $path .= '/p' . dechex($page['uid']); - } - /** @var IconFactory $iconFactory */ + if ($table === 'pages' && LicensingService::checkKey()) { $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $buttonLabel = LocalizationUtility::translate('backend.button.editPageContent', 'SgNews'); - $onclick = 'return sgNewsGoToPageModule(' . $row['uid'] . ', \'' . $path . '\');'; + $path = ''; + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $rootline = BackendUtility::BEgetRootLine($row['uid'], '', TRUE); + ksort($rootline); + $path = '/root'; + foreach ($rootline as $page) { + $path .= '/p' . dechex($page['uid']); + } + + $path = ', \'' . $path . '\''; + } + + $onclick = 'return TYPO3.SgNewsModule.sgNewsGoToPageModule(' . $row['uid'] . $path . ');'; $icon = $iconFactory->getIcon('actions-document-open-white', Icon::SIZE_SMALL)->render(); $wrap = ' <div class="btn-group" role="group">%s</div>'; $link = '<a href="#" onclick="' . $onclick . '" class="btn btn-primary" title="' . $buttonLabel . '">%s</a>'; $link = sprintf($link, $icon . ' ' . $buttonLabel); $out .= sprintf($wrap, $link); } + return $out; } } diff --git a/Classes/ViewHelpers/Backend/EditOnClickViewHelper.php b/Classes/ViewHelpers/Backend/EditOnClickViewHelper.php index 9a643a804a3c69b137da0205273b21cbd09de9ca..9645ebf43252d074dd791cd6151da6863d22f80b 100644 --- a/Classes/ViewHelpers/Backend/EditOnClickViewHelper.php +++ b/Classes/ViewHelpers/Backend/EditOnClickViewHelper.php @@ -34,21 +34,34 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; * Class EditOnClickViewHelper **/ class EditOnClickViewHelper extends AbstractViewHelper { + + /** + * Register the ViewHelper arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('table', 'string', 'The table for the clickenlarge link', TRUE); + $this->registerArgument('uid', 'int', 'The uid of the record to clickenlarge', TRUE); + $this->registerArgument('new', 'bool', 'Open a new record in the popup', FALSE, FALSE); + $this->registerArgument('type', 'string', 'The type of the news', FALSE, ''); + } + /** * Renders the onclick script for editing a record * - * @param string $table - * @param int $uid - * @param boolean $new - * @param string $type * @return string */ - public function render($table, $uid, $new = FALSE, $type = ''): string { + public function render(): string { + $table = $this->arguments['table']; + $uid = $this->arguments['uid']; + $new = $this->arguments['new']; + $type = $this->arguments['type']; $additionalParameters = ''; if ($new && $table === 'pages' && in_array($type, ['news', 'category'], TRUE)) { $additionalParameters = '&overrideVals[pages][doktype]=' . ($type === 'news' ? BackendNewsUtility::NEWS_DOKTYPE : BackendNewsUtility::CATEGORY_DOKTYPE); } + return BackendUtility::editOnClick( '&edit[' . $table . '][' . $uid . ']=' . ($new ? 'new' : 'edit') . $additionalParameters, '', -1 ); diff --git a/Classes/ViewHelpers/Backend/IconViewHelper.php b/Classes/ViewHelpers/Backend/IconViewHelper.php index ec51011e9fecff20b437cd472bc1fada4f80e25b..5788ca4d81acf229368e7c31b2566c411188b021 100644 --- a/Classes/ViewHelpers/Backend/IconViewHelper.php +++ b/Classes/ViewHelpers/Backend/IconViewHelper.php @@ -35,19 +35,28 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; * Class IconViewHelper **/ class IconViewHelper extends AbstractViewHelper { + + /** + * Initialize the ViewHelper arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('id', 'string', 'The id of the record', TRUE); + $this->registerArgument('size', 'string', 'The size of the icon', FALSE, ''); + $this->registerArgument('overlayId', 'string', 'The overlay of the icon', FALSE); + } + /** * Renders the icon for the specified identifier * with the requested size option and overlay. * - * @param string $id - * @param string $size - * @param string $overlayId * @return string * @throws \InvalidArgumentException */ - public function render($id, $size = '', $overlayId = NULL): string { - $id = trim($id); - $size = trim($size); + public function render(): string { + $id = trim($this->arguments['id']); + $size = trim($this->arguments['size']); + $overlayId = $this->arguments['overlayId']; switch ($size) { case 'small' : $size = Icon::SIZE_SMALL; @@ -59,7 +68,7 @@ class IconViewHelper extends AbstractViewHelper { $size = Icon::SIZE_DEFAULT; break; } - /** @var IconFactory $iconFactory */ + $iconFactory = GeneralUtility::makeInstance(IconFactory::class); return $iconFactory->getIcon($id, $size, $overlayId)->render(); } diff --git a/Classes/ViewHelpers/Backend/NewsItemTagsViewHelper.php b/Classes/ViewHelpers/Backend/NewsItemTagsViewHelper.php index 95bb30885895a73d43ba62179f82304db6754506..ebaa2980d917bcea4fd960c176381ac16a32fb95 100644 --- a/Classes/ViewHelpers/Backend/NewsItemTagsViewHelper.php +++ b/Classes/ViewHelpers/Backend/NewsItemTagsViewHelper.php @@ -33,23 +33,32 @@ use SGalinski\SgNews\ViewHelpers\AbstractViewHelper; * Class EditOnClickViewHelper **/ class NewsItemTagsViewHelper extends AbstractViewHelper { + + /** + * Initialize the ViewHelper arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('uid', 'int', 'The uid of the news', FALSE, 0); + $this->registerArgument('languageUid', 'int', 'The language uid', FALSE, 0); + } + /** * Renders the tags for the specified news uid * - * @param int $uid - * @param int $languageUid * @return string * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \InvalidArgumentException */ - public function render($uid = 0, $languageUid = 0): string { + public function render(): string { $out = ''; - $uid = (int) $uid; - $languageUid = (int) $languageUid; + $uid = $this->arguments['uid']; + $languageUid = $this->arguments['languageUid']; if ($uid) { $tags = BackendNewsUtility::getTagsForNewsItem($uid, $languageUid); $out = implode(', ', $tags); } + return $out; } } diff --git a/Classes/ViewHelpers/Backend/RecordIconViewHelper.php b/Classes/ViewHelpers/Backend/RecordIconViewHelper.php index 222e757e7c05b1c7abbb72f6c8de1f7ce809bdd7..20f18b705713daa8d7002da845edd6eb01f511f3 100644 --- a/Classes/ViewHelpers/Backend/RecordIconViewHelper.php +++ b/Classes/ViewHelpers/Backend/RecordIconViewHelper.php @@ -36,17 +36,27 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; * Class IconViewHelper **/ class RecordIconViewHelper extends AbstractViewHelper { + + /** + * Initialize the ViewHelper arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('table', 'string', 'The table of the record', TRUE); + $this->registerArgument('row', 'array', 'The row of the record icon', TRUE); + $this->registerArgument('clickMenu', 'bool', 'Render the click menu', FALSE, TRUE); + } + /** * Renders the icon for the specified record * - * @param string $table - * @param mixed $row - * @param boolean $clickMenu * @return string * @throws \InvalidArgumentException */ - public function render($table, $row, $clickMenu = TRUE): string { - /** @var IconFactory $iconFactory */ + public function render(): string { + $table = $this->arguments['table']; + $row = $this->arguments['row']; + $clickMenu = $this->arguments['clickMenu']; $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $toolTip = BackendUtility::getRecordToolTip($row, $table); $iconImg = '<span ' . $toolTip . '>' @@ -55,6 +65,7 @@ class RecordIconViewHelper extends AbstractViewHelper { if ($clickMenu) { return BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']); } + return $iconImg; } } diff --git a/Classes/ViewHelpers/Backend/TranslationLinksViewHelper.php b/Classes/ViewHelpers/Backend/TranslationLinksViewHelper.php index c9a46641cbb501cc376ae6ca0de40a1407924058..466edb9c78ac9de6b5861735d5a7849f75d47373 100644 --- a/Classes/ViewHelpers/Backend/TranslationLinksViewHelper.php +++ b/Classes/ViewHelpers/Backend/TranslationLinksViewHelper.php @@ -29,40 +29,54 @@ namespace SGalinski\SgNews\ViewHelpers\Backend; use SGalinski\SgNews\Service\LicensingService; use SGalinski\SgNews\Utility\BackendNewsUtility; use SGalinski\SgNews\ViewHelpers\AbstractViewHelper; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Type\Icon\IconState; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** * Class EditOnClickViewHelper **/ class TranslationLinksViewHelper extends AbstractViewHelper { + + /** + * Register the ViewHelp0er arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('uid', 'int', 'The uid of the record', TRUE); + $this->registerArgument('table', 'string', 'The table of the record', TRUE); + $this->registerArgument('pageUid', 'int', 'The uid of the page', FALSE, 0); + } + /** * Renders the translation links for the specified record * - * @param int $pageUid - * @param string $table - * @param int $uid * @return string * @throws \InvalidArgumentException */ - public function render($pageUid = 0, $table, $uid): string { + public function render(): string { + $uid = $this->arguments['uid']; + $table = $this->arguments['table']; + $pageUid = $this->arguments['pageUid']; $out = ''; if (!LicensingService::checkKey()) { return $out; } + $table = trim($table); if ($table !== 'pages' && !isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])) { return $out; } + $uid = (int) $uid; $pageUid = (int) $pageUid; $row = BackendUtility::getRecord($table, $uid); if ($row) { - /** @var IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $lanuageField = $GLOBALS['TCA'][$table]['ctrl']['languageField']; $currentLanguageUid = $table === 'pages' ? 0 : $row[$lanuageField]; @@ -76,52 +90,72 @@ class TranslationLinksViewHelper extends AbstractViewHelper { } else { $languages = BackendNewsUtility::getAvailableLanguages($pageUid); } + $editLabel = LocalizationUtility::translate('backend.action.edit', 'SgNews'); $newLabel = LocalizationUtility::translate('backend.action.new', 'SgNews'); $translationParameters = '&cmd[' . $table . '][' . $row['uid'] . '][localize]=%s'; - if ($table === 'pages') { - $translationParameters = '&edit[pages_language_overlay][' . $row['uid'] . ']=new'; - $translationParameters .= '&overrideVals[pages_language_overlay][doktype]=' . $row['doktype']; - $translationParameters .= '&overrideVals[pages_language_overlay][sys_language_uid]=%s'; + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $returnUrl = BackendUtility::getModuleUrl('web_SgNewsNews', ['id' => GeneralUtility::_GP('id')]); + } else { + $returnUrl = GeneralUtility::makeInstance(UriBuilder::class) + ->buildUriFromRoute('web_SgNewsNews', ['id' => GeneralUtility::_GP('id')]); } + foreach ($languages as $languageUid => $language) { $translatedUid = 0; if ((int) $languageUid <= 0) { $translationTable = $table; $translatedUid = $uid; } else { - $translationTable = $table === 'pages' ? 'pages_language_overlay' : $table; + $translationTable = $table; $translatedRows = BackendUtility::getRecordLocalization($table, $uid, $languageUid); if (count($translatedRows)) { $translatedUid = (int) $translatedRows[0]['uid']; } } + if ($translatedUid) { - $onClick = BackendUtility::editOnClick( - '&edit[' . $translationTable . '][' . $translatedUid . ']=edit', '', -1 - ); - $out .= ' <a href="#" onclick="' . $onClick . '" title="' . $language['title'] . ' [' . $editLabel . ']" >' . - $iconFactory->getIcon($language['flag'], Icon::SIZE_SMALL)->render() . - '</a>'; - } else { - if ($table === 'pages') { - $onClick = BackendUtility::editOnClick( - sprintf($translationParameters, $languageUid), '', -1 - ); + if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $link = BackendUtility::getModuleUrl('record_edit', [ + 'edit' => [ + $translationTable => [ + $translatedUid => 'edit' + ] + ], + 'returnUrl' => $returnUrl + ]); } else { - $onClick = 'window.location.href=' . BackendUtility::getLinkToDataHandlerAction( - sprintf($translationParameters, $languageUid), -1 - ) . ' return false;'; + $link = GeneralUtility::makeInstance(UriBuilder::class) + ->buildUriFromRoute('record_edit', [ + 'edit' => [ + $translationTable => [ + $translatedUid => 'edit' + ] + ], + 'returnUrl' => (string) $returnUrl + ]); } - $out .= ' <a href="#" onclick="' . $onClick . '" title="' . $language['title'] . ' [' . $newLabel . ']" >' . - $iconFactory->getIcon( - $language['flag'], Icon::SIZE_SMALL, 'overlay-new', + + $out .= ' <a href="' . $link . '" title="'. $language['title'] . ' [' . $editLabel . ']" >' + . $iconFactory->getIcon($language['flag'], Icon::SIZE_SMALL)->render() + . '</a>'; + } else { + $out .= ' <a href="' + . BackendUtility::getLinkToDataHandlerAction( + sprintf($translationParameters, $languageUid), $returnUrl + ) + . '" title="' . $language['title'] . ' [' . $newLabel . ']" >' + . $iconFactory->getIcon( + $language['flag'], + Icon::SIZE_SMALL, + 'overlay-new', IconState::cast(IconState::STATE_DISABLED) - )->render() . - '</a>'; + )->render() + . '</a>'; } } } + return $out; } } diff --git a/Classes/ViewHelpers/Backend/Widget/PaginateViewHelper.php b/Classes/ViewHelpers/Backend/Widget/PaginateViewHelper.php index b3dd0b0f381e942639154ac136b743b05b559b28..644806b9d8baa9ed11e7c0288846750fd119d2c6 100644 --- a/Classes/ViewHelpers/Backend/Widget/PaginateViewHelper.php +++ b/Classes/ViewHelpers/Backend/Widget/PaginateViewHelper.php @@ -33,7 +33,7 @@ use TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetViewHelper; */ class PaginateViewHelper extends AbstractWidgetViewHelper { /** - * @var \SGalinski\SgNews\ViewHelpers\Backend\Widget\Controller\PaginateController + * @var PaginateController */ protected $controller; @@ -42,25 +42,38 @@ class PaginateViewHelper extends AbstractWidgetViewHelper { * * @param PaginateController $controller */ - public function injectPaginateController( - PaginateController $controller - ) { + public function injectPaginateController(PaginateController $controller) { $this->controller = $controller; } + /** + * Initialize the ViewHelper arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('objects', 'mixed', 'The objects to paginate', TRUE); + $this->registerArgument('as', 'string', 'The name of the variable inside the pagination', TRUE); + $this->registerArgument( + 'configuration', + 'array', + 'The configuration of the pagination', + FALSE, + [ + 'itemsPerPage' => 10, + 'insertAbove' => FALSE, + 'insertBelow' => TRUE, + 'recordsLabel' => '' + ] + ); + } + /** * Renders the paginator * - * @param mixed $objects - * @param string $as - * @param array $configuration * @return string * @throws \TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException */ - public function render( - $objects, $as, - array $configuration = ['itemsPerPage' => 10, 'insertAbove' => FALSE, 'insertBelow' => TRUE, 'recordsLabel' => ''] - ): string { + public function render(): string { return $this->initiateSubRequest(); } } diff --git a/Classes/ViewHelpers/ExtendedIfViewHelper.php b/Classes/ViewHelpers/ExtendedIfViewHelper.php deleted file mode 100644 index 15bdd046be79eb8f88e7fe1ab3b71cc059b0f676..0000000000000000000000000000000000000000 --- a/Classes/ViewHelpers/ExtendedIfViewHelper.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php - -namespace SGalinski\SgNews\ViewHelpers; - -/*************************************************************** - * Copyright notice - * - * (c) sgalinski Internet Services (https://www.sgalinski.de) - * - * All rights reserved - * - * This script is part of the TYPO3 project. The TYPO3 project is - * free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * The GNU General Public License can be found at - * http://www.gnu.org/copyleft/gpl.html. - * - * This script is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * This copyright notice MUST APPEAR in all copies of the script! - ***************************************************************/ - -use TYPO3\CMS\Core\Utility\VersionNumberUtility; -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper; - -/** - * ExtendedIfViewHelper - */ -class ExtendedIfViewHelper extends AbstractConditionViewHelper { - /** - * Initializes the "then" and "else" arguments - */ - public function initializeArguments() { - parent::initializeArguments(); - if(VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < 8000000) { - $this->registerArgument( - 'condition', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE - ); - } - $this->registerArgument( - 'or', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE - ); - $this->registerArgument( - 'or2', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE - ); - $this->registerArgument( - 'or3', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE - ); - $this->registerArgument( - 'or4', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE - ); - $this->registerArgument( - 'and', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, TRUE - ); - $this->registerArgument( - 'and2', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, TRUE - ); - $this->registerArgument( - 'and3', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, TRUE - ); - $this->registerArgument( - 'and4', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, TRUE - ); - $this->registerArgument( - 'negate', 'boolean', 'Condition expression conforming to Fluid boolean rules', FALSE, FALSE - ); - } - - /** - * This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality. - * - * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method. - * @return bool - */ - static protected function evaluateCondition($arguments = NULL) { - $conditionResult = ( - isset($arguments['condition']) && $arguments['condition'] || - isset($arguments['or']) && $arguments['or'] || - isset($arguments['or2']) && $arguments['or2'] || - isset($arguments['or3']) && $arguments['or3'] || - isset($arguments['or4']) && $arguments['or4'] - ) && isset($arguments['and']) && $arguments['and'] && - isset($arguments['and2']) && $arguments['and2'] && - isset($arguments['and3']) && $arguments['and3'] && - isset($arguments['and4']) && $arguments['and4']; - - return isset($arguments['negate']) && $arguments['negate'] ? !$conditionResult : $conditionResult; - } -} diff --git a/Classes/ViewHelpers/GetReadingTimeViewHelper.php b/Classes/ViewHelpers/GetReadingTimeViewHelper.php index 69d48c258f8445b1ca17373212b392236c17eb92..eb601920b7563f7c97099834374ab3c6279a9cfd 100644 --- a/Classes/ViewHelpers/GetReadingTimeViewHelper.php +++ b/Classes/ViewHelpers/GetReadingTimeViewHelper.php @@ -26,7 +26,7 @@ namespace SGalinski\SgNews\ViewHelpers; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; /** * View helper that returns the estimates reading time of a given content @@ -36,13 +36,22 @@ use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; * <sg:getReadingTime content="" /> */ class GetReadingTimeViewHelper extends AbstractViewHelper { + + /** + * Register the ViewHelper arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('content', 'string', 'The content to read', TRUE); + } + /** * Returns the estimated reading time of the given content * - * @param string $content * @return string */ - public function render($content): string { + public function render(): string { + $content = $this->arguments['content']; $word = str_word_count(strip_tags($content)); $minutes = floor($word / 200); $seconds = floor($word % 200 / (200 / 60)); diff --git a/Classes/ViewHelpers/PageBrowserViewHelper.php b/Classes/ViewHelpers/PageBrowserViewHelper.php index 9f5ecba08db964953e1eaee60a8566e1d0ecbfe4..b117695b1233e9fda7f722cfb1d4cb67655489f8 100644 --- a/Classes/ViewHelpers/PageBrowserViewHelper.php +++ b/Classes/ViewHelpers/PageBrowserViewHelper.php @@ -26,7 +26,8 @@ namespace SGalinski\SgNews\ViewHelpers; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; +use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; /** @@ -46,14 +47,36 @@ class PageBrowserViewHelper extends AbstractViewHelper { */ protected $escapeOutput = FALSE; + /** + * @var ObjectManager + */ + protected $objectManager; + + /** + * Inject the ObjectManager + * + * @param ObjectManager $objectManager + */ + public function injectObjectManager(ObjectManager $objectManager) { + $this->objectManager = $objectManager; + } + + /** + * Initialize the ViewHelpers arguments + */ + public function initializeArguments() { + parent::initializeArguments(); + $this->registerArgument('numberOfPages', 'int', 'The number of pages to browse', TRUE); + } + /** * Render method of the view helper. * - * @param integer $numberOfPages * @return string * @throws \UnexpectedValueException */ - public function render($numberOfPages): string { + public function render(): string { + $numberOfPages = $this->arguments['numberOfPages']; $configuration = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_sgnews.']['pagebrowser.']; $configuration['settings.']['numberOfPages'] = (int) $numberOfPages; diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index bc56bc97757aaedb822e11d6cad2c27edf4cafd0..83de5f59a0ef3e4a1cf7eee6a3fe16efa6fe2fc1 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -1,444 +1,412 @@ <?php +/** + * + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ -$imageColumns = [ - 'tx_sgnews_teaser1_image' => [ - 'exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_teaser1_image', - 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( - 'tx_sgnews_teaser1_image', +call_user_func( + function ($extKey, $table) { + $localLangDbPath = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:'; + $localLangBackendPath = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:'; + foreach ( [ - 'maxitems' => 9999, - 'foreign_types' => [ - '0' => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ] + \SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE => [ + 'icon' => 'EXT:sg_news/Resources/Public/Images/Category.png', + 'locallangIndex' => 'pageType.category' + ], + \SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE => [ + 'icon' => 'EXT:sg_news/Resources/Public/Images/News.png', + 'locallangIndex' => 'pageType.news' + ] + ] as $doktype => $configuration) { + + // add the new doktype to the page type selector + $GLOBALS['TCA'][$table]['columns']['doktype']['config']['items'][] = [ + $localLangBackendPath . $configuration['locallangIndex'], + $doktype, + $configuration['icon'] + ]; + + // also add the new doktype to the page language overlays type selector (so that translations can inherit the same type) + $GLOBALS['TCA']['' . $table . '_language_overlay']['columns']['doktype']['config']['items'][] = [ + $localLangBackendPath . $configuration['locallangIndex'], + $doktype, + $configuration['icon'] + ]; + + $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$doktype] = 'tcarecords-' . $table . '-' . $doktype; + + // add the new doktype to the list of page types + $GLOBALS['PAGES_TYPES'][$doktype] = [ + 'type' => 'sys', + 'icon' => $configuration['icon'], + 'allowedTables' => '*', + ]; + } + + $GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE] = [ + 'showitem' => '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general, + --palette--;;standard, + --palette--;;titleDescriptionAndHighlightFlag, + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.editorial;editorialWithNewsAuthor, + tx_sgnews_related_news, tx_sgnews_tags, + --div--;' . $localLangDbPath . $table . '.tabs.images, + tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.metadata, + tx_projectbase_devnullrobots_flags, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.abstract;abstract, + tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.appearance, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.layout;layout, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.visibility;visibility, + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.access;access, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.behaviour, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.caching;caching, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.miscellaneous;miscellaneous, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, + --palette--;;language + ' + ]; + + $GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE] = [ + 'showitem' => '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general, + --palette--;;standard, + title, slug, tx_realurl_pathsegment, tx_realurl_exclude, + --div--;' . $localLangDbPath . $table . '.tabs.images, + tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.metadata, + tx_projectbase_devnullrobots_flags, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.abstract;abstract, + tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.appearance, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.layout;layout, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.visibility;visibility, + --palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.access;access, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.behaviour, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.caching;caching, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.miscellaneous;miscellaneous, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, + --palette--;;language + ' + ]; + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns( + $table, [ + 'tx_sgnews_teaser1_image' => [ + 'exclude' => TRUE, + 'label' => $localLangDbPath . $table . '.tx_sgnews_teaser1_image', + 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'tx_sgnews_teaser1_image', + [ + 'maxitems' => 9999, + 'foreign_types' => [ + '0' => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ] + ], + 'appearance' => [ + 'showPossibleLocalizationRecords' => TRUE, + 'showRemovedLocalizationRecords' => TRUE, + 'showSynchronizationLink' => TRUE, + 'showAllLocalizationLink' => TRUE, + ], + ], + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] + ), ], - 'appearance' => [ - 'showPossibleLocalizationRecords' => TRUE, - 'showRemovedLocalizationRecords' => TRUE, - 'showSynchronizationLink' => TRUE, - 'showAllLocalizationLink' => TRUE, + 'tx_sgnews_teaser2_image' => [ + 'exclude' => TRUE, + 'label' => $localLangDbPath . $table . '.tx_sgnews_teaser2_image', + 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'tx_sgnews_teaser2_image', + [ + 'maxitems' => 9999, + 'foreign_types' => [ + '0' => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ] + ], + 'appearance' => [ + 'showPossibleLocalizationRecords' => TRUE, + 'showRemovedLocalizationRecords' => TRUE, + 'showSynchronizationLink' => TRUE, + 'showAllLocalizationLink' => TRUE, + ], + ], + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] + ), ], - ], - $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] - ), - ], - 'tx_sgnews_teaser2_image' => [ - 'exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_teaser2_image', - 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( - 'tx_sgnews_teaser2_image', - [ - 'maxitems' => 9999, - 'foreign_types' => [ - '0' => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' + 'tx_sgnews_author' => [ + 'exclude' => TRUE, + 'l10n_exclude' => TRUE, + 'label' => $localLangDbPath . $table . '.tx_sgnews_author', + 'config' => [ + 'type' => 'group', + 'internal_type' => 'db', + 'allowed' => 'fe_users', + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, + 'items' => [ + ['', ''], + ], + 'wizards' => [ + 'suggest' => [ + 'type' => 'suggest', + ], + ], ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' + ], + 'tx_sgnews_related_news' => [ + 'exclude' => TRUE, + 'l10n_exclude' => TRUE, + 'label' => $localLangDbPath . $table . '.tx_sgnews_related_news', + 'config' => [ + 'type' => 'group', + 'internal_type' => 'db', + 'allowed' => $table, + 'size' => 5, + 'minitems' => 0, + 'maxitems' => 99, + 'wizards' => [ + 'suggest' => [ + 'type' => 'suggest', + ], + ], ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' + ], + 'tx_sgnews_highlighted' => [ + 'displayCond' => 'FIELD:tx_sgnews_never_highlighted:=:0', + 'exclude' => TRUE, + 'l10n_exclude' => TRUE, + 'label' => $localLangDbPath . $table . '.tx_sgnews_highlighted', + 'config' => [ + 'type' => 'check', ], - \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [ - 'showitem' => ' - --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, - --palette--;;filePalette' - ] ], - 'appearance' => [ - 'showPossibleLocalizationRecords' => TRUE, - 'showRemovedLocalizationRecords' => TRUE, - 'showSynchronizationLink' => TRUE, - 'showAllLocalizationLink' => TRUE, + 'tx_sgnews_never_highlighted' => [ + 'displayCond' => 'FIELD:tx_sgnews_highlighted:=:0', + 'exclude' => TRUE, + 'l10n_exclude' => TRUE, + 'label' => $localLangDbPath . $table . '.tx_sgnews_never_highlighted', + 'config' => [ + 'type' => 'check', + ], ], - ], - $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] - ), - ], -]; - -$columns = array_merge( - [ - 'tx_sgnews_author' => [ - 'exclude' => TRUE, - 'l10n_exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_author', - 'config' => [ - 'type' => 'group', - 'internal_type' => 'db', - 'allowed' => 'fe_users', - 'size' => 1, - 'minitems' => 0, - 'maxitems' => 1, - 'items' => [ - ['', ''], + 'tx_sgnews_tags' => [ + 'exclude' => 1, + 'label' => $localLangDbPath . $table . '.tx_sgnews_tags', + 'config' => [ + 'type' => 'select', + 'maxitems' => 9999, + 'size' => 10, + 'foreign_table' => 'sys_category', + 'foreign_table_where' => 'AND (IF (###PAGE_TSCONFIG_ID### = 0, 1, sys_category.pid = ###PAGE_TSCONFIG_ID###)) AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC', + 'MM' => 'sys_category_record_mm', + 'MM_match_fields' => [ + 'fieldname' => 'tx_sgnews_tags', + 'tablenames' => $table + ], + 'MM_opposite_field' => 'items', + 'renderType' => 'selectTree', + 'treeConfig' => [ + 'parentField' => 'parent', + 'appearance' => [ + 'expandAll' => 1, + 'maxLevels' => 99, + 'showHeader' => 1 + ] + ] + ] ], - 'wizards' => [ - 'suggest' => [ - 'type' => 'suggest', - ], + 'tx_sgnews_likes' => [ + 'label' => $localLangDbPath . $table . '.tx_sgnews_likes', + 'config' => [ + 'type' => 'input', + 'size' => '20', + 'eval' => 'trim', + ] ], - ], - ], - 'tx_sgnews_related_news' => [ - 'exclude' => TRUE, - 'l10n_exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_related_news', - 'config' => [ - 'type' => 'group', - 'internal_type' => 'db', - 'allowed' => 'pages', - 'size' => 5, - 'minitems' => 0, - 'maxitems' => 99, - 'wizards' => [ - 'suggest' => [ - 'type' => 'suggest', - ], + 'lastUpdated' => [ + 'exclude' => TRUE, + 'label' => 'LLL:EXT:cms/locallang_tca.xlf:' . $table . '.lastUpdated', + 'config' => [ + 'type' => 'input', + 'size' => '13', + 'max' => '20', + 'eval' => 'datetime', + 'default' => $GLOBALS['EXEC_TIME'], + ] ], - ], - ], - 'tx_sgnews_highlighted' => [ - 'displayCond' => 'FIELD:tx_sgnews_never_highlighted:=:0', - 'exclude' => TRUE, - 'l10n_exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_highlighted', - 'config' => [ - 'type' => 'check', - ], - ], - 'tx_sgnews_never_highlighted' => [ - 'displayCond' => 'FIELD:tx_sgnews_highlighted:=:0', - 'exclude' => TRUE, - 'l10n_exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_never_highlighted', - 'config' => [ - 'type' => 'check', - ], - ], - 'tx_sgnews_tags' => [ - 'exclude' => 1, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_tags', - 'config' => [ - 'type' => 'select', - 'maxitems' => 9999, - 'size' => 10, - 'foreign_table' => 'sys_category', - 'foreign_table_where' => 'AND (IF (###PAGE_TSCONFIG_ID### = 0, 1, sys_category.pid = ###PAGE_TSCONFIG_ID###)) AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC', - 'MM' => 'sys_category_record_mm', - 'MM_match_fields' => [ - 'fieldname' => 'tx_sgnews_tags', - 'tablenames' => 'pages' + 'tx_sgnews_date_end' => [ + 'exclude' => TRUE, + 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_date_end', + 'config' => [ + 'type' => 'input', + 'size' => '13', + 'max' => '20', + 'eval' => 'datetime', + 'default' => $GLOBALS['EXEC_TIME'], + ] ], - 'MM_opposite_field' => 'items', - 'renderType' => 'selectTree', - 'treeConfig' => [ - 'parentField' => 'parent', - 'appearance' => [ - 'expandAll' => 1, - 'maxLevels' => 99, - 'showHeader' => 1 + 'tx_sgnews_location' => [ + 'exclude' => TRUE, + 'label' => $localLangDbPath . $table . '.tx_sgnews_location', + 'config' => [ + 'type' => 'input', + 'size' => 20, + 'eval' => 'trim', + 'behaviour' => [ + 'allowLanguageSynchronization' => TRUE + ] ] ] ] - ], - 'tx_sgnews_likes' => [ - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_likes', - 'config' => [ - 'type' => 'input', - 'size' => '20', - 'eval' => 'trim', - ] - ], - 'lastUpdated' => [ - 'exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_date_start', - 'config' => [ - 'type' => 'input', - 'size' => '13', - 'max' => '20', - 'eval' => 'datetime', - 'default' => $GLOBALS['EXEC_TIME'], - ] - ], - 'tx_sgnews_date_end' => [ - 'exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_date_end', - 'config' => [ - 'type' => 'input', - 'size' => '13', - 'max' => '20', - 'eval' => 'datetime', - 'default' => $GLOBALS['EXEC_TIME'], - ] - ], - 'tx_sgnews_location' => [ - 'exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_location', - 'config' => [ - 'type' => 'input', - 'size' => 20, - 'eval' => 'trim' - ] - ] - ], $imageColumns -); -$languageOverlayColumns = array_merge( - [ - 'tx_sgnews_location' => [ - 'exclude' => TRUE, - 'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_location', - 'config' => [ - 'type' => 'input', - 'size' => 20, - 'eval' => 'trim' - ] - ] - ], $imageColumns -); -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $columns); -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages_language_overlay', $languageOverlayColumns); - -$GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag'] = [ - 'showitem' => 'subtitle;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.subtitle.inPalette, - --linebreak--, description, - --linebreak--, tx_realurl_pathsegment, tx_realurl_exclude, - --linebreak--, tx_sgnews_highlighted, tx_sgnews_never_highlighted', - 'canNotCollapse' => 1, -]; - -if (\SGalinski\SgNews\Utility\VersionUtility::isVersion870OrHigher()) { - $GLOBALS['TCA']['pages']['palettes']['editorialWithNewsAuthor'] = [ - 'showitem' => 'tx_sgnews_author;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_author.inPalette, - --linebreak--, - author;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.author_formlabel, - author_email;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.author_email_formlabel, - --linebreak--, lastUpdated;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.lastUpdated_formlabel,tx_sgnews_date_end, - --linebreak--,tx_sgnews_likes,tx_sgnews_location', - 'canNotCollapse' => 1, - ]; - - # - # Pages - # - $GLOBALS['TCA']['pages']['types'][116] = [ - 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard, - --palette--;;titleDescriptionAndHighlightFlag, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.editorial;editorialWithNewsAuthor, - tx_sgnews_related_news, tx_sgnews_tags, - --div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images, - tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata, - tx_projectbase_devnullrobots_flags, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract, - tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout, - --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;visibility, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.language;language, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.miscellaneous;miscellaneous, - ' - ]; - - $GLOBALS['TCA']['pages']['types'][117] = [ - 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard, - title, tx_realurl_pathsegment, tx_realurl_exclude, - --div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images, - tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata, - tx_projectbase_devnullrobots_flags, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract, - tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout, - --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;visibility, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.language;language, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.miscellaneous;miscellaneous, - ' - ]; + ); - # - # Pages Overlay - # - $GLOBALS['TCA']['pages_language_overlay']['types'][116] = [ - 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard, - subtitle;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.subtitle.inPalette, - description, tx_realurl_pathsegment, author, tx_sgnews_location, - --div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images, - tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract, - tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, - --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, - sys_language_uid, - --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;hiddenonly, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access' - ]; + $GLOBALS['TCA'][$table]['palettes']['titleDescriptionAndHighlightFlag'] = [ + 'showitem' => 'subtitle;' . $localLangDbPath . $table . '.subtitle.inPalette, + --linebreak--, title, + --linebreak--, description, + --linebreak--, slug, + --linebreak--, tx_realurl_pathsegment, tx_realurl_exclude, + --linebreak--, tx_sgnews_highlighted, tx_sgnews_never_highlighted', + 'canNotCollapse' => 1, + ]; - $GLOBALS['TCA']['pages_language_overlay']['types'][117] = [ - 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard, - title, tx_realurl_pathsegment, - --div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images, - tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract, - tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description, - --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, - sys_language_uid, - --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;hiddenonly, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access' - ]; -} else { - $GLOBALS['TCA']['pages']['palettes']['editorialWithNewsAuthor'] = [ - 'showitem' => 'tx_sgnews_author;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_author.inPalette, + $GLOBALS['TCA'][$table]['palettes']['editorialWithNewsAuthor'] = [ + 'showitem' => 'tx_sgnews_author;' . $localLangDbPath . $table . '.tx_sgnews_author.inPalette, --linebreak--, - author;LLL:EXT:cms/locallang_tca.xlf:pages.author_formlabel, - author_email;LLL:EXT:cms/locallang_tca.xlf:pages.author_email_formlabel, - --linebreak--, lastUpdated;LLL:EXT:cms/locallang_tca.xlf:pages.lastUpdated_formlabel,tx_sgnews_date_end,--linebreak--, - tx_sgnews_likes,--linebreak--,tx_sgnews_location', - 'canNotCollapse' => 1, - ]; + author;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.author_formlabel, + author_email;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.author_email_formlabel, + --linebreak--, lastUpdated;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.lastUpdated_formlabel, + tx_sgnews_date_end, + --linebreak--,tx_sgnews_likes,--linebreak--,tx_sgnews_location', + 'canNotCollapse' => 1, + ]; - # - # Pages - # - $GLOBALS['TCA']['pages']['types'][116] = [ - 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard, - --palette--;;titleDescriptionAndHighlightFlag, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.editorial;editorialWithNewsAuthor, - tx_sgnews_related_news, tx_sgnews_tags, - --div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images, - tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata, - tx_projectbase_devnullrobots_flags, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract, - tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout, - --div--;LLL:EXT:cms/locallang_tca.xlf:pages.tabs.access, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;visibility, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.language;language, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.miscellaneous;miscellaneous, - ' - ]; + // Removal of the realurl fields, if the extension isn't installed. + if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) { + $GLOBALS['TCA'][$table]['palettes']['titleDescriptionAndHighlightFlag'] = str_replace( + '--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,', '', + $GLOBALS['TCA'][$table]['palettes']['titleDescriptionAndHighlightFlag'] + ); + $GLOBALS['TCA'][$table]['types'][117] = str_replace( + 'tx_realurl_pathsegment, tx_realurl_exclude,', '', + $GLOBALS['TCA'][$table]['types'][117] + ); + } - $GLOBALS['TCA']['pages']['types'][117] = [ - 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard, - title, tx_realurl_pathsegment, tx_realurl_exclude, - --div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images, - tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata, - tx_projectbase_devnullrobots_flags, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract, - tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout, - --div--;LLL:EXT:cms/locallang_tca.xlf:pages.tabs.access, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;visibility, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.language;language, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.miscellaneous;miscellaneous, - ' - ]; + if (\version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '>')) { + // if TYPO3 9.5, exclude a lot of fields from the news doktype in localizations + foreach ( + $GLOBALS['TCA'][$table]['columns'] as $languageExcludeField => $_ + ) { + if ( + !\in_array($languageExcludeField, [ + 'doktype', + 'title', + 'subtitle', + 'description', + 'slug', + 'tx_sgnews_location', + 'tx_sgnews_teaser1_image', + 'tx_sgnews_teaser2_image', + 'abstract', + 'tx_projectbase_seo_titletag', + 'tx_projectbase_seo_canonicaltag', + 'hidden', + 'sys_language_uid', + 'tx_languagevisibility_visibility' + ]) + ) { + $GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides'][$languageExcludeField]['l10n_mode'] = 'exclude'; + } + } - # - # Pages Overlay - # - $GLOBALS['TCA']['pages_language_overlay']['types'][116] = [ - 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard, - subtitle;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.subtitle.inPalette, - description, tx_realurl_pathsegment, author, tx_sgnews_location, - --div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images, - tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract, - tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, - --div--;LLL:EXT:cms/locallang_tca.xlf:pages.tabs.access, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;hiddenonly, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access' - ]; - - $GLOBALS['TCA']['pages_language_overlay']['types'][117] = [ - 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard, - title, tx_realurl_pathsegment, - --div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images, - tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, - --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata, - --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract, - tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description, - --div--;LLL:EXT:cms/locallang_tca.xlf:pages.tabs.access, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;hiddenonly, - --palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access' - ]; -} + $GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides']['title']['label'] = + 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table . '.title'; + $GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides']['subtitle']['label'] = + 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table . '.subtitle'; + $GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides']['slug']['label'] = + 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table . '.slug'; + } + }, 'sg_news', 'pages' +); -// Removal of the realurl fields, if the extension isn't installed. -if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) { - $GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag'] = str_replace( - '--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,', '', - $GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag'] - ); - $GLOBALS['TCA']['pages']['types'][117] = str_replace( - 'tx_realurl_pathsegment, tx_realurl_exclude,', '', - $GLOBALS['TCA']['pages']['types'][117] - ); -} diff --git a/Configuration/TCA/Overrides/pages_language_overlay.php b/Configuration/TCA/Overrides/pages_language_overlay.php new file mode 100644 index 0000000000000000000000000000000000000000..0c0151b69bafa0591431fbe510c3ee56f4f9b7d4 --- /dev/null +++ b/Configuration/TCA/Overrides/pages_language_overlay.php @@ -0,0 +1,200 @@ +<?php +/** + * + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ + +if (\version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + call_user_func( + function ($extKey, $table) { + $pagesTable = 'pages'; + $localLangDbPath = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:'; + $localLangBackendPath = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:'; + + $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] .= ',tx_sgnews_teaser1_image,tx_sgnews_teaser2_image'; + + foreach ( + [ + \SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE => [ + 'icon' => 'EXT:sg_news/Resources/Public/Images/Category.png', + 'locallangIndex' => 'pageType.category' + ], + \SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE => [ + 'icon' => 'EXT:sg_news/Resources/Public/Images/News.png', + 'locallangIndex' => 'pageType.news' + ] + ] as $doktype => $configuration) { + // also add the new doktype to the page language overlays type selector (so that translations can inherit the same type) + $GLOBALS['TCA'][$table]['columns']['doktype']['config']['items'][] = [ + $localLangBackendPath . $configuration['locallangIndex'], + $doktype, + $configuration['icon'] + ]; + } + + $GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE] = [ + 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.standard;standard, + subtitle;' . $localLangDbPath . $pagesTable . '.subtitle.inPalette, + description, tx_realurl_pathsegment, author, tx_sgnews_location, + --div--;' . $localLangDbPath . $pagesTable . '.tabs.images, + tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $pagesTable . '.tabs.metadata, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $pagesTable . '.palettes.abstract;abstract, + tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, + sys_language_uid, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, + --palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.visibility;hiddenonly, + --palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.access;access' + ]; + + $GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE] = [ + 'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.standard;standard, + title, tx_realurl_pathsegment, + --div--;' . $localLangDbPath . $table . '.tabs.images, + tx_sgnews_teaser2_image, tx_sgnews_teaser1_image, + --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $pagesTable . '.tabs.metadata, + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $pagesTable . '.palettes.abstract;abstract, + tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, + sys_language_uid, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, + --palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.visibility;hiddenonly, + --palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.access;access' + ]; + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns( + $table, [ + 'tx_sgnews_teaser1_image' => [ + 'exclude' => TRUE, + 'label' => $localLangDbPath . $pagesTable . '.tx_sgnews_teaser1_image', + 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'tx_sgnews_teaser1_image', + [ + 'maxitems' => 9999, + 'foreign_types' => [ + '0' => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ] + ], + 'appearance' => [ + 'showPossibleLocalizationRecords' => TRUE, + 'showRemovedLocalizationRecords' => TRUE, + 'showSynchronizationLink' => TRUE, + 'showAllLocalizationLink' => TRUE, + ], + ], + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] + ), + ], + 'tx_sgnews_teaser2_image' => [ + 'exclude' => TRUE, + 'label' => $localLangDbPath . $pagesTable . '.tx_sgnews_teaser2_image', + 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'tx_sgnews_teaser2_image', + [ + 'maxitems' => 9999, + 'foreign_types' => [ + '0' => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ], + \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [ + 'showitem' => ' + --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, + --palette--;;filePalette' + ] + ], + 'appearance' => [ + 'showPossibleLocalizationRecords' => TRUE, + 'showRemovedLocalizationRecords' => TRUE, + 'showSynchronizationLink' => TRUE, + 'showAllLocalizationLink' => TRUE, + ], + ], + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] + ), + ], + 'tx_sgnews_location' => [ + 'exclude' => TRUE, + 'label' => $localLangDbPath . $pagesTable . '.tx_sgnews_location', + 'config' => [ + 'type' => 'input', + 'size' => 20, + 'eval' => 'trim' + ] + ] + ] + ); + + }, 'sg_news', 'pages_language_overlay' + ); +} diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php new file mode 100644 index 0000000000000000000000000000000000000000..99fb39b5a83b63134ca6cadff79d0f9e3a17985d --- /dev/null +++ b/Configuration/TCA/Overrides/sys_template.php @@ -0,0 +1,34 @@ +<?php +/** + * + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ + +call_user_func( + function ($extKey, $table) { + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( + $extKey, 'Configuration/TypoScript/Frontend', 'News System' + ); + + }, 'sg_news', 'sys_template' +); diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php new file mode 100644 index 0000000000000000000000000000000000000000..324ce830397d469e462cf4a21600fc51f8544dd1 --- /dev/null +++ b/Configuration/TCA/Overrides/tt_content.php @@ -0,0 +1,72 @@ +<?php +/** + * + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ + +call_user_func( + function ($extKey, $table) { + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( + $extKey, + 'Overview', + 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:pageTypeTitlePluginOverview.news' + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( + $extKey, + 'Latest', + 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:pageTypeTitlePluginLatest.news' + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( + $extKey, + 'ListByCategory', + 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:pageTypeTitlePluginCategory.news' + ); + + // Removal of the unused plugin setting fields + $GLOBALS['TCA'][$table]['types']['list']['subtypes_excludelist']['sgnews_overview'] = 'select_key,pages,recursive'; + $GLOBALS['TCA'][$table]['types']['list']['subtypes_excludelist']['sgnews_listbycategory'] = 'select_key,pages,recursive'; + $GLOBALS['TCA'][$table]['types']['list']['subtypes_excludelist']['sgnews_latest'] = 'select_key,pages,recursive'; + $GLOBALS['TCA'][$table]['types']['list']['subtypes_excludelist']['sgnews_singleview'] = 'select_key,pages,recursive'; + + // Flex form assignment + $pluginSignature = str_replace('_', '', $extKey) . '_overview'; + $GLOBALS['TCA'][$table]['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( + $pluginSignature, 'FILE:EXT:' . $extKey . '/Configuration/FlexForms/Overview.xml' + ); + + $pluginSignature = str_replace('_', '', $extKey) . '_listbycategory'; + $GLOBALS['TCA'][$table]['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( + $pluginSignature, 'FILE:EXT:' . $extKey . '/Configuration/FlexForms/ListByCategory.xml' + ); + + $pluginSignature = str_replace('_', '', $extKey) . '_latest'; + $GLOBALS['TCA'][$table]['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( + $pluginSignature, 'FILE:EXT:' . $extKey . '/Configuration/FlexForms/Latest.xml' + ); + }, 'sg_news', 'tt_content' +); diff --git a/Configuration/TsConfig/Page/NewContentElementWizard.tsconfig b/Configuration/TsConfig/Page/NewContentElementWizard.tsconfig index 16919383d136bbe83ea0fbd605bc37747fb93898..03d1198f7e89038a21ea8cf8f46a355d2ea82206 100644 --- a/Configuration/TsConfig/Page/NewContentElementWizard.tsconfig +++ b/Configuration/TsConfig/Page/NewContentElementWizard.tsconfig @@ -22,17 +22,6 @@ mod { } } - single { - iconIdentifier = sg_news-module - title = LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:titleSingleViewPlugin - description = LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:descriptionSingleViewPlugin - tt_content_defValues { - CType = list - list_type = sgnews_singleview - - } - } - category { iconIdentifier = sg_news-module title = LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:titleListByCategoryPlugin diff --git a/Configuration/TypoScript/Common/setup.txt b/Configuration/TypoScript/Common/setup.typoscript similarity index 100% rename from Configuration/TypoScript/Common/setup.txt rename to Configuration/TypoScript/Common/setup.typoscript diff --git a/Configuration/TypoScript/Frontend/constants.txt b/Configuration/TypoScript/Frontend/constants.typoscript similarity index 100% rename from Configuration/TypoScript/Frontend/constants.txt rename to Configuration/TypoScript/Frontend/constants.typoscript diff --git a/Configuration/TypoScript/Frontend/setup.txt b/Configuration/TypoScript/Frontend/setup.typoscript similarity index 91% rename from Configuration/TypoScript/Frontend/setup.txt rename to Configuration/TypoScript/Frontend/setup.typoscript index 2b962113731b44d1bd9999e437c7a11872094d9d..eea0da2829f887355e73f27ab42931045612bf9b 100644 --- a/Configuration/TypoScript/Frontend/setup.txt +++ b/Configuration/TypoScript/Frontend/setup.typoscript @@ -1,8 +1,8 @@ # include the endless scrolling javascript code page.includeJSFooterlibs { - sg_news_scrollbrowser = EXT:sg_news/Resources/Public/Scripts/ScrollBrowser.js - sg_news_tabs = EXT:sg_news/Resources/Public/Scripts/Tabs.js - sg_news_likes = EXT:sg_news/Resources/Public/Scripts/Likes.js + sg_news_scrollbrowser = EXT:sg_news/Resources/Public/JavaScript/ScrollBrowser.js + sg_news_tabs = EXT:sg_news/Resources/Public/JavaScript/Tabs.js + sg_news_likes = EXT:sg_news/Resources/Public/JavaScript/Likes.js } # news feed as own page type @@ -37,16 +37,6 @@ newsFeed { } } -[compatVersion = 7.6.0] - newsFeed.config.additionalHeaders > - newsFeed.config.additionalHeaders { - 10 { - header = Content-type:text/xml - replace = 1 - } - } -[global] - # news feed integration into the site page.headerData { 273905123652 = TEXT diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 88020cfe665c3715f4c82c5d03ba932d901ea327..547e8c36acdc49f4b764011c8e453351a6406503 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -23,35 +23,51 @@ </trans-unit> <trans-unit id="titleLatestPlugin" approved="yes"> <source>Latest News</source> - <target>Letzte News</target> + <target>Neueste News</target> </trans-unit> <trans-unit id="titleListByCategoryPlugin" approved="yes"> - <source>List News by Category/Tag</source> + <source>List News by Category/Tag.</source> <target>Liste News aus Kategorien/Tags</target> </trans-unit> <trans-unit id="titleOverviewPlugin" approved="yes"> <source>News Overview</source> - <target>News-Ãœbersicht</target> + <target>News Ãœbersicht</target> </trans-unit> <trans-unit id="titleSingleViewPlugin" approved="yes"> <source>News Single View</source> - <target>News-Einzelansicht</target> + <target>News Einzelansicht</target> </trans-unit> <trans-unit id="descriptionLatestPlugin"> - <source>Choose to show Latest News</source> - <target>Zeige die neuesten News </target> + <source>Show latest news.</source> + <target>Zeige die neuesten News.</target> </trans-unit> <trans-unit id="descriptionListByCategoryPlugin"> - <source>List News by Category/Tag</source> - <target>Liste News aus Kategorien/Tags</target> + <source>List news by category/tag.</source> + <target>Eine Liste der News aus Kategorien/Tags.</target> </trans-unit> <trans-unit id="descriptionOverviewPlugin"> - <source>Show an Overview of News</source> - <target>Ãœberblick der News</target> + <source>Show an overview of all news.</source> + <target>Ãœbersicht der News.</target> </trans-unit> <trans-unit id="descriptionSingleViewPlugin"> - <source>Show a Single View of News</source> - <target>Zeige Einzelansicht der News</target> + <source>Show a single view of news.</source> + <target>Zeige eine Einzelansicht der News.</target> + </trans-unit> + <trans-unit id="pageTypeTitlePluginOverview.news"> + <source>[News] News Overview</source> + <target>[News] News Ãœbersicht</target> + </trans-unit> + <trans-unit id="pageTypeTitlePluginLatest.news"> + <source>[News] News Latest</source> + <target>[News] Neueste News</target> + </trans-unit> + <trans-unit id="pageTypeTitlePluginCategory.news"> + <source>[News] News by Category</source> + <target>[News] News aus Kategorien</target> + </trans-unit> + <trans-unit id="pageTypeTitlePluginSingle.news"> + <source>[News] News Single View</source> + <target>[News] News Einzelansicht</target> </trans-unit> </body> </file> diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 882509d14907c02eb021c84c00ac0499f6dbe552..bcd2d6c488a74e0bbd5bd79de33c27edcd0863cd 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -69,6 +69,18 @@ <source><![CDATA[Use Image Cropping]]></source> <target><![CDATA[Bild-Cropping aktivieren]]></target> </trans-unit> + <trans-unit id="pages.title"> + <source><![CDATA[Pagetitle (automatically generated from Last Update + Headline)]]></source> + <target><![CDATA[Seitentitel (automatisch generiert aus Letzte Aktualisierung + Schlagzeile)]]></target> + </trans-unit> + <trans-unit id="pages.subtitle"> + <source><![CDATA[Headline]]></source> + <target><![CDATA[Schlagzeile]]></target> + </trans-unit> + <trans-unit id="pages.slug"> + <source><![CDATA[URL Segment (generated from Pagetitle initially, has to be updated manually)]]></source> + <target><![CDATA[URL Segment (initial generiert aus Seitentitel, muss manuell aktualisiert werden)]]></target> + </trans-unit> <trans-unit id="plugin.flexForm" approved="yes"> <source><![CDATA[Settings]]></source> <target><![CDATA[Einstellungen]]></target> diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 89fe73460248a0d4e5ad415d406f41dcc6c74c2a..5591f890d5ed5eb997c44ed3f0387feff38e367b 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -13,19 +13,19 @@ <source>Please upload an image first and save the form!</source> </trans-unit> <trans-unit id="pageTypeTitlePlugin.news"> - <source>[SgNews] Plugins</source> + <source>[News] Plugins</source> </trans-unit> <trans-unit id="pageTypeTitlePluginOverview.news"> - <source>[SgNews] News Overview</source> + <source>[News] News Overview</source> </trans-unit> <trans-unit id="pageTypeTitlePluginLatest.news"> - <source>[SgNews] News Latest</source> + <source>[News] News Latest</source> </trans-unit> <trans-unit id="pageTypeTitlePluginCategory.news"> - <source>[SgNews] News by Category</source> + <source>[News] News by Category</source> </trans-unit> <trans-unit id="pageTypeTitlePluginSingle.news"> - <source>[SgNews] News Single View</source> + <source>[News] News Single View</source> </trans-unit> <trans-unit id="pageType.category"> <source>Category</source> @@ -37,10 +37,7 @@ <source>Latest News</source> </trans-unit> <trans-unit id="descriptionLatestPlugin"> - <source>Choose to show Latest News</source> - </trans-unit> - <trans-unit id="descriptionLatestPlugin"> - <source>Show most recent news</source> + <source>Show latest news.</source> </trans-unit> <trans-unit id="titleListByCategoryPlugin"> <source>News by Category/Tag</source> @@ -48,20 +45,17 @@ <trans-unit id="descriptionListByCategoryPlugin"> <source>List news by category/tag</source> </trans-unit> - <trans-unit id="descriptionListByCategoryPlugin"> - <source>List News by Category/Tag</source> - </trans-unit> <trans-unit id="titleOverviewPlugin"> <source>News Overview</source> </trans-unit> <trans-unit id="descriptionOverviewPlugin"> - <source>Show an overview of all news</source> + <source>Show an overview of all news.</source> </trans-unit> <trans-unit id="titleSingleViewPlugin"> <source>News Single View</source> </trans-unit> <trans-unit id="descriptionSingleViewPlugin"> - <source>Show a single view of news</source> + <source>Show a single view of news.</source> </trans-unit> <trans-unit id="pageTitlePlugin.news"> <source>News</source> diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 68461c1c9c2fd04f90c06957645c6b9c5721ce95..f6984117e23156d21d5200a3c79393f39dae3f3a 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -54,6 +54,15 @@ <trans-unit id="pages.tx_sgnews_use_image_crop"> <source><![CDATA[Use Image Cropping]]></source> </trans-unit> + <trans-unit id="pages.title"> + <source><![CDATA[Pagetitle (automatically generated from Last Update + Headline)]]></source> + </trans-unit> + <trans-unit id="pages.subtitle"> + <source><![CDATA[Headline]]></source> + </trans-unit> + <trans-unit id="pages.slug"> + <source><![CDATA[URL Segment (generated from Pagetitle initially, has to be updated manually)]]></source> + </trans-unit> <trans-unit id="plugin.flexForm"> <source><![CDATA[Settings]]></source> </trans-unit> diff --git a/Resources/Private/Layouts/Backend.html b/Resources/Private/Layouts/Backend.html index 8d0991466df8c7f8062ccf12204fd4fac8bd4864..64e0cc27efc6450bd9a8ece23576cc25f4975990 100644 --- a/Resources/Private/Layouts/Backend.html +++ b/Resources/Private/Layouts/Backend.html @@ -1,13 +1,11 @@ {namespace core = TYPO3\CMS\Core\ViewHelpers} {namespace sg=SGalinski\SgNews\ViewHelpers} -<f:be.container enableClickMenu="FALSE" loadExtJs="FALSE" +<f:be.container includeRequireJsModules="{ - 0: 'TYPO3/CMS/Backend/AjaxDataHandler', - 1: '{f:if(condition: \'{typo3Version} < 8000000 \', then: \'TYPO3/CMS/Backend/ClickMenu\', else: \'TYPO3/CMS/Backend/ContextMenu\')}', - 2: 'TYPO3/CMS/Backend/Tooltip', - 2: 'TYPO3/CMS/Recordlist/Tooltip'}" - includeJsFiles="{0: '{f:uri.resource(path: \'Scripts/Backend.js\')}'}"> + 0: 'TYPO3/CMS/Backend/ContextMenu', + 1: 'TYPO3/CMS/Backend/Tooltip', + 2: 'TYPO3/CMS/SgNews/Backend'}"> <div class="module" data-module-id="" data-module-name=""> <div class="module-docheader t3js-module-docheader"> <div class="module-docheader-bar module-docheader-bar-navigation t3js-module-docheader-bar t3js-module-docheader-bar-navigation"> @@ -21,7 +19,16 @@ </f:for> </div> <div class="module-docheader-bar-column-right"> - <span class="typo3-docheader-pagePath"><f:translate key="LLL:EXT:lang/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw></span> + <span class="typo3-docheader-pagePath"> + <f:if condition="{typo3Version} < 9000000"> + <f:then> + <f:translate key="LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw> + </f:then> + <f:else> + <f:translate key="LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path" />: <f:format.raw>{docHeader.metaInformation.path}</f:format.raw> + </f:else> + </f:if> + </span> <f:format.raw>{docHeader.metaInformation.recordInformation}</f:format.raw> </div> </div> diff --git a/Resources/Private/Partials/Backend/SelectPage.html b/Resources/Private/Partials/Backend/SelectPage.html index 7957f4311a70b4c27c564dca73be38e690c25823..ebcf27a8b1ee3809362bfabac88f7782d0c4bc25 100644 --- a/Resources/Private/Partials/Backend/SelectPage.html +++ b/Resources/Private/Partials/Backend/SelectPage.html @@ -17,9 +17,9 @@ <f:for each="{pages}" as="page"> <tr data-uid="{page.uid}"> <td nowrap="nowrap" class="col-title"> - <a href="#" onclick="sgNewsGoToPage({page.uid}, '{page.path}'); return false;"> + <f:link.action class="sg-news_pageswitch" action="index" additionalParams="{id: page.uid, returnUrl: returnUrl}" additionalAttributes="{data-page: page.uid, data-path: page.path}"> <sg:backend.recordIcon table="pages" row="{page}" clickMenu="0" /> {page._thePathFull} - </a> + </f:link.action> </td> </tr> </f:for> @@ -27,4 +27,4 @@ </table> </div> </div> -</f:if> \ No newline at end of file +</f:if> diff --git a/Resources/Private/Partials/TeaserOverview.html b/Resources/Private/Partials/TeaserOverview.html index 7fa33c223cc2b3ee39524878663c06a50104b69a..74e5f9c4a81a292572018ebd4293dc53dd6490aa 100644 --- a/Resources/Private/Partials/TeaserOverview.html +++ b/Resources/Private/Partials/TeaserOverview.html @@ -19,27 +19,29 @@ --> </f:comment> -<f:alias map="{singleViewUri: '{f:uri.page(pageUid: \'{newsMetaData.news.uid}\')}'}"> - <a href="{singleViewUri}"> - <div class="tx-sgnews-single-header {f:if(condition: newsMetaData.imageObject, then: 'tx-sgnews-single-header-image')}"> - <f:if condition="{newsMetaData.imageObject}"> - <div class="tx-sgnews-single-image"> - <picture> - <source media="(max-width: 1200px)" - srcset="{f:uri.image(src: newsMetaData.imageObject.uid, treatIdAsReference: '1', width: '1200c', height: '403c', cropVariant: 'small')}"> - <f:image image="{newsMetaData.imageObject}" alt="" width="1845c" - height="619c" cropVariant="large"/> - </picture> - </div> - </f:if> - <div class="tx-sgnews-single-header-content"> - <div class="tx-sgnews-teaser-title"> - <h1>{newsMetaData.news.subtitleWithFallbackToTitle}</h1> - </div> - <div class="tx-sgnews-teaser"> - <div class="tx-sgnews-teaser-inner"> - <div class="tx-sgnews-teaser-meta"> +<f:variable name="singleViewUri"><f:uri.page pageUid="{newsMetaData.news.uid}" /></f:variable> + +<a href="{singleViewUri}"> + <div class="tx-sgnews-single-header {f:if(condition: newsMetaData.imageObject, then: 'tx-sgnews-single-header-image')}"> + <f:if condition="{newsMetaData.imageObject}"> + <div class="tx-sgnews-single-image"> + <picture> + <source media="(max-width: 1200px)" + srcset="{f:uri.image(src: newsMetaData.imageObject.uid, treatIdAsReference: '1', width: '1200c', height: '403c', cropVariant: 'small')}"> + <f:image image="{newsMetaData.imageObject}" alt="" width="1845c" + height="619c" cropVariant="large"/> + </picture> + </div> + </f:if> + <div class="tx-sgnews-single-header-content"> + <div class="tx-sgnews-teaser-title"> + <h1>{newsMetaData.news.subtitleWithFallbackToTitle}</h1> + </div> + <div class="tx-sgnews-teaser"> + <div class="tx-sgnews-teaser-inner"> + <div class="tx-sgnews-teaser-meta"> <span class="author"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="#FFF" d="M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"/></svg> <f:if condition="{newsMetaData.news.authorFrontendUser}"> <f:then> <f:if condition="{newsMetaData.news.authorFrontendUser.www}"> @@ -59,31 +61,34 @@ </f:if> </span> - <f:if condition="{newsMetaData.news.location}"> + <f:if condition="{newsMetaData.news.location}"> <span class="location"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="#FFF" d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0z"/></svg> {newsMetaData.news.location} </span> - </f:if> + </f:if> - <span class="date"> + <span class="date"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#FFF" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm57.1 350.1L224.9 294c-3.1-2.3-4.9-5.9-4.9-9.7V116c0-6.6 5.4-12 12-12h48c6.6 0 12 5.4 12 12v137.7l63.5 46.2c5.4 3.9 6.5 11.4 2.6 16.8l-28.2 38.8c-3.9 5.3-11.4 6.5-16.8 2.6z"/></svg> <f:format.date format="{f:translate(key:'frontend.dateformat')}">{newsMetaData.news.lastUpdated}</f:format.date> </span> - <span class="category"> - {newsMetaData.category.subtitleWithFallbackToTitle} - </span> - <f:if condition="{newsMetaData.news.tags}"> - <br /> - <span class="tags"> - <f:for each="{newsMetaData.news.tags}" as="tag" iteration="it"> - {tag.title}<f:if condition="{it.isLast}"><f:else>, </f:else></f:if> - </f:for> - </span> - </f:if> - </div> + <span class="category"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#FFF" d="M0 252.118V48C0 21.49 21.49 0 48 0h204.118a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882L293.823 497.941c-18.745 18.745-49.137 18.745-67.882 0L14.059 286.059A48 48 0 0 1 0 252.118zM112 64c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z"/></svg> + {newsMetaData.category.subtitleWithFallbackToTitle} + </span> + <f:if condition="{newsMetaData.news.tags}"> + <br /> + <span class="tags"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="#FFF" d="M497.941 225.941L286.059 14.059A48 48 0 0 0 252.118 0H48C21.49 0 0 21.49 0 48v204.118a48 48 0 0 0 14.059 33.941l211.882 211.882c18.744 18.745 49.136 18.746 67.882 0l204.118-204.118c18.745-18.745 18.745-49.137 0-67.882zM112 160c-26.51 0-48-21.49-48-48s21.49-48 48-48 48 21.49 48 48-21.49 48-48 48zm513.941 133.823L421.823 497.941c-18.745 18.745-49.137 18.745-67.882 0l-.36-.36L527.64 323.522c16.999-16.999 26.36-39.6 26.36-63.64s-9.362-46.641-26.36-63.64L331.397 0h48.721a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882z"/></svg> + <f:for each="{newsMetaData.news.tags}" as="tag" iteration="it"> + {tag.title}<f:if condition="{it.isLast}"><f:else>, </f:else></f:if> + </f:for> + </span> + </f:if> </div> </div> </div> </div> - </a> -</f:alias> + </div> +</a> diff --git a/Resources/Private/Templates/Latest/Index.html b/Resources/Private/Templates/Latest/Index.html index fb2216d954374548d97649aefff716685e82fecc..a730b911f1b03e325d8c876d7e5f363f4a3aecef 100644 --- a/Resources/Private/Templates/Latest/Index.html +++ b/Resources/Private/Templates/Latest/Index.html @@ -25,12 +25,16 @@ <f:if condition="{newsMetaData -> f:count()} > 1"> <a class="left carousel-control" href="#carousel-latest-news" role="button" data-slide="prev"> - <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" width="30" height="44"> + <path fill="#FFF" d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"/> + </svg> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#carousel-latest-news" role="button" data-slide="next"> - <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" width="30" height="44"> + <path fill="#FFF" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/> + </svg> <span class="sr-only">Next</span> </a> </f:if> diff --git a/Resources/Private/Templates/PageBrowser/Index.html b/Resources/Private/Templates/PageBrowser/Index.html index 2087a374f5fec2a9ddd56b6f0ac31cb3f5bb1b7f..3350986bd86946d06a051aa604e89c7a8ed838d4 100644 --- a/Resources/Private/Templates/PageBrowser/Index.html +++ b/Resources/Private/Templates/PageBrowser/Index.html @@ -24,13 +24,13 @@ </f:else> </f:if> - <sg:extendedIf condition="{enableLessPages}" and="{showLessPages}"> + <f:if condition="{enableLessPages} && {showLessPages}"> <li> <a href="{enableLessPagesLink}"> ... </a> </li> - </sg:extendedIf> + </f:if> <f:for each="{pageLinks}" as="pageLink"> <f:if condition="{pageLink.isCurrentPage}"> @@ -54,13 +54,13 @@ </f:if> </f:for> - <sg:extendedIf condition="{enableMorePages}" and="{showNextPages}"> + <f:if condition="{enableMorePages} && {showNextPages}"> <li> <a href="{enableMorePagesLink}"> ... </a> </li> - </sg:extendedIf> + </f:if> <f:if condition="{nextPageExist}"> <f:then> diff --git a/Resources/Private/Templates/SingleView/SingleView.html b/Resources/Private/Templates/SingleView/SingleView.html index 3fcc2c126804882a425cba62d92102bfb867c3d7..297b9e61731f2aac1c6b71fb4763027d6d768120 100644 --- a/Resources/Private/Templates/SingleView/SingleView.html +++ b/Resources/Private/Templates/SingleView/SingleView.html @@ -1,7 +1,7 @@ <f:layout name="Default" /> +{namespace base=SGalinski\ProjectBase\ViewHelpers} {namespace sg=SGalinski\SgNews\ViewHelpers} -{namespace rx=Reelworx\RxShariff\ViewHelper} <f:section name="main"> <f:if condition="{settings.publisher}"> @@ -55,6 +55,7 @@ <div class="tx-sgnews-teaser-inner"> <div class="tx-sgnews-teaser-meta"> <span class="author"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="#FFF" d="M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"/></svg> <f:if condition="{newsMetaData.news.authorFrontendUser}"> <f:then> <f:if condition="{newsMetaData.news.authorFrontendUser.www}"> @@ -75,15 +76,18 @@ </span> <f:if condition="{newsMetaData.news.location}"> <span class="location"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="#FFF" d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0z"/></svg> {newsMetaData.news.location} </span> </f:if> <span class="date"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#FFF" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm57.1 350.1L224.9 294c-3.1-2.3-4.9-5.9-4.9-9.7V116c0-6.6 5.4-12 12-12h48c6.6 0 12 5.4 12 12v137.7l63.5 46.2c5.4 3.9 6.5 11.4 2.6 16.8l-28.2 38.8c-3.9 5.3-11.4 6.5-16.8 2.6z"/></svg> <f:format.date format="{f:translate(key:'frontend.dateformat')}">{newsMetaData.news.lastUpdated}</f:format.date> </span> <span class="category"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#FFF" d="M0 252.118V48C0 21.49 21.49 0 48 0h204.118a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882L293.823 497.941c-18.745 18.745-49.137 18.745-67.882 0L14.059 286.059A48 48 0 0 1 0 252.118zM112 64c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z"/></svg> <a href="{f:uri.page(pageUid: '{newsMetaData.category.uid}')}"> {newsMetaData.category.subtitleWithFallbackToTitle} </a> @@ -91,6 +95,7 @@ <f:if condition="{newsMetaData.news.tags}"> <br /> <span class="tags"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="#FFF" d="M497.941 225.941L286.059 14.059A48 48 0 0 0 252.118 0H48C21.49 0 0 21.49 0 48v204.118a48 48 0 0 0 14.059 33.941l211.882 211.882c18.744 18.745 49.136 18.746 67.882 0l204.118-204.118c18.745-18.745 18.745-49.137 0-67.882zM112 160c-26.51 0-48-21.49-48-48s21.49-48 48-48 48 21.49 48 48-21.49 48-48 48zm513.941 133.823L421.823 497.941c-18.745 18.745-49.137 18.745-67.882 0l-.36-.36L527.64 323.522c16.999-16.999 26.36-39.6 26.36-63.64s-9.362-46.641-26.36-63.64L331.397 0h48.721a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882z"/></svg> <f:for each="{newsMetaData.news.tags}" as="tag" iteration="it"> {tag.title}<f:if condition="{it.isLast}"><f:else>, </f:else></f:if> </f:for> @@ -125,7 +130,7 @@ <hr> <div class="tx-sgnews-meta-bar"> - <rx:shariff services="facebook,twitter,googleplus,whatsapp" enableBackend="true" /> + <base:sharer /> <div class="tx-sgnews-likes" id="tx-sgnews-likes" data-uid="{newsMetaData.news.uid}"> <button class="tx-sgnews-like-buton btn btn-sm btn-info"> <span class="tx-sgnews-number-of-likes"> @@ -163,10 +168,11 @@ <section class="content dark-bg"> <div class="container"> <div class="tx-sgnews-single-footer"> - <sg:extendedIf condition="{previousNews}" or="{nextNews}"> + <f:if condition="{previousNews} || {nextNews}"> <div class="tx-sgnews-single-footer-browser"> <f:if condition="{previousNews}"> <a href="{f:uri.page(pageUid: '{previousNews.uid}')}" class="btn btn-md btn-info tx-sgnews-footer-browser-previous"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#FFF" d="M256 504C119 504 8 393 8 256S119 8 256 8s248 111 248 248-111 248-248 248zM142.1 273l135.5 135.5c9.4 9.4 24.6 9.4 33.9 0l17-17c9.4-9.4 9.4-24.6 0-33.9L226.9 256l101.6-101.6c9.4-9.4 9.4-24.6 0-33.9l-17-17c-9.4-9.4-24.6-9.4-33.9 0L142.1 239c-9.4 9.4-9.4 24.6 0 34z"/></svg> <f:translate key="frontend.singleview.previousArticle" /> </a> </f:if> @@ -174,10 +180,11 @@ <f:if condition="{nextNews}"> <a href="{f:uri.page(pageUid: '{nextNews.uid}')}" class="btn btn-md btn-info tx-sgnews-footer-browser-next"> <f:translate key="frontend.singleview.nextArticle" /> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#FFF" d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zm113.9 231L234.4 103.5c-9.4-9.4-24.6-9.4-33.9 0l-17 17c-9.4 9.4-9.4 24.6 0 33.9L285.1 256 183.5 357.6c-9.4 9.4-9.4 24.6 0 33.9l17 17c9.4 9.4 24.6 9.4 33.9 0L369.9 273c9.4-9.4 9.4-24.6 0-34z"/></svg> </a> </f:if> </div> - </sg:extendedIf> + </f:if> </div> </div> </section> diff --git a/Resources/Public/JavaScript/Backend.js b/Resources/Public/JavaScript/Backend.js new file mode 100644 index 0000000000000000000000000000000000000000..b96871811a2cecdf3cf3786f86a8fed963e7131d --- /dev/null +++ b/Resources/Public/JavaScript/Backend.js @@ -0,0 +1,117 @@ +/*************************************************************** + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +define([ + 'jquery', + 'TYPO3/CMS/Backend/ModuleMenu', + 'TYPO3/CMS/Backend/Viewport' +], function($, ModuleMenu, Viewport) { + 'use strict'; + + var SgNewsModule = { + init: function() { + $.get(TYPO3.settings.ajaxUrls['sg_news::ajaxPing']); + $('#filter-reset-btn').on('click', function(event) { + event.preventDefault(); + this.form.reset(); + $(this).closest('form').find('select').val(''); + $('#filter-search').val(''); + this.form.submit(); + }); + $('.sg-news_pageswitch').on('click', function(event) { + event.preventDefault(); + SgNewsModule.goTo('web_SgNewsNews', event.target.dataset.page, event.target.dataset.path); + }); + }, + + goTo: function(module, id, path) { + if (TYPO3.version < 9000000) { + var tree = top.Ext.getCmp('typo3-pagetree'); + if (tree) { + tree.activeTree.selectPath(path); + } else if(top.nav) { + top.nav.invokePageId(id, function(path) { + var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree); + callback.apply(this, arguments); + var node = top.nav.getSelected(); + if (node) { + top.TYPO3.Components.PageTree.Actions.singleClick(node, top.TYPO3.Components.PageTree.Tree); + } + }); + } + parent.TYPO3.ModuleMenu.App.showModule(module, 'id=' + id); + } else { + var pageTreeNodes = Viewport.NavigationContainer.PageTree.instance.nodes; + for (var nodeIndex in pageTreeNodes) { + if (pageTreeNodes.hasOwnProperty(nodeIndex) && pageTreeNodes[nodeIndex].identifier === parseInt(id)) { + Viewport.NavigationContainer.PageTree.selectNode(pageTreeNodes[nodeIndex]); + break; + } + } + ModuleMenu.App.showModule(module, 'id=' + id); + } + }, + + sgNewsGoToNewsModule: function(uid, path) { + this.goTo('web_SgNewsNews', uid, path); + return false; + }, + + sgNewsGoToPageModule: function(uid, path) { + this.goTo('web_layout', uid, path); + return false; + } + }; + + TYPO3.SgNewsModule = SgNewsModule; + + SgNewsModule.init(); + + return SgNewsModule; +}); + +// functions for backend docheader functionality +function jumpExt(URL, anchor) { + var anc = anchor ? anchor : ""; + window.location.href = URL + (T3_THIS_LOCATION ? "&returnUrl=" + T3_THIS_LOCATION : "") + anc; + return false; +} + +function jumpSelf(URL) { + window.location.href = URL + (T3_RETURN_URL ? "&returnUrl=" + T3_RETURN_URL : ""); + return false; +} + +function jumpToUrl(URL) { + window.location.href = URL; + return false; +} + +function setHighlight(id) { + top.fsMod.recentIds["web"] = id; + top.fsMod.navFrameHighlightedID["web"] = "pages" + id + "_" + top.fsMod.currentBank; // For highlighting + if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) { + top.content.nav_frame.refresh_nav(); + } +} diff --git a/Resources/Public/Scripts/CategoryFilter.js b/Resources/Public/JavaScript/CategoryFilter.js similarity index 100% rename from Resources/Public/Scripts/CategoryFilter.js rename to Resources/Public/JavaScript/CategoryFilter.js diff --git a/Resources/Public/Scripts/Likes.js b/Resources/Public/JavaScript/Likes.js similarity index 100% rename from Resources/Public/Scripts/Likes.js rename to Resources/Public/JavaScript/Likes.js diff --git a/Resources/Public/Scripts/ScrollBrowser.js b/Resources/Public/JavaScript/ScrollBrowser.js similarity index 100% rename from Resources/Public/Scripts/ScrollBrowser.js rename to Resources/Public/JavaScript/ScrollBrowser.js diff --git a/Resources/Public/Scripts/Tabs.js b/Resources/Public/JavaScript/Tabs.js similarity index 100% rename from Resources/Public/Scripts/Tabs.js rename to Resources/Public/JavaScript/Tabs.js diff --git a/Resources/Public/Sass/styles.scss b/Resources/Public/Sass/styles.scss index ce56dd75b204a1bbe61fd3e872d351329e5dcc8a..657d400436a4cd0e42295b5985ca50a3cd823bf4 100644 --- a/Resources/Public/Sass/styles.scss +++ b/Resources/Public/Sass/styles.scss @@ -199,19 +199,13 @@ display: inline-block; } - &:before { + svg { margin-right: 5px; - font-family: 'Glyphicons Halflings'; - content: '\e257'; - font-size: 10px; - width: 20px; - height: 20px; display: inline-block; - border-radius: 50%; - text-align: center; - line-height: 2; - background-color: $btn-info-color; - color: $btn-info-bg; + height: 18px; + width: auto; + vertical-align: middle; + transform: translateY(-1px); } } @@ -224,19 +218,14 @@ float: right; display: inline-block; } - &:after { + + svg { margin-left: 5px; - font-family: 'Glyphicons Halflings'; - content: '\e258'; - font-size: 10px; - width: 20px; - height: 20px; display: inline-block; - border-radius: 50%; - text-align: center; - line-height: 2; - background-color: $btn-info-color; - color: $btn-info-bg; + height: 18px; + width: auto; + vertical-align: middle; + transform: translateY(-1px); } } @@ -347,7 +336,7 @@ margin-left: 10px; } - .shariff { + .sharer-container { flex-grow: 1; } } @@ -365,10 +354,10 @@ } .tx-sgnews-filter-bar { + margin: 25px 0; display: flex; flex-wrap: wrap; justify-content: flex-start; - margin: 25px 0px 25px 0px; .form-control { display: inline-block; diff --git a/Resources/Public/Scripts/Backend.js b/Resources/Public/Scripts/Backend.js deleted file mode 100644 index 7a32bfb4a8819e01ed115670447b9f3b2ef81677..0000000000000000000000000000000000000000 --- a/Resources/Public/Scripts/Backend.js +++ /dev/null @@ -1,101 +0,0 @@ -(function($) { - $(document).ready(function() { - $.get(TYPO3.settings.ajaxUrls['sg_news::ajaxPing']); - $('#filter-reset-btn').on('click', function(event) { - event.preventDefault(); - this.form.reset(); - $(this).closest('form').find('select').val(''); - $('#filter-search').val(''); - this.form.submit(); - }); - }); -})(TYPO3.jQuery); - -// functions for backend docheader functionality -function jumpExt(URL, anchor) { // - var anc = anchor ? anchor : ""; - window.location.href = URL + (T3_THIS_LOCATION ? "&returnUrl=" + T3_THIS_LOCATION : "") + anc; - return false; -} - -function jumpSelf(URL) { // - window.location.href = URL + (T3_RETURN_URL ? "&returnUrl=" + T3_RETURN_URL : ""); - return false; -} - -function jumpToUrl(URL) { - window.location.href = URL; - return false; -} - -function setHighlight(id) { // - top.fsMod.recentIds["web"] = id; - top.fsMod.navFrameHighlightedID["web"] = "pages" + id + "_" + top.fsMod.currentBank; // For highlighting - if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) { - top.content.nav_frame.refresh_nav(); - } -} - -/** - * Switches to the spefied page in the BE - * - * @param {number} uid - * @param {string} path - */ -function sgNewsGoToPage(uid, path, selectOnly) { - parent.fsMod.recentIds['web'] = uid; - if(typeof selectOnly === 'undefined') { - selectOnly = false; - } - selectOnly = Boolean(selectOnly); - if (top.nav) { - if (selectOnly) { - top.nav.invokePageId(uid, gotToPageCallbackNoFollow); - } else { - top.nav.invokePageId(uid, gotToPageCallback); - } - } else { - var tree = top.Ext.getCmp('typo3-pagetree'); - if (tree) { - tree.activeTree.selectPath(path); - } - if (selectOnly) { - return; - } - var separator = '?'; - if (top.currentSubScript.indexOf('?') !== -1) { - separator = '&'; - } - top.TYPO3.Backend.ContentContainer.setUrl( - top.currentSubScript + separator + 'id=' + uid - ); - } -} - - -/** - * Callback for page selection in the pagetree without follow - */ -function gotToPageCallbackNoFollow(path){ - var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree); - callback.apply(this, arguments); -} - - -/** - * Callback for page selection in the pagetree - */ -function gotToPageCallback(path){ - var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree); - callback.apply(this, arguments); - var node = top.nav.getSelected(); - if (node) { - top.TYPO3.Components.PageTree.Actions.singleClick(node, top.TYPO3.Components.PageTree.Tree); - } -} - -function sgNewsGoToPageModule(uid, path) { - sgNewsGoToPage(uid, path, true); - parent.TYPO3.ModuleMenu.App.showModule('web_layout'); - return false; -} diff --git a/composer.json b/composer.json index f6d965ccd713e93f669230b8e292db9147b5f926..888f5749e7aaef0a4352d04107e97a05dade7948 100644 --- a/composer.json +++ b/composer.json @@ -24,15 +24,15 @@ } ], "require": { - "roave/security-advisories": "dev-master", - "typo3/cms-core": "7.6.0 - 8.7.99", - "stefanfroemken/repair_translation": "^1.0" + "typo3/cms-core": "^8.7.0 || ^9.5.1" + }, + "require-dev": { + "roave/security-advisories": "dev-master" }, "suggest": { "sgalinski/languagevisibility": "Minimum version 1.1 required, if multi language is enabled", "sgalinski/sg-ajax": "Needed for the like feature", - "sgalinski/sg-comments": "Flexible comments system", - "typo3-ter/rx-shariff": "Social Share possibilities" + "sgalinski/sg-comments": "Flexible comments system" }, "replace": { "sg_news": "self.version" diff --git a/ext_emconf.php b/ext_emconf.php index e9446682ac6bdfbc20601b1a63c59654103a664a..4f0701098d4b40fd4a6b290853d764aac787269e 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -22,13 +22,12 @@ $EM_CONF[$_EXTKEY] = [ 'version' => '5.9.0', 'constraints' => [ 'depends' => [ - 'typo3' => '7.6.0-8.7.99', - 'php' => '7.0.0-7.2.99', + 'typo3' => '8.7.0-9.5.99', + 'php' => '7.0.0-7.3.99', ], 'conflicts' => [], 'suggests' => [ - 'sg_comments' => '2.1.0-', - 'rx_shariff' => '5.0.1-', + 'sg_comments' => '3.0.0', 'sg_ajax' => '1.0.6-', 'languagevisibility' => '1.1.0-', ], diff --git a/ext_localconf.php b/ext_localconf.php index 7f5a9e71f4c91b7436176b38336b65c2557b5ba7..e28cc8f162ba3be0fe15cf947f61d3e2e85496f7 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,109 +1,140 @@ <?php - -if (!defined('TYPO3_MODE')) { - die('Access denied.'); -} - -$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] .= ',tx_sgnews_teaser1_image,tx_sgnews_teaser2_image'; - -/** @noinspection PhpUndefinedVariableInspection */ -$extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('sg_news'); - -// common typoscript configuration -$tsPath = $extPath . 'Configuration/TypoScript/Common/'; -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(file_get_contents($tsPath . 'setup.txt')); - -// plugin configurations -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'SGalinski.sg_news', - 'Overview', - ['Overview' => 'overview',], - ['Overview' => '',] -); - -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'SGalinski.sg_news', - 'ListByCategory', - ['ListByCategory' => 'index',], - ['ListByCategory' => '',] -); - -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'SGalinski.sg_news', - 'SingleView', - ['SingleView' => 'singleView',], - ['SingleView' => '',] -); - -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'SGalinski.sg_news', - 'NewsFeed', - ['NewsFeed' => 'index',], - ['NewsFeed' => '',] +/** + * + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ + +call_user_func( + function ($extKey) { + // common typoscript configuration + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup( + '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $extKey . '/Configuration/TypoScript/Common/setup.typoscript">' + ); + + // plugin configurations + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'SGalinski.' . $extKey, + 'Overview', + ['Overview' => 'overview',], + ['Overview' => '',] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'SGalinski.' . $extKey, + 'ListByCategory', + ['ListByCategory' => 'index',], + ['ListByCategory' => '',] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'SGalinski.' . $extKey, + 'SingleView', + ['SingleView' => 'singleView',], + ['SingleView' => '',] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'SGalinski.' . $extKey, + 'NewsFeed', + ['NewsFeed' => 'index',], + ['NewsFeed' => '',] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'SGalinski.' . $extKey, + 'Latest', + ['Latest' => 'index',], + ['Latest' => '',] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'SGalinski.' . $extKey, + 'ListByCategory', + ['ListByCategory' => 'index',], + ['ListByCategory' => '',] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'SGalinski.' . $extKey, + 'PageBrowser', + ['PageBrowser' => 'index',], + ['PageBrowser' => '',] + ); + + if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) { + \SGalinski\SgAjax\Service\AjaxRegistration::configureAjaxFrontendPlugin( + $extKey, [ + 'Ajax\Like' => 'addLike', + ] + ); + } + + // hook registration + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = + 'SGalinski\SgNews\TCA\TcaProvider'; + + // Xclasses + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Core\Page\PageRenderer'] = + ['className' => 'SGalinski\SgNews\Xclass\PageRenderer']; + + // add realurl configuration + if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) { + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['sgnews'] = + \SGalinski\SgNews\Hooks\RealUrlAutoConfiguration::class . '->addNewsConfig'; + } + + /** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */ + $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( + \TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class + ); + + $signalSlotDispatcher->connect( + \TYPO3\CMS\Backend\Controller\EditDocumentController::class, + 'preInitAfter', + \SGalinski\SgNews\Hooks\EditDocumentController::class, + 'preInitAfter' + ); + + if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'])) { + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'] = []; + } + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'][] = + \SGalinski\SgNews\Hooks\PageLayoutController::class . '->addNewsModuleLink'; + + // register command controllers + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = + 'SGalinski\SgNews\Command\MigrateNewsCommandController'; + + // add the new doktype to the list of types available from the new page menu at the top of the page tree + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig( + 'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . \SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE . ')' . PHP_EOL + . 'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . \SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE . ')' + ); + + \SGalinski\SgNews\Utility\BackendNewsUtility::registerIcons(); + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig( + '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $extKey . '/Configuration/TsConfig/Page/NewContentElementWizard.tsconfig">' + ); + }, 'sg_news' ); - -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'SGalinski.sg_news', - 'Latest', - ['Latest' => 'index',], - ['Latest' => '',] -); - -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'SGalinski.sg_news', - 'ListByCategory', - ['ListByCategory' => 'index',], - ['ListByCategory' => '',] -); - -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( - 'SGalinski.sg_news', - 'PageBrowser', - ['PageBrowser' => 'index',], - ['PageBrowser' => '',] -); - -if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) { - \SGalinski\SgAjax\Service\AjaxRegistration::configureAjaxFrontendPlugin('sg_news', [ - 'Ajax\Like' => 'addLike', - ] - ); -} - -// hook registration -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = - 'EXT:sg_news/Classes/TCA/TcaProvider.php:SGalinski\SgNews\TCA\TcaProvider'; - -// Xclasses -$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Core\Page\PageRenderer'] = - ['className' => 'SGalinski\SgNews\Xclass\PageRenderer']; - -// add realurl configuration -if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) { - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['sgnews'] = - \SGalinski\SgNews\Hooks\RealUrlAutoConfiguration::class . '->addNewsConfig'; -} - -/** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */ -$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); - -$signalSlotDispatcher->connect( - \TYPO3\CMS\Backend\Controller\EditDocumentController::class, - 'preInitAfter', - \SGalinski\SgNews\Hooks\EditDocumentController::class, - 'preInitAfter' -); - -if(!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'])) { - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'] = []; -} -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'][] = - \SGalinski\SgNews\Hooks\PageLayoutController::class . '->addNewsModuleLink'; - -// register command controllers -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = - 'SGalinski\SgNews\Command\MigrateNewsCommandController'; - -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig( - '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:sg_news/Configuration/TsConfig/Page/NewContentElementWizard.tsconfig">' -); \ No newline at end of file diff --git a/ext_tables.php b/ext_tables.php index 3007830262e2e561f4230b525dd1f981bdee6083..8437913b05fb14d4529473be8c6966d04e8bcdc1 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,175 +1,52 @@ <?php - -if (!defined('TYPO3_MODE')) { - die('Access denied.'); -} - -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( - 'sg_news', 'Configuration/TypoScript/Frontend', 'News System' -); - -TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( - 'sg_news', 'Overview', - 'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageTypeTitlePluginOverview.news' -); - -TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( - 'sg_news', 'Latest', - 'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageTypeTitlePluginLatest.news' -); - -TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( - 'sg_news', 'SingleView', - 'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageTypeTitlePluginSingle.news' -); - -TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( - 'sg_news', 'ListByCategory', - 'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageTypeTitlePluginCategory.news' -); - -if (TYPO3_MODE === 'BE') { - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( - 'SGalinski.sg_news', - 'web', - 'News', - '', - [ - 'Backend' => 'index', - ], - [ - 'access' => 'user,group', - 'icon' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg', - 'labels' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang.xlf', - ] - ); -} - -// Removal of the unused plugin setting fields -$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_overview'] = 'select_key,pages,recursive'; -$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_listbycategory'] = 'select_key,pages,recursive'; -$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_latest'] = 'select_key,pages,recursive'; -$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_singleview'] = 'select_key,pages,recursive'; - -// Flex form assignment -$pluginSignature = str_replace('_', '', 'sg_news') . '_overview'; -$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( - $pluginSignature, 'FILE:EXT:sg_news/Configuration/FlexForms/Overview.xml' -); - -$pluginSignature = str_replace('_', '', 'sg_news') . '_listbycategory'; -$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( - $pluginSignature, 'FILE:EXT:sg_news/Configuration/FlexForms/ListByCategory.xml' -); - -$pluginSignature = str_replace('_', '', 'sg_news') . '_latest'; -$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( - $pluginSignature, 'FILE:EXT:sg_news/Configuration/FlexForms/Latest.xml' -); - -// Define the new doktypes -/** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */ -$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); - -################################### -### Define the Category Doktype ### -################################### - -$customPageDoktype = 117; - -// add the new doktype to the list of page types -$GLOBALS['PAGES_TYPES'][$customPageDoktype] = [ - 'type' => 'sys', - 'icon' => 'EXT:sg_news/Resources/Public/Images/Category.png', - 'allowedTables' => '*', -]; - -// add the new doktype to the page type selector -$GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'][] = [ - 'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.category', - $customPageDoktype, - 'EXT:sg_news/Resources/Public/Images/Category.png' -]; - -// also add the new doktype to the page language overlays type selector (so that translations can inherit the same type) -$GLOBALS['TCA']['pages_language_overlay']['columns']['doktype']['config']['items'][] = [ - 'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.category', - $customPageDoktype, - 'EXT:sg_news/Resources/Public/Images/Category.png' -]; - -// register new icon -$iconRegistry->registerIcon( - 'tcarecords-pages-' . $customPageDoktype, - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, - ['source' => 'EXT:sg_news/Resources/Public/Images/Category.png'] +/** + * + * Copyright notice + * + * (c) sgalinski Internet Services (https://www.sgalinski.de) + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + */ + +call_user_func( + function ($extKey) { + if (TYPO3_MODE === 'BE') { + $navigationComponentId = 'TYPO3/CMS/Backend/PageTree/PageTreeElement'; + if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { + $navigationComponentId = 'typo3-pagetree'; + } + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + 'SGalinski.' . $extKey, + 'web', + 'News', + '', + [ + 'Backend' => 'index', + ], + [ + 'access' => 'user,group', + 'icon' => 'EXT:' . $extKey . '/Resources/Public/Icons/module-sgnews.svg', + 'labels' => 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang.xlf', + 'navigationComponentId' => $navigationComponentId + ] + ); + } + }, 'sg_news' ); -$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = 'tcarecords-pages-' . $customPageDoktype; - -// add the new doktype to the list of types available from the new page menu at the top of the page tree -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig( - 'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . $customPageDoktype . ')' -); - -############################### -### Define the News Doktype ### -############################### - -$customPageDoktype = 116; - -// add the new doktype to the list of page types -$GLOBALS['PAGES_TYPES'][$customPageDoktype] = [ - 'type' => 'sys', - 'icon' => 'EXT:sg_news/Resources/Public/Images/News.png', - 'allowedTables' => '*', -]; - -// add the new doktype to the page type selector -$GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'][] = [ - 'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.news', - $customPageDoktype, - 'EXT:sg_news/Resources/Public/Images/News.png' -]; - -// also add the new doktype to the page language overlays type selector (so that translations can inherit the same type) -$GLOBALS['TCA']['pages_language_overlay']['columns']['doktype']['config']['items'][] = [ - 'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.news', - $customPageDoktype, - 'EXT:sg_news/Resources/Public/Images/News.png' -]; - -// register new icon -$iconRegistry->registerIcon( - 'tcarecords-pages-' . $customPageDoktype, - \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class, - ['source' => 'EXT:sg_news/Resources/Public/Images/News.png'] -); -$iconRegistry->registerIcon( - 'actions-document-open-white', - \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - ['source' => 'EXT:sg_news/Resources/Public/Icons/actions-document-open-white.svg'] -); -$iconRegistry->registerIcon( - 'sg_news-module', - \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - ['source' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg'] -); -$iconRegistry->registerIcon( - 'sg_news-module-transparent', - \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - ['source' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews-transparent.svg'] -); - -$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = 'tcarecords-pages-' . $customPageDoktype; - -// add the new doktype to the list of types available from the new page menu at the top of the page tree -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig( - 'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . $customPageDoktype . ')' -); - -if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) { - \SGalinski\SgAjax\Service\AjaxRegistration::registerAjaxFrontendPlugin('sg_news'); -}