Skip to content

Commit

Permalink
[DOCS] Update ChangeLog
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbltr committed Feb 7, 2025
1 parent b9152a8 commit 0ed9f4b
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 56 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ChangeLog
Upcoming version
[FEATURE] Set default sorting direction for "customranking" to "desc". Thanks to Markus Hackel. https://github.com/tpwd/ke_search/issues/279
[BUGFIX] Fix typo in constants.typoscript filename. Thanks to nebrot. https://github.com/tpwd/ke_search/commit/e762364111a78ea8b2378b634ca7cf77d3ae0903#r151745378
[TASK] Migrate usage of StandaloneView to ViewFactoryInterface. https://github.com/tpwd/ke_search/issues/249

Version 6.3.0, 24 January 2025
[FEATURE] Add support for site sets. https://github.com/tpwd/ke_search/issues/278
Expand Down
73 changes: 45 additions & 28 deletions Classes/Plugins/ResultlistPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@

use Psr\Http\Message\ServerRequestInterface;
use Tpwd\KeSearchPremium\Headless\HeadlessApi;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Pagination\ArrayPaginator;
use TYPO3\CMS\Core\Pagination\SlidingWindowPagination;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\View\ViewFactoryData;
use TYPO3\CMS\Core\View\ViewFactoryInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;

/**
Expand All @@ -35,10 +38,17 @@
*/
class ResultlistPlugin extends PluginBase
{
/**
* @var StandaloneView
*/
protected $resultListView;
private ?ViewFactoryInterface $viewFactory;

Check failure on line 41 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.2, ^12)

Property Tpwd\KeSearch\Plugins\ResultlistPlugin::$viewFactory has unknown class TYPO3\CMS\Core\View\ViewFactoryInterface as its type.

Check failure on line 41 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.3, ^12)

Property Tpwd\KeSearch\Plugins\ResultlistPlugin::$viewFactory has unknown class TYPO3\CMS\Core\View\ViewFactoryInterface as its type.

Check failure on line 41 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.1, ^12)

Property Tpwd\KeSearch\Plugins\ResultlistPlugin::$viewFactory has unknown class TYPO3\CMS\Core\View\ViewFactoryInterface as its type.

// TODO: Inject ViewFactoryInterface once TYPO3 v13 is the minimum requirement
//public function __construct(
//private readonly ViewFactoryInterface $viewFactory,
//) {}
public function __construct() {
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$this->viewFactory = GeneralUtility::makeInstance(ViewFactoryInterface::class);

Check failure on line 49 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.2, ^12)

Class TYPO3\CMS\Core\View\ViewFactoryInterface not found.

Check failure on line 49 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.3, ^12)

Class TYPO3\CMS\Core\View\ViewFactoryInterface not found.

Check failure on line 49 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.1, ^12)

Class TYPO3\CMS\Core\View\ViewFactoryInterface not found.
}
}

