Initial commit: is_searchbar out of the box. v3.0.1

This commit is contained in:
Isabelle Anno
2025-11-19 13:26:29 +01:00
committed by Isabelle
commit e9a487dd01
53 changed files with 7103 additions and 0 deletions

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Oksydan\IsSearchbar\Hook;
abstract class AbstractDisplayHook extends AbstractHook
{
public function execute(array $params): string
{
if (!$this->shouldBlockBeDisplayed($params)) {
return '';
}
$this->assignTemplateVariables($params);
return $this->module->fetch($this->getTemplateFullPath());
}
protected function assignTemplateVariables(array $params)
{
}
protected function shouldBlockBeDisplayed(array $params)
{
return true;
}
public function getTemplateFullPath(): string
{
return "module:{$this->module->name}/views/templates/hook/{$this->getTemplate()}";
}
abstract protected function getTemplate(): string;
}

View File

@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace Oksydan\IsSearchbar\Hook;
abstract class AbstractHook implements HookInterface
{
protected $module;
protected $context;
public function __construct(\Module $module, \Context $context)
{
$this->module = $module;
$this->context = $context;
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Oksydan\IsSearchbar\Hook;
class DisplaySearch extends AbstractDisplayHook
{
private const TEMPLATE_FILE = 'is_searchbar.tpl';
protected function getTemplate(): string
{
return DisplaySearch::TEMPLATE_FILE;
}
protected function assignTemplateVariables(array $params)
{
$variables = [
'ajax_search_url' => $this->context->link->getModuleLink($this->module->name, 'ajaxSearch'),
'search_controller_url' => $this->context->link->getPageLink('search', null, null, null, false, null, true),
];
if (!array_key_exists('search_string', $this->context->smarty->getTemplateVars())) {
$variables['search_string'] = '';
}
$this->context->smarty->assign($variables);
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Oksydan\IsSearchbar\Hook;
class DisplayTop extends AbstractDisplayHook
{
private const TEMPLATE_FILE = 'is_searchbar.tpl';
protected function getTemplate(): string
{
return DisplayTop::TEMPLATE_FILE;
}
protected function assignTemplateVariables(array $params)
{
$variables = [
'ajax_search_url' => $this->context->link->getModuleLink($this->module->name, 'ajaxSearch'),
'search_controller_url' => $this->context->link->getPageLink('search', null, null, null, false, null, true),
];
if (!array_key_exists('search_string', $this->context->smarty->getTemplateVars())) {
$variables['search_string'] = '';
}
$this->context->smarty->assign($variables);
}
}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Oksydan\IsSearchbar\Hook;
interface HookInterface
{
public function execute(array $params);
}

View File

@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;