From 6c9b851a774024071281b929d0867dff5b66850e Mon Sep 17 00:00:00 2001 From: Fabrice Creuzot Date: Wed, 3 Mar 2021 20:00:00 +0000 Subject: [PATCH] Version 6.6.0 --- README.md | 20 +- composer.json | 4 +- .../Apijs/Block/Adminhtml/Config/Help.php | 4 +- .../Luigifab/Apijs/Block/Adminhtml/Demo.php | 2 +- .../Block/Adminhtml/Rewrite/Additional.php | 2 +- .../Block/Adminhtml/Rewrite/Category.php | 6 +- .../Apijs/Block/Adminhtml/Rewrite/Config.php | 6 +- .../Apijs/Block/Adminhtml/Rewrite/Gallery.php | 2 +- .../Apijs/Block/Adminhtml/Rewrite/Tree.php | 2 +- .../Luigifab/Apijs/Block/Browser.php | 2 +- .../community/Luigifab/Apijs/Helper/Data.php | 22 +- .../Luigifab/Apijs/Helper/Rewrite/Image.php | 225 ++++++++------ .../Luigifab/Apijs/Model/Observer.php | 4 +- .../community/Luigifab/Apijs/Model/Python.php | 29 +- .../Luigifab/Apijs/Model/Rewrite/Media.php | 6 +- .../Luigifab/Apijs/Model/Rewrite/Mediares.php | 6 +- .../Apijs/Model/Rewrite/Validator.php | 6 +- .../Luigifab/Apijs/Model/Useragentparser.php | 20 +- .../controllers/Apijs/CacheController.php | 8 +- .../controllers/Apijs/MediaController.php | 20 +- .../controllers/Apijs/WysiwygController.php | 8 +- .../Luigifab/Apijs/etc/adminhtml.xml | 2 +- .../community/Luigifab/Apijs/etc/config.xml | 6 +- .../community/Luigifab/Apijs/etc/system.xml | 6 +- .../community/Luigifab/Apijs/lib/image.py | 281 ++++++++++-------- src/app/code/community/Luigifab/Apijs/readme | 20 +- ...l4-install-6.4.0.php => install-6.6.0.php} | 8 +- .../default/default/layout/luigifab/apijs.xml | 6 +- .../template/luigifab/apijs/browser.phtml | 2 +- .../template/luigifab/apijs/content.phtml | 2 +- .../template/luigifab/apijs/demo.phtml | 58 ++-- .../template/luigifab/apijs/files.phtml | 4 +- .../template/luigifab/apijs/gallery.phtml | 42 ++- .../base/default/layout/luigifab/apijs.xml | 2 +- .../template/luigifab/apijs/browser.phtml | 2 +- .../template/luigifab/apijs/demo.phtml | 2 +- .../template/luigifab/apijs/media.phtml | 2 +- src/app/etc/modules/Luigifab_Apijs.xml | 2 +- src/app/locale/cs_CZ/Luigifab_Apijs.csv | 3 +- src/app/locale/de_AT/Luigifab_Apijs.csv | 5 +- src/app/locale/de_CH/Luigifab_Apijs.csv | 5 +- src/app/locale/de_DE/Luigifab_Apijs.csv | 5 +- src/app/locale/es_AR/Luigifab_Apijs.csv | 4 +- src/app/locale/es_CL/Luigifab_Apijs.csv | 4 +- src/app/locale/es_CO/Luigifab_Apijs.csv | 4 +- src/app/locale/es_CR/Luigifab_Apijs.csv | 4 +- src/app/locale/es_ES/Luigifab_Apijs.csv | 4 +- src/app/locale/es_MX/Luigifab_Apijs.csv | 4 +- src/app/locale/es_PA/Luigifab_Apijs.csv | 4 +- src/app/locale/es_PE/Luigifab_Apijs.csv | 4 +- src/app/locale/es_VE/Luigifab_Apijs.csv | 4 +- src/app/locale/fr_CA/Luigifab_Apijs.csv | 7 +- src/app/locale/fr_CH/Luigifab_Apijs.csv | 53 ++++ src/app/locale/fr_FR/Luigifab_Apijs.csv | 7 +- src/app/locale/it_CH/Luigifab_Apijs.csv | 7 +- src/app/locale/it_IT/Luigifab_Apijs.csv | 7 +- src/app/locale/pl_PL/Luigifab_Apijs.csv | 5 +- src/app/locale/pt_PT/Luigifab_Apijs.csv | 4 +- src/app/locale/sk_SK/Luigifab_Apijs.csv | 5 +- src/app/locale/uk_UA/Luigifab_Apijs.csv | 1 + .../css/luigifab/apijs/apijs-openmage.min.css | 8 +- .../css/luigifab/apijs/apijs-print.min.css | 10 +- .../luigifab/apijs/apijs-print.min.css.map | 1 + .../luigifab/apijs/apijs-screen-rtl.min.css | 10 +- .../apijs/apijs-screen-rtl.min.css.map | 1 + .../css/luigifab/apijs/apijs-screen.min.css | 10 +- .../luigifab/apijs/apijs-screen.min.css.map | 1 + .../default/css/luigifab/apijs/styles.css | 18 +- .../css/luigifab/apijs/styles.min.css.map | 1 + .../js/luigifab/apijs/apijs-openmage.min.js | 7 +- .../default/js/luigifab/apijs/apijs.min.js | 9 +- .../js/luigifab/apijs/apijs.min.js.map | 1 + .../default/default/js/luigifab/apijs/app.js | 19 +- .../default/js/luigifab/apijs/app.min.js.map | 1 + .../css/luigifab/apijs/apijs-openmage.min.css | 8 +- .../css/luigifab/apijs/apijs-print.min.css | 10 +- .../luigifab/apijs/apijs-print.min.css.map | 1 + .../luigifab/apijs/apijs-screen-rtl.min.css | 10 +- .../apijs/apijs-screen-rtl.min.css.map | 1 + .../css/luigifab/apijs/apijs-screen.min.css | 10 +- .../luigifab/apijs/apijs-screen.min.css.map | 1 + .../default/css/luigifab/apijs/styles.css | 6 +- .../css/luigifab/apijs/styles.min.css.map | 1 + .../default/js/luigifab/apijs/apijs.min.js | 9 +- .../js/luigifab/apijs/apijs.min.js.map | 1 + src/var/connect/luigifab-apijs.xml | 275 ----------------- 86 files changed, 670 insertions(+), 761 deletions(-) rename src/app/code/community/Luigifab/Apijs/sql/apijs_setup/{mysql4-install-6.4.0.php => install-6.6.0.php} (89%) create mode 100644 src/app/locale/fr_CH/Luigifab_Apijs.csv create mode 100644 src/app/locale/uk_UA/Luigifab_Apijs.csv create mode 100644 src/skin/adminhtml/default/default/css/luigifab/apijs/apijs-print.min.css.map create mode 100644 src/skin/adminhtml/default/default/css/luigifab/apijs/apijs-screen-rtl.min.css.map create mode 100644 src/skin/adminhtml/default/default/css/luigifab/apijs/apijs-screen.min.css.map create mode 100644 src/skin/adminhtml/default/default/css/luigifab/apijs/styles.min.css.map create mode 100644 src/skin/adminhtml/default/default/js/luigifab/apijs/apijs.min.js.map create mode 100644 src/skin/adminhtml/default/default/js/luigifab/apijs/app.min.js.map create mode 100644 src/skin/frontend/base/default/css/luigifab/apijs/apijs-print.min.css.map create mode 100644 src/skin/frontend/base/default/css/luigifab/apijs/apijs-screen-rtl.min.css.map create mode 100644 src/skin/frontend/base/default/css/luigifab/apijs/apijs-screen.min.css.map create mode 100644 src/skin/frontend/base/default/css/luigifab/apijs/styles.min.css.map create mode 100644 src/skin/frontend/base/default/js/luigifab/apijs/apijs.min.js.map delete mode 100644 src/var/connect/luigifab-apijs.xml diff --git a/README.md b/README.md index 9b13923..88d2640 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@ # apijs -Beautiful javascript popup and slideshow for OpenMage and Magento. +Beautiful javascript popup and slideshow for [OpenMage](https://github.com/OpenMage/magento-lts). -For more information, go to https://www.luigifab.fr/apijs or https://www.luigifab.fr/openmage/apijs or https://www.luigifab.fr/magento/apijs or https://www.luigifab.fr/redmine/apijs (IPv6 is required, it's not a joke). No IPv6? It's possible to get an IPv6 thanks to *Miredo*. Run `sudo apt install miredo` and `sudo service miredo force-start`. +For more information, go to https://www.luigifab.fr/apijs and https://www.luigifab.fr/openmage/apijs (IPv6 is required, it's not a joke). No IPv6? It's possible to get an IPv6 thanks to *Miredo*. Run `sudo apt install miredo` and `sudo service miredo force-start`. -- for the app, go to https://www.github.com/luigifab/apijs -- for the plugin for Redmine, go to https://www.github.com/luigifab/redmine-apijs -- for the bundle for Symfony, go to https://www.github.com/luigifab/symfony-apijs +- for the app, go to [apijs](https://www.github.com/luigifab/apijs) +- for the plugin for Redmine, go to [redmine-apijs](https://www.github.com/luigifab/redmine-apijs) +- for the bundle for Symfony, go to [symfony-apijs](https://www.github.com/luigifab/symfony-apijs) -This repository is a mirror. To install the module, please use the extension key or the composer key available in the documentation. +This repository is a releases mirror. To install the module, please use the composer key available in the documentation. -- Current version: 6.5.0 (12/12/2020) -- Compatibility: OpenMage 19+, Magento Community 1.9+, PHP 7.2 / 7.3 / 7.4 / 8.0 -- Client compatibility: Firefox 36+, Chrome 31+, Opera 19+, Edge 16+, Safari 9+ +- Current version: 6.6.0 (03/03/2021) +- Compatibility: OpenMage 19.x / 20.x, PHP 7.2 / 7.3 / 7.4 / 8.0, Python 3.3 / 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 +- 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) - Other translations: Czech (cs), Dutch (nl), Japanese (ja), Polish (pl), Slovak (sk) -- Other translations: Chinese (zh), Russian (ru), Turkish (tr) +- Other translations: Chinese (zh), Russian (ru), Turkish (tr), Ukrainian (uk) - License: GNU GPL 2+ If you like, take some of your time to improve the translations, go to https://bit.ly/2HyCCEc. diff --git a/composer.json b/composer.json index dea9a83..db2bafb 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "type": "magento-module", "name": "luigifab/openmage-apijs", - "description": "Beautiful javascript popup and slideshow for OpenMage and Magento.", + "description": "Beautiful javascript popup and slideshow for OpenMage.", "homepage": "https://github.com/luigifab/openmage-apijs", "license": "GPL-2.0-or-later", "authors": [ @@ -53,6 +53,7 @@ ["src/app/locale/es_PE/Luigifab_Apijs.csv", "app/locale/es_PE/Luigifab_Apijs.csv"], ["src/app/locale/es_VE/Luigifab_Apijs.csv", "app/locale/es_VE/Luigifab_Apijs.csv"], ["src/app/locale/fr_CA/Luigifab_Apijs.csv", "app/locale/fr_CA/Luigifab_Apijs.csv"], + ["src/app/locale/fr_CH/Luigifab_Apijs.csv", "app/locale/fr_CH/Luigifab_Apijs.csv"], ["src/app/locale/fr_FR/Luigifab_Apijs.csv", "app/locale/fr_FR/Luigifab_Apijs.csv"], ["src/app/locale/it_CH/Luigifab_Apijs.csv", "app/locale/it_CH/Luigifab_Apijs.csv"], ["src/app/locale/it_IT/Luigifab_Apijs.csv", "app/locale/it_IT/Luigifab_Apijs.csv"], @@ -64,6 +65,7 @@ ["src/app/locale/ru_RU/Luigifab_Apijs.csv", "app/locale/ru_RU/Luigifab_Apijs.csv"], ["src/app/locale/sk_SK/Luigifab_Apijs.csv", "app/locale/sk_SK/Luigifab_Apijs.csv"], ["src/app/locale/tr_TR/Luigifab_Apijs.csv", "app/locale/tr_TR/Luigifab_Apijs.csv"], + ["src/app/locale/uk_UA/Luigifab_Apijs.csv", "app/locale/uk_UA/Luigifab_Apijs.csv"], ["src/app/locale/zh_CN/Luigifab_Apijs.csv", "app/locale/zh_CN/Luigifab_Apijs.csv"], ["src/app/etc/modules/Luigifab_Apijs.xml", "app/etc/modules/Luigifab_Apijs.xml"], ["src/app/code/community/Luigifab/Apijs/", "app/code/community/Luigifab/Apijs/"], diff --git a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Config/Help.php b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Config/Help.php index eed2d06..bcf3bf4 100644 --- a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Config/Help.php +++ b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Config/Help.php @@ -1,9 +1,9 @@ + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Demo.php b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Demo.php index df3d1c3..7096a7a 100644 --- a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Demo.php +++ b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Demo.php @@ -3,7 +3,7 @@ * Created D/20/11/2011 * Updated M/28/02/2017 * - * Copyright 2008-2020 | Fabrice Creuzot (luigifab) + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Additional.php b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Additional.php index cabd6b7..087c1c0 100644 --- a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Additional.php +++ b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Additional.php @@ -3,7 +3,7 @@ * Created M/06/10/2020 * Updated M/06/10/2020 * - * Copyright 2008-2020 | Fabrice Creuzot (luigifab) + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Category.php b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Category.php index aab9c02..bd9733b 100644 --- a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Category.php +++ b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Category.php @@ -1,9 +1,9 @@ + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -33,7 +33,7 @@ public function getElementHtml() { if ($this->getValue()) { $url = $this->_getUrl(); $url = (mb_stripos($url, 'http') === 0) ? $url : Mage::getBaseUrl('media').$url; - $html .= sprintf(' %s (%s) ', $url, addslashes($this->getValue()), $this->getHtmlId(), Mage::helper('apijs')->__('Preview'), $this->getValue()); + $html .= sprintf(' %s (%s) ', $url, addslashes($this->getValue()), $this->getHtmlId(), Mage::helper('apijs')->__('Preview'), $this->getValue()); // pas de this->helper ici } return $html.$this->_getDeleteCheckbox().''; diff --git a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Config.php b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Config.php index 0d9505e..1067381 100644 --- a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Config.php +++ b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Config.php @@ -1,9 +1,9 @@ + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -33,7 +33,7 @@ public function getElementHtml() { if ($this->getValue()) { $url = $this->_getUrl(); $url = (mb_stripos($url, 'http') === 0) ? $url : Mage::getBaseUrl('media').$url; - $html .= sprintf(' %s (%s) ', $url, addslashes($this->getValue()), $this->getHtmlId(), Mage::helper('apijs')->__('Preview'), $this->getValue()); + $html .= sprintf(' %s (%s) ', $url, addslashes($this->getValue()), $this->getHtmlId(), Mage::helper('apijs')->__('Preview'), $this->getValue()); // pas de $this->helper } return $html.$this->_getDeleteCheckbox().''; diff --git a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Gallery.php b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Gallery.php index 7a0af33..8f39398 100644 --- a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Gallery.php +++ b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Gallery.php @@ -3,7 +3,7 @@ * Created S/04/10/2014 * Updated L/06/07/2020 * - * Copyright 2008-2020 | Fabrice Creuzot (luigifab) + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Tree.php b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Tree.php index 46883bb..f53a5d4 100644 --- a/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Tree.php +++ b/src/app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Tree.php @@ -3,7 +3,7 @@ * Created S/04/01/2020 * Updated M/29/09/2020 * - * Copyright 2008-2020 | Fabrice Creuzot (luigifab) + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Block/Browser.php b/src/app/code/community/Luigifab/Apijs/Block/Browser.php index 4667f06..241f71a 100644 --- a/src/app/code/community/Luigifab/Apijs/Block/Browser.php +++ b/src/app/code/community/Luigifab/Apijs/Block/Browser.php @@ -3,7 +3,7 @@ * Created V/11/10/2019 * Updated V/11/10/2019 * - * Copyright 2008-2020 | Fabrice Creuzot (luigifab) + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Helper/Data.php b/src/app/code/community/Luigifab/Apijs/Helper/Data.php index 470243e..583f429 100644 --- a/src/app/code/community/Luigifab/Apijs/Helper/Data.php +++ b/src/app/code/community/Luigifab/Apijs/Helper/Data.php @@ -1,9 +1,9 @@ + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -24,7 +24,8 @@ public function getVersion() { } public function _(string $data, ...$values) { - return (mb_stripos($txt = $this->__(' '.$data, ...$values), ' ') === 0) ? $this->__($data, ...$values) : $txt; + $text = $this->__(' '.$data, ...$values); + return ($text[0] == ' ') ? $this->__($data, ...$values) : $text; } public function escapeEntities($data, bool $quotes = false) { @@ -70,23 +71,25 @@ public function getWysiwygImageDir(bool $cache = false, bool $old = false) { } - public function resizeImage($product, $type, $path, $width, $height, $fixed) { + public function resizeImage($product, $type, $path, int $width, int $height, bool $fixed) { $resource = Mage::helper('catalog/image')->init($product, $type, $path, $fixed); - if ($fixed) + if (Mage::getStoreConfigFlag('apijs/general/python')) + $resource->resize($width, $height); + else if ($fixed) $resource->resize($width, $height); else if ($resource->getOriginalWidth() > $width) $resource->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize($width, null); else if ($resource->getOriginalHeight() > $height) $resource->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize(null, $height); else - $resource->resize($width, $height); + $resource->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize($width, $height); return (string) $resource; } - public function getBaseImage($product, &$default, $images, $total, $id = 0) { + public function getBaseImage($product, &$default, array $images, int $total, int $id = 0) { $mWidth = (int) Mage::getStoreConfig('apijs/gallery/picture_width'); $mHeight = (int) Mage::getStoreConfig('apijs/gallery/picture_height'); @@ -151,7 +154,7 @@ public function getBaseImage($product, &$default, $images, $total, $id = 0) { return $data; } - public function getThumbnail($product, $default, $image, $id) { + public function getThumbnail($product, $default, object $image, int $id) { $tWidth = (int) Mage::getStoreConfig('apijs/gallery/thumbnail_width'); $tHeight = (int) Mage::getStoreConfig('apijs/gallery/thumbnail_height'); @@ -180,6 +183,7 @@ public function getThumbnail($product, $default, $image, $id) { return $data; } + public function removeFiles(string $dir, string $file) { // recherche tous les fichiers avec la commande find @@ -236,7 +240,7 @@ public function getTabName($product = null) { return null; } - public function renderGalleryBlock(Mage_Catalog_Model_Product $product) { + public function renderGalleryBlock(object $product) { Mage::register('current_product', $product); diff --git a/src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php b/src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php index db7a2f8..45d810d 100644 --- a/src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php +++ b/src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php @@ -1,11 +1,10 @@ - * Copyright 2019-2020 | Fabrice Creuzot - * Copyright 2020 | Jérôme Siau + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) + * Copyright 2019-2021 | Fabrice Creuzot * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -21,25 +20,24 @@ class Luigifab_Apijs_Helper_Rewrite_Image extends Mage_Catalog_Helper_Image { - public function getModel() { - return $this->_getModel(); - } - public function init($product, $attribute, $path = null, $fixed = true) { $this->_reset(); + // debug + //if (!isset($this->_debugBegin)) $this->_debugBegin = microtime(true); + //if (!isset($this->_debugCount)) $this->_debugCount = 0; + //if (!isset($this->_debugCache)) $this->_debugCache = 0; + //if (!isset($this->_debugRenew)) $this->_debugRenew = 0; + //$this->_debugCount += 1; + //$this->_debugStart = microtime(true); + //Mage::log('Open file '.$path.'...'); + // sans le dossier, cela ne génère pas les miniatures wysiwyg ou category $dir = Mage::helper('apijs')->getCatalogProductImageDir(true); if (!is_dir($dir)) @mkdir($dir, 0755, true); - //if (!isset($this->_begin)) $this->_begin = microtime(true); - //if (!isset($this->_count)) $this->_count = 0; - //$this->_count += 1; - //$this->_start = microtime(true); - //Mage::log('Openning file '.$path.'...'); - if ($attribute == 'wysiwyg') { // wysiwyg/abc/xyz.jpg => .../media/wysiwyg/abc/xyz.jpg if ($path[0] != '/') @@ -59,108 +57,130 @@ public function init($product, $attribute, $path = null, $fixed = true) { $this->_setModel($model); // cache de la config et des urls générées - if (empty($this->_config) || empty($this->_urls)) { + if (empty($this->_cacheConfig) || empty($this->_cacheUrls)) { - $this->_config = @json_decode(Mage::app()->loadCache('apijs_config'), true); - if (empty($this->_config) || !is_array($this->_config)) { - $this->_config = [ + $this->_cacheConfig = Mage::app()->useCache('config') ? @json_decode(Mage::app()->loadCache('apijs_config'), true) : null; + if (empty($this->_cacheConfig) || !is_array($this->_cacheConfig)) { + $this->_cacheConfig = [ 'date' => date('Y-m-d H:i:s \U\T\C'), 'apijs/general/python' => Mage::getStoreConfigFlag('apijs/general/python'), 'apijs/general/remove_store_id' => Mage::getStoreConfigFlag('apijs/general/remove_store_id') ]; } - $this->_urls = @json_decode(Mage::app()->loadCache('apijs_urls'), true); - if (empty($this->_urls) || !is_array($this->_urls)) { - $this->_urls = [ + $this->_cacheUrls = Mage::app()->useCache('config') ? @json_decode(Mage::app()->loadCache('apijs_urls'), true) : null; + if (empty($this->_cacheUrls) || !is_array($this->_cacheUrls)) { + $this->_cacheUrls = [ 'date' => date('Y-m-d H:i:s \U\T\C') ]; } } // watermark - if (!array_key_exists('design/watermark/'.$attribute.'_image', $this->_config)) { - $this->_config['design/watermark/'.$attribute.'_image'] = Mage::getStoreConfig('design/watermark/'.$attribute.'_image'); - $this->_config['design/watermark/'.$attribute.'_imageOpacity'] = Mage::getStoreConfig('design/watermark/'.$attribute.'_imageOpacity'); - $this->_config['design/watermark/'.$attribute.'_position'] = Mage::getStoreConfig('design/watermark/'.$attribute.'_position'); - $this->_config['design/watermark/'.$attribute.'_size'] = Mage::getStoreConfig('design/watermark/'.$attribute.'_size'); + if (!array_key_exists('design/watermark/'.$attribute.'_image', $this->_cacheConfig)) { + $this->_cacheConfig['design/watermark/'.$attribute.'_image'] = Mage::getStoreConfig('design/watermark/'.$attribute.'_image'); + $this->_cacheConfig['design/watermark/'.$attribute.'_imageOpacity'] = Mage::getStoreConfig('design/watermark/'.$attribute.'_imageOpacity'); + $this->_cacheConfig['design/watermark/'.$attribute.'_position'] = Mage::getStoreConfig('design/watermark/'.$attribute.'_position'); + $this->_cacheConfig['design/watermark/'.$attribute.'_size'] = Mage::getStoreConfig('design/watermark/'.$attribute.'_size'); } - if (!empty($this->_config['design/watermark/'.$attribute.'_image'])) { - $this->setWatermark($this->_config['design/watermark/'.$attribute.'_image']); - $this->setWatermarkImageOpacity($this->_config['design/watermark/'.$attribute.'_imageOpacity']); - $this->setWatermarkPosition($this->_config['design/watermark/'.$attribute.'_position']); - $this->setWatermarkSize($this->_config['design/watermark/'.$attribute.'_size']); + if (!empty($this->_cacheConfig['design/watermark/'.$attribute.'_image'])) { + $this->setWatermark($this->_cacheConfig['design/watermark/'.$attribute.'_image']); + $this->setWatermarkImageOpacity($this->_cacheConfig['design/watermark/'.$attribute.'_imageOpacity']); + $this->setWatermarkPosition($this->_cacheConfig['design/watermark/'.$attribute.'_position']); + $this->setWatermarkSize($this->_cacheConfig['design/watermark/'.$attribute.'_size']); } if (empty($path)) $path = $product->getData($attribute); - $this->_svg = (!empty($path) && (mb_substr($path, -4) == '.svg')); - $this->setImageFile($path); - $this->trySetBaseFile($model, $path); - - if ($this->_config['apijs/general/python']) { - $processor = Mage::getSingleton('apijs/python')->setFilename($model->getBaseFile())->setFixed($fixed); - $model->setImageProcessor($processor); - } + $this->_svg = !empty($path) && (mb_substr($path, -4) == '.svg'); + $this->_fixed = $fixed; + $this->_imageFile = $path; return $this; } + public function getModel() { + return $this->_getModel(); + } + public function getImageProcessor() { return $this->_getModel()->getImageProcessor(); } public function getOriginalWidth() { - return empty($this->_svg) ? parent::getOriginalWidth() : 0; + + if (empty($this->_svg)) { + if (empty($this->_getModel()->getBaseFile())) + $this->setBaseFile(); + return parent::getOriginalWidth(); + } + + return 0; } public function getOriginalHeight() { - return empty($this->_svg) ? parent::getOriginalHeight() : 0; + + if (empty($this->_svg)) { + if (empty($this->_getModel()->getBaseFile())) + $this->setBaseFile(); + return parent::getOriginalHeight(); + } + + return 0; + } + + public function validateUploadFile($path) { + return (is_file($path) && in_array(mime_content_type($path), ['image/svg', 'image/svg+xml'])) ? true : parent::validateUploadFile($path); } - private function trySetBaseFile($model, $path) { + public function setBaseFile() { - try { - // essaye le fichier source - $this->wrapSetBaseFile($model, $path); + //$go = microtime(true); + $model = $this->_getModel(); + $file = Mage::helper('apijs')->getCatalogProductImageDir().trim($this->_imageFile, '/'); + + if ($this->_cacheConfig['apijs/general/python']) { + $processor = Mage::getSingleton('apijs/python')->setFilename($file)->setFixed($this->_fixed); + $model->setImageProcessor($processor); } - catch (Exception $e) { - try { - // si le fichier source n'existe pas - // essaye avec le placeholder - $model->setBaseFile('/no_selection'); + + try { + // essaye le fichier source ou le placeholder + // setWatermarkFile pour avoir une url unique + // par exemple, en cas de suppression de l'image a.jpg, puis de l'ajout de l'image a.jpg, même nom mais contenu différent + if (is_file($file)) { + $old = $model->getWatermarkFile(); + $model->setWatermarkFile($old.filemtime($file)); + $model->setBaseFile($this->_imageFile); + $model->setWatermarkFile($old); } - catch (Exception $e) { - $area = Mage::getDesign()->getArea(); - if ($area == 'adminhtml') - Mage::getDesign()->setArea('frontend'); - // si le placeholder n'existe pas - // essaye avec le placeholder image - $model->setDestinationSubdir('image'); + else { $model->setBaseFile('/no_selection'); - // si ça crash encore - // c'est éventuellement la faute à un lien symbolique, quelque part dans media, au lieu d'être complètement sur media - if ($area == 'adminhtml') - Mage::getDesign()->setArea($area); + $this->_imageFile = $model->getBaseFile(); + if (is_object($processor)) + $processor->setFilename($this->_imageFile); } } - } - - private function wrapSetBaseFile($model, $file) { - - $filename = Mage::helper('apijs')->getCatalogProductImageDir().$file; - - // pour avoir une url unique - // par exemple, en cas de suppression de l'image a.jpg, puis de l'ajout de l'image a.jpg, même nom mais contenu différent - $old = $model->getWatermarkFile(); - $model->setWatermarkFile(is_file($filename) ? $old.filemtime($filename) : $old); - $model->setBaseFile($file); - $model->setWatermarkFile($old); - } + catch (Throwable $e) { + $area = Mage::getDesign()->getArea(); + if ($area == 'adminhtml') + Mage::getDesign()->setArea('frontend'); + // si le placeholder n'existe pas + // essaye avec le placeholder image + $model->setDestinationSubdir('image'); + $model->setBaseFile('/no_selection'); + $this->_imageFile = $model->getBaseFile(); + if (is_object($processor)) + $processor->setFilename($this->_imageFile); + // si ça crash encore + // c'est éventuellement la faute à un lien symbolique, quelque part dans media, au lieu d'être complètement sur media + if ($area == 'adminhtml') + Mage::getDesign()->setArea($area); + } - public function validateUploadFile($path) { - return (is_file($path) && in_array(mime_content_type($path), ['image/svg', 'image/svg+xml'])) ? true : parent::validateUploadFile($path); + //Mage::log(' setBaseFile '.number_format(microtime(true) - $go, 4)); + return $this; } public function __toString() { @@ -168,17 +188,19 @@ public function __toString() { $model = $this->_getModel(); if (!empty($this->_svg)) { $this->resize(0, 0); - if (!$this->_config['apijs/general/python']) { + if (!$this->_cacheConfig['apijs/general/python']) { if ($model->getDestinationSubdir() == 'wysiwyg') - return Mage::getBaseUrl('media').str_replace('../', '', $this->getImageFile()); + return Mage::getBaseUrl('media').str_replace('../', '', $this->_imageFile); if ($model->getDestinationSubdir() == 'category') - return Mage::getBaseUrl('media').'catalog/category/'.$this->getImageFile(); - return Mage::getBaseUrl('media').'catalog/product'.$this->getImageFile(); + return Mage::getBaseUrl('media').'catalog/category/'.$this->_imageFile; + // (true) + return Mage::getBaseUrl('media').'catalog/product/'.$this->_imageFile; } } try { - $this->wrapSetBaseFile($model, $this->getImageFile()); + //$go = microtime(true); + $this->setBaseFile(); if ($model->getDestinationSubdir() == 'wysiwyg') { // if ($model->isCached()) @@ -191,10 +213,12 @@ public function __toString() { $filename = str_replace(['../', '//'], ['', '/'], Mage::helper('apijs')->getWysiwygImageDir(true). mb_substr($filename, mb_stripos($filename, '/'.$dir.'/') + mb_strlen('/'.$dir.'/'))); - if (array_key_exists($filename, $this->_urls)) { - $url = $this->_urls[$filename]; + if (array_key_exists($filename, $this->_cacheUrls)) { + //Mage::log(' CACHE HIT '.$filename); $this->_debugCache++; + $url = $this->_cacheUrls[$filename]; } else { + //Mage::log(' generate '.$filename); $this->_debugRenew++; if (!is_file($filename)) { if (!empty($this->_scheduleRotate)) @@ -216,7 +240,7 @@ public function __toString() { $url = str_replace('../', '', preg_replace('#catalog/product/cache/(?:[0-9]+/)?'.$dir.'/#', $dir.'/cache/', $url)); // cache - $this->_urls[$filename] = $url; + $this->_cacheUrls[$filename] = $url; } } else if ($model->getDestinationSubdir() == 'category') { @@ -228,10 +252,12 @@ public function __toString() { $filename = $model->getNewFile(); $filename = str_replace(['../', '//', '/category/', '/catalog/product/'], ['', '/', '/', '/catalog/category/'], $filename); - if (array_key_exists($filename, $this->_urls)) { - $url = $this->_urls[$filename]; + if (array_key_exists($filename, $this->_cacheUrls)) { + //Mage::log(' CACHE HIT '.$filename); $this->_debugCache++; + $url = $this->_cacheUrls[$filename]; } else { + //Mage::log(' generate '.$filename); $this->_debugRenew++; if (!is_file($filename)) { if (!empty($this->_scheduleRotate)) @@ -253,7 +279,7 @@ public function __toString() { $url = str_replace(['../', '/category/', '/catalog/product/'], ['', '/', '/catalog/category/'], $url); // cache - $this->_urls[$filename] = $url; + $this->_cacheUrls[$filename] = $url; } } else { @@ -261,13 +287,15 @@ public function __toString() { // /x/y/xyz.jpg // .../media/catalog/product/cache/[0/]category/1200x/040ec09b1e35df139433887a97daa66f/x/y/xyz.jpg $filename = $model->getNewFile(); - if ($this->_config['apijs/general/remove_store_id']) + if ($this->_cacheConfig['apijs/general/remove_store_id']) $filename = preg_replace('#/cache/\d+/#', '/cache/', $filename); - if (array_key_exists($filename, $this->_urls)) { - $url = $this->_urls[$filename]; + if (array_key_exists($filename, $this->_cacheUrls)) { + //Mage::log(' CACHE HIT '.$filename); $this->_debugCache++; + $url = $this->_cacheUrls[$filename]; } else { + //Mage::log(' generate '.$filename); $this->_debugRenew++; if (!is_file($filename)) { if (!empty($this->_scheduleRotate)) @@ -285,29 +313,30 @@ public function __toString() { // return $model->getUrl(); // .../media/catalog/product/cache/[0/]category/1200x/040ec09b1e35df139433887a97daa66f/x/y/xyz.jpg $url = $model->getUrl(); - if ($this->_config['apijs/general/remove_store_id']) + if ($this->_cacheConfig['apijs/general/remove_store_id']) $url = preg_replace('#/cache/\d+/#', '/cache/', $url); // cache - $this->_urls[$filename] = $url; + $this->_cacheUrls[$filename] = $url; } } } - catch (Exception $e) { + catch (Throwable $e) { $url = Mage::getDesign()->getSkinUrl($this->getPlaceholder()); } - //Mage::log('Closing file after '.number_format(microtime(true) - $this->_start, 2).' / since start '.number_format(microtime(true) - $this->_begin, 2).' / nb '.$this->_count); + //Mage::log(' toString '.number_format(microtime(true) - $go, 4)); + //Mage::log(' closing file after '.number_format(microtime(true) - $this->_debugStart, 4).' / since first init '.number_format(microtime(true) - $this->_debugBegin, 4).' / total '.$this->_debugCount.' = cache '.$this->_debugCache.' + generate '.$this->_debugRenew); return $url; } public function __destruct() { - if (!empty($this->_config) && Mage::app()->useCache('config')) // ici la balise XML du cache, ci-dessous une clef et le tag du cache - Mage::app()->saveCache(json_encode($this->_config), 'apijs_config', ['CONFIG']); + if (!empty($this->_cacheConfig) && Mage::app()->useCache('config')) + Mage::app()->saveCache(json_encode($this->_cacheConfig), 'apijs_config', [Mage_Core_Model_Config::CACHE_TAG]); - if (!empty($this->_urls) && Mage::app()->useCache('block_html')) // ici la balise XML du cache, ci-dessous une clef et le tag du cache - Mage::app()->saveCache(json_encode($this->_urls), 'apijs_urls', ['CONFIG', 'BLOCK_HTML']); + if (!empty($this->_cacheUrls) && Mage::app()->useCache('block_html')) + Mage::app()->saveCache(json_encode($this->_cacheUrls), 'apijs_urls', [Mage_Core_Model_Config::CACHE_TAG, Mage_Core_Block_Abstract::CACHE_GROUP]); } } \ No newline at end of file diff --git a/src/app/code/community/Luigifab/Apijs/Model/Observer.php b/src/app/code/community/Luigifab/Apijs/Model/Observer.php index e2c0e81..c71b178 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Observer.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Observer.php @@ -1,9 +1,9 @@ + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Model/Python.php b/src/app/code/community/Luigifab/Apijs/Model/Python.php index d4fb774..c3fe610 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Python.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Python.php @@ -1,9 +1,9 @@ + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -20,11 +20,11 @@ class Luigifab_Apijs_Model_Python extends Varien_Image { // singleton + protected $_python; protected $_quality = 100; protected $_files = []; - protected $_pids = []; - protected $_core = 1; - protected $_python; + protected $_pids = []; + protected $_core = 1; protected $_svg; public function __construct($file = null, $adapter = null) { @@ -60,7 +60,8 @@ public function getProgramVersions($helpPil, $helpSco) { } else { exec($cmd.' --version 2>&1', $pyt); - $pyt = str_replace('Python ', '', trim(implode($pyt))); + $pyt = trim(str_replace('Python', '', implode($pyt))); + $pyt = implode('.', array_slice(preg_split('#\D#', $pyt), 0, 3)); exec($cmd.' -c "from PIL import Image; print(Image.__version__)" 2>&1', $pil); $pil = trim(implode($pil)); @@ -69,6 +70,8 @@ public function getProgramVersions($helpPil, $helpSco) { $pil = 'not available'; else if (mb_stripos($pil, '__version__') !== false) $pil = 'available'; + else + $pil = implode('.', array_slice(preg_split('#\D#', $pil), 0, 3)); exec($cmd.' -c "import scour; print(scour.__version__)" 2>&1', $sco); $sco = trim(implode($sco)); @@ -77,6 +80,8 @@ public function getProgramVersions($helpPil, $helpSco) { $sco = 'not available'; else if (mb_stripos($sco, '__version__') !== false) $sco = 'available'; + else + $sco = implode('.', array_slice(preg_split('#\D#', $sco), 0, 3)); } return sprintf('python %s / python-pil %s %s / python-scour %s %s / %d cpu', $pyt, $pil, $helpPil, $sco, $helpSco, $this->_core); @@ -111,8 +116,12 @@ public function save($destination = null, $newFilename = null) { str_replace('Apijs/etc', 'Apijs/lib/image.py', Mage::getModuleDir('etc', 'Luigifab_Apijs')), escapeshellarg($this->_fileName), escapeshellarg($destination), - empty($this->_resizeWidth) ? 0 : $this->_resizeWidth, - empty($this->_resizeHeight) ? 0 : $this->_resizeHeight, + empty($this->_resizeFixed) ? + (empty($this->_resizeWidth) ? 0 : $this->_resizeWidth) : + (empty($this->_resizeWidth) ? (empty($this->_resizeHeight) ? 0 : $this->_resizeHeight) : $this->_resizeWidth), + empty($this->_resizeFixed) ? + (empty($this->_resizeHeight) ? 0 : $this->_resizeHeight) : + (empty($this->_resizeHeight) ? (empty($this->_resizeWidth) ? 0 : $this->_resizeWidth) : $this->_resizeHeight), // uniquement pour JPEG (ignoré et toujouts à 9 pour PNG, inutile pour GIF) $this->_quality, empty($this->_resizeFixed) ? '' : 'fixed' @@ -127,7 +136,7 @@ public function save($destination = null, $newFilename = null) { $this->reset(); } - catch (Exception $e) { + catch (Throwable $e) { Mage::logException($e); throw $e; } @@ -184,7 +193,7 @@ public function isSvg() { if (is_null($this->_svg)) { $this->open(); - $this->_svg = (mb_stripos($this->_fileName, '.svg') !== false) || in_array(mime_content_type($this->_fileName), ['image/svg', 'image/svg+xml']); + $this->_svg = (mb_substr($this->_fileName, -4) == '.svg') || in_array(mime_content_type($this->_fileName), ['image/svg', 'image/svg+xml']); } return $this->_svg; diff --git a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Media.php b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Media.php index fed7b6b..5775e5d 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Media.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Media.php @@ -1,10 +1,10 @@ - * Copyright 2019-2020 | Fabrice Creuzot + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) + * Copyright 2019-2021 | Fabrice Creuzot * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Mediares.php b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Mediares.php index c19250a..16371a3 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Mediares.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Mediares.php @@ -1,10 +1,10 @@ - * Copyright 2019-2020 | Fabrice Creuzot + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) + * Copyright 2019-2021 | Fabrice Creuzot * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Validator.php b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Validator.php index 0d05b6b..c882c40 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Validator.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Rewrite/Validator.php @@ -1,9 +1,9 @@ + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -32,7 +32,7 @@ public function validate($path) { $processor = Mage::getSingleton('apijs/python'); $processor->setFilename($path)->resize($processor->getOriginalWidth(), $processor->getOriginalHeight())->save($path); } - catch (Exception $e) { + catch (Throwable $e) { Mage::throwException('Invalid image: '.$e->getMessage()); } diff --git a/src/app/code/community/Luigifab/Apijs/Model/Useragentparser.php b/src/app/code/community/Luigifab/Apijs/Model/Useragentparser.php index dad702f..6070d2d 100644 --- a/src/app/code/community/Luigifab/Apijs/Model/Useragentparser.php +++ b/src/app/code/community/Luigifab/Apijs/Model/Useragentparser.php @@ -1,10 +1,10 @@ + * Copyright 2013-2021 | Jesse G. Donat * https://github.com/donatj/PhpUserAgent * - * Copyright 2019-2020 | Fabrice Creuzot (luigifab) - * https://gist.github.com/luigifab/4cb373e75f3cd2f342ca6bc25504b149 (1.1.0-fork2) + * Copyright 2019-2021 | Fabrice Creuzot (luigifab) + * https://gist.github.com/luigifab/4cb373e75f3cd2f342ca6bc25504b149 (1.3.0-fork1) * * Parses a user agent string into its important parts * Licensed under the MIT License @@ -20,13 +20,13 @@ public function parse($userAgent = null) { $browser = null; $version = null; $empty = ['platform' => $platform, 'browser' => $browser, 'version' => $version]; - $priority = ['Xbox One', 'Xbox', 'Windows Phone', 'Tizen', 'Android', 'FreeBSD', 'NetBSD', 'OpenBSD', 'CrOS', 'X11']; + $priority = ['Xbox One', 'Xbox', 'Windows Phone', 'Tizen', 'Android', 'FreeBSD', 'NetBSD', 'OpenBSD', 'CrOS', 'X11', 'Sailfish']; - if (!$userAgent) return $empty; + if (empty($userAgent)) return $empty; if (preg_match('/\((.*?)\)/m', $userAgent, $parentMatches)) { preg_match_all( - '/(?PBB\d+;|Android|CrOS|Tizen|iPhone|iPad|iPod|Linux|(Open|Net|Free)BSD|Macintosh|Windows(\ Phone)?|Silk|linux-gnu|BlackBerry|PlayBook|X11|(New\ )?Nintendo\ (WiiU?|3?DS|Switch)|Xbox(\ One)?) (?:\ [^;]*)? (?:;|$)/imx', + '/(?PBB\d+;|Android|Adr|Symbian|Sailfish|CrOS|Tizen|iPhone|iPad|iPod|Linux|(Open|Net|Free)BSD|Macintosh|Windows(\ Phone)?|Silk|linux-gnu|BlackBerry|PlayBook|X11|(New\ )?Nintendo\ (WiiU?|3?DS|Switch)|Xbox(\ One)?) (?:\ [^;]*)? (?:;|$)/imx', $parentMatches[1], $result); $result['platform'] = array_unique($result['platform']); if (count($result['platform']) > 1) { @@ -44,10 +44,12 @@ public function parse($userAgent = null) { $platform = 'Linux'; else if ($platform == 'CrOS') $platform = 'Chrome OS'; + else if ($platform == 'Adr') + $platform = 'Android'; preg_match_all( // ["browser" => ["Firefox"...], "version" => ["45.0"...]] - '/(?PCamino|Kindle(\ Fire)?|Firefox|Iceweasel|IceCat|Safari|MSIE|Trident|AppleWebKit|TizenBrowser|(?:Headless)?Chrome|YaBrowser|Vivaldi|IEMobile|Opera|OPR|Silk|Midori|Edge|Edg|CriOS|UCBrowser|Puffin|OculusBrowser|SamsungBrowser|Baiduspider|Applebot|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|Valve\ Steam\ Tenfoot|NintendoBrowser|PLAYSTATION\ (\d|Vita)+) (?:\)?;?) (?:(?:[:\/ ])(?P[0-9A-Z.]+)|\/(?:[A-Z]*))/ix', + '/(?PCamino|Kindle(\ Fire)?|Firefox|Iceweasel|IceCat|Safari|MSIE|Trident|AppleWebKit|TizenBrowser|(?:Headless)?Chrome|YaBrowser|Vivaldi|IEMobile|Opera|OPR|Silk|Midori|Edge|Edg|CriOS|UCBrowser|Puffin|OculusBrowser|SamsungBrowser|SailfishBrowser|XiaoMi\/MiuiBrowser|Baiduspider|Applebot|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|Valve\ Steam\ Tenfoot|NintendoBrowser|PLAYSTATION\ (\d|Vita)+) (?:\)?;?) (?:(?:[:\/ ])(?P[0-9A-Z.]+)|\/(?:[A-Z]*))/ix', $userAgent, $result); @@ -77,7 +79,7 @@ public function parse($userAgent = null) { $key = 0; $val = ''; - if ($this->findT($lowerBrowser, ['OPR' => 'Opera', 'UCBrowser' => 'UC Browser', 'YaBrowser' => 'Yandex', 'Iceweasel' => 'Firefox', 'Icecat' => 'Firefox', 'CriOS' => 'Chrome', 'Edg' => 'Edge'], $key, $browser)) { + if ($this->findT($lowerBrowser, ['OPR' => 'Opera', 'UCBrowser' => 'UC Browser', 'YaBrowser' => 'Yandex', 'Iceweasel' => 'Firefox', 'Icecat' => 'Firefox', 'CriOS' => 'Chrome', 'Edg' => 'Edge', 'XiaoMi/MiuiBrowser' => 'MiuiBrowser'], $key, $browser)) { $version = $result['version'][$key]; } else if ($this->find($lowerBrowser, 'Playstation Vita', $key, $platform)) { @@ -116,7 +118,7 @@ public function parse($userAgent = null) { } } } - else if ($this->find($lowerBrowser, ['Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome'], $key, $browser)) { + else if ($this->find($lowerBrowser, ['Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome', 'SailfishBrowser'], $key, $browser)) { $version = $result['version'][$key]; } else if ($rv_result && $this->find($lowerBrowser, 'Trident')) { diff --git a/src/app/code/community/Luigifab/Apijs/controllers/Apijs/CacheController.php b/src/app/code/community/Luigifab/Apijs/controllers/Apijs/CacheController.php index e79296d..b75b54a 100644 --- a/src/app/code/community/Luigifab/Apijs/controllers/Apijs/CacheController.php +++ b/src/app/code/community/Luigifab/Apijs/controllers/Apijs/CacheController.php @@ -1,10 +1,10 @@ - * Copyright 2019-2020 | Fabrice Creuzot + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) + * Copyright 2019-2021 | Fabrice Creuzot * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -72,7 +72,7 @@ public function clearCacheAction() { $this->_getSession()->addSuccess($this->__('The image cache was cleaned.')); } } - catch (Exception $e) { + catch (Throwable $e) { $this->_getSession()->addError($e->getMessage()); } diff --git a/src/app/code/community/Luigifab/Apijs/controllers/Apijs/MediaController.php b/src/app/code/community/Luigifab/Apijs/controllers/Apijs/MediaController.php index 257ed0e..a514c3e 100644 --- a/src/app/code/community/Luigifab/Apijs/controllers/Apijs/MediaController.php +++ b/src/app/code/community/Luigifab/Apijs/controllers/Apijs/MediaController.php @@ -1,10 +1,10 @@ - * Copyright 2019-2020 | Fabrice Creuzot + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) + * Copyright 2019-2021 | Fabrice Creuzot * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -38,7 +38,7 @@ private function disableAllBuffer() { for ($i = 0; $i < ob_get_level(); $i++) ob_end_clean(); } - catch (Exception $e) { } + catch (Throwable $e) { } echo ' '; } @@ -99,7 +99,7 @@ public function uploadWidgetAction() { $success[] = $filepath; } - catch (Exception $e) { + catch (Throwable $e) { $errors[] = $e->getMessage(); } } @@ -107,7 +107,7 @@ public function uploadWidgetAction() { // retour $result = $this->formatResult($success, $errors, 'ok'); } - catch (Exception $e) { + catch (Throwable $e) { $result = $e->getMessage(); } @@ -203,7 +203,7 @@ public function uploadProductAction() { $success[] = $filepath; } - catch (Exception $e) { + catch (Throwable $e) { $errors[] = $e->getMessage(); } } @@ -233,7 +233,7 @@ public function uploadProductAction() { // html $result = $this->formatResult($success, $errors, $help->renderGalleryBlock($product)); } - catch (Exception $e) { + catch (Throwable $e) { $result = $e->getMessage(); } @@ -275,7 +275,7 @@ public function saveAction() { // html $result = $this->formatResult(null, null, Mage::helper('apijs')->renderGalleryBlock($product)); } - catch (Exception $e) { + catch (Throwable $e) { $result = $e->getMessage(); } @@ -363,7 +363,7 @@ public function removeAction() { // html $result = $this->formatResult(null, null, $help->renderGalleryBlock($product)); } - catch (Exception $e) { + catch (Throwable $e) { $result = $e->getMessage(); } diff --git a/src/app/code/community/Luigifab/Apijs/controllers/Apijs/WysiwygController.php b/src/app/code/community/Luigifab/Apijs/controllers/Apijs/WysiwygController.php index f01c1a2..7b29e63 100644 --- a/src/app/code/community/Luigifab/Apijs/controllers/Apijs/WysiwygController.php +++ b/src/app/code/community/Luigifab/Apijs/controllers/Apijs/WysiwygController.php @@ -1,10 +1,10 @@ - * Copyright 2019-2020 | Fabrice Creuzot + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) + * Copyright 2019-2021 | Fabrice Creuzot * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify @@ -149,7 +149,7 @@ public function renameFileAction() { Mage::app()->getCacheInstance()->cleanType('block_html'); } } - catch (Exception $e) { + catch (Throwable $e) { $result = ['error' => true, 'message' => $e->getMessage()]; $this->getResponse()->setBody(json_encode($result)); } diff --git a/src/app/code/community/Luigifab/Apijs/etc/adminhtml.xml b/src/app/code/community/Luigifab/Apijs/etc/adminhtml.xml index 70e9e42..c4ef253 100644 --- a/src/app/code/community/Luigifab/Apijs/etc/adminhtml.xml +++ b/src/app/code/community/Luigifab/Apijs/etc/adminhtml.xml @@ -3,7 +3,7 @@ * Created D/26/02/2012 * Updated D/09/02/2020 * - * Copyright 2008-2020 | Fabrice Creuzot (luigifab) + * Copyright 2008-2021 | Fabrice Creuzot (luigifab) * https://www.luigifab.fr/openmage/apijs * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Apijs/etc/config.xml b/src/app/code/community/Luigifab/Apijs/etc/config.xml index ed83646..c3fefd6 100644 --- a/src/app/code/community/Luigifab/Apijs/etc/config.xml +++ b/src/app/code/community/Luigifab/Apijs/etc/config.xml @@ -1,9 +1,9 @@