From 1641ce9dd450139320d15a037586a3efb8fd155a Mon Sep 17 00:00:00 2001 From: Fabrice Creuzot Date: Sun, 1 Jan 2023 20:00:00 +0000 Subject: [PATCH] Version 4.4.0 --- README.md | 4 +- .../Minifier/Block/Adminhtml/Config/Check.php | 8 +-- .../Block/Adminhtml/Config/Comment.php | 4 +- .../Minifier/Block/Adminhtml/Config/Debug.php | 8 +-- .../Minifier/Block/Adminhtml/Config/Help.php | 4 +- .../Block/Adminhtml/Config/Server.php | 9 ++-- .../Minifier/Block/Adminhtml/Rewrite/Head.php | 4 +- .../Minifier/Block/Adminhtml/Rewrite/Html.php | 4 +- .../Luigifab/Minifier/Block/Calendar.php | 4 +- .../Luigifab/Minifier/Block/Rewrite/Head.php | 4 +- .../Luigifab/Minifier/Block/Rewrite/Html.php | 4 +- .../Luigifab/Minifier/Helper/Data.php | 16 +++--- .../Luigifab/Minifier/Helper/Rewrite/Js.php | 4 +- .../Luigifab/Minifier/Model/Files.php | 24 ++++----- .../Luigifab/Minifier/Model/Observer.php | 40 +++++++------- .../Minifier/Model/Rewrite/Package.php | 36 +++++++------ .../Minifier/Model/Rewrite/Translate.php | 13 +++-- .../Luigifab/Minifier/Model/Source/Cache.php | 8 +-- .../Minifier/Model/Source/Favicon.php | 8 +-- .../Luigifab/Minifier/Model/Source/Minify.php | 8 +-- .../Minifier/controllers/DebugController.php | 53 +++++++++---------- .../controllers/Minifier/DebugController.php | 4 +- .../Luigifab/Minifier/etc/adminhtml.xml | 4 +- .../Luigifab/Minifier/etc/config.xml | 10 ++-- .../Luigifab/Minifier/etc/system.xml | 4 +- .../Luigifab/Minifier/lib/minify.php | 10 ++-- .../code/community/Luigifab/Minifier/readme | 10 ++-- .../{install-4.3.0.php => install-4.4.0.php} | 12 ++--- .../minifier_setup/upgrade-2.3.0-4.0.0.php | 12 ++--- .../minifier_setup/upgrade-3.0.0-4.0.0.php | 12 ++--- .../minifier_setup/upgrade-3.1.0-4.0.0.php | 12 ++--- .../minifier_setup/upgrade-3.2.0-4.0.0.php | 12 ++--- .../minifier_setup/upgrade-3.3.0-4.0.0.php | 12 ++--- .../minifier_setup/upgrade-3.4.0-4.0.0.php | 12 ++--- .../minifier_setup/upgrade-4.0.0-4.1.0.php | 12 ++--- .../default/layout/luigifab/minifier.xml | 10 ++-- .../template/luigifab/minifier/footer.phtml | 4 +- .../template/luigifab/minifier/head.phtml | 9 ++-- .../template/luigifab/minifier/header.phtml | 14 ++--- .../template/luigifab/minifier/menu.phtml | 4 +- .../base/default/layout/luigifab/minifier.xml | 4 +- .../template/luigifab/minifier/head.phtml | 4 +- src/app/etc/modules/Luigifab_Minifier.xml | 6 +-- 43 files changed, 240 insertions(+), 220 deletions(-) rename src/app/code/community/Luigifab/Minifier/sql/minifier_setup/{install-4.3.0.php => install-4.4.0.php} (88%) diff --git a/README.md b/README.md index b0b2e24..13330d7 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ For more information, go to https://www.luigifab.fr/openmage/minifier (IPv6 is r This repository is a releases mirror. To install the module, please use the composer key available in the documentation. -- Current version: 4.3.2 (10/10/2022) -- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1 +- Current version: 4.4.0 (01/01/2023) +- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 - Client compatibility: Firefox 36+, Chrome 32+, Opera 19+, Edge 16+, Safari 9+ - Translations: English (en), French (fr-FR/fr-CA), German (de), Italian (it), Portuguese (pt-PT/pt-BR), Spanish (es) / Chinese (zh), Czech (cs), Dutch (nl), Greek (el), Hungarian (hu), Japanese (ja), Polish (pl), Romanian (ro), Russian (ru), Slovak (sk), Turkish (tr), Ukrainian (uk) - License: GNU GPL 2+ diff --git a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Check.php b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Check.php index e575550..49b0bdd 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Check.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Check.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -20,7 +20,7 @@ class Luigifab_Minifier_Block_Adminhtml_Config_Check extends Mage_Adminhtml_Block_System_Config_Form_Field { public function render(Varien_Data_Form_Element_Abstract $element) { - $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue()->unsPath(); return parent::render($element); } diff --git a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Comment.php b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Comment.php index 6d8f581..0234b0c 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Comment.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Comment.php @@ -3,8 +3,8 @@ * Created S/01/02/2020 * Updated J/12/11/2020 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Debug.php b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Debug.php index 0bdc65a..9124217 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Debug.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Debug.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -20,7 +20,7 @@ class Luigifab_Minifier_Block_Adminhtml_Config_Debug extends Mage_Adminhtml_Block_System_Config_Form_Field { public function render(Varien_Data_Form_Element_Abstract $element) { - $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue()->unsPath(); return parent::render($element); } diff --git a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Help.php b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Help.php index c7f40fd..8e2eb80 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Help.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Help.php @@ -3,8 +3,8 @@ * Created S/20/06/2015 * Updated V/20/05/2022 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Server.php b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Server.php index bf21bac..e4afafb 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Server.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Config/Server.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -21,7 +21,8 @@ class Luigifab_Minifier_Block_Adminhtml_Config_Server extends Mage_Adminhtml_Blo public function render(Varien_Data_Form_Element_Abstract $element) { - return str_replace(['`', "\n"], [chr(194).chr(160), '
'], '## THE REQUIRED CONFIGURATION + // getPath PR 2774 + return str_replace(['`', "\n"], [chr(194).chr(160), '
'], '## THE REQUIRED CONFIGURATION ## for apache (virtual host or htaccess) RewriteRule (.*)skin/.*/favicon.ico $1favicon.ico [L] diff --git a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Rewrite/Head.php b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Rewrite/Head.php index b072743..2b4a411 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Rewrite/Head.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Rewrite/Head.php @@ -3,8 +3,8 @@ * Created M/01/09/2015 * Updated D/06/10/2019 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Rewrite/Html.php b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Rewrite/Html.php index b7b4a72..39c7229 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Rewrite/Html.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Adminhtml/Rewrite/Html.php @@ -3,8 +3,8 @@ * Created S/20/06/2015 * Updated S/31/08/2019 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/Block/Calendar.php b/src/app/code/community/Luigifab/Minifier/Block/Calendar.php index 237e339..72fa1c2 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Calendar.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Calendar.php @@ -3,8 +3,8 @@ * Created D/20/05/2018 * Updated D/18/07/2021 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/Block/Rewrite/Head.php b/src/app/code/community/Luigifab/Minifier/Block/Rewrite/Head.php index 4f3f047..42f453c 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Rewrite/Head.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Rewrite/Head.php @@ -3,8 +3,8 @@ * Created M/01/09/2015 * Updated D/15/11/2020 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/Block/Rewrite/Html.php b/src/app/code/community/Luigifab/Minifier/Block/Rewrite/Html.php index 9191530..1677b4d 100644 --- a/src/app/code/community/Luigifab/Minifier/Block/Rewrite/Html.php +++ b/src/app/code/community/Luigifab/Minifier/Block/Rewrite/Html.php @@ -3,8 +3,8 @@ * Created S/20/06/2015 * Updated S/31/08/2019 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/Helper/Data.php b/src/app/code/community/Luigifab/Minifier/Helper/Data.php index 772c889..7c7609f 100644 --- a/src/app/code/community/Luigifab/Minifier/Helper/Data.php +++ b/src/app/code/community/Luigifab/Minifier/Helper/Data.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -19,6 +19,8 @@ class Luigifab_Minifier_Helper_Data extends Mage_Core_Helper_Abstract { + protected $_cpucore; + public function getVersion() { return (string) Mage::getConfig()->getModuleConfig('Luigifab_Minifier')->version; } @@ -111,7 +113,7 @@ public function getUsername() { $user = $action->getFullActionName(); // frontend else - $user = sprintf('frontend %d', Mage::app()->getStore()->getData('code')); + $user = sprintf('frontend %s', Mage::app()->getStore()->getData('code')); return $user; } @@ -119,12 +121,12 @@ public function getUsername() { public function getNumberOfCpuCore() { - if (empty($this->cpucore)) { + if (empty($this->_cpucore)) { exec('nproc', $data); - $this->cpucore = max(1, (int) trim(implode($data))); + $this->_cpucore = max(1, (int) trim(implode($data))); } - return $this->cpucore; + return $this->_cpucore; } public function afterToHtml(string $html) { diff --git a/src/app/code/community/Luigifab/Minifier/Helper/Rewrite/Js.php b/src/app/code/community/Luigifab/Minifier/Helper/Rewrite/Js.php index ff6c34f..65c335a 100644 --- a/src/app/code/community/Luigifab/Minifier/Helper/Rewrite/Js.php +++ b/src/app/code/community/Luigifab/Minifier/Helper/Rewrite/Js.php @@ -3,8 +3,8 @@ * Created L/16/07/2018 * Updated V/11/02/2022 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/Model/Files.php b/src/app/code/community/Luigifab/Minifier/Model/Files.php index 48dc79a..f76c67f 100644 --- a/src/app/code/community/Luigifab/Minifier/Model/Files.php +++ b/src/app/code/community/Luigifab/Minifier/Model/Files.php @@ -1,11 +1,11 @@ - * Copyright 2022 | Fabrice Creuzot - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2022-2023 | Fabrice Creuzot + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -22,9 +22,7 @@ class Luigifab_Minifier_Model_Files extends Mage_Core_Model_Layout_Update { public function getMinifiedFiles(int $storeId) { - if (($storeId == 0) && !Mage::getStoreConfigFlag('minifier/cssjs/enabled_back')) - return []; - if (($storeId != 0) && !Mage::getStoreConfigFlag('minifier/cssjs/enabled_front', $storeId)) + if (!Mage::getStoreConfigFlag(($storeId == 0) ? 'minifier/cssjs/enabled_back' : 'minifier/cssjs/enabled_front', $storeId)) return []; $dir = Mage::getBaseDir('media').'/minifier-cache/'; @@ -131,7 +129,8 @@ protected function minifyFiles(array $items) { array_map('unlink', glob($outdated)); $new = true; - $cmd = sprintf('php %s %s %s %s %d >> %s 2>&1 & echo $!', + $cmd = sprintf('%s %s %s %s %s %d >> %s 2>&1 & echo $!', + 'php'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION, str_replace('Minifier/etc', 'Minifier/lib/minify.php', Mage::getModuleDir('etc', 'Luigifab_Minifier')), (mb_stripos($source, '.css') === false) ? 'js' : 'css', escapeshellarg($source), @@ -184,7 +183,8 @@ protected function mergeFiles(string $dest, array $data) { unset($files[$idx]); } - $cmd = sprintf('php %s %s %s %s %d >> %s 2>&1', + $cmd = sprintf('%s %s %s %s %s %d >> %s 2>&1', + 'php'.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION, str_replace('Minifier/etc', 'Minifier/lib/minify.php', Mage::getModuleDir('etc', 'Luigifab_Minifier')), (mb_stripos($dest, '.js') === false) ? 'mergecss' : 'mergejs', implode(',', array_map('escapeshellarg', $files)), @@ -271,12 +271,12 @@ protected function searchFiles(object $design, int $storeId) { // récupère la liste des fichiers depuis le layout $head = Mage::app()->getLayout()->getBlock('head'); $doc = new DOMDocument(); - @$doc->loadHTML($this->merge('all')->_packageLayout->asNiceXml()); + @$doc->loadHTML($this->merge('all')->_packageLayout->asNiceXml(), LIBXML_NOERROR); $xpath = new DomXPath($doc); foreach ($xpath->query('//action[@method="removeItem"]') as $element) { - if (stripos($element->getNodePath(), 'oauth') !== false) + if (str_contains($element->getNodePath(), 'oauth')) continue; $config = $element->getAttribute('ifconfig'); @@ -304,7 +304,7 @@ protected function searchFiles(object $design, int $storeId) { foreach ($xpath->query('//action[@method="addItem"]|//action[@method="addCss"]|//action[@method="addJs"]') as $element) { - if (stripos($element->getNodePath(), 'oauth') !== false) + if (str_contains($element->getNodePath(), 'oauth')) continue; $config = $element->getAttribute('ifconfig'); diff --git a/src/app/code/community/Luigifab/Minifier/Model/Observer.php b/src/app/code/community/Luigifab/Minifier/Model/Observer.php index 1c4997a..1e74331 100644 --- a/src/app/code/community/Luigifab/Minifier/Model/Observer.php +++ b/src/app/code/community/Luigifab/Minifier/Model/Observer.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -30,10 +30,10 @@ public function clearMinifiedFiles(Varien_Event_Observer $observer) { Mage::getBaseDir('media').'/js/' ]; - exec('rm -rf '.implode(' ', $dirs)); - exec('rm -f '.Mage::getBaseDir('media').'/minifier-cache/virtual*'); + exec('rm -rf '.implode(' ', array_map('escapeshellarg', $dirs))); + exec('rm -f '.escapeshellarg(Mage::getBaseDir('media').'/minifier-cache/virtual*')); - $this->updateConfig($observer); + $this->clearCache($observer); } // EVENT admin_system_config_changed_section_minifier (adminhtml) @@ -46,7 +46,7 @@ public function clearCache(Varien_Event_Observer $observer) { } // EVENT controller_action_predispatch_adminhtml_index_changeLocale (adminhtml) - public function updateBackgendLanguage(Varien_Event_Observer $observer) { + public function updateBackendLanguage(Varien_Event_Observer $observer) { $locale = $observer->getData('controller_action')->getRequest()->getParam('locale'); Mage::getSingleton('core/session')->setData('locale', $locale); @@ -70,18 +70,23 @@ public function setBackendLanguage(Varien_Event_Observer $observer) { protected function searchCurrentLocale(array $locales, string $result = 'en_US') { + $codes = []; + // recherche des préférences dans HTTP_ACCEPT_LANGUAGE // https://stackoverflow.com/a/33748742 - $codes = array_reduce( - empty(getenv('HTTP_ACCEPT_LANGUAGE')) ? [] : explode(',', getenv('HTTP_ACCEPT_LANGUAGE')), - static function ($items, $item) { - [$code, $q] = explode(';q=', $item.';q=1'); - $items[str_replace('-', '_', $code)] = (float) $q; - return $items; - }, []); - - arsort($codes); - $codes = array_map('\strval', array_keys($codes)); + if (!empty(getenv('HTTP_ACCEPT_LANGUAGE'))) { + + $codes = array_reduce( + explode(',', getenv('HTTP_ACCEPT_LANGUAGE')), + static function ($items, $item) { + [$code, $q] = explode(';q=', $item.';q=1'); + $items[str_replace('-', '_', $code)] = (float) $q; + return $items; + }, []); + + arsort($codes); + $codes = array_map('\strval', array_keys($codes)); + } // ajoute la locale présente dans l'url en premier car elle est prioritaire if (!empty($_GET['lang'])) { @@ -92,7 +97,6 @@ static function ($items, $item) { } // cherche la locale à utiliser - // essaye es ou fil puis es_ES ou fil_PH foreach ($codes as $code) { if ((strlen($code) >= 2) && !str_contains($code, '_')) { diff --git a/src/app/code/community/Luigifab/Minifier/Model/Rewrite/Package.php b/src/app/code/community/Luigifab/Minifier/Model/Rewrite/Package.php index 5a0a15b..56aa4b8 100644 --- a/src/app/code/community/Luigifab/Minifier/Model/Rewrite/Package.php +++ b/src/app/code/community/Luigifab/Minifier/Model/Rewrite/Package.php @@ -1,11 +1,11 @@ - * Copyright 2022 | Fabrice Creuzot - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2022-2023 | Fabrice Creuzot + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -20,32 +20,38 @@ class Luigifab_Minifier_Model_Rewrite_Package extends Mage_Core_Model_Design_Package { + protected $_configKey; + public function __construct() { parent::__construct(); - $this->_hasKey = false; - if (Mage::getStoreConfig('minifier/cssjs/solution') == 2) { + $value = Mage::getStoreConfig('minifier/cssjs/solution'); + if ($value == 2) { // by file - $this->_hasKey = true; + $this->_configKey = true; } - else if (Mage::getStoreConfig('minifier/cssjs/solution') == 1) { + else if ($value == 1) { // global - $this->_hasKey = '-'.Mage::getStoreConfig('minifier/cssjs/value'); + $this->_configKey = '-'.Mage::getStoreConfig('minifier/cssjs/value'); if (Mage::getIsDeveloperMode()) - $this->_hasKey = '-00'.date('YmdHis'); + $this->_configKey = '-00'.date('YmdHis'); + } + else { + // disabled + $this->_configKey = false; } } public function getFinalUrl($fileName, $url) { // no key - if (empty($this->_hasKey)) + if (empty($this->_configKey)) return str_replace('-zzyyxx', '', $url); // global key - if ($this->_hasKey !== true) - return str_replace('-zzyyxx', $this->_hasKey, $url); + if ($this->_configKey !== true) + return str_replace('-zzyyxx', $this->_configKey, $url); // by file if (empty($fileName)) @@ -64,10 +70,9 @@ public function getSkinUrl($file = null, array $params = []) { } // prevent reading files outside of the proper directory while still allowing symlinked files - Varien_Profiler::start(__METHOD__); if (!empty($file) && str_contains($file, '..')) { Mage::log(sprintf('Invalid path requested: %s (params: %s)', $file, json_encode($params)), Zend_Log::ERR); - throw new RuntimeException('Invalid path requested.'); + throw new RuntimeException(sprintf('Invalid path requested: %s', $file)); } if (empty($params['_type'])) @@ -90,7 +95,6 @@ public function getSkinUrl($file = null, array $params = []) { $result = $this->getFinalUrl(null, $this->getSkinBaseUrl($params)); } - Varien_Profiler::stop(__METHOD__); return $result; } diff --git a/src/app/code/community/Luigifab/Minifier/Model/Rewrite/Translate.php b/src/app/code/community/Luigifab/Minifier/Model/Rewrite/Translate.php index dba0f0e..e4dc125 100644 --- a/src/app/code/community/Luigifab/Minifier/Model/Rewrite/Translate.php +++ b/src/app/code/community/Luigifab/Minifier/Model/Rewrite/Translate.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -19,10 +19,15 @@ class Luigifab_Minifier_Model_Rewrite_Translate extends Mage_Core_Model_Translate { + protected $_configShare; + protected $_configOverwrite; + public function __construct() { + + parent::__construct(); + $this->_configShare = Mage::getStoreConfigFlag('minifier/general/translations_share'); $this->_configOverwrite = Mage::getStoreConfigFlag('minifier/general/translations_overwrite'); - parent::__construct(); } protected function _loadModuleTranslation($moduleName, $files, $forceReload = false) { diff --git a/src/app/code/community/Luigifab/Minifier/Model/Source/Cache.php b/src/app/code/community/Luigifab/Minifier/Model/Source/Cache.php index 66984a3..e9f73bf 100644 --- a/src/app/code/community/Luigifab/Minifier/Model/Source/Cache.php +++ b/src/app/code/community/Luigifab/Minifier/Model/Source/Cache.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -19,6 +19,8 @@ class Luigifab_Minifier_Model_Source_Cache { + protected $_options; + public function toOptionArray() { if (empty($this->_options)) { diff --git a/src/app/code/community/Luigifab/Minifier/Model/Source/Favicon.php b/src/app/code/community/Luigifab/Minifier/Model/Source/Favicon.php index 88e8715..101b1a2 100644 --- a/src/app/code/community/Luigifab/Minifier/Model/Source/Favicon.php +++ b/src/app/code/community/Luigifab/Minifier/Model/Source/Favicon.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -19,6 +19,8 @@ class Luigifab_Minifier_Model_Source_Favicon { + protected $_options; + public function toOptionArray() { if (empty($this->_options)) { diff --git a/src/app/code/community/Luigifab/Minifier/Model/Source/Minify.php b/src/app/code/community/Luigifab/Minifier/Model/Source/Minify.php index 993ecef..09defad 100644 --- a/src/app/code/community/Luigifab/Minifier/Model/Source/Minify.php +++ b/src/app/code/community/Luigifab/Minifier/Model/Source/Minify.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -19,6 +19,8 @@ class Luigifab_Minifier_Model_Source_Minify { + protected $_options; + public function toOptionArray() { if (empty($this->_options)) { diff --git a/src/app/code/community/Luigifab/Minifier/controllers/DebugController.php b/src/app/code/community/Luigifab/Minifier/controllers/DebugController.php index bc2aaeb..ab8ca4f 100644 --- a/src/app/code/community/Luigifab/Minifier/controllers/DebugController.php +++ b/src/app/code/community/Luigifab/Minifier/controllers/DebugController.php @@ -1,10 +1,10 @@ - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published @@ -80,14 +80,17 @@ protected function formatData(array $files) { return $files; } - public function indexAction() { - + public function preDispatch() { Mage::register('turpentine_nocache_flag', true, true); + parent::preDispatch(); + } + + public function indexAction() { if (Mage::getStoreConfigFlag('minifier/cssjs/debug_enabled') && Mage::getStoreConfigFlag(Mage::app()->getStore()->isAdmin() ? 'minifier/cssjs/enabled_back' : 'minifier/cssjs/enabled_front')) { - $passwd = Mage::getStoreConfig('minifier/cssjs/debug_password'); - if (!empty($passwd) && ($this->getRequest()->getParam('pass') != $passwd)) { + $pass = Mage::getStoreConfig('minifier/cssjs/debug_password'); + if (!empty($pass) && ($this->getRequest()->getParam('pass') != $pass)) { $link = ''; $text = 'invalid pass'; } @@ -95,18 +98,18 @@ public function indexAction() { $files = Mage::getSingleton('core/session')->getData('minifier'); if (empty(Mage::getSingleton('core/cookie')->get('minifier'))) { - $link = ' - start'; + $link = ' - start'; if (empty($files)) - $link .= ' - clear'; + $link .= ' - clear'; else - $link .= ' - clear'; + $link .= ' - clear'; } else { - $link = ' - stop'; + $link = ' - stop'; if (empty($files)) - $link .= ' - clear'; + $link .= ' - clear'; else - $link .= ' - clear'; + $link .= ' - clear'; } if (is_array($files)) @@ -130,12 +133,10 @@ public function indexAction() { public function startAction() { - Mage::register('turpentine_nocache_flag', true, true); - - $passwd = Mage::getStoreConfig('minifier/cssjs/debug_password'); - if (Mage::getStoreConfigFlag('minifier/cssjs/debug_enabled') && (empty($passwd) || ($this->getRequest()->getParam('pass') == $passwd))) { + $pass = Mage::getStoreConfig('minifier/cssjs/debug_password'); + if (Mage::getStoreConfigFlag('minifier/cssjs/debug_enabled') && (empty($pass) || ($this->getRequest()->getParam('pass') == $pass))) { Mage::getSingleton('core/cookie')->set('minifier', 1, true); - $this->_redirect('*/*/index', ['pass' => $passwd]); + $this->_redirect('*/*/index', ['pass' => $pass]); } else { $this->_redirect('*/*/index'); @@ -144,12 +145,10 @@ public function startAction() { public function clearAction() { - Mage::register('turpentine_nocache_flag', true, true); - - $passwd = Mage::getStoreConfig('minifier/cssjs/debug_password'); - if (Mage::getStoreConfigFlag('minifier/cssjs/debug_enabled') && (empty($passwd) || ($this->getRequest()->getParam('pass') == $passwd))) { + $pass = Mage::getStoreConfig('minifier/cssjs/debug_password'); + if (Mage::getStoreConfigFlag('minifier/cssjs/debug_enabled') && (empty($pass) || ($this->getRequest()->getParam('pass') == $pass))) { Mage::getSingleton('core/session')->setData('minifier', null); - $this->_redirect('*/*/index', ['pass' => $passwd]); + $this->_redirect('*/*/index', ['pass' => $pass]); } else { $this->_redirect('*/*/index'); @@ -158,12 +157,10 @@ public function clearAction() { public function stopAction() { - Mage::register('turpentine_nocache_flag', true, true); - - $passwd = Mage::getStoreConfig('minifier/cssjs/debug_password'); - if (Mage::getStoreConfigFlag('minifier/cssjs/debug_enabled') && (empty($passwd) || ($this->getRequest()->getParam('pass') == $passwd))) { + $pass = Mage::getStoreConfig('minifier/cssjs/debug_password'); + if (Mage::getStoreConfigFlag('minifier/cssjs/debug_enabled') && (empty($pass) || ($this->getRequest()->getParam('pass') == $pass))) { Mage::getSingleton('core/cookie')->delete('minifier'); - $this->_redirect('*/*/index', ['pass' => $passwd]); + $this->_redirect('*/*/index', ['pass' => $pass]); } else { $this->_redirect('*/*/index'); diff --git a/src/app/code/community/Luigifab/Minifier/controllers/Minifier/DebugController.php b/src/app/code/community/Luigifab/Minifier/controllers/Minifier/DebugController.php index bde9b46..391c03c 100644 --- a/src/app/code/community/Luigifab/Minifier/controllers/Minifier/DebugController.php +++ b/src/app/code/community/Luigifab/Minifier/controllers/Minifier/DebugController.php @@ -3,8 +3,8 @@ * Created D/15/11/2020 * Updated D/15/11/2020 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/etc/adminhtml.xml b/src/app/code/community/Luigifab/Minifier/etc/adminhtml.xml index a07501d..2ea4e78 100644 --- a/src/app/code/community/Luigifab/Minifier/etc/adminhtml.xml +++ b/src/app/code/community/Luigifab/Minifier/etc/adminhtml.xml @@ -3,8 +3,8 @@ * Created L/27/06/2011 * Updated D/09/02/2020 * - * Copyright 2011-2022 | Fabrice Creuzot (luigifab) - * https://www.luigifab.fr/openmage/minifier + * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * https://github.com/luigifab/openmage-minifier * * This program is free software, you can redistribute it or modify * it under the terms of the GNU General Public License (GPL) as published diff --git a/src/app/code/community/Luigifab/Minifier/etc/config.xml b/src/app/code/community/Luigifab/Minifier/etc/config.xml index ffb4a0f..b4bd20a 100644 --- a/src/app/code/community/Luigifab/Minifier/etc/config.xml +++ b/src/app/code/community/Luigifab/Minifier/etc/config.xml @@ -1,10 +1,10 @@ + https://www.luigifab.fr/openmage/rss.xml