first commit
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use WapplerSystems\Meilisearch\Widget\AbstractWidgetController;
|
||||
use TYPO3\CMS\Core\Utility\ArrayUtility;
|
||||
|
||||
/**
|
||||
* Class AbstractPaginateWidgetController
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
abstract class AbstractPaginateWidgetController extends AbstractWidgetController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $configuration = [
|
||||
'insertAbove' => true,
|
||||
'insertBelow' => true,
|
||||
'maximumNumberOfLinks' => 10,
|
||||
'addQueryStringMethod' => '',
|
||||
'templatePath' => ''
|
||||
];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $currentPage = 1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $displayRangeStart;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $displayRangeEnd;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $maximumNumberOfLinks = 99;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $numberOfPages = 1;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $templatePath = '';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initializeAction() {
|
||||
$configuration = is_array($this->widgetConfiguration['configuration']) ? $this->widgetConfiguration['configuration'] : [];
|
||||
ArrayUtility::mergeRecursiveWithOverrule($this->configuration, $configuration, false);
|
||||
$this->maximumNumberOfLinks = (int)$this->configuration['maximumNumberOfLinks'];
|
||||
if (!empty($this->configuration['templatePath'])) {
|
||||
$this->templatePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->configuration['templatePath']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If a certain number of links should be displayed, adjust before and after
|
||||
* amounts accordingly.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function calculateDisplayRange()
|
||||
{
|
||||
$maximumNumberOfLinks = $this->maximumNumberOfLinks;
|
||||
if ($maximumNumberOfLinks > $this->numberOfPages) {
|
||||
$maximumNumberOfLinks = $this->numberOfPages;
|
||||
}
|
||||
$delta = floor($maximumNumberOfLinks / 2);
|
||||
$this->displayRangeStart = $this->currentPage - $delta;
|
||||
$this->displayRangeEnd = $this->currentPage + $delta - ($maximumNumberOfLinks % 2 === 0 ? 1 : 0);
|
||||
if ($this->displayRangeStart < 1) {
|
||||
$this->displayRangeEnd -= $this->displayRangeStart - 1;
|
||||
}
|
||||
if ($this->displayRangeEnd > $this->numberOfPages) {
|
||||
$this->displayRangeStart -= $this->displayRangeEnd - $this->numberOfPages;
|
||||
}
|
||||
$this->displayRangeStart = (int)max($this->displayRangeStart, 1);
|
||||
$this->displayRangeEnd = (int)min($this->displayRangeEnd, $this->numberOfPages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with the keys "pages", "current", "numberOfPages", "nextPage" & "previousPage"
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function buildPagination()
|
||||
{
|
||||
$this->calculateDisplayRange();
|
||||
$pages = [];
|
||||
for ($i = $this->displayRangeStart; $i <= $this->displayRangeEnd; $i++) {
|
||||
$pages[] = ['number' => $i, 'isCurrent' => $i === $this->currentPage];
|
||||
}
|
||||
$pagination = ['pages' => $pages, 'current' => $this->currentPage, 'numberOfPages' => $this->numberOfPages, 'displayRangeStart' => $this->displayRangeStart, 'displayRangeEnd' => $this->displayRangeEnd, 'hasLessPages' => $this->displayRangeStart > 2, 'hasMorePages' => $this->displayRangeEnd + 1 < $this->numberOfPages];
|
||||
if ($this->currentPage < $this->numberOfPages) {
|
||||
$pagination['nextPage'] = $this->currentPage + 1;
|
||||
}
|
||||
if ($this->currentPage > 1) {
|
||||
$pagination['previousPage'] = $this->currentPage - 1;
|
||||
}
|
||||
|
||||
// calculate starting count for <ol> (items per page multiplied by (number of pages -1) and adding +1)
|
||||
$pagination['resultCountStart'] = (($this->getItemsPerPage() * ($this->currentPage - 1)) + 1);
|
||||
return $pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
abstract protected function getItemsPerPage();
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use WapplerSystems\Meilisearch\Domain\Search\FrequentSearches\FrequentSearchesService;
|
||||
use WapplerSystems\Meilisearch\Widget\AbstractWidgetController;
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\LoggerAwareTrait;
|
||||
use TYPO3\CMS\Core\Cache\CacheManager;
|
||||
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
|
||||
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Class FrequentlySearchedController
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
class FrequentlySearchedController extends AbstractWidgetController implements LoggerAwareInterface
|
||||
{
|
||||
use LoggerAwareTrait;
|
||||
|
||||
/**
|
||||
* Initializes the cache for this command.
|
||||
*
|
||||
* @return FrontendInterface|null
|
||||
*/
|
||||
protected function getInitializedCache(): ?FrontendInterface
|
||||
{
|
||||
$cacheIdentifier = 'tx_meilisearch';
|
||||
/* @var FrontendInterface $cacheInstance */
|
||||
try {
|
||||
$cacheInstance = GeneralUtility::makeInstance(CacheManager::class)->getCache($cacheIdentifier);
|
||||
} catch (NoSuchCacheException $exception) {
|
||||
$this->logger->error('Getting cache failed: ' . $exception->getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return $cacheInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Last searches
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$tsfe = $GLOBALS['TSFE'];
|
||||
$cache = $this->getInitializedCache();
|
||||
$configuration = $this->controllerContext->getTypoScriptConfiguration();
|
||||
|
||||
/* @var FrequentSearchesService $frequentSearchesService */
|
||||
$frequentSearchesService = GeneralUtility::makeInstance(
|
||||
FrequentSearchesService::class,
|
||||
/** @scrutinizer ignore-type */ $configuration,
|
||||
/** @scrutinizer ignore-type */ $cache,
|
||||
/** @scrutinizer ignore-type */ $tsfe
|
||||
);
|
||||
|
||||
$frequentSearches = $frequentSearchesService->getFrequentSearchTerms();
|
||||
$minimumSize = $configuration->getSearchFrequentSearchesMinSize();
|
||||
$maximumSize = $configuration->getSearchFrequentSearchesMaxSize();
|
||||
|
||||
$this->view->assign(
|
||||
'contentArguments',
|
||||
[
|
||||
'frequentSearches' => $this->enrichFrequentSearchesInfo($frequentSearches, $minimumSize, $maximumSize)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enrich the frequentSearches
|
||||
*
|
||||
* @param array Frequent search terms as array with terms as keys and hits as the value
|
||||
* @param int $minimumSize
|
||||
* @param int $maximumSize
|
||||
* @return array An array with content for the frequent terms markers
|
||||
*/
|
||||
protected function enrichFrequentSearchesInfo(array $frequentSearchTerms, int $minimumSize, int $maximumSize): array
|
||||
{
|
||||
$frequentSearches = [];
|
||||
if (count($frequentSearchTerms)) {
|
||||
$maximumHits = max(array_values($frequentSearchTerms));
|
||||
$minimumHits = min(array_values($frequentSearchTerms));
|
||||
$spread = $maximumHits - $minimumHits;
|
||||
$step = ($spread == 0) ? 1 : ($maximumSize - $minimumSize) / $spread;
|
||||
|
||||
foreach ($frequentSearchTerms as $term => $hits) {
|
||||
$size = round($minimumSize + (($hits - $minimumHits) * $step));
|
||||
$frequentSearches[] = [
|
||||
'q' => htmlspecialchars_decode($term),
|
||||
'hits' => $hits,
|
||||
'style' => 'font-size: ' . $size . 'px', 'class' => 'tx-solr-frequent-term-' . $size,
|
||||
'size' => $size
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $frequentSearches;
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping\GroupItem;
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
|
||||
|
||||
|
||||
/**
|
||||
* Class GroupItemPaginateController
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
class GroupItemPaginateController extends AbstractPaginateWidgetController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SearchResultSet
|
||||
*/
|
||||
protected $resultSet;
|
||||
|
||||
/**
|
||||
* @var GroupItem
|
||||
*/
|
||||
protected $groupItem;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initializeAction()
|
||||
{
|
||||
parent::initializeAction();
|
||||
|
||||
$this->resultSet = $this->widgetConfiguration['resultSet'];
|
||||
$this->groupItem = $this->widgetConfiguration['groupItem'];
|
||||
$this->configuration['itemsPerPage'] = $this->getItemsPerPage();
|
||||
|
||||
$this->numberOfPages = (int)ceil($this->groupItem->getAllResultCount() / $this->configuration['itemsPerPage']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the number of results per page. When nothing is configured 10 will be returned.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getItemsPerPage()
|
||||
{
|
||||
$perPage = (int)$this->groupItem->getGroup()->getResultsPerPage();
|
||||
return $perPage > 0 ? $perPage : 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \WapplerSystems\Meilisearch\Mvc\Controller\SolrControllerContext $controllerContext
|
||||
* @return \WapplerSystems\Meilisearch\Mvc\Controller\SolrControllerContext
|
||||
*/
|
||||
protected function setActiveSearchResultSet($controllerContext) {
|
||||
$controllerContext->setSearchResultSet($this->resultSet);
|
||||
return $controllerContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
// set current page
|
||||
$groupName = $this->groupItem->getGroup()->getGroupName();
|
||||
$groupItemValue = $this->groupItem->getGroupValue();
|
||||
$this->currentPage = $this->resultSet->getUsedSearchRequest()->getGroupItemPage($groupName, $groupItemValue);
|
||||
if ($this->currentPage < 1) {
|
||||
$this->currentPage = 1;
|
||||
}
|
||||
$this->view->assign('contentArguments', [$this->widgetConfiguration['as'] => $this->groupItem->getSearchResults(), 'pagination' => $this->buildPagination()]);
|
||||
$this->view->assign('configuration', $this->configuration);
|
||||
$this->view->assign('resultSet', $this->resultSet);
|
||||
$this->view->assign('groupItem', $this->groupItem);
|
||||
|
||||
if (!empty($this->templatePath)) {
|
||||
$this->view->setTemplatePathAndFilename($this->templatePath);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use WapplerSystems\Meilisearch\Domain\Search\LastSearches\LastSearchesService;
|
||||
use WapplerSystems\Meilisearch\Widget\AbstractWidgetController;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Class LastSearchesController
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
class LastSearchesController extends AbstractWidgetController
|
||||
{
|
||||
/**
|
||||
* Last searches
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$typoScriptConfiguration = $this->controllerContext->getTypoScriptConfiguration();
|
||||
$lastSearchesService = GeneralUtility::makeInstance(
|
||||
LastSearchesService::class,
|
||||
/** @scrutinizer ignore-type */ $typoScriptConfiguration
|
||||
);
|
||||
$this->view->assign('contentArguments', ['lastSearches' => $lastSearchesService->getLastSearches()]);
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
|
||||
|
||||
|
||||
/**
|
||||
* Class ResultPaginateController
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
class ResultPaginateController extends AbstractPaginateWidgetController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var SearchResultSet
|
||||
*/
|
||||
protected $resultSet;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initializeAction()
|
||||
{
|
||||
parent::initializeAction();
|
||||
|
||||
$this->resultSet = $this->widgetConfiguration['resultSet'];
|
||||
$this->configuration['itemsPerPage'] = $this->getItemsPerPage();
|
||||
|
||||
$this->numberOfPages = (int)ceil($this->resultSet->getAllResultCount() / $this->configuration['itemsPerPage']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the number of results per page. When nothing is configured 10 will be returned.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getItemsPerPage()
|
||||
{
|
||||
$perPage = (int)$this->resultSet->getUsedSearch()->getQuery()->getRows();
|
||||
return $perPage > 0 ? $perPage : 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \WapplerSystems\Meilisearch\Mvc\Controller\SolrControllerContext $controllerContext
|
||||
* @return \WapplerSystems\Meilisearch\Mvc\Controller\SolrControllerContext
|
||||
*/
|
||||
protected function setActiveSearchResultSet($controllerContext) {
|
||||
$controllerContext->setSearchResultSet($this->resultSet);
|
||||
return $controllerContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
// set current page
|
||||
$this->currentPage = $this->resultSet->getUsedPage();
|
||||
if ($this->currentPage < 1) {
|
||||
$this->currentPage = 1;
|
||||
}
|
||||
$this->view->assign('contentArguments', [$this->widgetConfiguration['as'] => $this->resultSet->getSearchResults(), 'pagination' => $this->buildPagination()]);
|
||||
$this->view->assign('configuration', $this->configuration);
|
||||
$this->view->assign('resultSet', $this->resultSet);
|
||||
if (!empty($this->templatePath)) {
|
||||
$this->view->setTemplatePathAndFilename($this->templatePath);
|
||||
}
|
||||
}
|
||||
}
|
50
Classes/ViewHelpers/Widget/FrequentlySearchedViewHelper.php
Normal file
50
Classes/ViewHelpers/Widget/FrequentlySearchedViewHelper.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller\FrequentlySearchedController;
|
||||
use WapplerSystems\Meilisearch\Widget\AbstractWidgetViewHelper;
|
||||
|
||||
/**
|
||||
* Class FrequentlySearchedViewHelper
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
class FrequentlySearchedViewHelper extends AbstractWidgetViewHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* @var FrequentlySearchedController
|
||||
*/
|
||||
protected $controller;
|
||||
|
||||
/**
|
||||
* @param FrequentlySearchedController $controller
|
||||
*/
|
||||
public function injectFrequentlySearchedController(FrequentlySearchedController $controller)
|
||||
{
|
||||
$this->controller = $controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
|
||||
* @throws \TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->initiateSubRequest();
|
||||
}
|
||||
}
|
71
Classes/ViewHelpers/Widget/GroupItemPaginateViewHelper.php
Normal file
71
Classes/ViewHelpers/Widget/GroupItemPaginateViewHelper.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Frans Saris <frans@beech.it> & Timo Hund <timo.hund@dkd.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 WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping\GroupItem;
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
|
||||
use WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller\GroupItemPaginateController;
|
||||
use WapplerSystems\Meilisearch\Widget\AbstractWidgetViewHelper;
|
||||
|
||||
/**
|
||||
* Class GroupItemPaginateViewHelper
|
||||
*/
|
||||
class GroupItemPaginateViewHelper extends AbstractWidgetViewHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* @var GroupItemPaginateController
|
||||
*/
|
||||
protected $controller;
|
||||
|
||||
/**
|
||||
* @param GroupItemPaginateController $groupItemPaginateController
|
||||
*/
|
||||
public function injectGroupItemPaginateController(GroupItemPaginateController $groupItemPaginateController)
|
||||
{
|
||||
$this->controller = $groupItemPaginateController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('resultSet', SearchResultSet::class, 'resultSet', true);
|
||||
$this->registerArgument('groupItem', GroupItem::class, 'groupItem', true);
|
||||
$this->registerArgument('as', 'string', 'as', false, 'documents');
|
||||
$this->registerArgument('configuration', 'array', 'configuration', false, ['insertAbove' => true, 'insertBelow' => true, 'maximumNumberOfLinks' => 10, 'templatePath' => '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
|
||||
* @throws \TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->initiateSubRequest();
|
||||
}
|
||||
}
|
50
Classes/ViewHelpers/Widget/LastSearchesViewHelper.php
Normal file
50
Classes/ViewHelpers/Widget/LastSearchesViewHelper.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller\LastSearchesController;
|
||||
use WapplerSystems\Meilisearch\Widget\AbstractWidgetViewHelper;
|
||||
|
||||
/**
|
||||
* Class LastSearchesViewHelper
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
class LastSearchesViewHelper extends AbstractWidgetViewHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* @var LastSearchesController
|
||||
*/
|
||||
protected $controller;
|
||||
|
||||
/**
|
||||
* @param LastSearchesController $lastSearchesController
|
||||
*/
|
||||
public function injectLastSearchesController(LastSearchesController $lastSearchesController)
|
||||
{
|
||||
$this->controller = $lastSearchesController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
|
||||
* @throws \TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->initiateSubRequest();
|
||||
}
|
||||
}
|
69
Classes/ViewHelpers/Widget/ResultPaginateViewHelper.php
Normal file
69
Classes/ViewHelpers/Widget/ResultPaginateViewHelper.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\ViewHelpers\Widget;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Frans Saris <frans@beech.it> & Timo Hund <timo.hund@dkd.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 WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
|
||||
use WapplerSystems\Meilisearch\ViewHelpers\Widget\Controller\ResultPaginateController;
|
||||
use WapplerSystems\Meilisearch\Widget\AbstractWidgetViewHelper;
|
||||
|
||||
/**
|
||||
* Class ResultPaginateViewHelper
|
||||
*/
|
||||
class ResultPaginateViewHelper extends AbstractWidgetViewHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ResultPaginateController
|
||||
*/
|
||||
protected $controller;
|
||||
|
||||
/**
|
||||
* @param ResultPaginateController $resultPaginateController
|
||||
*/
|
||||
public function injectResultPaginateController(ResultPaginateController $resultPaginateController)
|
||||
{
|
||||
$this->controller = $resultPaginateController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('resultSet', SearchResultSet::class, 'resultSet', true);
|
||||
$this->registerArgument('as', 'string', 'as', false, 'documents');
|
||||
$this->registerArgument('configuration', 'array', 'configuration', false, ['insertAbove' => true, 'insertBelow' => true, 'maximumNumberOfLinks' => 10, 'templatePath' => '']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
|
||||
* @throws \TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->initiateSubRequest();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user