Skip to content
Snippets Groups Projects
Commit f0b692d1 authored by Fabian Galinski's avatar Fabian Galinski :pouting_cat:
Browse files

Merge branch 'task_apply_language_visibility_to_the_news' into 'master'

Task apply language visibility to the news

See merge request !1
parents b83c58d4 76dfa5e4
No related branches found
No related tags found
1 merge request!1Task apply language visibility to the news
...@@ -55,10 +55,12 @@ class LatestController extends AbstractController { ...@@ -55,10 +55,12 @@ class LatestController extends AbstractController {
/** /**
* Renders the news overview * Renders the news overview
* *
* @param array $newsMetaData
* @param int $offset
* @return void * @return void
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/ */
public function indexAction() { public function indexAction(array $newsMetaData = [], $offset = 0) {
$limit = ((int) $this->settings['limit']); $limit = ((int) $this->settings['limit']);
$limit = ($limit < 1 ? 1 : $limit); $limit = ($limit < 1 ? 1 : $limit);
...@@ -69,10 +71,9 @@ class LatestController extends AbstractController { ...@@ -69,10 +71,9 @@ class LatestController extends AbstractController {
} }
$latestNewsEntries = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories( $latestNewsEntries = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories(
$limit, FALSE, $categoryUids, 0, TRUE, $this->settings['sortBy'], $tagUids $limit, FALSE, $categoryUids, $offset, TRUE, $this->settings['sortBy'], $tagUids
); );
$newsMetaData = [];
$categories = []; $categories = [];
foreach ($latestNewsEntries as $latestNewsEntry) { foreach ($latestNewsEntries as $latestNewsEntry) {
/** @var News $latestNewsEntry */ /** @var News $latestNewsEntry */
...@@ -88,8 +89,25 @@ class LatestController extends AbstractController { ...@@ -88,8 +89,25 @@ class LatestController extends AbstractController {
} }
$newsMetaData[] = $this->getMetaDataForNews($latestNewsEntry, $category); $newsMetaData[] = $this->getMetaDataForNews($latestNewsEntry, $category);
// Make sure, that the amount is the same as the configured limit.
if (count($newsMetaData) >= $limit) {
break;
}
} }
// Redo this function, until $newsMetaData gets the $limit. Needed because of languagevisibility.
if (count($newsMetaData) < $limit) {
$offset += $limit;
$maxCount = $this->newsRepository->getCountOfLastUpdatedOrHighlightedNewsByCategories(
FALSE, $categoryUids, TRUE, $this->settings['sortBy'], $tagUids
);
if ($offset < $maxCount) {
$this->indexAction($newsMetaData, $offset);
return;
}
}
$this->view->assign('newsMetaData', $newsMetaData); $this->view->assign('newsMetaData', $newsMetaData);
} }
} }
...@@ -55,10 +55,11 @@ class ListByCategoryController extends AbstractController { ...@@ -55,10 +55,11 @@ class ListByCategoryController extends AbstractController {
/** /**
* Renders the news list of a category * Renders the news list of a category
* *
* @param array $newsMetaData
* @return void * @return void
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/ */
public function indexAction() { public function indexAction(array $newsMetaData = []) {
$filterByCategories = FALSE; $filterByCategories = FALSE;
$categoryUids = GeneralUtility::intExplode(',', $this->settings['categories']); $categoryUids = GeneralUtility::intExplode(',', $this->settings['categories']);
$tagUids = GeneralUtility::intExplode(',', $this->settings['tags'], TRUE); $tagUids = GeneralUtility::intExplode(',', $this->settings['tags'], TRUE);
...@@ -87,7 +88,6 @@ class ListByCategoryController extends AbstractController { ...@@ -87,7 +88,6 @@ class ListByCategoryController extends AbstractController {
$newsCount = $this->newsRepository->newsCountByCategories($categoryUids, $tagUids); $newsCount = $this->newsRepository->newsCountByCategories($categoryUids, $tagUids);
$numberOfPages = ($newsPerPage <= 0 ? 0 : ceil($newsCount / $newsPerPage)); $numberOfPages = ($newsPerPage <= 0 ? 0 : ceil($newsCount / $newsPerPage));
$newsMetaData = [];
$headerSet = FALSE; $headerSet = FALSE;
$news = $this->newsRepository->findAllSortedNewsByCategories( $news = $this->newsRepository->findAllSortedNewsByCategories(
$categoryUids, $newsPerPage, $offset, $this->settings['sortBy'], $tagUids $categoryUids, $newsPerPage, $offset, $this->settings['sortBy'], $tagUids
...@@ -108,6 +108,16 @@ class ListByCategoryController extends AbstractController { ...@@ -108,6 +108,16 @@ class ListByCategoryController extends AbstractController {
} }
} }
// Redo this function, until one variable get the amount of $newsPerPage. Reduces the amount of ajax calls. Needed because of languagevisibility.
if (count($newsMetaData) < $newsPerPage) {
$nextPage = $currentPageBrowserPage + 1;
if ($nextPage <= $numberOfPages) {
GeneralUtility::_GETset(['tx_sgnews_pagebrowser' => ['currentPage' => $nextPage]]);
$this->indexAction($newsMetaData);
return;
}
}
$this->view->assign('numberOfPages', $numberOfPages); $this->view->assign('numberOfPages', $numberOfPages);
$this->view->assign('newsMetaData', $newsMetaData); $this->view->assign('newsMetaData', $newsMetaData);
$this->view->assign('categories', $categories); $this->view->assign('categories', $categories);
......
...@@ -111,10 +111,12 @@ class OverviewController extends AbstractController { ...@@ -111,10 +111,12 @@ class OverviewController extends AbstractController {
/** /**
* Renders the news overview grouped by categories * Renders the news overview grouped by categories
* *
* @param array $newsByCategory
* @param array $allNews
* @return void * @return void
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/ */
protected function overviewWithCategories() { protected function overviewWithCategories(array $newsByCategory = [], array $allNews = []) {
$newsLimitPerCategory = (int) $this->settings['newsLimit']; $newsLimitPerCategory = (int) $this->settings['newsLimit'];
$this->categoryRepository->setDefaultOrderings(['sorting' => Query::ORDER_ASCENDING]); $this->categoryRepository->setDefaultOrderings(['sorting' => Query::ORDER_ASCENDING]);
...@@ -147,24 +149,35 @@ class OverviewController extends AbstractController { ...@@ -147,24 +149,35 @@ class OverviewController extends AbstractController {
/** @var News $newsEntry */ /** @var News $newsEntry */
$categoryId = $newsEntry->getPid(); $categoryId = $newsEntry->getPid();
$category = $categoriesById[$categoryId]; $category = $categoriesById[$categoryId];
if (!$category) {
// Category isn't visible.
continue;
}
$data = $this->getMetaDataForNews($newsEntry, $category); $data = $this->getMetaDataForNews($newsEntry, $category);
$newsMetaData[$categoryId][] = $data; $newsMetaData[$categoryId][] = $data;
} }
} }
$newsByCategory = []; $maxNewsPerCategory = 0;
foreach ($categoriesById as $categoryId => $category) { foreach ($categoriesById as $categoryId => $category) {
/** @var $category Category */ /** @var $category Category */
$newsByCategory[$categoryId] = [ if (isset($newsByTag[$categoryId])) {
'record' => $category, /** @var $category Category */
'recordId' => $categoryId, $newsByCategory[$categoryId]['newsMetaData'] =
'recordType' => 'category', array_merge($newsByCategory[$categoryId]['newsMetaData'], $newsMetaData[$categoryId]);
'newsMetaData' => $newsMetaData[$categoryId] } else {
]; $newsByCategory[$categoryId] = [
'record' => $category,
'recordId' => $categoryId,
'recordType' => 'category',
'newsMetaData' => $newsMetaData[$categoryId]
];
}
$maxNewsPerCategory = max($newsByCategory, count($newsByTag[$categoryId]['newsMetaData']));
} }
$allNews = [];
$news = $this->newsRepository->findAllSortedNewsByCategories( $news = $this->newsRepository->findAllSortedNewsByCategories(
$categoryIds, $newsLimitPerCategory, $offset, $this->settings['sortBy'] $categoryIds, $newsLimitPerCategory, $offset, $this->settings['sortBy']
); );
...@@ -172,6 +185,10 @@ class OverviewController extends AbstractController { ...@@ -172,6 +185,10 @@ class OverviewController extends AbstractController {
/** @var News $newsEntry */ /** @var News $newsEntry */
$categoryId = $newsEntry->getPid(); $categoryId = $newsEntry->getPid();
$category = $categoriesById[$categoryId]; $category = $categoriesById[$categoryId];
if (!$category) {
// Category isn't visible.
continue;
}
$data = $this->getMetaDataForNews($newsEntry, $category); $data = $this->getMetaDataForNews($newsEntry, $category);
$allNews[] = $data; $allNews[] = $data;
...@@ -181,6 +198,16 @@ class OverviewController extends AbstractController { ...@@ -181,6 +198,16 @@ class OverviewController extends AbstractController {
$newsCount = $this->newsRepository->newsCountByCategories($categoryIds); $newsCount = $this->newsRepository->newsCountByCategories($categoryIds);
$numberOfPages = ($newsLimitPerCategory <= 0 ? 0 : ceil($newsCount / $newsLimitPerCategory)); $numberOfPages = ($newsLimitPerCategory <= 0 ? 0 : ceil($newsCount / $newsLimitPerCategory));
// Redo this function, until one variable get the amount of newsLimitPerTag. Reduces the amount of ajax calls. Needed because of languagevisibility.
if ($maxNewsPerCategory < $newsLimitPerCategory && count($allNews) < $newsLimitPerCategory) {
$nextPage = $currentPageBrowserPage + 1;
if ($nextPage <= $numberOfPages) {
GeneralUtility::_GETset(['tx_sgnews_pagebrowser' => ['currentPage' => $nextPage]]);
$this->overviewWithCategories($newsByCategory, $allNews);
return;
}
}
$this->view->assign('numberOfPages', $numberOfPages); $this->view->assign('numberOfPages', $numberOfPages);
$this->view->assign('newsItems', $newsByCategory); $this->view->assign('newsItems', $newsByCategory);
$this->view->assign('groupBy', 'category'); $this->view->assign('groupBy', 'category');
...@@ -190,10 +217,12 @@ class OverviewController extends AbstractController { ...@@ -190,10 +217,12 @@ class OverviewController extends AbstractController {
/** /**
* Renders the news overview grouped by tags * Renders the news overview grouped by tags
* *
* @param array $newsByTag
* @param array $allNews
* @return void * @return void
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/ */
protected function overviewWithTags() { protected function overviewWithTags(array $newsByTag = [], array $allNews = []) {
$newsLimitPerTag = (int) $this->settings['newsLimit']; $newsLimitPerTag = (int) $this->settings['newsLimit'];
$this->tagRepository->setDefaultOrderings(['sorting' => Query::ORDER_ASCENDING]); $this->tagRepository->setDefaultOrderings(['sorting' => Query::ORDER_ASCENDING]);
...@@ -234,24 +263,40 @@ class OverviewController extends AbstractController { ...@@ -234,24 +263,40 @@ class OverviewController extends AbstractController {
$categoriesById[$categoryId] = $this->categoryRepository->findByUid($categoryId); $categoriesById[$categoryId] = $this->categoryRepository->findByUid($categoryId);
} }
$category = $categoriesById[$categoryId]; $category = $categoriesById[$categoryId];
if (!$category) {
// Category isn't visible.
continue;
}
$data = $this->getMetaDataForNews($newsEntry, $category); $data = $this->getMetaDataForNews($newsEntry, $category);
$newsMetaData[$tagId][] = $data; $newsMetaData[$tagId][] = $data;
} }
} }
$newsByTag = []; $maxNewsPerTag = 0;
foreach ($tagsById as $tagId => $tag) { foreach ($tagsById as $tagId => $tag) {
/** @var $category Category */ if (count($newsMetaData[$tagId]) <= 0) {
$newsByTag[$tagId] = [ // Hide empty tags.
'record' => $tag, continue;
'recordId' => $tagId, }
'recordType' => 'tag',
'newsMetaData' => $newsMetaData[$tagId] if (isset($newsByTag[$tagId])) {
]; /** @var $category Category */
$newsByTag[$tagId]['newsMetaData'] =
array_merge($newsByTag[$tagId]['newsMetaData'], $newsMetaData[$tagId]);
} else {
/** @var $category Category */
$newsByTag[$tagId] = [
'record' => $tag,
'recordId' => $tagId,
'recordType' => 'tag',
'newsMetaData' => $newsMetaData[$tagId]
];
}
$maxNewsPerTag = max($maxNewsPerTag, count($newsByTag[$tagId]['newsMetaData']));
} }
$allNews = [];
$news = $this->newsRepository->findAllSortedNewsByCategories( $news = $this->newsRepository->findAllSortedNewsByCategories(
NULL, $newsLimitPerTag, $offset, $this->settings['sortBy'], $tagIds NULL, $newsLimitPerTag, $offset, $this->settings['sortBy'], $tagIds
); );
...@@ -262,6 +307,10 @@ class OverviewController extends AbstractController { ...@@ -262,6 +307,10 @@ class OverviewController extends AbstractController {
$categoriesById[$categoryId] = $this->categoryRepository->findByUid($categoryId); $categoriesById[$categoryId] = $this->categoryRepository->findByUid($categoryId);
} }
$category = $categoriesById[$categoryId]; $category = $categoriesById[$categoryId];
if (!$category) {
// Category isn't visible.
continue;
}
$data = $this->getMetaDataForNews($newsEntry, $category); $data = $this->getMetaDataForNews($newsEntry, $category);
$allNews[] = $data; $allNews[] = $data;
...@@ -271,6 +320,16 @@ class OverviewController extends AbstractController { ...@@ -271,6 +320,16 @@ class OverviewController extends AbstractController {
$newsCount = $this->newsRepository->newsCountByCategories([], $tagIds); $newsCount = $this->newsRepository->newsCountByCategories([], $tagIds);
$numberOfPages = ($newsLimitPerTag <= 0 ? 0 : ceil($newsCount / $newsLimitPerTag)); $numberOfPages = ($newsLimitPerTag <= 0 ? 0 : ceil($newsCount / $newsLimitPerTag));
// Redo this function, until one variable get the amount of newsLimitPerTag. Reduces the amount of ajax calls. Needed because of languagevisibility.
if ($maxNewsPerTag < $newsLimitPerTag && count($allNews) < $newsLimitPerTag) {
$nextPage = $currentPageBrowserPage + 1;
if ($nextPage <= $numberOfPages) {
GeneralUtility::_GETset(['tx_sgnews_pagebrowser' => ['currentPage' => $nextPage]]);
$this->overviewWithTags($newsByTag, $allNews);
return;
}
}
$this->view->assign('numberOfPages', $numberOfPages); $this->view->assign('numberOfPages', $numberOfPages);
$this->view->assign('newsItems', $newsByTag); $this->view->assign('newsItems', $newsByTag);
$this->view->assign('groupBy', 'tag'); $this->view->assign('groupBy', 'tag');
...@@ -280,10 +339,11 @@ class OverviewController extends AbstractController { ...@@ -280,10 +339,11 @@ class OverviewController extends AbstractController {
/** /**
* Renders the news in a paginated list * Renders the news in a paginated list
* *
* @param array $newsMetaData
* @return void * @return void
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/ */
protected function overviewWithoutCategoriesAction() { protected function overviewWithoutCategoriesAction(array $newsMetaData = []) {
$offset = 0; $offset = 0;
$newsPerPage = (int) $this->settings['newsLimit']; $newsPerPage = (int) $this->settings['newsLimit'];
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage']; $currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage'];
...@@ -318,7 +378,6 @@ class OverviewController extends AbstractController { ...@@ -318,7 +378,6 @@ class OverviewController extends AbstractController {
} }
} }
$newsMetaData = [];
$news = $this->newsRepository->findAllSortedNewsByCategories( $news = $this->newsRepository->findAllSortedNewsByCategories(
$categoryIds, $newsPerPage, $offset, $this->settings['sortBy'] $categoryIds, $newsPerPage, $offset, $this->settings['sortBy']
); );
...@@ -331,6 +390,16 @@ class OverviewController extends AbstractController { ...@@ -331,6 +390,16 @@ class OverviewController extends AbstractController {
$this->highlightBestFitNews($categoryIds); $this->highlightBestFitNews($categoryIds);
$numberOfPages = ($newsPerPage <= 0 ? 0 : ceil($newsCount / $newsPerPage)); $numberOfPages = ($newsPerPage <= 0 ? 0 : ceil($newsCount / $newsPerPage));
// Redo this function, until one variable get the amount of newsLimitPerTag. Reduces the amount of ajax calls. Needed because of languagevisibility.
if (count($newsMetaData) < $newsPerPage) {
$nextPage = $currentPageBrowserPage + 1;
if ($nextPage <= $numberOfPages) {
GeneralUtility::_GETset(['tx_sgnews_pagebrowser' => ['currentPage' => $nextPage]]);
$this->overviewWithoutCategoriesAction($newsMetaData);
return;
}
}
$this->view->assign('numberOfPages', $numberOfPages); $this->view->assign('numberOfPages', $numberOfPages);
$this->view->assign('newsMetaData', $newsMetaData); $this->view->assign('newsMetaData', $newsMetaData);
} }
......
...@@ -34,11 +34,6 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage; ...@@ -34,11 +34,6 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
* News * News
*/ */
class News extends CategoryAndNews { class News extends CategoryAndNews {
/**
* @var string
*/
protected $navTitle = '';
/** /**
* @var string * @var string
*/ */
...@@ -260,7 +255,7 @@ class News extends CategoryAndNews { ...@@ -260,7 +255,7 @@ class News extends CategoryAndNews {
* @return void * @return void
*/ */
public function setNeverHighlighted($neverHighlighted) { public function setNeverHighlighted($neverHighlighted) {
$this->neverHighlighted = ($neverHighlighted === TRUE); $this->neverHighlighted = ($neverHighlighted == TRUE);
} }
/** /**
...@@ -295,6 +290,4 @@ class News extends CategoryAndNews { ...@@ -295,6 +290,4 @@ class News extends CategoryAndNews {
public function setLikes($likes) { public function setLikes($likes) {
$this->likes = $likes; $this->likes = $likes;
} }
} }
...@@ -155,6 +155,49 @@ class NewsRepository extends AbstractRepository { ...@@ -155,6 +155,49 @@ class NewsRepository extends AbstractRepository {
public function findLastUpdatedOrHighlightedNewsByCategories( public function findLastUpdatedOrHighlightedNewsByCategories(
$limit = 1, $onlyHighlighted = FALSE, array $categoryIds = NULL, $limit = 1, $onlyHighlighted = FALSE, array $categoryIds = NULL,
$offset = 0, $hideNeverHighlightedNews = FALSE, $sortBy = 'date', array $tagIds = NULL $offset = 0, $hideNeverHighlightedNews = FALSE, $sortBy = 'date', array $tagIds = NULL
) {
return $this->getQueryForLastUpdatedOrHighlightedNewsByCategories(
$limit, $onlyHighlighted, $categoryIds, $offset, $hideNeverHighlightedNews, $sortBy, $tagIds
)->execute();
}
/**
* Returns the count of all possible last news.
*
* @param bool $onlyHighlighted
* @param array $categoryIds NULL, if the category filter isn't applied, otherwise an array with the categories uid.
* @param int $offset
* @param bool $hideNeverHighlightedNews
* @param string $sortBy date or positionInTree
* @param array $tagIds NULL, if the tag filter isn't applied, otherwise an array with the tag uids.
* @return int
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function getCountOfLastUpdatedOrHighlightedNewsByCategories(
$onlyHighlighted = FALSE, array $categoryIds = NULL, $hideNeverHighlightedNews = FALSE, $sortBy = 'date',
array $tagIds = NULL
) {
return $this->getQueryForLastUpdatedOrHighlightedNewsByCategories(
0, $onlyHighlighted, $categoryIds, 0, $hideNeverHighlightedNews, $sortBy, $tagIds
)->count();
}
/**
* Returns the query object of the LastUpdatedOrHighlightedNewsByCategories.
*
* @param int $limit
* @param bool $onlyHighlighted
* @param array $categoryIds NULL, if the category filter isn't applied, otherwise an array with the categories uid.
* @param int $offset
* @param bool $hideNeverHighlightedNews
* @param string $sortBy date or positionInTree
* @param array $tagIds NULL, if the tag filter isn't applied, otherwise an array with the tag uids.
* @return QueryInterface
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
protected function getQueryForLastUpdatedOrHighlightedNewsByCategories(
$limit = 1, $onlyHighlighted = FALSE, array $categoryIds = NULL,
$offset = 0, $hideNeverHighlightedNews = FALSE, $sortBy = 'date', array $tagIds = NULL
) { ) {
$query = $this->createQuery(); $query = $this->createQuery();
$constraints = NULL; $constraints = NULL;
...@@ -215,7 +258,7 @@ class NewsRepository extends AbstractRepository { ...@@ -215,7 +258,7 @@ class NewsRepository extends AbstractRepository {
$query->setOffset($offset); $query->setOffset($offset);
} }
return $query->matching($constraints)->execute(); return $query->matching($constraints);
} }
// /** // /**
......
...@@ -26,7 +26,10 @@ namespace SGalinski\SgNews\Xclass; ...@@ -26,7 +26,10 @@ namespace SGalinski\SgNews\Xclass;
***************************************************************/ ***************************************************************/
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Qom; use TYPO3\CMS\Extbase\Persistence\Generic\Qom;
use TYPO3\Languagevisibility\Service\FrontendServices;
/** /**
* Xclass for the TYPO3 db backend, which handles, that the l18n_cfg parameters are used for pages in Extbase. * Xclass for the TYPO3 db backend, which handles, that the l18n_cfg parameters are used for pages in Extbase.
...@@ -85,6 +88,7 @@ class Typo3DbBackend extends \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo ...@@ -85,6 +88,7 @@ class Typo3DbBackend extends \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo
} }
} }
$isLanguagevisibilityLoaded = ExtensionManagementUtility::isLoaded('languagevisibility');
$overlaidRows = array(); $overlaidRows = array();
foreach ($rows as $row) { foreach ($rows as $row) {
// If current row is a translation select its parent // If current row is a translation select its parent
...@@ -106,12 +110,23 @@ class Typo3DbBackend extends \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo ...@@ -106,12 +110,23 @@ class Typo3DbBackend extends \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo
} }
$pageRepository->versionOL($tableName, $row, true); $pageRepository->versionOL($tableName, $row, true);
if ($tableName == 'pages') { if ($tableName == 'pages') {
// Start of the patch
// Applies the language visibility logic.
if ($isLanguagevisibilityLoaded && is_object($GLOBALS['TSFE'])) {
$sysLanguageUid = $GLOBALS['TSFE']->sys_language_uid;
if (!FrontendServices::checkVisiblityForElement((int) $row['uid'], $tableName, $sysLanguageUid)) {
// Page not visible
continue;
}
}
// End of the patch
$row = $pageRepository->getPageOverlay($row, $querySettings->getLanguageUid()); $row = $pageRepository->getPageOverlay($row, $querySettings->getLanguageUid());
if ($row === null || !is_array($row)) { if ($row === null || !is_array($row)) {
continue; continue;
} }
// Start of the patch // Start of the patch
$l18nConfiguration = $row['l18n_cfg']; $l18nConfiguration = $row['l18n_cfg'];
if ($l18nConfiguration > 0) { if ($l18nConfiguration > 0) {
......
...@@ -214,4 +214,7 @@ You find the settings in the **Fontend/constants.txt** configuration file: ...@@ -214,4 +214,7 @@ You find the settings in the **Fontend/constants.txt** configuration file:
} }
--- ---
###### addLike ###### addLike
Automatically adds an AJAX like button to each single news entry. Automatically adds an AJAX like button to each single news entry.
Make sure, that the extension sg_ajax is installed, otherwise this feature will be disabled.
If it should be like this, then make sure to remove this button from the sg_news default templates.
...@@ -3,35 +3,50 @@ ...@@ -3,35 +3,50 @@
{namespace sg=SGalinski\SgNews\ViewHelpers} {namespace sg=SGalinski\SgNews\ViewHelpers}
<f:section name="main"> <f:section name="main">
<f:if condition="{newsItems}"> <div class="tx-sgnews-categories">
<div class="tx-sgnews-categories"> <ul class="nav nav-tabs">
<ul class="nav nav-tabs"> <li class="tx-sgnews-category active">
<li class="tx-sgnews-category active"> <a data-toggle="tab" href="#sgnewsTab0">
<a data-toggle="tab" href="#sgnewsTab0"> <f:translate key="frontend.overview.allTabLabel" />
<f:translate key="frontend.overview.allTabLabel" /> </a>
</li>
<f:for each="{newsItems}" as="dataItems">
<li class="tx-sgnews-category">
<a data-toggle="tab" href="#sgnewsTab{dataItems.record.uid}">
<f:if condition="{dataItems.recordType} == 'category'">
<f:then>
{dataItems.record.subtitleWithFallbackToTitle}
</f:then>
<f:else>
{dataItems.record.title}
</f:else>
</f:if>
</a> </a>
</li> </li>
<f:for each="{newsItems}" as="dataItems"> </f:for>
<li class="tx-sgnews-category"> </ul>
<a data-toggle="tab" href="#sgnewsTab{dataItems.record.uid}">
<f:if condition="{dataItems.recordType} == 'category'">
<f:then>
{dataItems.record.subtitleWithFallbackToTitle}
</f:then>
<f:else>
{dataItems.record.title}
</f:else>
</f:if>
</a>
</li>
</f:for>
</ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane active" id="sgnewsTab0"> <div class="tab-pane active" id="sgnewsTab0">
<h4 class="tx-sgnews-tab-title"><f:translate key="frontend.overview.allTabLabel" /></h4> <h4 class="tx-sgnews-tab-title"><f:translate key="frontend.overview.allTabLabel" /></h4>
<ul class="tx-sgnews-list tx-sgnews-list-0 row" data-record="0"> <ul class="tx-sgnews-list tx-sgnews-list-0 row" data-record="0">
<f:for each="{allNews}" as="newsMetaDataEntry"> <f:for each="{allNews}" as="newsMetaDataEntry">
<li class="col-md-4 col-sm-6 col-xs-12">
<f:render partial="Teaser" arguments="{
newsMetaData: newsMetaDataEntry,
headerTag: '<h2>',
closingHeaderTag: '</h2>',
showCategory: '{f:if(condition: \'{groupBy} == \"category\"\', then: 0, else: 1)}'
}" />
</li>
</f:for>
</ul>
</div>
<f:for each="{newsItems}" as="dataItems">
<div class="tab-pane" id="sgnewsTab{dataItems.record.uid}">
<h4 class="tx-sgnews-tab-title">{dataItems.record.title}</h4>
<ul class="tx-sgnews-list tx-sgnews-list-{dataItems.record.uid} row" data-record="{dataItems.record.uid}">
<f:for each="{dataItems.newsMetaData}" as="newsMetaDataEntry">
<li class="col-md-4 col-sm-6 col-xs-12"> <li class="col-md-4 col-sm-6 col-xs-12">
<f:render partial="Teaser" arguments="{ <f:render partial="Teaser" arguments="{
newsMetaData: newsMetaDataEntry, newsMetaData: newsMetaDataEntry,
...@@ -42,35 +57,18 @@ ...@@ -42,35 +57,18 @@
</li> </li>
</f:for> </f:for>
</ul> </ul>
</div>
<f:for each="{newsItems}" as="dataItems">
<div class="tab-pane" id="sgnewsTab{dataItems.record.uid}">
<h4 class="tx-sgnews-tab-title">{dataItems.record.title}</h4>
<ul class="tx-sgnews-list tx-sgnews-list-{dataItems.record.uid} row" data-record="{dataItems.record.uid}">
<f:for each="{dataItems.newsMetaData}" as="newsMetaDataEntry">
<li class="col-md-4 col-sm-6 col-xs-12">
<f:render partial="Teaser" arguments="{
newsMetaData: newsMetaDataEntry,
headerTag: '<h2>',
closingHeaderTag: '</h2>',
showCategory: '{f:if(condition: \'{groupBy} == \"category\"\', then: 0, else: 1)}'
}" />
</li>
</f:for>
</ul>
<f:if condition="{dataItems.recordType} == 'category'"> <f:if condition="{dataItems.recordType} == 'category'">
<div class="text-center"> <div class="text-center">
<a class="btn btn-md btn-success category-{dataByCategory.category.uid}" href="{f:uri.page(pageUid: '{dataByCategory.category.uid}')}"> <a class="btn btn-md btn-success category-{dataByCategory.category.uid}" href="{f:uri.page(pageUid: '{dataByCategory.category.uid}')}">
<f:translate key="frontend.overview.showAllEntries" /> <f:translate key="frontend.overview.showAllEntries" />
</a> </a>
</div> </div>
</f:if> </f:if>
</div> </div>
</f:for> </f:for>
</div>
</div> </div>
</div>
<sg:pageBrowser numberOfPages="{numberOfPages}" /> <sg:pageBrowser numberOfPages="{numberOfPages}" />
</f:if>
</f:section> </f:section>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"license": [ "license": [
"GPL-2.0+" "GPL-2.0+"
], ],
"version": "3.7.1", "version": "3.8.0",
"support": { "support": {
}, },
"repositories": [ "repositories": [
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
"typo3/cms-core": "^7.6" "typo3/cms-core": "^7.6"
}, },
"suggest": { "suggest": {
"sgalinski/sg-ajax": "Needed for the like feature",
"sgalinski/sg-comments": "Flexible comments system", "sgalinski/sg-comments": "Flexible comments system",
"typo3-ter/rx-shariff": "Social Share possibilities" "typo3-ter/rx-shariff": "Social Share possibilities"
}, },
......
...@@ -19,7 +19,7 @@ $EM_CONF[$_EXTKEY] = [ ...@@ -19,7 +19,7 @@ $EM_CONF[$_EXTKEY] = [
'modify_tables' => '', 'modify_tables' => '',
'clearCacheOnLoad' => 0, 'clearCacheOnLoad' => 0,
'lockType' => '', 'lockType' => '',
'version' => '3.7.1', 'version' => '3.8.0',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'typo3' => '7.6.0-7.6.99', 'typo3' => '7.6.0-7.6.99',
...@@ -29,6 +29,7 @@ $EM_CONF[$_EXTKEY] = [ ...@@ -29,6 +29,7 @@ $EM_CONF[$_EXTKEY] = [
'suggests' => [ 'suggests' => [
'sg_comments' => '2.1.0-', 'sg_comments' => '2.1.0-',
'rx_shariff' => '5.0.1-', 'rx_shariff' => '5.0.1-',
'sg_ajax' => '1.0.6-',
], ],
], ],
'suggests' => [], 'suggests' => [],
......
...@@ -63,10 +63,12 @@ $tsPath = $extPath . 'Configuration/TypoScript/Common/'; ...@@ -63,10 +63,12 @@ $tsPath = $extPath . 'Configuration/TypoScript/Common/';
['PageBrowser' => '',] ['PageBrowser' => '',]
); );
\SGalinski\SgAjax\Service\AjaxRegistration::configureAjaxFrontendPlugin('sg_news', [ if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) {
'Ajax\Like' => 'addLike', \SGalinski\SgAjax\Service\AjaxRegistration::configureAjaxFrontendPlugin('sg_news', [
] 'Ajax\Like' => 'addLike',
); ]
);
}
// hook registration // hook registration
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] =
......
...@@ -138,4 +138,6 @@ $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = 'tcar ...@@ -138,4 +138,6 @@ $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = 'tcar
'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . $customPageDoktype . ')' 'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . $customPageDoktype . ')'
); );
\SGalinski\SgAjax\Service\AjaxRegistration::registerAjaxFrontendPlugin('sg_news'); if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) {
\SGalinski\SgAjax\Service\AjaxRegistration::registerAjaxFrontendPlugin('sg_news');
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment