Skip to content

Commit

Permalink
Merge branch 'georgringer:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kanow committed Sep 16, 2024
2 parents 158b4e3 + 9003bf7 commit 3608717
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CategoryController extends NewsController
/**
* List categories
*/
public function listAction(array $overwriteDemand = null): ResponseInterface
public function listAction(?array $overwriteDemand = null): ResponseInterface
{
$demand = $this->createDemandObjectFromSettings($this->settings);
$demand->setActionAndClass(__METHOD__, __CLASS__);
Expand Down
36 changes: 19 additions & 17 deletions Classes/Controller/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ protected function overwriteDemandObject(NewsDemand $demand, array $overwriteDem
*
* @param array|null $overwriteDemand
*/
public function listAction(array $overwriteDemand = null): ResponseInterface
public function listAction(?array $overwriteDemand = null): ResponseInterface
{
$possibleRedirect = $this->forwardToDetailActionWhenRequested();
if ($possibleRedirect) {
Expand Down Expand Up @@ -264,20 +264,22 @@ public function listAction(array $overwriteDemand = null): ResponseInterface
$this->view->assignMultiple($event->getAssignedValues());

// pagination
$paginationConfiguration = $this->settings['list']['paginate'] ?? [];
$itemsPerPage = (int)(($paginationConfiguration['itemsPerPage'] ?? '') ?: 10);
$maximumNumberOfLinks = (int)($paginationConfiguration['maximumNumberOfLinks'] ?? 0);
if ((int)($this->settings['hidePagination'] ?? 0) === 0) {
$paginationConfiguration = $this->settings['list']['paginate'] ?? [];
$itemsPerPage = (int)(($paginationConfiguration['itemsPerPage'] ?? '') ?: 10);
$maximumNumberOfLinks = (int)($paginationConfiguration['maximumNumberOfLinks'] ?? 0);

$currentPage = max(1, $this->request->hasArgument('currentPage') ? (int)$this->request->getArgument('currentPage') : 1);
$paginator = GeneralUtility::makeInstance(QueryResultPaginator::class, $event->getAssignedValues()['news'], $currentPage, $itemsPerPage, (int)($this->settings['limit'] ?? 0), (int)($this->settings['offset'] ?? 0));
$paginationClass = $paginationConfiguration['class'] ?? SimplePagination::class;
$pagination = $this->getPagination($paginationClass, $maximumNumberOfLinks, $paginator);
$currentPage = max(1, $this->request->hasArgument('currentPage') ? (int)$this->request->getArgument('currentPage') : 1);
$paginator = GeneralUtility::makeInstance(QueryResultPaginator::class, $event->getAssignedValues()['news'], $currentPage, $itemsPerPage, (int)($this->settings['limit'] ?? 0), (int)($this->settings['offset'] ?? 0));
$paginationClass = $paginationConfiguration['class'] ?? SimplePagination::class;
$pagination = $this->getPagination($paginationClass, $maximumNumberOfLinks, $paginator);

$this->view->assign('pagination', [
'currentPage' => $currentPage,
'paginator' => $paginator,
'pagination' => $pagination,
]);
$this->view->assign('pagination', [
'currentPage' => $currentPage,
'paginator' => $paginator,
'pagination' => $pagination,
]);
}

Cache::addPageCacheTagsByDemandObject($demand);
return $this->htmlResponse();
Expand Down Expand Up @@ -357,7 +359,7 @@ public function selectedListAction(): ResponseInterface
* @param News $news news item
* @param int $currentPage current page for optional pagination
*/
public function detailAction(News $news = null, $currentPage = 1): ResponseInterface
public function detailAction(?News $news = null, $currentPage = 1): ResponseInterface
{
if ($news === null || ($this->settings['isShortcut'] ?? false)) {
$previewNewsId = (int)($this->settings['singleNews'] ?? 0);
Expand Down Expand Up @@ -464,7 +466,7 @@ protected function isPreviewOfHiddenRecordsEnabled(): bool
/**
* Render a menu by dates, e.g. years, months or dates
*/
public function dateMenuAction(array $overwriteDemand = null): ResponseInterface
public function dateMenuAction(?array $overwriteDemand = null): ResponseInterface
{
$demand = $this->createDemandObjectFromSettings($this->settings);
$demand->setActionAndClass(__METHOD__, __CLASS__);
Expand Down Expand Up @@ -513,7 +515,7 @@ public function dateMenuAction(array $overwriteDemand = null): ResponseInterface
* Display the search form
*/
public function searchFormAction(
Search $search = null,
?Search $search = null,
array $overwriteDemand = []
): ResponseInterface {
$demand = $this->createDemandObjectFromSettings($this->settings);
Expand Down Expand Up @@ -545,7 +547,7 @@ public function searchFormAction(
* Displays the search result
*/
public function searchResultAction(
Search $search = null,
?Search $search = null,
array $overwriteDemand = []
): ResponseInterface {
$demand = $this->createDemandObjectFromSettings($this->settings);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class TagController extends NewsController
{
public function listAction(array $overwriteDemand = null): ResponseInterface
public function listAction(?array $overwriteDemand = null): ResponseInterface
{
// Default value is wrong for tags
if ($this->settings['orderBy'] === 'datetime') {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Dto/NewsDemand.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public function getSearch(): ?Search
* @param Search|null $search search object
* @return NewsDemand
*/
public function setSearch(Search $search = null): NewsDemand
public function setSearch(?Search $search = null): NewsDemand
{
$this->search = $search;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Seo/NewsXmlSitemapDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NewsXmlSitemapDataProvider extends AbstractXmlSitemapDataProvider
* @param ContentObjectRenderer|null $cObj
* @throws MissingConfigurationException
*/
public function __construct(ServerRequestInterface $request, string $key, array $config = [], ContentObjectRenderer $cObj = null)
public function __construct(ServerRequestInterface $request, string $key, array $config = [], ?ContentObjectRenderer $cObj = null)
{
parent::__construct($request, $key, $config, $cObj);

Expand Down
2 changes: 1 addition & 1 deletion Classes/Utility/ClassCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ClassCacheManager
/**
* @param PhpFrontend $classCache
*/
public function __construct(PhpFrontend $classCache = null)
public function __construct(?PhpFrontend $classCache = null)
{
if ($classCache === null) {
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Utility/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ClassLoader implements SingletonInterface
*
* @param PhpFrontend $classCache
*/
public function __construct(PhpFrontend $classCache = null, ClassCacheManager $classCacheManager = null)
public function __construct(?PhpFrontend $classCache = null, ?ClassCacheManager $classCacheManager = null)
{
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
if ($versionInformation->getMajorVersion() === 10) {
Expand Down
2 changes: 0 additions & 2 deletions Documentation/Misc/Changelog/11-0-0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ With the change `b8e2b3ea` the routing configuration has been simplified.
type: PersistedAliasMapper
tableName: tx_news_domain_model_news
routeFieldName: path_segment
type: NewsTitle
# now
aspects:
Expand Down
6 changes: 3 additions & 3 deletions Documentation/Tutorials/BestPractice/Routing/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ The following example will only provide routing for the detail view:
_arguments:
news-title: news
aspects:
news-title:
news:
type: NewsTitle
Please note the placeholder :code:`{news-title}`:
Expand Down Expand Up @@ -279,7 +279,7 @@ filter news records, their titles (slugs) are used.
defaults:
page: '0'
aspects:
news-title:
news:
type: NewsTitle
page:
type: StaticRangeMapper
Expand Down Expand Up @@ -426,7 +426,7 @@ by date. Also includes configuration for the pagination.
date-year: '\d+'
page: '\d+'
aspects:
news-title:
news:
type: NewsTitle
page:
type: StaticRangeMapper
Expand Down
11 changes: 4 additions & 7 deletions Documentation/Tutorials/BestPractice/Seo/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ This chapters covers all configurations which are relevant for search engine opt
regarding the news extension.

.. note::
All settings described require TYPO3 9 and the the system extension "seo" installed.
All settings described require system extension :composer:`typo3/cms-seo` installed.


.. only:: html

.. contents::
:local:
:depth: 2
.. contents::
:local:
:depth: 2

Page title for single news
--------------------------
Expand Down
12 changes: 11 additions & 1 deletion Resources/Private/Partials/Detail/Opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@
<n:metaTag property="og:type" content="{settings.opengraph.type}" />
<n:metaTag property="og:url" content="" useCurrentDomain="1" />
<n:metaTag property="og:site_name" content="{settings.opengraph.site_name}" />

<f:if condition="{newsItem.firstPreview}">
<f:variable name="ogImagePath" value="{f:uri.image(src:'{newsItem.firstPreview.uid}', treatIdAsReference:1, maxWidth:'1200')}" />
<f:then>
<f:variable name="ogImage" value="{newsItem.firstPreview}" />
</f:then>
<f:else if="{newsItem.falMedia}">
<f:variable name="ogImage" value="{newsItem.falMedia.0}" />
</f:else>
</f:if>

<f:if condition="{ogImage}">
<f:variable name="ogImagePath" value="{f:uri.image(src:'{ogImage.uid}', treatIdAsReference:1, maxWidth:'1200')}" />
<n:metaTag
property="og:image"
content="{ogImagePath}"
Expand Down
2 changes: 1 addition & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
config.pageTitleProviders {
news {
provider = GeorgRinger\News\Seo\NewsTitleProvider
before = altPageTitle,record,seo
before = record,seo
}
}
'));
Expand Down

0 comments on commit 3608717

Please sign in to comment.