/**
* The main method of the PlugIn
Expand All @@ -64,13 +74,36 @@ public function main(string $content, array $conf, ServerRequestInterface $reque
return $this->pi_wrapInBaseClass($content);
}

// Check if "Static Templates" / "Site Sets" have been included
if (empty($this->conf['view'])) {
$content = '<div id="textmessage">' . $this->translate('error_templatePaths') . '</div>';
return $this->pi_wrapInBaseClass($content);
}

// init template
$this->initFluidTemplate();
// Initialize the view
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$viewFactoryData = new ViewFactoryData(

Check failure on line 85 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.2, ^12)

Instantiated class TYPO3\CMS\Core\View\ViewFactoryData not found.

Check failure on line 85 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.3, ^12)

Instantiated class TYPO3\CMS\Core\View\ViewFactoryData not found.

Check failure on line 85 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.1, ^12)

Instantiated class TYPO3\CMS\Core\View\ViewFactoryData not found.
templateRootPaths: $this->conf['view']['templateRootPaths'],
partialRootPaths: $this->conf['view']['partialRootPaths'],
layoutRootPaths: $this->conf['view']['layoutRootPaths'],
request: $this->request,
);
$view = $this->viewFactory->create($viewFactoryData);

Check failure on line 91 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.2, ^12)

Call to method create() on an unknown class TYPO3\CMS\Core\View\ViewFactoryInterface.

Check failure on line 91 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.3, ^12)

Call to method create() on an unknown class TYPO3\CMS\Core\View\ViewFactoryInterface.

Check failure on line 91 in Classes/Plugins/ResultlistPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.1, ^12)

Call to method create() on an unknown class TYPO3\CMS\Core\View\ViewFactoryInterface.
} else {
$view = GeneralUtility::makeInstance(StandaloneView::class);
if (method_exists($view, 'setRequest')) {
$view->setRequest($GLOBALS['TYPO3_REQUEST']);
}
$view->setTemplateRootPaths($this->conf['view']['templateRootPaths']);
$view->setPartialRootPaths($this->conf['view']['partialRootPaths']);
$view->setLayoutRootPaths($this->conf['view']['layoutRootPaths']);
$view->setTemplate('ResultList');
}

// Make settings available in fluid template
$view->assign('conf', $this->conf);
$view->assign('extConf', $this->extConf);
$view->assign('extConfPremium', $this->extConfPremium);

// hook for initials
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'] ?? null)) {
Expand Down Expand Up @@ -123,29 +156,13 @@ public function main(string $content, array $conf, ServerRequestInterface $reque
}

// generate HTML output
$this->resultListView->assignMultiple($this->fluidTemplateVariables);
$htmlOutput = $this->resultListView->render();
$view->assignMultiple($this->fluidTemplateVariables);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$htmlOutput = $view->render('ResultList');
} else {
$htmlOutput = $view->render();
}

return $htmlOutput;
}

/**
* inits the standalone fluid template
*/
public function initFluidTemplate()
{
$this->resultListView = GeneralUtility::makeInstance(StandaloneView::class);
if (method_exists($this->resultListView, 'setRequest')) {
$this->resultListView->setRequest($GLOBALS['TYPO3_REQUEST']);
}
$this->resultListView->setTemplateRootPaths($this->conf['view']['templateRootPaths']);
$this->resultListView->setPartialRootPaths($this->conf['view']['partialRootPaths']);
$this->resultListView->setLayoutRootPaths($this->conf['view']['layoutRootPaths']);
$this->resultListView->setTemplate('ResultList');

// make settings available in fluid template
$this->resultListView->assign('conf', $this->conf);
$this->resultListView->assign('extConf', $this->extConf);
$this->resultListView->assign('extConfPremium', $this->extConfPremium);
}
}
74 changes: 46 additions & 28 deletions Classes/Plugins/SearchboxPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
* GNU General Public License for more details.
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use Psr\Http\Message\ServerRequestInterface;
use Tpwd\KeSearchPremium\Headless\HeadlessApi;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\View\ViewFactoryData;
use TYPO3\CMS\Core\View\ViewFactoryInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;

/**
Expand All @@ -32,10 +36,17 @@
*/
class SearchboxPlugin extends PluginBase
{
/**
* @var StandaloneView
*/
protected $searchFormView;
private ?ViewFactoryInterface $viewFactory;

Check failure on line 39 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.2, ^12)

Property Tpwd\KeSearch\Plugins\SearchboxPlugin::$viewFactory has unknown class TYPO3\CMS\Core\View\ViewFactoryInterface as its type.

Check failure on line 39 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.3, ^12)

Property Tpwd\KeSearch\Plugins\SearchboxPlugin::$viewFactory has unknown class TYPO3\CMS\Core\View\ViewFactoryInterface as its type.

Check failure on line 39 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.1, ^12)

Property Tpwd\KeSearch\Plugins\SearchboxPlugin::$viewFactory has unknown class TYPO3\CMS\Core\View\ViewFactoryInterface as its type.

// TODO: Inject ViewFactoryInterface once TYPO3 v13 is the minimum requirement
//public function __construct(
//private readonly ViewFactoryInterface $viewFactory,
//) {}
public function __construct() {
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$this->viewFactory = GeneralUtility::makeInstance(ViewFactoryInterface::class);

Check failure on line 47 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.2, ^12)

Class TYPO3\CMS\Core\View\ViewFactoryInterface not found.

Check failure on line 47 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.3, ^12)

Class TYPO3\CMS\Core\View\ViewFactoryInterface not found.

Check failure on line 47 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.1, ^12)

Class TYPO3\CMS\Core\View\ViewFactoryInterface not found.
}
}

