Skip to content

Commit

Permalink
Merge pull request #54 from Oksydan/develop
Browse files Browse the repository at this point in the history
Release new version 4.1.2
  • Loading branch information
Oksydan authored Nov 16, 2024
2 parents 4742234 + 151e70a commit 07fcccb
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 11 deletions.
3 changes: 2 additions & 1 deletion is_themecore.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Is_themecore extends Module
'objectShopUrlAddAfter',
'objectShopUrlUpdateAfter',
'objectShopUrlDeleteAfter',
'actionFrontControllerInitBefore',
];

/**
Expand All @@ -58,7 +59,7 @@ public function __construct()
{
$this->name = 'is_themecore';
$this->tab = 'others';
$this->version = '4.1.1';
$this->version = '4.1.2';
$this->author = 'Igor Stępień';
$this->ps_versions_compliancy = ['min' => '8.0.0', 'max' => _PS_VERSION_];

Expand Down
13 changes: 11 additions & 2 deletions src/Core/ListingDisplay/ThemeListDisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ class ThemeListDisplay
'list',
];

public function setDisplay($display)
protected function getRequest(): Request
{
Request::setFactory(static function ($query, $request, $attributes, $cookies, $files, $server, $content) {
return new Request($query, $request, $attributes, $cookies, [], $server, $content);
});

return Request::createFromGlobals();
}

public function setDisplay($display): Response
{
if (!in_array($display, $this->displayList)) {
$display = \Configuration::get(GeneralConfiguration::THEMECORE_DISPLAY_LIST);
Expand All @@ -35,7 +44,7 @@ public function setDisplay($display)

public function getDisplay()
{
$displayFromCookie = Request::createFromGlobals()->cookies->get($this->cookieName);
$displayFromCookie = $this->getRequest()->cookies->get($this->cookieName);

if ($displayFromCookie) {
return $displayFromCookie;
Expand Down
10 changes: 7 additions & 3 deletions src/Hook/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ public function hookActionProductSearchAfter(): void
$this->context->controller->unregisterJavascript('facetedsearch_front');
$this->context->controller->unregisterStylesheet('facetedsearch_front');

$this->context->controller->unregisterJavascript('jquery-ui');
$this->context->controller->unregisterStylesheet('jquery-ui');
$this->context->controller->unregisterStylesheet('jquery-ui-theme');
$needsJQueryUi = \Module::isEnabled('pm_advancedsearch4') && $this->context->controller instanceof \ProductListingFrontController;

if (!$needsJQueryUi) {
$this->context->controller->unregisterJavascript('jquery-ui');
$this->context->controller->unregisterStylesheet('jquery-ui');
$this->context->controller->unregisterStylesheet('jquery-ui-theme');
}
}

public function hookActionFrontControllerSetMedia()
Expand Down
18 changes: 13 additions & 5 deletions src/Hook/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@
class Header extends AbstractHook
{
public const HOOK_LIST = [
'actionFrontControllerInitBefore',
'displayHeader',
];

public function hookActionFrontControllerInitBefore(): void
{
$themeListDisplay = new ThemeListDisplay();
$this->context->smarty->assign([
'listingDisplayType' => $themeListDisplay->getDisplay(),
'preloadCss' => \Configuration::get(GeneralConfiguration::THEMECORE_PRELOAD_CSS),
'webpEnabled' => \Configuration::get(WebpConfiguration::THEMECORE_WEBP_ENABLED),
'loadPartytown' => (bool) \Configuration::get(GeneralConfiguration::THEMECORE_LOAD_PARTY_TOWN),
'debugPartytown' => (bool) \Configuration::get(GeneralConfiguration::THEMECORE_DEBUG_PARTY_TOWN),
]);
}

public function hookDisplayHeader(): string
{
$themeListDisplay = new ThemeListDisplay();
Expand All @@ -32,12 +45,7 @@ public function hookDisplayHeader(): string
}

$this->context->smarty->assign([
'listingDisplayType' => $themeListDisplay->getDisplay(),
'preloadCss' => \Configuration::get(GeneralConfiguration::THEMECORE_PRELOAD_CSS),
'webpEnabled' => \Configuration::get(WebpConfiguration::THEMECORE_WEBP_ENABLED),
'jsonData' => $this->getStructuredData(),
'loadPartytown' => (bool) \Configuration::get(GeneralConfiguration::THEMECORE_LOAD_PARTY_TOWN),
'debugPartytown' => (bool) \Configuration::get(GeneralConfiguration::THEMECORE_DEBUG_PARTY_TOWN),
'partytownScript' => $this->getPartytownScript(),
'partytownScriptUri' => $this->getPartytownScriptUri(),
]);
Expand Down
14 changes: 14 additions & 0 deletions upgrade/upgrade-4-1-2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

if (!defined('_PS_VERSION_')) {
exit;
}

if (file_exists(dirname(__FILE__) . '../vendor/autoload.php')) {
require_once dirname(__FILE__) . '../vendor/autoload.php';
}

function upgrade_module_4_1_2($module)
{
return $module->registerHook('actionFrontControllerInitBefore');
}

0 comments on commit 07fcccb

Please sign in to comment.