Compare commits
4
Commits
main
..
92fd21d137
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92fd21d137 | ||
|
|
ea9b67ffc5 | ||
|
|
e2c4f265c2 | ||
|
|
28f8794e16 |
@@ -70,12 +70,12 @@ class Is_themecore extends Module
|
|||||||
$this->displayName = $this->trans(
|
$this->displayName = $this->trans(
|
||||||
'Theme core module',
|
'Theme core module',
|
||||||
[],
|
[],
|
||||||
'Modules.Isthemecore.Admin'
|
'Modules.isthemecore.Admin'
|
||||||
);
|
);
|
||||||
$this->description = $this->trans(
|
$this->description = $this->trans(
|
||||||
'Required for theme to work.',
|
'Required for theme to work.',
|
||||||
[],
|
[],
|
||||||
'Modules.Isthemecore.Admin'
|
'Modules.isthemecore.Admin'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->tabs = [
|
$this->tabs = [
|
||||||
@@ -85,9 +85,8 @@ class Is_themecore extends Module
|
|||||||
'route_name' => 'is_themecore_module_settings',
|
'route_name' => 'is_themecore_module_settings',
|
||||||
'parent_class_name' => 'CONFIGURE',
|
'parent_class_name' => 'CONFIGURE',
|
||||||
'visible' => false,
|
'visible' => false,
|
||||||
'active' => true,
|
|
||||||
'wording' => 'Theme core module settings',
|
'wording' => 'Theme core module settings',
|
||||||
'wording_domain' => 'Modules.Isthemecore.Admin',
|
'wording_domain' => 'Modules.isthemecore.Admin',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -184,7 +183,6 @@ class Is_themecore extends Module
|
|||||||
$router = $container->get('router');
|
$router = $container->get('router');
|
||||||
|
|
||||||
Tools::redirectAdmin($router->generate('is_themecore_module_settings'));
|
Tools::redirectAdmin($router->generate('is_themecore_module_settings'));
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Oksydan\Module\IsThemeCore\Controller\Admin;
|
|||||||
use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface;
|
use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface;
|
||||||
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
|
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
|
||||||
use PrestaShopBundle\Security\Annotation\AdminSecurity;
|
use PrestaShopBundle\Security\Annotation\AdminSecurity;
|
||||||
use PrestaShopBundle\Security\Attribute\DemoRestricted;
|
use PrestaShopBundle\Security\Annotation\DemoRestricted;
|
||||||
use PrestaShopBundle\Security\Annotation\ModuleActivated;
|
use PrestaShopBundle\Security\Annotation\ModuleActivated;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
@@ -23,7 +23,7 @@ class SettingsController extends FrameworkBundleAdminController
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @AdminSecurity(
|
* @AdminSecurity(
|
||||||
* "is_granted('read', request.get('_legacy_controller'))",
|
* "is_granted(['read'], request.get('_legacy_controller'))",
|
||||||
* message="You do not have permission to access this."
|
* message="You do not have permission to access this."
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
@@ -53,13 +53,14 @@ class SettingsController extends FrameworkBundleAdminController
|
|||||||
* redirectRoute="is_themecore_module_settings"
|
* redirectRoute="is_themecore_module_settings"
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
|
* @DemoRestricted(redirectRoute="is_themecore_module_settings")
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*
|
*
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
#[DemoRestricted(redirectRoute: 'is_themecore_module_settings')]
|
|
||||||
public function processGeneralFormAction(Request $request)
|
public function processGeneralFormAction(Request $request)
|
||||||
{
|
{
|
||||||
return $this->processForm(
|
return $this->processForm(
|
||||||
@@ -76,13 +77,14 @@ class SettingsController extends FrameworkBundleAdminController
|
|||||||
* redirectRoute="is_themecore_module_settings"
|
* redirectRoute="is_themecore_module_settings"
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
|
* @DemoRestricted(redirectRoute="is_themecore_module_settings")
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*
|
*
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
#[DemoRestricted(redirectRoute: 'is_themecore_module_settings')]
|
|
||||||
public function processWebpFormAction(Request $request)
|
public function processWebpFormAction(Request $request)
|
||||||
{
|
{
|
||||||
return $this->processForm(
|
return $this->processForm(
|
||||||
@@ -93,13 +95,14 @@ class SettingsController extends FrameworkBundleAdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @DemoRestricted(redirectRoute="is_themecore_module_settings")
|
||||||
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*
|
*
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
#[DemoRestricted(redirectRoute: 'is_themecore_module_settings')]
|
|
||||||
public function processWebpEraseImages(Request $request)
|
public function processWebpEraseImages(Request $request)
|
||||||
{
|
{
|
||||||
$time_start = microtime(true);
|
$time_start = microtime(true);
|
||||||
@@ -107,22 +110,22 @@ class SettingsController extends FrameworkBundleAdminController
|
|||||||
|
|
||||||
switch ($request->get('type')) {
|
switch ($request->get('type')) {
|
||||||
case 'all':
|
case 'all':
|
||||||
$eraser->setQuery(\_PS_ROOT_DIR_);
|
$eraser->setQuery(_PS_ROOT_DIR_);
|
||||||
break;
|
break;
|
||||||
case 'product':
|
case 'product':
|
||||||
$eraser->setQuery(\_PS_IMG_DIR_ . 'p/');
|
$eraser->setQuery(_PS_PROD_IMG_DIR_);
|
||||||
break;
|
break;
|
||||||
case 'module':
|
case 'module':
|
||||||
$eraser->setQuery(\_PS_MODULE_DIR_);
|
$eraser->setQuery(_PS_MODULE_DIR_);
|
||||||
break;
|
break;
|
||||||
case 'cms':
|
case 'cms':
|
||||||
$eraser->setQuery(\_PS_IMG_DIR_ . 'cms/');
|
$eraser->setQuery(_PS_IMG_DIR_ . 'cms/');
|
||||||
break;
|
break;
|
||||||
case 'themes':
|
case 'themes':
|
||||||
$eraser->setQuery(\_PS_ROOT_DIR_ . '/themes/');
|
$eraser->setQuery(_PS_ROOT_DIR_ . '/themes/');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$eraser->setQuery(\_PS_ROOT_DIR_);
|
$eraser->setQuery(_PS_ROOT_DIR_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +134,7 @@ class SettingsController extends FrameworkBundleAdminController
|
|||||||
$time_end = microtime(true);
|
$time_end = microtime(true);
|
||||||
$execution_time = round($time_end - $time_start, 2);
|
$execution_time = round($time_end - $time_start, 2);
|
||||||
|
|
||||||
$this->addFlash('success', $this->trans('%1$s - webp images has been erased successfully in %2$ss', 'Modules.Isthemecore.Admin', [$eraser->getFilesCount(), $execution_time]));
|
$this->addFlash('success', $this->trans('%1$s - webp images has been erased successfully in %2$ss', 'Modules.isthemecore.Admin', [$eraser->getFilesCount(), $execution_time]));
|
||||||
|
|
||||||
return $this->redirectToRoute('is_themecore_module_settings');
|
return $this->redirectToRoute('is_themecore_module_settings');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,9 +190,114 @@ class SmartyHelperFunctions
|
|||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
public static function isBright($hexColor)
|
|
||||||
|
|
||||||
|
|
||||||
|
/* CUSTOM ADDITIONS BELOW */
|
||||||
|
|
||||||
|
|
||||||
|
public static function isBright($hexColor)
|
||||||
{
|
{
|
||||||
$calculator = new ColorBrightnessCalculator();
|
$calculator = new ColorBrightnessCalculator();
|
||||||
return $calculator->isBright($hexColor);
|
return $calculator->isBright($hexColor);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static function displaySvgIcon($params){
|
||||||
|
/*
|
||||||
|
Helper to display SVG icons stored in themes/falcon/_dev/img/icons/
|
||||||
|
registered under public_html/modules/is_themecore/src/Hook/Smarty.php
|
||||||
|
|
||||||
|
Usage examples in a TPL file:
|
||||||
|
|
||||||
|
{svg_icon file='person.svg' fill='red' width='24' height='24'}
|
||||||
|
{svg_icon file='person.svg'}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Grab svg under falcon/_dev/img and display an error if not found
|
||||||
|
if (empty($params['file'])) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$icon_path = _PS_THEME_DIR_ . '/_dev/img/' . basename($params['file']);
|
||||||
|
|
||||||
|
if (!is_file($icon_path)) {
|
||||||
|
if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_) {
|
||||||
|
return 'Invalid SVG path: ' . htmlspecialchars($icon_path);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$svg_content = file_get_contents($icon_path);
|
||||||
|
|
||||||
|
/* Define an associative array of SVG properties
|
||||||
|
If the property is a style, addd it in a style tag.
|
||||||
|
If the property is an attribute, replace it in the svg code.
|
||||||
|
|
||||||
|
This reduces the risk of interfering with other attributes. */
|
||||||
|
$svg_props = array(
|
||||||
|
'width' => 'style',
|
||||||
|
'height' => 'style',
|
||||||
|
'opacity' => 'style',
|
||||||
|
'fill' => 'attribute',
|
||||||
|
'stroke' => 'attribute',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Styles
|
||||||
|
$styles = [];
|
||||||
|
foreach ($svg_props as $prop => $type) {
|
||||||
|
if ($type === 'style' && !empty($params[$prop])) {
|
||||||
|
$value = $params[$prop];
|
||||||
|
if (in_array($prop, ['width', 'height']) && is_numeric($value)) {
|
||||||
|
$value .= 'px';
|
||||||
|
}
|
||||||
|
$styles[] = $prop . ': ' . $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($styles)) {
|
||||||
|
$style_attr = 'style="' . implode('; ', $styles) . '"';
|
||||||
|
$svg_content = preg_replace('/(<svg[^>]*?)>/', '$1 ' . $style_attr . '>', $svg_content, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attributes
|
||||||
|
foreach ($svg_props as $prop => $type) {
|
||||||
|
if ($type === 'attribute' && !empty($params[$prop])) {
|
||||||
|
$value = $params[$prop];
|
||||||
|
// Use word boundaries to avoid matching partial names like fill-opacity or stroke-width
|
||||||
|
// Replace ALL occurrences of the attribute
|
||||||
|
$svg_content = preg_replace(
|
||||||
|
'/\b' . preg_quote($prop) . '\b\s*=\s*"[^"]*"/',
|
||||||
|
$prop . '="' . $value . '"',
|
||||||
|
$svg_content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $svg_content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function displayPriceSplit($price, $show_currency = false) {
|
||||||
|
/* Helper to split the price into euros and cents to make it more stylish
|
||||||
|
registered under public_html/modules/is_themecore/src/Hook/Smarty.php
|
||||||
|
|
||||||
|
Usage examples in a TPL file:
|
||||||
|
{price_split price=$product.price}
|
||||||
|
|
||||||
|
*/
|
||||||
|
//Convert to a string and only keep numbers, commas and dots
|
||||||
|
$currency_name = \Context::getContext()->currency->name;
|
||||||
|
$currency_symbol = \Context::getContext()->currency->symbol;
|
||||||
|
$price_string = implode(',', $price);
|
||||||
|
$price_string = preg_replace('/[^0-9,.]/', '', $price_string);
|
||||||
|
|
||||||
|
// Split by comma and wrap each part in a span
|
||||||
|
$price_parts = explode(',', $price_string);
|
||||||
|
if (count($price_parts) >= 2) {
|
||||||
|
echo '<span class="currency" aria-label="' . htmlspecialchars($currency_name) . '">' . ($show_currency ? $currency_symbol : '') . $price_parts[0] . '</span>';
|
||||||
|
echo '<sup class="cents" aria-label="cents">' . $price_parts[1] . '</sup>';
|
||||||
|
} else {
|
||||||
|
foreach ($price_parts as $part) {
|
||||||
|
echo '<span>' . $part . '</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ use PrestaShopBundle\Form\Admin\Type\SwitchType;
|
|||||||
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
|
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class GeneralType extends TranslatorAwareType
|
class GeneralType extends TranslatorAwareType
|
||||||
{
|
{
|
||||||
@@ -52,7 +52,7 @@ class GeneralType extends TranslatorAwareType
|
|||||||
ChoiceType::class,
|
ChoiceType::class,
|
||||||
[
|
[
|
||||||
'choices' => $this->displayListChoices,
|
'choices' => $this->displayListChoices,
|
||||||
'label' => $this->trans('Default list display', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Default list display', 'Modules.isthemecore.Admin'),
|
||||||
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_DISPLAY_LIST,
|
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_DISPLAY_LIST,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -60,8 +60,8 @@ class GeneralType extends TranslatorAwareType
|
|||||||
SwitchType::class,
|
SwitchType::class,
|
||||||
[
|
[
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => $this->trans('Early hints (HTTP 103) enabled', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Early hints (HTTP 103) enabled', 'Modules.isthemecore.Admin'),
|
||||||
'help' => $this->trans('Cloudflare CDN, Early hints option have to enabled. <a href="https://developers.cloudflare.com/cache/about/early-hints/">More information</a>', 'Modules.Isthemecore.Admin'),
|
'help' => $this->trans('Cloudflare CDN, Early hints option have to enabled. <a href="https://developers.cloudflare.com/cache/about/early-hints/">More information</a>', 'Modules.isthemecore.Admin'),
|
||||||
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_EARLY_HINTS,
|
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_EARLY_HINTS,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -69,7 +69,7 @@ class GeneralType extends TranslatorAwareType
|
|||||||
SwitchType::class,
|
SwitchType::class,
|
||||||
[
|
[
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => $this->trans('Preload css enabled, only working with CCC for css option enabled', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Preload css enabled, only working with CCC for css option enabled', 'Modules.isthemecore.Admin'),
|
||||||
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_PRELOAD_CSS,
|
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_PRELOAD_CSS,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -77,8 +77,8 @@ class GeneralType extends TranslatorAwareType
|
|||||||
SwitchType::class,
|
SwitchType::class,
|
||||||
[
|
[
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => $this->trans('Load partytown script', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Load partytown script', 'Modules.isthemecore.Admin'),
|
||||||
'help' => $this->trans('Be aware that partytown is still beta. Make sure that everything is working as expected before pushing it to your production store.', 'Modules.Isthemecore.Admin'),
|
'help' => $this->trans('Be aware that partytown is still beta. Make sure that everything is working as expected before pushing it to your production store.', 'Modules.isthemecore.Admin'),
|
||||||
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_LOAD_PARTY_TOWN,
|
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_LOAD_PARTY_TOWN,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -86,7 +86,7 @@ class GeneralType extends TranslatorAwareType
|
|||||||
SwitchType::class,
|
SwitchType::class,
|
||||||
[
|
[
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => $this->trans('Enable debug mode for partytown', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Enable debug mode for partytown', 'Modules.isthemecore.Admin'),
|
||||||
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_DEBUG_PARTY_TOWN,
|
'multistore_configuration_key' => GeneralConfiguration::THEMECORE_DEBUG_PARTY_TOWN,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Routing\RouterInterface;
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
|
|
||||||
if ($webpDisabled) {
|
if ($webpDisabled) {
|
||||||
$extraAttributes = [
|
$extraAttributes = [
|
||||||
'alert_message' => $this->trans('Webp converters not available contact your admin or hosting provider.', 'Modules.Isthemecore.Admin'),
|
'alert_message' => $this->trans('Webp converters not available contact your admin or hosting provider.', 'Modules.isthemecore.Admin'),
|
||||||
'alert_type' => 'danger',
|
'alert_type' => 'danger',
|
||||||
'alert_position' => 'append',
|
'alert_position' => 'append',
|
||||||
];
|
];
|
||||||
@@ -91,7 +91,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
array_merge(
|
array_merge(
|
||||||
[
|
[
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => $this->trans('Enable WEBP', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Enable WEBP', 'Modules.isthemecore.Admin'),
|
||||||
'disabled' => $webpDisabled,
|
'disabled' => $webpDisabled,
|
||||||
],
|
],
|
||||||
$extraAttributes
|
$extraAttributes
|
||||||
@@ -101,7 +101,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
SwitchType::class,
|
SwitchType::class,
|
||||||
[
|
[
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => $this->trans('Enable better RGB->YUV color conversion', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Enable better RGB->YUV color conversion', 'Modules.isthemecore.Admin'),
|
||||||
'disabled' => $webpDisabled,
|
'disabled' => $webpDisabled,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -109,8 +109,8 @@ class WebpType extends TranslatorAwareType
|
|||||||
TextType::class,
|
TextType::class,
|
||||||
[
|
[
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => $this->trans('Webp quality', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Webp quality', 'Modules.isthemecore.Admin'),
|
||||||
'help' => $this->trans('Range 1-100', 'Modules.Isthemecore.Admin'),
|
'help' => $this->trans('Range 1-100', 'Modules.isthemecore.Admin'),
|
||||||
'disabled' => $webpDisabled,
|
'disabled' => $webpDisabled,
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
$this->getRangeConstraint(1, 100),
|
$this->getRangeConstraint(1, 100),
|
||||||
@@ -122,7 +122,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
ChoiceType::class,
|
ChoiceType::class,
|
||||||
[
|
[
|
||||||
'choices' => $this->convertersList,
|
'choices' => $this->convertersList,
|
||||||
'label' => $this->trans('Webp converter options', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Webp converter options', 'Modules.isthemecore.Admin'),
|
||||||
'disabled' => $webpDisabled,
|
'disabled' => $webpDisabled,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
@@ -130,12 +130,12 @@ class WebpType extends TranslatorAwareType
|
|||||||
return ['disabled' => $this->convertersListFull[$choice]['disabled']];
|
return ['disabled' => $this->convertersListFull[$choice]['disabled']];
|
||||||
},
|
},
|
||||||
'choice_label' => function ($choice) {
|
'choice_label' => function ($choice) {
|
||||||
return $this->convertersListFull[$choice]['label'] . ($this->convertersListFull[$choice]['disabled'] ? '<span class="ml-1 badge badge-danger">' . $this->trans('not available', 'Modules.Isthemecore.Admin') . '</span>' : '');
|
return $this->convertersListFull[$choice]['label'] . ($this->convertersListFull[$choice]['disabled'] ? '<span class="ml-1 badge badge-danger">' . $this->trans('not available', 'Modules.isthemecore.Admin') . '</span>' : '');
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->add('erase_all_webp', IconButtonType::class, [
|
->add('erase_all_webp', IconButtonType::class, [
|
||||||
'label' => $this->trans('Erase all webp images', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Erase all webp images', 'Modules.isthemecore.Admin'),
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'icon' => 'delete',
|
'icon' => 'delete',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
@@ -149,7 +149,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
->add('erase_product_webp', IconButtonType::class, [
|
->add('erase_product_webp', IconButtonType::class, [
|
||||||
'label' => $this->trans('Erase all product webp images', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Erase all product webp images', 'Modules.isthemecore.Admin'),
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'icon' => 'delete',
|
'icon' => 'delete',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
@@ -163,7 +163,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
->add('erase_modules_webp', IconButtonType::class, [
|
->add('erase_modules_webp', IconButtonType::class, [
|
||||||
'label' => $this->trans('Erase all modules webp images', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Erase all modules webp images', 'Modules.isthemecore.Admin'),
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'icon' => 'delete',
|
'icon' => 'delete',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
@@ -177,7 +177,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
->add('erase_cms_webp', IconButtonType::class, [
|
->add('erase_cms_webp', IconButtonType::class, [
|
||||||
'label' => $this->trans('Erase all CMS webp images', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Erase all CMS webp images', 'Modules.isthemecore.Admin'),
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'icon' => 'delete',
|
'icon' => 'delete',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
@@ -191,7 +191,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
->add('erase_themes_webp', IconButtonType::class, [
|
->add('erase_themes_webp', IconButtonType::class, [
|
||||||
'label' => $this->trans('Erase all themes webp images', 'Modules.Isthemecore.Admin'),
|
'label' => $this->trans('Erase all themes webp images', 'Modules.isthemecore.Admin'),
|
||||||
'type' => 'link',
|
'type' => 'link',
|
||||||
'icon' => 'delete',
|
'icon' => 'delete',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
@@ -222,7 +222,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
private function getNotBlankConstraint()
|
private function getNotBlankConstraint()
|
||||||
{
|
{
|
||||||
return new NotBlank([
|
return new NotBlank([
|
||||||
'message' => $this->trans('This field cannot be empty.', 'Modules.Isthemecore.Admin'),
|
'message' => $this->trans('This field cannot be empty.', 'Modules.isthemecore.Admin'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ class WebpType extends TranslatorAwareType
|
|||||||
'max' => $max,
|
'max' => $max,
|
||||||
'invalidMessage' => $this->trans(
|
'invalidMessage' => $this->trans(
|
||||||
'This field value have to be between %min% and %max%.',
|
'This field value have to be between %min% and %max%.',
|
||||||
'Modules.Isthemecore.Admin',
|
'Modules.isthemecore.Admin',
|
||||||
[
|
[
|
||||||
'%min%' => $min,
|
'%min%' => $min,
|
||||||
'%max%' => $max,
|
'%max%' => $max,
|
||||||
|
|||||||
@@ -56,5 +56,15 @@ public function hookActionDispatcherBefore(): void
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!isset($this->context->smarty->registered_plugins['function']['svg_icon'])) {
|
||||||
|
$this->context->smarty->registerPlugin('function', 'svg_icon', ['Oksydan\Module\IsThemeCore\Core\Smarty\SmartyHelperFunctions', 'displaySvgIcon']);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isset($this->context->smarty->registered_plugins['function']['price_split'])) {
|
||||||
|
$this->context->smarty->registerPlugin('function', 'price_split', ['Oksydan\Module\IsThemeCore\Core\Smarty\SmartyHelperFunctions', 'displayPriceSplit']);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
'form': general_form,
|
'form': general_form,
|
||||||
'form_id': 'settings_general_form',
|
'form_id': 'settings_general_form',
|
||||||
'form_action': path('is_themecore_module_settings_general_save'),
|
'form_action': path('is_themecore_module_settings_general_save'),
|
||||||
'card_header': 'General' | trans({}, 'Modules.Isthemecore.Admin'),
|
'card_header': 'General' | trans({}, 'Modules.isthemecore.Admin'),
|
||||||
'cancel_path': 'is_themecore_module_settings'
|
'cancel_path': 'is_themecore_module_settings'
|
||||||
} %}
|
} %}
|
||||||
</div>
|
</div>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
'form': webp_form,
|
'form': webp_form,
|
||||||
'form_id': 'settings_webp_form',
|
'form_id': 'settings_webp_form',
|
||||||
'form_action': path('is_themecore_module_settings_webp_save'),
|
'form_action': path('is_themecore_module_settings_webp_save'),
|
||||||
'card_header': 'Webp' | trans({}, 'Modules.Isthemecore.Admin'),
|
'card_header': 'Webp' | trans({}, 'Modules.isthemecore.Admin'),
|
||||||
'icon_header': 'image',
|
'icon_header': 'image',
|
||||||
'cancel_path': 'is_themecore_module_settings'
|
'cancel_path': 'is_themecore_module_settings'
|
||||||
} %}
|
} %}
|
||||||
|
|||||||
Reference in New Issue
Block a user