/**
* The main method of the PlugIn
Expand All @@ -56,13 +67,36 @@ public function main(string $content, array $conf, ServerRequestInterface $reque
// @extensionScannerIgnoreLine
$this->init($request);

// Check if "Static Templates" / "Site Sets" have been included
if (empty($this->conf['view'])) {
$content = '<div id="textmessage">' . $this->translate('error_templatePaths') . '</div>';
return $this->pi_wrapInBaseClass($content);
}

// init template for search box
$this->initFluidTemplate();
// Initialize the view
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$viewFactoryData = new ViewFactoryData(

Check failure on line 78 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.2, ^12)

Instantiated class TYPO3\CMS\Core\View\ViewFactoryData not found.

Check failure on line 78 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.3, ^12)

Instantiated class TYPO3\CMS\Core\View\ViewFactoryData not found.

Check failure on line 78 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.1, ^12)

Instantiated class TYPO3\CMS\Core\View\ViewFactoryData not found.
templateRootPaths: $this->conf['view']['templateRootPaths'],
partialRootPaths: $this->conf['view']['partialRootPaths'],
layoutRootPaths: $this->conf['view']['layoutRootPaths'],
request: $this->request,
);
$view = $this->viewFactory->create($viewFactoryData);

Check failure on line 84 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.2, ^12)

Call to method create() on an unknown class TYPO3\CMS\Core\View\ViewFactoryInterface.

Check failure on line 84 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.3, ^12)

Call to method create() on an unknown class TYPO3\CMS\Core\View\ViewFactoryInterface.

Check failure on line 84 in Classes/Plugins/SearchboxPlugin.php

View workflow job for this annotation

GitHub Actions / Build PHP/TYPO3 (8.1, ^12)

Call to method create() on an unknown class TYPO3\CMS\Core\View\ViewFactoryInterface.
} else {
$view = GeneralUtility::makeInstance(StandaloneView::class);
if (method_exists($view, 'setRequest')) {
$view->setRequest($GLOBALS['TYPO3_REQUEST']);
}
$view->setTemplateRootPaths($this->conf['view']['templateRootPaths']);
$view->setPartialRootPaths($this->conf['view']['partialRootPaths']);
$view->setLayoutRootPaths($this->conf['view']['layoutRootPaths']);
$view->setTemplate('SearchForm');
}

// Make settings available in fluid template
$view->assign('conf', $this->conf);
$view->assign('extConf', $this->extConf);
$view->assign('extConfPremium', $this->extConfPremium);

// hook for initials
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['initials'] ?? null)) {
Expand All @@ -84,29 +118,13 @@ public function main(string $content, array $conf, ServerRequestInterface $reque
}

// assign variables and do the rendering
$this->searchFormView->assignMultiple($this->fluidTemplateVariables);
$htmlOutput = $this->searchFormView->render();

return $htmlOutput;
}

/**
* inits the standalone fluid template
*/
public function initFluidTemplate()
{
$this->searchFormView = GeneralUtility::makeInstance(StandaloneView::class);
if (method_exists($this->searchFormView, 'setRequest')) {
$this->searchFormView->setRequest($GLOBALS['TYPO3_REQUEST']);
$view->assignMultiple($this->fluidTemplateVariables);
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) {
$htmlOutput = $view->render('SearchForm');
} else {
$htmlOutput = $view->render();
}
$this->searchFormView->setTemplateRootPaths($this->conf['view']['templateRootPaths']);
$this->searchFormView->setPartialRootPaths($this->conf['view']['partialRootPaths']);
$this->searchFormView->setLayoutRootPaths($this->conf['view']['layoutRootPaths']);
$this->searchFormView->setTemplate('SearchForm');

// make settings available in fluid template
$this->searchFormView->assign('conf', $this->conf);
$this->searchFormView->assign('extConf', $this->extConf);
$this->searchFormView->assign('extConfPremium', $this->extConfPremium);
return $htmlOutput;
}
}
4 changes: 4 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ services:
resource: '../Classes/Service/*'
public: true

Tpwd\KeSearch\Plugins\:
resource: '../Classes/Plugins/*'
public: true

Tpwd\KeSearch\Controller\:
resource: '../Classes/Controller/*'
public: true
Expand Down

0 comments on commit 0ed9f4b

Please sign in to comment.