From 98a16f18e63a978fb951c87247df2d8dd637ff27 Mon Sep 17 00:00:00 2001 From: Fabrice Creuzot Date: Mon, 1 Jan 2024 20:00:00 +0000 Subject: [PATCH] Version 4.6.0 --- README.md | 9 +- .../Block/Adminhtml/Config/Addresses.php | 49 ++++++ .../Block/Adminhtml/Config/Fields.php | 2 +- .../Block/Adminhtml/Config/Heading.php | 2 +- .../Block/Adminhtml/Config/Help.php | 12 +- .../Versioning/Block/Adminhtml/Config/Ip.php | 2 +- .../Versioning/Block/Adminhtml/History.php | 8 +- .../Block/Adminhtml/History/Grid.php | 8 +- .../Versioning/Block/Adminhtml/Repository.php | 20 +-- .../Block/Adminhtml/Repository/Grid.php | 2 +- .../Versioning/Block/Adminhtml/Status.php | 28 +-- .../Luigifab/Versioning/Helper/Data.php | 11 +- .../Luigifab/Versioning/Model/Demo.php | 2 +- .../Luigifab/Versioning/Model/History.php | 22 +-- .../Luigifab/Versioning/Model/Interface.php | 8 +- .../Luigifab/Versioning/Model/Observer.php | 67 +++----- .../Luigifab/Versioning/Model/Scm.php | 24 ++- .../Luigifab/Versioning/Model/Scm/Git.php | 162 ++++++++++-------- .../Versioning/Model/Source/Array.php | 56 ++++++ .../Versioning/Model/Source/Number.php | 2 +- .../Luigifab/Versioning/Model/Source/Type.php | 12 +- .../Luigifab/Versioning/Model/Upgrade.php | 73 ++++---- .../Versioning/RepositoryController.php | 25 +-- .../Luigifab/Versioning/etc/adminhtml.xml | 2 +- .../Luigifab/Versioning/etc/config.xml | 7 +- .../Luigifab/Versioning/etc/jstranslator.xml | 2 +- .../Luigifab/Versioning/etc/system.xml | 29 ++-- .../code/community/Luigifab/Versioning/readme | 25 +-- .../default/layout/luigifab/versioning.xml | 30 ++-- .../luigifab/versioning/forgotpassword.phtml | 10 +- .../template/luigifab/versioning/login.phtml | 10 +- src/app/etc/modules/Luigifab_Versioning.xml | 2 +- src/app/locale/de_AT/Luigifab_Versioning.csv | 1 - src/app/locale/de_CH/Luigifab_Versioning.csv | 1 - src/app/locale/de_DE/Luigifab_Versioning.csv | 1 - src/app/locale/es_AR/Luigifab_Versioning.csv | 1 - src/app/locale/es_CL/Luigifab_Versioning.csv | 1 - src/app/locale/es_CO/Luigifab_Versioning.csv | 1 - src/app/locale/es_CR/Luigifab_Versioning.csv | 1 - src/app/locale/es_ES/Luigifab_Versioning.csv | 1 - src/app/locale/es_MX/Luigifab_Versioning.csv | 1 - src/app/locale/es_PA/Luigifab_Versioning.csv | 1 - src/app/locale/es_PE/Luigifab_Versioning.csv | 1 - src/app/locale/es_VE/Luigifab_Versioning.csv | 1 - src/app/locale/fr_CA/Luigifab_Versioning.csv | 1 - src/app/locale/fr_CH/Luigifab_Versioning.csv | 1 - src/app/locale/fr_FR/Luigifab_Versioning.csv | 1 - src/app/locale/it_CH/Luigifab_Versioning.csv | 1 - src/app/locale/it_IT/Luigifab_Versioning.csv | 1 - src/app/locale/pl_PL/Luigifab_Versioning.csv | 1 - src/app/locale/pt_BR/Luigifab_Versioning.csv | 1 - src/app/locale/pt_PT/Luigifab_Versioning.csv | 1 - src/errors/404.php | 6 +- src/errors/503.php | 6 +- src/errors/config/readme | 2 +- src/errors/page.php | 22 ++- src/errors/processor.php | 88 ++++++---- src/errors/report.php | 6 +- src/errors/upgrade.php | 6 +- .../css/luigifab/versioning/styles.css | 13 +- .../css/luigifab/versioning/styles.min.css | 4 +- .../luigifab/versioning/styles.min.css.map | 2 +- .../default/js/luigifab/versioning/app.js | 12 +- .../default/js/luigifab/versioning/app.min.js | 4 +- .../js/luigifab/versioning/app.min.js.map | 2 +- 65 files changed, 519 insertions(+), 397 deletions(-) create mode 100644 src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Addresses.php create mode 100644 src/app/code/community/Luigifab/Versioning/Model/Source/Array.php diff --git a/README.md b/README.md index 62b465b..ea914f8 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,11 @@ Stop russian war. **🇺🇦 Free Ukraine!** A module to automatize the updates using GIT for [OpenMage](https://github.com/OpenMage/magento-lts). -For more information, go to https://www.luigifab.fr/openmage/versioning (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/openmage/versioning (IPv6 is required). -This repository is a releases mirror. To install the module, please use the composer key available in the documentation. - -- Current version: 4.5.3 (10/10/2023) +- Current version: 4.6.0 (01/01/2024) - Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3 - 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+ +- License: GNU GPL 2.0+ If you like, take some of your time to improve the translations, go to https://bit.ly/2HyCCEc. diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Addresses.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Addresses.php new file mode 100644 index 0000000..385db0e --- /dev/null +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Addresses.php @@ -0,0 +1,49 @@ + + * https://github.com/luigifab/openmage-versioning + * + * This program is free software, you can redistribute it or modify + * it under the terms of the GNU General Public License (GPL) as published + * by the free software foundation, either version 2 of the license, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but without any warranty, without even the implied warranty of + * merchantability or fitness for a particular purpose. See the + * GNU General Public License (GPL) for more details. + */ + +class Luigifab_Versioning_Block_Adminhtml_Config_Addresses extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract { + + public function _prepareToRender() { + + if (str_contains($this->getElement()->getHtmlId(), 'email')) { + $this->addColumn('email', [ + 'label' => $this->__('Email Address'), + 'style' => 'width:95%;', + 'class' => 'input-text required-entry validate-email', + ]); + unset($this->_columns['addr']); + } + else { + $this->addColumn('addr', [ + 'label' => 'IPv4 / IPv6', + 'style' => 'width:95%;', + 'class' => 'input-text required-entry', + ]); + unset($this->_columns['email']); + } + + $this->_addAfter = false; + } + + protected function _toHtml() { + $html = parent::_toHtml(); + $this->_isPreparedToRender = false; + return $html; + } +} \ No newline at end of file diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Fields.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Fields.php index d207795..3250f49 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Fields.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Fields.php @@ -3,7 +3,7 @@ * Created S/30/09/2017 * Updated D/01/10/2017 * - * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Heading.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Heading.php index 4af3c1f..cd03bdd 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Heading.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Heading.php @@ -3,7 +3,7 @@ * Created J/07/02/2013 * Updated S/03/12/2022 * - * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Help.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Help.php index afedd88..d45f271 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Help.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Help.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -23,13 +23,13 @@ public function render(Varien_Data_Form_Element_Abstract $element) { $msg = $this->checkChanges(); if ($msg !== true) - return sprintf('

%s %s Stop russian war. 🇺🇦 Free Ukraine! | %3$s | ⚠ IPv6

%s
%s

', - 'Luigifab/Versioning', $this->helper('versioning')->getVersion(), 'luigifab.fr/openmage/versioning', + return sprintf('

%s %s Stop russian war. 🇺🇦 Free Ukraine! | github.com | %4$s - ⚠ IPv6

%5$s
%6$s

', + 'Luigifab/Versioning', $this->helper('versioning')->getVersion(), 'openmage-versioning', 'luigifab.fr/openmage/versioning', $this->__('INCOMPLETE MODULE INSTALLATION'), $this->__('Changes in %s are not present. Please read the documentation.', $msg)); - return sprintf('

%s %s Stop russian war. 🇺🇦 Free Ukraine! | %3$s | ⚠ IPv6

', - 'Luigifab/Versioning', $this->helper('versioning')->getVersion(), 'luigifab.fr/openmage/versioning'); + return sprintf('

%s %s Stop russian war. 🇺🇦 Free Ukraine! | github.com | %4$s - ⚠ IPv6

', + 'Luigifab/Versioning', $this->helper('versioning')->getVersion(), 'openmage-versioning', 'luigifab.fr/openmage/versioning'); } protected function checkChanges() { diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Ip.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Ip.php index 2488b69..80c1568 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Ip.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Config/Ip.php @@ -3,7 +3,7 @@ * Created S/04/02/2017 * Updated S/03/12/2022 * - * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/History.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/History.php index 0ccbb73..df60396 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/History.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/History.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -35,13 +35,13 @@ public function __construct() { $this->_addButton('back', [ 'label' => $this->__('Back'), 'onclick' => "setLocation('".$this->getUrl('*/*/index')."');", - 'class' => 'back' + 'class' => 'back', ]); $this->_addButton('status', [ 'label' => $this->__('Repository status'), 'onclick' => "setLocation('".$this->getUrl('*/*/status')."');", - 'class' => 'go' + 'class' => 'go', ]); } diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/History/Grid.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/History/Grid.php index 14341a5..979b799 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/History/Grid.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/History/Grid.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -35,8 +35,8 @@ public function __construct() { protected function _prepareCollection() { - $page = $this->getParam($this->getVarNamePage(), 1); - $size = $this->getParam($this->getVarNameLimit(), 20); + $page = (int) $this->getParam($this->getVarNamePage(), 1); + $size = (int) $this->getParam($this->getVarNameLimit(), 20); $this->setCollection(Mage::getModel('versioning/history')->init($page, $size)); return parent::_prepareCollection(); diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Repository.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Repository.php index c629f42..d0bfa5f 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Repository.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Repository.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -37,7 +37,7 @@ public function __construct() { 'label' => 'diff', 'title' => $this->__('Show diff'), 'onclick' => "versioning.goDiff('".$this->getUrl('*/*/status', ['from' => 'abc', 'to' => 'abc'])."');", - 'class' => 'go' + 'class' => 'go', ]); } @@ -45,27 +45,27 @@ public function __construct() { 'label' => 'log', 'title' => $this->__('Updates history'), 'onclick' => "setLocation('".$this->getUrl('*/*/history')."');", - 'class' => 'go' + 'class' => 'go', ]); $this->_addButton('status', [ 'label' => 'status', 'title' => $this->__('Repository status'), 'onclick' => "setLocation('".$this->getUrl('*/*/status')."');", - 'class' => 'go' + 'class' => 'go', ]); if (is_file($this->helper('versioning')->getMaintenanceFlag())) { $this->_addButton('maintenance_flag', [ 'label' => $this->__('Remove the maintenance page'), 'onclick' => "versioning.cancelFlag('".$this->getUrl('*/*/delMaintenanceFlag')."');", - 'class' => 'delpage delete' + 'class' => 'delpage delete', ]); } else { $this->_addButton('maintenance_flag', [ 'label' => $this->__('Enable the maintenance page'), - 'onclick' => "versioning.confirmFlag('".$this->getUrl('*/*/addMaintenanceFlag')."', this.textContent, '".$this->helper('versioning')->getMaintenanceInfo()."');" + 'onclick' => "versioning.confirmFlag('".$this->getUrl('*/*/addMaintenanceFlag')."', this.textContent, '".$this->helper('versioning')->getMaintenanceInfo()."');", ]); } @@ -73,13 +73,13 @@ public function __construct() { $this->_addButton('upgrade_flag', [ 'label' => $this->__('Remove the update page'), 'onclick' => "versioning.cancelFlag('".$this->getUrl('*/*/delUpgradeFlag')."');", - 'class' => 'delpage delete' + 'class' => 'delpage delete', ]); } else { $this->_addButton('upgrade_flag', [ 'label' => $this->__('Enable the update page'), - 'onclick' => "versioning.confirmFlag('".$this->getUrl('*/*/addUpgradeFlag')."', this.textContent, '".$this->helper('versioning')->getUpgradeInfo()."');" + 'onclick' => "versioning.confirmFlag('".$this->getUrl('*/*/addUpgradeFlag')."', this.textContent, '".$this->helper('versioning')->getUpgradeInfo()."');", ]); } } @@ -102,7 +102,7 @@ public function getGridHtml() { 'parents' => $commit->getData('parents'), 'branch' => $commit->getData('branch'), 'col' => $commit->getData('column'), - 'row' => $cnt-- + 'row' => $cnt--, ]; } diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Repository/Grid.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Repository/Grid.php index 714f2bd..74bac34 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Repository/Grid.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Repository/Grid.php @@ -3,7 +3,7 @@ * Created S/03/12/2011 * Updated S/19/02/2022 * - * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Status.php b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Status.php index 237e42f..97a457c 100644 --- a/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Status.php +++ b/src/app/code/community/Luigifab/Versioning/Block/Adminhtml/Status.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -48,20 +48,20 @@ public function __construct() { $this->_addButton('back', [ 'label' => $this->__('Back'), 'onclick' => "setLocation('".$this->getUrl('*/*/index')."');", - 'class' => 'back' + 'class' => 'back', ]); $this->_addButton('log', [ 'label' => $this->__('Updates history'), 'onclick' => "setLocation('".$this->getUrl('*/*/history')."');", - 'class' => 'go' + 'class' => 'go', ]); if (!empty($from)) { $this->_addButton('status', [ 'label' => $this->__('Repository status'), 'onclick' => "setLocation('".$this->getUrl('*/*/status')."');", - 'class' => 'go' + 'class' => 'go', ]); } } @@ -77,12 +77,20 @@ public function getGridHtml() { if (!empty($dir)) $dir = str_replace(['"','\'','|','\\'], '', $dir); - if (!empty($from)) - return '
'.$system->getCurrentDiffStatus($from, $to, $dir, $excl).'
'. - '
'.$system->getCurrentDiff($from, $to, $dir, $excl).'
'; + if (empty($from)) + $html = '
'.$system->getCurrentStatus($dir, $excl).'
'. + '
'.$system->getCurrentDiff(null, null, $dir, $excl, true).'
'. + '
'.$system->getCurrentDiff(null, null, $dir, $excl).'
'; else - return '
'.$system->getCurrentStatus($dir, $excl).'
'. - '
'.$system->getCurrentDiff(null, null, $dir, $excl).'
'; + $html = '
'.$system->getCurrentDiffStatus($from, $to, $dir, $excl).'
'. + '
'.$system->getCurrentDiff($from, $to, $dir, $excl).'
'; + + $dir = $system->getRootDir(); + + // @see https://github.com/luigifab/webext-openfileeditor + return preg_replace_callback('#(=== )(.*/.*\.\w+)'.$data[2].' + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -67,8 +67,9 @@ public function getNumber($value, array $options = []) { return Zend_Locale_Format::toNumber($value, $options); } - public function getNumberToHumanSize(int $number) { + public function getNumberToHumanSize($number) { + $number = (float) $number; if ($number < 1) { $data = ''; } @@ -189,10 +190,6 @@ public function getUpgradeInfo() { return base64_encode(str_replace(['<', '>'], ['[', ']'], $html)); } - public function getLock() { - return Mage::getBaseDir('var').'/versioning.lock'; - } - public function getHistoryLog() { return Mage::getBaseDir('log').'/versioning.csv'; } diff --git a/src/app/code/community/Luigifab/Versioning/Model/Demo.php b/src/app/code/community/Luigifab/Versioning/Model/Demo.php index a19d71f..55c3966 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/Demo.php +++ b/src/app/code/community/Luigifab/Versioning/Model/Demo.php @@ -3,7 +3,7 @@ * Created V/02/11/2012 * Updated D/18/07/2021 * - * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Versioning/Model/History.php b/src/app/code/community/Luigifab/Versioning/Model/History.php index 0190c21..54023f2 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/History.php +++ b/src/app/code/community/Luigifab/Versioning/Model/History.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -20,21 +20,15 @@ class Luigifab_Versioning_Model_History extends Varien_Data_Collection { protected $_pageSize = true; - protected $_isCollectionLoaded = true; - // collection spécifique (ou pas...) avec un simple array - // avec un jolie bricolage mais c'est pas très important public function init(int $page, int $size) { - $help = Mage::helper('versioning'); - $file = $help->getHistoryLog(); + $helper = Mage::helper('versioning'); + $file = $helper->getHistoryLog(); if (is_file($file)) { - // recherche des données - // construction d'un premier tableau $resource = fopen($file, 'rb'); - while (!empty($line = fgetcsv($resource, 50000, ',', '`'))) { if (!empty($line[0])) { @@ -67,7 +61,7 @@ public function init(int $page, int $size) { // remplace le texte par sa version traduite if ((mb_stripos($item->getData('details'), 'An upgrade is already underway') === 0) || (mb_stripos($item->getData('details'), 'An update is in progress') === 0)) - $item->setData('details', $help->__('Stop! Stop! Stop! An update is in progress.')); + $item->setData('details', $helper->__('Stop! Stop! Stop! An update is in progress.')); $this->_items[] = $item; } @@ -75,12 +69,10 @@ public function init(int $page, int $size) { fclose($resource); - // première sauvegarde $this->_items = array_reverse($this->_items); $this->_totalRecords = count($this->_items); - // collection finale - // construction de second tableau + // final collection $items = []; $from = ($page - 1) * $size; $to = ($page - 1) * $size + $size; @@ -90,8 +82,8 @@ public function init(int $page, int $size) { $items[] = $item; } - // seconde sauvegarde $this->_items = $items; + $this->_setIsLoaded(); } return $this; diff --git a/src/app/code/community/Luigifab/Versioning/Model/Interface.php b/src/app/code/community/Luigifab/Versioning/Model/Interface.php index ef50462..6886658 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/Interface.php +++ b/src/app/code/community/Luigifab/Versioning/Model/Interface.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -25,13 +25,15 @@ public function isSoftwareInstalled(); public function getSoftwareVersion(); + public function getRootDir(); + public function getCommitsCollection(bool $local = false); public function getCurrentBranch(); public function getCurrentRevision(); - public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = null); + public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = null, $cached = false); public function getCurrentDiffStatus($from = null, $to = null, $dir = null, $excl = null); diff --git a/src/app/code/community/Luigifab/Versioning/Model/Observer.php b/src/app/code/community/Luigifab/Versioning/Model/Observer.php index f944f1b..edb67d0 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/Observer.php +++ b/src/app/code/community/Luigifab/Versioning/Model/Observer.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -20,32 +20,27 @@ class Luigifab_Versioning_Model_Observer { // EVENT admin_system_config_changed_section_versioning (adminhtml) - // Erreur 503 (maintenance.flag) + // Error 503 (maintenance.flag) // = (*.csv) Titre de la page / Titre / Contenu texte ou html / Texte avec délai du rechargement automatique // = (error503.ip) Désactiver la page à partir des adresses IP suivantes - // Mise à jour (upgrade.flag) + // Update (upgrade.flag) // = (*.csv) Titre de la page / Titre / Contenu texte ou html / Texte avec délai du rechargement automatique // = (upgrade.ip) Désactiver la page à partir des adresses IP suivantes - // Rapport d'erreur + // Error report // = (*.csv) Titre de la page / Titre / Contenu texte ou html // = (report.ip) Afficher le rapport à partir des adresses IP suivantes // = (config.dat) Envoyer le rapport par email à - // Erreur 404 système + // System error 404 // = (*.csv) Titre de la page / Titre / Contenu texte ou html public function updateConfig() { - // vérification du répertoire $dir = BP.'/errors/config'; - if (!is_dir($dir)) @mkdir($dir, 0755); if (!is_dir($dir) || !is_writable($dir)) Mage::throwException('Directory errors/config does not exist or is not writable.'); - // récupération de toute la configuration utile - // enregistre le tout dans un tableau avant d'enregistrer le tout dans les fichiers *.csv, config.ip et config.dat $global = []; - foreach (Mage::app()->getWebsites() as $website) { foreach ($website->getGroups() as $group) { foreach ($group->getStores() as $store) { @@ -60,43 +55,35 @@ public function updateConfig() { $this->updateIpConfig($global); } - - // $global ici dans l'ordre, mais l'ordre n'a aucune importance + // $global // fr_FR => Array // [error503_pagetitle] [error503_title] [error503_content] [error503_autoreload] [error503_byip] // [upgrade_pagetitle] [upgrade_title] [upgrade_content] [upgrade_autoreload] [upgrade_byip] // [report_pagetitle] [report_title] [report_content] [report_byip] [report_email] // [report_pagetitle] [report_title] [error404_content] - // pagetitle/title, content, autoreload (*.csv) + // *title* *content* *autoreload* (*.csv) protected function updateTranslations(array $global) { $translations = []; - - // extraction des traductions locale par locale - // il se peut aussi qu'il n'y en ait qu'une seule foreach ($global as $locale => $config) { - // extraction de la configuration pour la locale foreach ($config as $key => $value) { $value = str_replace('"', '""', trim($value)); - // versioning/downtime/*title if (str_contains($key, 'title')) { if (!empty($value)) $translations[$locale][] = '"'.$key.'","'.$value.'"'; } - // versioning/downtime/*content else if (str_contains($key, 'content')) { if (!empty($value) && (mb_strpos($value, '<') === 0)) $translations[$locale][] = '"'.$key.'","'.$value.'"'; else if (!empty($value)) - $translations[$locale][] = '"'.$key.'","

'.str_replace("\n", '
', $value).'

"'; + $translations[$locale][] = '"'.$key.'","

'.str_replace("\n", '
', $value).'

"'; } - // versioning/downtime/*autoreload else if (str_contains($key, 'autoreload')) { if (!empty($value) && str_contains($value, '[') && str_contains($value, ']')) @@ -105,31 +92,31 @@ protected function updateTranslations(array $global) { } } - // sauvegarde des données (format CSV) array_map('unlink', glob(BP.'/errors/config/*.csv')); - if (count($translations) > 0) { - foreach ($translations as $locale => $values) - file_put_contents(BP.'/errors/config/'.$locale.'.csv', implode("\n", $values)); - } + foreach ($translations as $locale => $values) + file_put_contents(BP.'/errors/config/'.$locale.'.csv', implode("\n", $values)); } - // email, custom (config.dat) + // *email* *custom* (config.dat) protected function updateDataConfig(array $global) { $config = []; - - // extraction de la configuration foreach (reset($global) as $key => $value) { $value = trim($value); if (empty($value)) continue; - if (str_contains($key, '_email') || str_contains($key, '_custom')) + if (str_contains($key, 'email')) { + $value = @unserialize($value, ['allowed_classes' => false]); + $value = array_map(static function ($val) { return array_pop($val); }, array_values($value)); + $config[] = $key.'='.implode(' ', $value); + } + else if (str_contains($key, 'custom')) { $config[] = $key.'='.str_replace('=', '', $value); + } } - // sauvegarde des données dans un seul fichier (format CSV) $file = BP.'/errors/config/config.dat'; if (count($config) > 0) file_put_contents($file, implode("\n", $config)); @@ -137,30 +124,26 @@ protected function updateDataConfig(array $global) { unlink($file); } - // byip (error503.ip upgrade.ip report.ip) + // *byip* (error503.ip upgrade.ip report.ip) protected function updateIpConfig(array $global) { $config = []; - - // extraction de la configuration foreach (reset($global) as $key => $value) { $value = trim($value); if (empty($value)) continue; - if (str_contains($key, '_byip')) { + if (str_contains($key, 'byip')) { $key = substr($key, 0, strrpos($key, '_')); // not mb_substr mb_strrpos - $value = array_filter(preg_split('#\s+#', $value)); + $value = @unserialize($value, ['allowed_classes' => false]); + $value = array_map(static function ($val) { return array_pop($val); }, array_values($value)); $config[$key][] = '-'.implode("-\n-", $value).'-'; } } - // sauvegarde des données dans plusieurs fichiers (format spécial) array_map('unlink', glob(BP.'/errors/config/*.ip')); - if (count($config) > 0) { - foreach ($config as $key => $values) - file_put_contents(BP.'/errors/config/'.$key.'.ip', implode("\n", $values)); - } + foreach ($config as $key => $values) + file_put_contents(BP.'/errors/config/'.$key.'.ip', implode("\n", $values)); } } \ No newline at end of file diff --git a/src/app/code/community/Luigifab/Versioning/Model/Scm.php b/src/app/code/community/Luigifab/Versioning/Model/Scm.php index edbfd9d..fad85b7 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/Scm.php +++ b/src/app/code/community/Luigifab/Versioning/Model/Scm.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -20,6 +20,7 @@ abstract class Luigifab_Versioning_Model_Scm implements Luigifab_Versioning_Model_Interface { protected $_version; + protected $_branch; protected $_revision; protected $_items; @@ -29,7 +30,7 @@ public function getType() { public function isSoftwareInstalled() { - exec(escapeshellcmd($this->getType()).' --version', $data, $return); + exec(escapeshellcmd($this->_code).' --version', $data, $return); if ($return == 0) { $data = preg_replace('#[^\d.]#', '', trim(implode($data))); @@ -47,16 +48,25 @@ public function getSoftwareVersion() { return $this->_version; } + public function getRootDir() { + + $dir = realpath(BP); + if (!is_dir($dir.'/.'.$this->_code)) + $dir = realpath(BP.'/..'); + + return $dir; + } + protected function markExcludedFile(string $line, array $excl, bool $check = false) { - // par min + // min if ((mb_stripos($line, '.min.') !== false) && in_array('min', $excl)) { if ($check) return true; $line = str_replace('.min.', '.§{#{§min§}#}§.', $line); } - // par extension + // extension $ign = mb_strrpos($line, '.'); $ign = mb_substr($line, ($ign > 0) ? $ign + 1 : mb_strrpos($line, '/') + 1); if (in_array($ign, $excl)) { @@ -65,7 +75,7 @@ protected function markExcludedFile(string $line, array $excl, bool $check = fal $line = str_replace('.'.$ign, '.§{#{§'.$ign.'§}#}§', $line); } - // par nom de fichier + // file name $ign = basename($line); if (in_array($ign, $excl)) { $line = str_replace('/'.$ign, '/§{#{§'.$ign.'§}#}§', $line); @@ -73,7 +83,7 @@ protected function markExcludedFile(string $line, array $excl, bool $check = fal return true; } - // par nom de dossier + // directory name $ign = explode('/', $line); foreach ($ign as $itm) { $ign = in_array($itm, $excl); diff --git a/src/app/code/community/Luigifab/Versioning/Model/Scm/Git.php b/src/app/code/community/Luigifab/Versioning/Model/Scm/Git.php index 85816aa..6633f51 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/Scm/Git.php +++ b/src/app/code/community/Luigifab/Versioning/Model/Scm/Git.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -19,10 +19,7 @@ class Luigifab_Versioning_Model_Scm_Git extends Luigifab_Versioning_Model_Scm { - // singleton protected $_code = 'git'; - protected $_branch; - protected $_revision; // génère une collection à partir de l'historique des commits du dépôt @@ -44,9 +41,9 @@ public function getCommitsCollection(bool $local = false) { $configsh = realpath('../.git/ssh/config.sh'); } - $help = Mage::helper('versioning'); - $desc = version_compare($this->getSoftwareVersion(), '1.7.2', '>=') ? '%B' : '%s%n%b'; - $line = (int) Mage::getStoreConfig('versioning/scm/number'); + $helper = Mage::helper('versioning'); + $desc = version_compare($this->getSoftwareVersion(), '1.7.2', '>=') ? '%B' : '%s%n%b'; + $line = (int) Mage::getStoreConfig('versioning/scm/number'); // lecture de l'historique des commits if ($local) { @@ -82,12 +79,12 @@ public function getCommitsCollection(bool $local = false) { $pos = mb_stripos($data, 'escapeEntities($data)); + $data = 'Response:'."\n".(empty($data) ? 'empty' : $helper->escapeEntities($data)); - $error = ($local ? $help->__('Can not get local commits history.') : $help->__('Can not get remote commits history.')). + $error = ($local ? $helper->__('Can not get local commits history.') : $helper->__('Can not get remote commits history.')). "\n\n". '
'.trim($data).
-					($local ? '' : "\n".'The git/config file:'."\n".$help->escapeEntities(trim(file_get_contents(is_file('./.git/config') ? './.git/config' : '../.git/config'))))
+					($local ? '' : "\n".'The git/config file:'."\n".$helper->escapeEntities(trim(file_get_contents(is_file('./.git/config') ? './.git/config' : '../.git/config'))))
 				.'
'; if ((PHP_SAPI != 'cli') && Mage::app()->getStore()->isAdmin() && Mage::getSingleton('admin/session')->isLoggedIn()) @@ -107,16 +104,15 @@ public function getCommitsCollection(bool $local = false) { $xml->loadXML(''.$data.''); // extraction des données - // construction de la collection des commits $this->_items = new Varien_Data_Collection(); - foreach ($xml->getElementsByTagName('log') as $logentry) { + foreach ($xml->getElementsByTagName('log') as $domNodeList) { - $revision = trim($logentry->getElementsByTagName('revno')->item(0)->firstChild->nodeValue); - $parents = trim($logentry->getElementsByTagName('parents')->item(0)->firstChild->nodeValue); - $author = trim($logentry->getElementsByTagName('committer')->item(0)->firstChild->nodeValue); - $timestamp = trim($logentry->getElementsByTagName('timestamp')->item(0)->firstChild->nodeValue); - $description = trim($logentry->getElementsByTagName('message')->item(0)->firstChild->nodeValue); + $revision = trim($domNodeList->getElementsByTagName('revno')->item(0)->firstChild->nodeValue); + $parents = trim($domNodeList->getElementsByTagName('parents')->item(0)->firstChild->nodeValue); + $author = trim($domNodeList->getElementsByTagName('committer')->item(0)->firstChild->nodeValue); + $timestamp = trim($domNodeList->getElementsByTagName('timestamp')->item(0)->firstChild->nodeValue); + $description = trim($domNodeList->getElementsByTagName('message')->item(0)->firstChild->nodeValue); preg_match('#\s*{([^}]+)}\s*$#', $description, $branch); if (!empty($branch)) { @@ -138,7 +134,7 @@ public function getCommitsCollection(bool $local = false) { $item->setData('parents', explode(' ', $parents)); $item->setData('date', date('c', strtotime($timestamp))); $item->setData('author', preg_replace('#<[^>]+>#', '', $author)); - $item->setData('description', $help->escapeEntities($description)); + $item->setData('description', $helper->escapeEntities($description)); $this->_items->addItem($item); } @@ -176,10 +172,11 @@ public function getCurrentRevision() { return $this->_revision; } - public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = null) { + public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = null, $cached = false) { - $help = Mage::helper('versioning'); + $helper = Mage::helper('versioning'); $limit = (int) Mage::getStoreConfig('versioning/general/diff_limit'); + $rename = (int) Mage::getStoreConfig('versioning/general/diff_rename'); $filter = Mage::getStoreConfig('versioning/general/diff_filter'); $cut = false; $ign = false; @@ -187,37 +184,42 @@ public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = nu // --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]] // Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), // have their Type changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). - // https://github.com/git/git/commit/36617af7ed594d1928554356d809bd611c642dd2 (ignore-blank-lines) - if (version_compare($this->getSoftwareVersion(), '1.8.4', '>=')) - $command = 'git diff -U'.$limit.' --diff-filter='.escapeshellarg($filter).' --ignore-all-space --ignore-blank-lines'; + // @see https://github.com/git/git/commit/36617af7ed594d1928554356d809bd611c642dd2 (ignore-blank-lines) + // @see https://github.com/git/git/commit/e8b2dc2c2a8415bfd180ecf5cc237a54e69ac2e9 (find-renames/M) + if (version_compare($this->getSoftwareVersion(), '2.18', '>=')) + $cmd = 'git diff -U'.$limit.' --diff-filter='.escapeshellarg($filter).' --ignore-all-space --ignore-blank-lines -M'.$rename; + else if (version_compare($this->getSoftwareVersion(), '1.8.4', '>=')) + $cmd = 'git diff -U'.$limit.' --diff-filter='.escapeshellarg($filter).' --ignore-all-space --ignore-blank-lines'; else if (version_compare($this->getSoftwareVersion(), '1.5', '>=')) - $command = 'git diff -U'.$limit.' --diff-filter='.escapeshellarg($filter).' --ignore-all-space'; + $cmd = 'git diff -U'.$limit.' --diff-filter='.escapeshellarg($filter).' --ignore-all-space'; else - $command = 'git diff -U'.$limit.' --diff-filter='.escapeshellarg($filter); + $cmd = 'git diff -U'.$limit.' --diff-filter='.escapeshellarg($filter); - // https://github.com/git/git/commit/296d4a94e7231a1d57356889f51bff57a1a3c5a1 (ignore-matching-lines) + // @see https://github.com/git/git/commit/296d4a94e7231a1d57356889f51bff57a1a3c5a1 (ignore-matching-lines) if (!empty($excl) && version_compare($this->getSoftwareVersion(), '2.30.0', '>=')) { if (str_contains($excl, 'copyright')) - $command .= ' --ignore-matching-lines " Copyright\s+©?\s*20[0-9][0-9](-20[0-9][0-9])? "'; + $cmd .= ' --ignore-matching-lines " Copyright\s+©?\s*20[0-9][0-9](-20[0-9][0-9])? "'; if (str_contains($excl, 'updatedat')) - $command .= ' --ignore-matching-lines " Updated [A-Z]/[0-9][0-9]/[0-9][0-9]/20[0-9][0-9]"'; + $cmd .= ' --ignore-matching-lines " Updated [A-Z]/[0-9][0-9]/[0-9][0-9]/20[0-9][0-9]"'; } if (!empty($from) && !empty($to)) - $command .= ' '.escapeshellarg($from).'..'.escapeshellarg($to); + $cmd .= ' '.escapeshellarg($from).'..'.escapeshellarg($to); else if (!empty($from)) - $command .= ' '.escapeshellarg($from).'..'; + $cmd .= ' '.escapeshellarg($from).'..'; + if ($cached) + $cmd = str_replace('git diff', 'git diff --cached', $cmd); if (!empty($dir)) - $command .= ' '.str_replace(' ', "' '", escapeshellarg($dir)); + $cmd .= ' '.str_replace(' ', "' '", escapeshellarg($dir)); if (!empty($excl)) $excl = explode(',', $excl); - // https://stackoverflow.com/a/55891251/2980105 (diff-highlight) + // @see https://stackoverflow.com/a/55891251/2980105 (diff-highlight) if (is_executable('/usr/share/doc/git/contrib/diff-highlight/diff-highlight')) - exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$command.' | /usr/share/doc/git/contrib/diff-highlight/diff-highlight', $lines); + exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$cmd.' | /usr/share/doc/git/contrib/diff-highlight/diff-highlight', $lines); else - exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$command, $lines); + exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$cmd, $lines); foreach ($lines as $i => $line) { @@ -235,7 +237,7 @@ public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = nu } else if (mb_stripos($line, 'diff --git a') === 0) { $cut = mb_stripos($line, '.min.') !== false; // 13 = mb_strlen('diff --git a/') - $lines[$i] = "\n".'=== '.mb_substr($help->escapeEntities($line), 13, mb_stripos($line, ' b/') - 13).''; + $lines[$i] = "\n".'=== '.mb_substr($helper->escapeEntities($line), 13, mb_stripos($line, ' b/') - 13).''; if (is_array($excl)) { $ign = $cut && in_array('min', $excl); $ign = $ign ?: $this->markExcludedFile($line, $excl, true); @@ -251,25 +253,25 @@ public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = nu } else if ($cut && (mb_strlen($line) > 1500)) { if ($line[0] == '+') - $lines[$i] = ''.mb_substr($help->escapeEntities($line), 0, 1500).'...'; + $lines[$i] = ''.mb_substr($helper->escapeEntities($line), 0, 1500).'...'; else if ($line[0] == '-') - $lines[$i] = ''.mb_substr($help->escapeEntities($line), 0, 1500).'...'; + $lines[$i] = ''.mb_substr($helper->escapeEntities($line), 0, 1500).'...'; else - $lines[$i] = mb_substr($help->escapeEntities($line), 0, 1500).'...'; + $lines[$i] = mb_substr($helper->escapeEntities($line), 0, 1500).'...'; $lines[$i] = str_replace(['', ''], '', $lines[$i]); } else if ($line[0] == '+') { - $lines[$i] = ''.$help->escapeEntities($line).''; + $lines[$i] = ''.$helper->escapeEntities($line).''; } else if ($line[0] == '-') { - $lines[$i] = ''.$help->escapeEntities($line).''; + $lines[$i] = ''.$helper->escapeEntities($line).''; } else { - $lines[$i] = $help->escapeEntities($line); + $lines[$i] = $helper->escapeEntities($line); } } - return ''.str_replace('\'', '', $command).''."\n". + return ''.str_replace('\'', '', $cmd).''."\n". 'Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R),'."\n". 'have their Type changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B).'."\n". str_replace(["\t", '', ''], [' ', '', ''], implode("\n", $lines)); @@ -277,82 +279,86 @@ public function getCurrentDiff($from = null, $to = null, $dir = null, $excl = nu public function getCurrentDiffStatus($from = null, $to = null, $dir = null, $excl = null) { - $help = Mage::helper('versioning'); + $helper = Mage::helper('versioning'); + $rename = (int) Mage::getStoreConfig('versioning/general/diff_rename'); - // https://github.com/git/git/commit/36617af7ed594d1928554356d809bd611c642dd2 (ignore-blank-lines) - if (version_compare($this->getSoftwareVersion(), '1.8.4', '>=')) - $command = 'git diff --name-status --ignore-all-space --ignore-blank-lines'; + // @see https://github.com/git/git/commit/36617af7ed594d1928554356d809bd611c642dd2 (ignore-blank-lines) + // @see https://github.com/git/git/commit/e8b2dc2c2a8415bfd180ecf5cc237a54e69ac2e9 (find-renames/M); + if (version_compare($this->getSoftwareVersion(), '2.18', '>=')) + $cmd = 'git diff --name-status --ignore-all-space --ignore-blank-lines -M'.$rename; + else if (version_compare($this->getSoftwareVersion(), '1.8.4', '>=')) + $cmd = 'git diff --name-status --ignore-all-space --ignore-blank-lines'; else if (version_compare($this->getSoftwareVersion(), '1.5', '>=')) - $command = 'git diff --name-status --ignore-all-space'; + $cmd = 'git diff --name-status --ignore-all-space'; else - $command = 'git diff --name-status'; + $cmd = 'git diff --name-status'; if (!empty($from) && !empty($to)) - $command .= ' '.escapeshellarg($from).'..'.escapeshellarg($to); + $cmd .= ' '.escapeshellarg($from).'..'.escapeshellarg($to); else if (!empty($from)) - $command .= ' '.escapeshellarg($from).'..'; + $cmd .= ' '.escapeshellarg($from).'..'; if (!empty($dir)) - $command .= ' '.str_replace(' ', "' '", escapeshellarg($dir)); + $cmd .= ' '.str_replace(' ', "' '", escapeshellarg($dir)); if (!empty($excl)) $excl = explode(',', $excl); if (is_executable('/usr/share/doc/git/contrib/diff-highlight/diff-highlight')) - exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$command.' | /usr/share/doc/git/contrib/diff-highlight/diff-highlight', $lines); + exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$cmd.' | /usr/share/doc/git/contrib/diff-highlight/diff-highlight', $lines); else - exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$command, $lines); + exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$cmd, $lines); // Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), Type changed (T), Unmerged (U), Unknown (X), pairing Broken (B) // C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy) foreach ($lines as $i => $line) { if (mb_stripos($line, 'A') === 0) { - $lines[$i] = str_replace('A'."\t", "\t\t".str_replace('-', ' ', $help->__('new file:-------')), $line); + $lines[$i] = str_replace('A'."\t", "\t\t".str_replace('-', ' ', $helper->__('new file:-------')), $line); } else if (mb_stripos($line, 'C') === 0) { - $lines[$i] = preg_replace("#C\d*\t#", "\t\t".str_replace('-', ' ', $help->__('copied:---------')), $line); + $lines[$i] = preg_replace("#C\d*\t#", "\t\t".str_replace('-', ' ', $helper->__('copied:---------')), $line); } else if (mb_stripos($line, 'D') === 0) { - $lines[$i] = str_replace('D'."\t", "\t\t".str_replace('-', ' ', $help->__('deleted:--------')), $line); + $lines[$i] = str_replace('D'."\t", "\t\t".str_replace('-', ' ', $helper->__('deleted:--------')), $line); } else if (mb_stripos($line, 'M') === 0) { - $lines[$i] = str_replace('M'."\t", "\t\t".str_replace('-', ' ', $help->__('modified:-------')), $line); + $lines[$i] = str_replace('M'."\t", "\t\t".str_replace('-', ' ', $helper->__('modified:-------')), $line); } else if (mb_stripos($line, 'R') === 0) { - $tmp = preg_split('#\s+#', $line); + $tmp = (array) preg_split('#\s+#', $line); // (yes) if ((count($tmp) == 3) && (($pos = mb_strrpos($tmp[2], '/')) !== false) && (mb_stripos($tmp[1], mb_substr($tmp[2], 0, $pos)) === 0)) $line = $tmp[0]."\t".$tmp[1].' > '.mb_substr($tmp[2], $pos + 1); - $lines[$i] = preg_replace("#R\d*\t#", "\t\t".str_replace('-', ' ', $help->__('renamed:--------')), $line); + $lines[$i] = preg_replace("#R\d*\t#", "\t\t".str_replace('-', ' ', $helper->__('renamed:--------')), $line); } else if (mb_stripos($line, 'T') === 0) { - $lines[$i] = str_replace('T'."\t", "\t\t".str_replace('-', ' ', $help->__('type changed:---')), $line); + $lines[$i] = str_replace('T'."\t", "\t\t".str_replace('-', ' ', $helper->__('type changed:---')), $line); } else if (mb_stripos($line, 'U') === 0) { - $lines[$i] = str_replace('U'."\t", "\t\t".str_replace('-', ' ', $help->__('unmerged:-------')), $line); + $lines[$i] = str_replace('U'."\t", "\t\t".str_replace('-', ' ', $helper->__('unmerged:-------')), $line); } else if (mb_stripos($line, 'X') === 0) { - $lines[$i] = str_replace('X'."\t", "\t\t".str_replace('-', ' ', $help->__('unknown:--------')), $line); + $lines[$i] = str_replace('X'."\t", "\t\t".str_replace('-', ' ', $helper->__('unknown:--------')), $line); } else if (mb_stripos($line, 'B') === 0) { - $lines[$i] = str_replace('B'."\t", "\t\t".str_replace('-', ' ', $help->__('pairing broken:-')), $line); + $lines[$i] = str_replace('B'."\t", "\t\t".str_replace('-', ' ', $helper->__('pairing broken:-')), $line); } if (is_array($excl)) $lines[$i] = $this->markExcludedFile($lines[$i], $excl); } - return ''.str_replace('\'', '', $command).''."\n". - $help->__('For the current diff')."\n\n". - str_replace(["\t", '§{#{§', '§}#}§', '', ''], [' ', '', '', '', ''], $help->escapeEntities(implode("\n", $lines))); + return ''.str_replace('\'', '', $cmd).''."\n". + $helper->__('For the current diff')."\n\n". + str_replace(["\t", '§{#{§', '§}#}§', '', ''], [' ', '', '', '', ''], $helper->escapeEntities(implode("\n", $lines))); } public function getCurrentStatus($dir = null, $excl = null) { - $command = 'git status'; + $cmd = 'git status'; if (!empty($dir)) - $command .= ' '.str_replace(' ', "' '", escapeshellarg($dir)); + $cmd .= ' '.str_replace(' ', "' '", escapeshellarg($dir)); - exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$command, $lines); + exec('LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8 '.$cmd, $lines); if (!empty($excl)) { $excl = explode(',', $excl); @@ -362,7 +368,7 @@ public function getCurrentStatus($dir = null, $excl = null) { } } - return ''.str_replace('\'', '', $command).''."\n". + return ''.str_replace('\'', '', $cmd).''."\n". str_replace(['§{#{§', '§}#}§'], ['', ''], Mage::helper('versioning')->escapeEntities(implode("\n", $lines))); } @@ -375,22 +381,26 @@ public function upgradeToRevision($object, $log, $revision) { $revision = escapeshellarg($revision); if (is_dir('../.git/')) { - exec('export LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8; + exec(' + export LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8; echo "git fetch" >> '.$log.'; git fetch; echo "git clean -f -d" >> '.$log.'; git clean -f -d .. >> '.$log.' 2>&1; echo "git reset --hard '.$revision.'" >> '.$log.'; - git reset --hard '.$revision.' >> '.$log.' 2>&1;', $data, $val); + git reset --hard '.$revision.' >> '.$log.' 2>&1; + ', $data, $val); } else { - exec('export LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8; + exec(' + export LANG='.Mage::getSingleton('core/locale')->getLocaleCode().'.utf8; echo "git fetch" >> '.$log.'; git fetch; echo "git clean -f -d" >> '.$log.'; git clean -f -d >> '.$log.' 2>&1; echo "git reset --hard '.$revision.'" >> '.$log.'; - git reset --hard '.$revision.' >> '.$log.' 2>&1;', $data, $val); + git reset --hard '.$revision.' >> '.$log.' 2>&1; + ', $data, $val); } $data = trim(file_get_contents($log)); @@ -399,7 +409,7 @@ public function upgradeToRevision($object, $log, $revision) { $object->writeCommand($data); foreach ($lines as $line) { - if (mb_stripos($line, 'fatal: ') === 0) + if (str_starts_with($line, 'fatal: ')) Mage::throwException(str_replace('fatal: ', '', $line)); } diff --git a/src/app/code/community/Luigifab/Versioning/Model/Source/Array.php b/src/app/code/community/Luigifab/Versioning/Model/Source/Array.php new file mode 100644 index 0000000..ddf1d72 --- /dev/null +++ b/src/app/code/community/Luigifab/Versioning/Model/Source/Array.php @@ -0,0 +1,56 @@ + + * https://github.com/luigifab/openmage-versioning + * + * This program is free software, you can redistribute it or modify + * it under the terms of the GNU General Public License (GPL) as published + * by the free software foundation, either version 2 of the license, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but without any warranty, without even the implied warranty of + * merchantability or fitness for a particular purpose. See the + * GNU General Public License (GPL) for more details. + */ + +class Luigifab_Versioning_Model_Source_Array extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array { + + // @deprecated + protected function _afterLoad() { + + $data = $this->getValue(); + + if (!is_array($data)) { + if (empty($data) || ($data == 'a:0:{}')) { + $this->setValue(false); + } + else if (str_contains($data, '{')) { + try { + $this->setValue(@unserialize($data, ['allowed_classes' => false])); + } + catch (Throwable $t) { + Mage::logException($t); + $this->setValue(false); + } + } + else { + $ukey = '_'.substr(md5($this->getPath()), 0, 10).'_'; // not mb_substr + $uuid = round(microtime(true) * 1000 - 10000); + // compatibility with previous version + $values = []; + $isAddr = str_contains($this->getPath(), 'byip'); + $array = array_filter(preg_split('#\s+#', $data)); + foreach ($array as $idx => $value) + $values[$ukey.($uuid + $idx)] = [$isAddr ? 'addr' : 'email' => $value]; + + $this->setValue($values); + } + } + + return $this; + } +} \ No newline at end of file diff --git a/src/app/code/community/Luigifab/Versioning/Model/Source/Number.php b/src/app/code/community/Luigifab/Versioning/Model/Source/Number.php index 701984b..57a07f8 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/Source/Number.php +++ b/src/app/code/community/Luigifab/Versioning/Model/Source/Number.php @@ -3,7 +3,7 @@ * Created S/03/03/2012 * Updated S/19/02/2022 * - * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Versioning/Model/Source/Type.php b/src/app/code/community/Luigifab/Versioning/Model/Source/Type.php index d60bc0d..ed18318 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/Source/Type.php +++ b/src/app/code/community/Luigifab/Versioning/Model/Source/Type.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -26,14 +26,14 @@ public function toOptionArray() { if (empty($this->_options)) { $this->_options = []; - $help = Mage::helper('versioning'); - $keys = Mage::getConfig()->getNode('global/models/versioning/adaptators')->asArray(); + $helper = Mage::helper('versioning'); + $keys = Mage::getConfig()->getNode('global/models/versioning/adaptators')->asArray(); foreach ($keys as $key) { $system = Mage::getSingleton($key); $this->_options[$key] = ['value' => $key, 'label' => $system->isSoftwareInstalled() ? - $help->__('%s (%s)', strtoupper($system->getType()), $system->getSoftwareVersion()) : // not mb_strtoupper - $help->__('%s (not available)', strtoupper($system->getType()))]; // not mb_strtoupper + $helper->__('%s (%s)', strtoupper($system->getType()), $system->getSoftwareVersion()) : // not mb_strtoupper + $helper->__('%s (not available)', strtoupper($system->getType()))]; // not mb_strtoupper } ksort($this->_options); diff --git a/src/app/code/community/Luigifab/Versioning/Model/Upgrade.php b/src/app/code/community/Luigifab/Versioning/Model/Upgrade.php index d03c599..f1f0759 100644 --- a/src/app/code/community/Luigifab/Versioning/Model/Upgrade.php +++ b/src/app/code/community/Luigifab/Versioning/Model/Upgrade.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -21,17 +21,18 @@ class Luigifab_Versioning_Model_Upgrade { // désactivation des tampons (sauf si zlib.output_compression) // cela permet d'afficher la page au fur et à mesure de l'avancement - // https://stackoverflow.com/a/25835968 + // @see https://stackoverflow.com/a/25835968 public function disableAllBuffer() { header('Content-Encoding: chunked'); header('Connection: Keep-Alive'); - ini_set('max_execution_time', 900); - ini_set('output_buffering', 0); - ini_set('implicit_flush', 1); - ini_set('display_errors', 1); + ini_set('max_execution_time', (PHP_VERSION_ID < 80100) ? '900' : 900); + ini_set('output_buffering', (PHP_VERSION_ID < 80100) ? '0' : 0); + ini_set('implicit_flush', (PHP_VERSION_ID < 80100) ? '1' : 1); + ini_set('display_errors', (PHP_VERSION_ID < 80100) ? '1' : 1); ob_implicit_flush(); ignore_user_abort(true); + set_time_limit(900); try { while (ob_get_level() > 0) @@ -46,10 +47,10 @@ public function disableAllBuffer() { // log les informations de la mise à jour public function process(string $targetRevision, bool $flag) { - $help = Mage::helper('versioning'); - $system = $help->getSystem(); - $lock = $help->getLock(); - $log = $help->getLastLog(); + $helper = Mage::helper('versioning'); + $lock = Mage::getBaseDir('var').'/versioning.lock'; + $system = $helper->getSystem(); + $log = $helper->getLastLog(); try { // données de l'historique @@ -58,7 +59,7 @@ public function process(string $targetRevision, bool $flag) { 'date' => date('c'), // 0 'current_rev' => $system->getCurrentRevision(), // 1 'target_rev' => $targetRevision, // 2 - 'remote_addr' => $help->getIpAddr(), // 3 + 'remote_addr' => $helper->getIpAddr(), // 3 'user' => Mage::getSingleton('admin/session')->getData('user')->getData('username'), // 4 'duration' => microtime(true), // 5 'status' => 'Upgrade in progress', // 6 @@ -66,7 +67,7 @@ public function process(string $targetRevision, bool $flag) { ]; // ÉTAPE 1 - $this->writeTitle($help->__('1) Locking and configuration check')); + $this->writeTitle($helper->__('1) Locking and configuration check')); if (Mage::getSingleton('admin/session')->isAllowed('tools/versioning/upgrade') !== true) Mage::throwException('Not authorized'); @@ -78,15 +79,15 @@ public function process(string $targetRevision, bool $flag) { unlink($log); if (!empty($H['branch'])) - $this->writeNotice($help->__('Repository: %s / Branch: %s / Current revision: %s / Requested revision: %s', + $this->writeNotice($helper->__('Repository: %s / Branch: %s / Current revision: %s / Requested revision: %s', $system->getType(), $H['branch'], $H['current_rev'], $targetRevision)); else - $this->writeNotice($help->__('Repository: %s / Current revision: %s / Requested revision: %s', + $this->writeNotice($helper->__('Repository: %s / Current revision: %s / Requested revision: %s', $system->getType(), $H['current_rev'], $targetRevision)); file_put_contents($lock, $H['current_rev'].'/'.$H['target_rev'].' from '.$H['remote_addr'].' by '.$H['user'], LOCK_EX); if ($flag) - copy($lock, $help->getUpgradeFlag()); + copy($lock, $helper->getUpgradeFlag()); // ÉTAPE 2 et 3 // avec les événements before et after @@ -94,18 +95,18 @@ public function process(string $targetRevision, bool $flag) { Mage::dispatchEvent('admin_versioning_upgrade_before', ['repository' => $system, 'revision' => $targetRevision, 'controller' => $this]); - $this->writeTitle($help->__('2) Updating'), true); + $this->writeTitle($helper->__('2) Updating'), true); $system->upgradeToRevision($this, $log, $targetRevision); $this->writeEvent('admin_versioning_upgrade_after...'); Mage::dispatchEvent('admin_versioning_upgrade_after', ['repository' => $system, 'revision' => $targetRevision, 'controller' => $this]); - $this->writeTitle($help->__('3) Cache'), true); + $this->writeTitle($helper->__('3) Cache'), true); $this->clearAllCache(); // ÉTAPE 4 - $this->writeTitle($help->__('4) Unlocking')); + $this->writeTitle($helper->__('4) Unlocking')); unlink($lock); $H['duration'] = ceil(microtime(true) - $H['duration']); @@ -113,11 +114,11 @@ public function process(string $targetRevision, bool $flag) { $result = [ 'url' => '*/versioning_repository/index', - 'title' => $help->__('Update completed (revision %s)', $targetRevision), - 'error' => false + 'title' => $helper->__('Update completed (revision %s)', $targetRevision), + 'error' => false, ]; - Mage::getSingleton('adminhtml/session')->addSuccess($help->__('Update to revision %s completed.', $targetRevision)); + Mage::getSingleton('adminhtml/session')->addSuccess($helper->__('Update to revision %s completed.', $targetRevision)); } catch (Throwable $t) { @@ -127,18 +128,18 @@ public function process(string $targetRevision, bool $flag) { if (in_array($t->getMessage(), ['Not authorized', 'An update is in progress'])) { if ($t->getMessage() == 'An update is in progress') { - $this->writeError($help->__('Stop! Stop! Stop! An update is in progress.')); - Mage::getSingleton('adminhtml/session')->addError($help->__('Please wait, an update is in progress.')); + $this->writeError($helper->__('Stop! Stop! Stop! An update is in progress.')); + Mage::getSingleton('adminhtml/session')->addError($helper->__('Please wait, an update is in progress.')); } else { - $this->writeError($help->__('You are not authorized to perform this operation.')); - Mage::getSingleton('adminhtml/session')->addError($help->__('You are not authorized to perform this operation.')); + $this->writeError($helper->__('You are not authorized to perform this operation.')); + Mage::getSingleton('adminhtml/session')->addError($helper->__('You are not authorized to perform this operation.')); } $result = [ 'url' => '*/versioning_repository/index', - 'title' => $help->__('Update error (revision %s)', $targetRevision), - 'error' => true + 'title' => $helper->__('Update error (revision %s)', $targetRevision), + 'error' => true, ]; } else { @@ -152,19 +153,19 @@ public function process(string $targetRevision, bool $flag) { Mage::dispatchEvent('admin_versioning_upgrade_after', ['repository' => $system, 'revision' => $targetRevision, 'controller' => $this, 'exception' => $t]); - $this->writeTitle($help->__('4) Unlocking'), true); + $this->writeTitle($helper->__('4) Unlocking'), true); if (is_file($lock)) unlink($lock); $result = [ 'url' => '*/versioning_repository/history', - 'title' => $help->__('Update error (revision %s)', $targetRevision), - 'error' => true + 'title' => $helper->__('Update error (revision %s)', $targetRevision), + 'error' => true, ]; } } - file_put_contents($help->getHistoryLog(), '`'.implode('`,`', $H).'`'."\n", FILE_APPEND | LOCK_EX); + file_put_contents($helper->getHistoryLog(), '`'.implode('`,`', $H).'`'."\n", FILE_APPEND | LOCK_EX); return $result; } @@ -172,22 +173,27 @@ public function process(string $targetRevision, bool $flag) { // ajoute un peu de code HTML pour faire plus jolie protected function writeTitle(string $data, bool $endEvent = false) { echo $endEvent ? ''."\n".$data."\n" : "\n".$data."\n"; + return $this; } protected function writeEvent(string $data) { echo '',$data,"\n"; + return $this; } public function writeError(string $data) { echo '',$data,'',"\n"; + return $this; } public function writeNotice(string $data) { echo '',$data,'',"\n"; + return $this; } public function writeCommand(string $data) { echo '',$data,'',"\n"; + return $this; } // tente de vider totalement le cache (du moins essaye) @@ -225,9 +231,10 @@ protected function clearAllCache() { Mage::getBaseDir('media').'/css/', Mage::getBaseDir('media').'/css_secure/', Mage::getBaseDir('media').'/js_secure/', - Mage::getBaseDir('media').'/js/' + Mage::getBaseDir('media').'/js/', ]; exec('rm -rf '.implode(' ', array_map('escapeshellarg', $dirs))); + return $this; } } \ No newline at end of file diff --git a/src/app/code/community/Luigifab/Versioning/controllers/Versioning/RepositoryController.php b/src/app/code/community/Luigifab/Versioning/controllers/Versioning/RepositoryController.php index 02187d6..c341a61 100644 --- a/src/app/code/community/Luigifab/Versioning/controllers/Versioning/RepositoryController.php +++ b/src/app/code/community/Luigifab/Versioning/controllers/Versioning/RepositoryController.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -85,10 +85,12 @@ public function historyAction() { public function addUpgradeFlagAction() { if (!Mage::getSingleton('admin/session')->isFirstPageAfterLogin()) { - $help = Mage::helper('versioning'); - $file = $help->getUpgradeFlag(); - if (!is_file($file)) - file_put_contents($file, sprintf('Flag from %s by %s', $help->getIpAddr(), Mage::getSingleton('admin/session')->getData('user')->getData('username'))); + $helper = Mage::helper('versioning'); + $file = $helper->getUpgradeFlag(); + if (!is_file($file)) { + $user = Mage::getSingleton('admin/session')->getData('user')->getData('username'); + file_put_contents($file, sprintf('Flag from %s by %s', $helper->getIpAddr(), $user)); + } } $this->_redirect('*/*/index'); @@ -97,10 +99,12 @@ public function addUpgradeFlagAction() { public function addMaintenanceFlagAction() { if (!Mage::getSingleton('admin/session')->isFirstPageAfterLogin()) { - $help = Mage::helper('versioning'); - $file = $help->getMaintenanceFlag(); - if (!is_file($file)) - file_put_contents($file, sprintf('Flag from %s by %s', $help->getIpAddr(), Mage::getSingleton('admin/session')->getData('user')->getData('username'))); + $helper = Mage::helper('versioning'); + $file = $helper->getMaintenanceFlag(); + if (!is_file($file)) { + $user = Mage::getSingleton('admin/session')->getData('user')->getData('username'); + file_put_contents($file, sprintf('Flag from %s by %s', $helper->getIpAddr(), $user)); + } } $this->_redirect('*/*/index'); @@ -137,6 +141,7 @@ public function upgradeAction() { Mage::getSingleton('adminhtml/session')->addError($this->__('Please configure the module before using it.')); return $this->_redirect('*/system_config/edit', ['section' => 'versioning']); } + if (empty($revision) || Mage::getSingleton('admin/session')->isFirstPageAfterLogin()) { return $this->_redirect('*/versioning_repository/index'); } diff --git a/src/app/code/community/Luigifab/Versioning/etc/adminhtml.xml b/src/app/code/community/Luigifab/Versioning/etc/adminhtml.xml index a3f79d5..918b62e 100644 --- a/src/app/code/community/Luigifab/Versioning/etc/adminhtml.xml +++ b/src/app/code/community/Luigifab/Versioning/etc/adminhtml.xml @@ -3,7 +3,7 @@ * Created J/22/12/2011 * Updated D/09/02/2020 * - * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify diff --git a/src/app/code/community/Luigifab/Versioning/etc/config.xml b/src/app/code/community/Luigifab/Versioning/etc/config.xml index cc6bc27..bdf8e02 100644 --- a/src/app/code/community/Luigifab/Versioning/etc/config.xml +++ b/src/app/code/community/Luigifab/Versioning/etc/config.xml @@ -1,9 +1,9 @@ - + skin_css @@ -26,15 +26,15 @@ media="screen, projection" + + + + + - - skin_css - css/luigifab/versioning/styles.min.css - media="screen, projection" - skin_js js/luigifab/versioning/app.min.js @@ -54,25 +54,15 @@ - - - skin_css - css/luigifab/versioning/styles.min.css - media="screen, projection" - - + + - - skin_css - css/luigifab/versioning/styles.min.css - media="screen, projection" - skin_js js/luigifab/versioning/app.min.js diff --git a/src/app/design/adminhtml/default/default/template/luigifab/versioning/forgotpassword.phtml b/src/app/design/adminhtml/default/default/template/luigifab/versioning/forgotpassword.phtml index 54a41f9..b8af21e 100644 --- a/src/app/design/adminhtml/default/default/template/luigifab/versioning/forgotpassword.phtml +++ b/src/app/design/adminhtml/default/default/template/luigifab/versioning/forgotpassword.phtml @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -18,8 +18,8 @@ */ $locale = substr(Mage::getSingleton('core/locale')->getLocaleCode(), 0, 2); -$help = $this->helper('versioning'); -$cssjs = $help->getCssJsHtml(); +$helper = $this->helper('versioning'); +$cssjs = $helper->getCssJsHtml(); ?> @@ -61,7 +61,7 @@ $cssjs = $help->getCssJsHtml();
diff --git a/src/app/design/adminhtml/default/default/template/luigifab/versioning/login.phtml b/src/app/design/adminhtml/default/default/template/luigifab/versioning/login.phtml index 5006a1a..667a686 100644 --- a/src/app/design/adminhtml/default/default/template/luigifab/versioning/login.phtml +++ b/src/app/design/adminhtml/default/default/template/luigifab/versioning/login.phtml @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -18,8 +18,8 @@ */ $locale = substr(Mage::getSingleton('core/locale')->getLocaleCode(), 0, 2); -$help = $this->helper('versioning'); -$cssjs = $help->getCssJsHtml(); +$helper = $this->helper('versioning'); +$cssjs = $helper->getCssJsHtml(); ?> @@ -65,7 +65,7 @@ $cssjs = $help->getCssJsHtml();
diff --git a/src/app/etc/modules/Luigifab_Versioning.xml b/src/app/etc/modules/Luigifab_Versioning.xml index 22ea875..ae34320 100644 --- a/src/app/etc/modules/Luigifab_Versioning.xml +++ b/src/app/etc/modules/Luigifab_Versioning.xml @@ -3,7 +3,7 @@ * Created S/03/12/2011 * Updated M/28/02/2017 * - * Copyright 2011-2023 | Fabrice Creuzot (luigifab) + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify diff --git a/src/app/locale/de_AT/Luigifab_Versioning.csv b/src/app/locale/de_AT/Luigifab_Versioning.csv index 304dc2f..7222b09 100644 --- a/src/app/locale/de_AT/Luigifab_Versioning.csv +++ b/src/app/locale/de_AT/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Text mit automatischer Ladungsfrist" "Use [10] for a 10-seconds delay.","Für einen 10-Sekunden-Frist [10] benutzen." "Disable the page from these IP addresses","Ab den folgenden IP-Adressen Seite deaktivieren" -"Separate addresses by a space.","E-Mail-Adressen durch einen Abstand trennen." "Your IP address","Ihre IP-Adresse" "Update (upgrade.flag)","Update (upgrade.flag)" "Error report","Fehlerbericht" diff --git a/src/app/locale/de_CH/Luigifab_Versioning.csv b/src/app/locale/de_CH/Luigifab_Versioning.csv index 304dc2f..7222b09 100644 --- a/src/app/locale/de_CH/Luigifab_Versioning.csv +++ b/src/app/locale/de_CH/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Text mit automatischer Ladungsfrist" "Use [10] for a 10-seconds delay.","Für einen 10-Sekunden-Frist [10] benutzen." "Disable the page from these IP addresses","Ab den folgenden IP-Adressen Seite deaktivieren" -"Separate addresses by a space.","E-Mail-Adressen durch einen Abstand trennen." "Your IP address","Ihre IP-Adresse" "Update (upgrade.flag)","Update (upgrade.flag)" "Error report","Fehlerbericht" diff --git a/src/app/locale/de_DE/Luigifab_Versioning.csv b/src/app/locale/de_DE/Luigifab_Versioning.csv index 304dc2f..7222b09 100644 --- a/src/app/locale/de_DE/Luigifab_Versioning.csv +++ b/src/app/locale/de_DE/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Text mit automatischer Ladungsfrist" "Use [10] for a 10-seconds delay.","Für einen 10-Sekunden-Frist [10] benutzen." "Disable the page from these IP addresses","Ab den folgenden IP-Adressen Seite deaktivieren" -"Separate addresses by a space.","E-Mail-Adressen durch einen Abstand trennen." "Your IP address","Ihre IP-Adresse" "Update (upgrade.flag)","Update (upgrade.flag)" "Error report","Fehlerbericht" diff --git a/src/app/locale/es_AR/Luigifab_Versioning.csv b/src/app/locale/es_AR/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_AR/Luigifab_Versioning.csv +++ b/src/app/locale/es_AR/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/es_CL/Luigifab_Versioning.csv b/src/app/locale/es_CL/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_CL/Luigifab_Versioning.csv +++ b/src/app/locale/es_CL/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/es_CO/Luigifab_Versioning.csv b/src/app/locale/es_CO/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_CO/Luigifab_Versioning.csv +++ b/src/app/locale/es_CO/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/es_CR/Luigifab_Versioning.csv b/src/app/locale/es_CR/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_CR/Luigifab_Versioning.csv +++ b/src/app/locale/es_CR/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/es_ES/Luigifab_Versioning.csv b/src/app/locale/es_ES/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_ES/Luigifab_Versioning.csv +++ b/src/app/locale/es_ES/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/es_MX/Luigifab_Versioning.csv b/src/app/locale/es_MX/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_MX/Luigifab_Versioning.csv +++ b/src/app/locale/es_MX/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/es_PA/Luigifab_Versioning.csv b/src/app/locale/es_PA/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_PA/Luigifab_Versioning.csv +++ b/src/app/locale/es_PA/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/es_PE/Luigifab_Versioning.csv b/src/app/locale/es_PE/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_PE/Luigifab_Versioning.csv +++ b/src/app/locale/es_PE/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/es_VE/Luigifab_Versioning.csv b/src/app/locale/es_VE/Luigifab_Versioning.csv index 7b38fee..d4c24aa 100644 --- a/src/app/locale/es_VE/Luigifab_Versioning.csv +++ b/src/app/locale/es_VE/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto con periodo de recarga automática" "Use [10] for a 10-seconds delay.","Utilizar [10] por 10 segundos de espera." "Disable the page from these IP addresses","Desactivar la página a partir de las siguientes direcciones IP" -"Separate addresses by a space.","Separar las direcciones por un espacio." "Your IP address","Su dirección IP" "Update (upgrade.flag)","Actualización (upgrade.flag)" "Error report","Informe de error" diff --git a/src/app/locale/fr_CA/Luigifab_Versioning.csv b/src/app/locale/fr_CA/Luigifab_Versioning.csv index 32eebf0..4fa281f 100644 --- a/src/app/locale/fr_CA/Luigifab_Versioning.csv +++ b/src/app/locale/fr_CA/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texte avec délai du rechargement automatique" "Use [10] for a 10-seconds delay.","Utiliser [10] pour 10 secondes de délai." "Disable the page from these IP addresses","Désactiver la page à partir des adresses IP suivantes" -"Separate addresses by a space.","Séparer les adresses par un espace." "Your IP address","Votre adresse IP" "Update (upgrade.flag)","Mise à jour (upgrade.flag)" "Error report","Rapport d'erreur" diff --git a/src/app/locale/fr_CH/Luigifab_Versioning.csv b/src/app/locale/fr_CH/Luigifab_Versioning.csv index 6569bbe..b07ea4f 100644 --- a/src/app/locale/fr_CH/Luigifab_Versioning.csv +++ b/src/app/locale/fr_CH/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texte avec délai du rechargement automatique" "Use [10] for a 10-seconds delay.","Utiliser [10] pour 10 secondes de délai." "Disable the page from these IP addresses","Désactiver la page à partir des adresses IP suivantes" -"Separate addresses by a space.","Séparer les adresses par un espace." "Your IP address","Votre adresse IP" "Update (upgrade.flag)","Mise à jour (upgrade.flag)" "Error report","Rapport d'erreur" diff --git a/src/app/locale/fr_FR/Luigifab_Versioning.csv b/src/app/locale/fr_FR/Luigifab_Versioning.csv index 6569bbe..b07ea4f 100644 --- a/src/app/locale/fr_FR/Luigifab_Versioning.csv +++ b/src/app/locale/fr_FR/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texte avec délai du rechargement automatique" "Use [10] for a 10-seconds delay.","Utiliser [10] pour 10 secondes de délai." "Disable the page from these IP addresses","Désactiver la page à partir des adresses IP suivantes" -"Separate addresses by a space.","Séparer les adresses par un espace." "Your IP address","Votre adresse IP" "Update (upgrade.flag)","Mise à jour (upgrade.flag)" "Error report","Rapport d'erreur" diff --git a/src/app/locale/it_CH/Luigifab_Versioning.csv b/src/app/locale/it_CH/Luigifab_Versioning.csv index cc992ec..37e45da 100644 --- a/src/app/locale/it_CH/Luigifab_Versioning.csv +++ b/src/app/locale/it_CH/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Testo con proroga della ricarica automatica" "Use [10] for a 10-seconds delay.","Utilizzare [10] per 10 secondi di proroga." "Disable the page from these IP addresses","Disabilitare la pagine a partire dai seguenti indirizzi IP" -"Separate addresses by a space.","Separare gli indirizzi con uno spazio." "Your IP address","Il vostro indirizzo IP" "Update (upgrade.flag)","Aggiornamento (upgrade.flag)" "Error report","Rapporto d'errore" diff --git a/src/app/locale/it_IT/Luigifab_Versioning.csv b/src/app/locale/it_IT/Luigifab_Versioning.csv index cc992ec..37e45da 100644 --- a/src/app/locale/it_IT/Luigifab_Versioning.csv +++ b/src/app/locale/it_IT/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Testo con proroga della ricarica automatica" "Use [10] for a 10-seconds delay.","Utilizzare [10] per 10 secondi di proroga." "Disable the page from these IP addresses","Disabilitare la pagine a partire dai seguenti indirizzi IP" -"Separate addresses by a space.","Separare gli indirizzi con uno spazio." "Your IP address","Il vostro indirizzo IP" "Update (upgrade.flag)","Aggiornamento (upgrade.flag)" "Error report","Rapporto d'errore" diff --git a/src/app/locale/pl_PL/Luigifab_Versioning.csv b/src/app/locale/pl_PL/Luigifab_Versioning.csv index ce605a3..1411945 100644 --- a/src/app/locale/pl_PL/Luigifab_Versioning.csv +++ b/src/app/locale/pl_PL/Luigifab_Versioning.csv @@ -1,5 +1,4 @@ "Page title","Tytuł strony" -"Separate addresses by a space.","Oddziel adresy przerwą." "INCOMPLETE MODULE INSTALLATION","NIEKOMPLETNA INSTALACJA MODUŁU" "Changes in %s are not present. Please read the documentation.","Wystąpił błąd (%s)." "IP address","Adres IP" diff --git a/src/app/locale/pt_BR/Luigifab_Versioning.csv b/src/app/locale/pt_BR/Luigifab_Versioning.csv index beb07af..b73bf7a 100644 --- a/src/app/locale/pt_BR/Luigifab_Versioning.csv +++ b/src/app/locale/pt_BR/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto com período de recarga automática" "Use [10] for a 10-seconds delay.","Usar [10] por 10 segundos de prazo." "Disable the page from these IP addresses","Desativar a página a partir dos endereços IP seguintes" -"Separate addresses by a space.","Separar os endereços por um espaço." "Your IP address","O seu endereço IP" "Update (upgrade.flag)","Atualização (upgrade.flag)" "Error report","Relatório de erro" diff --git a/src/app/locale/pt_PT/Luigifab_Versioning.csv b/src/app/locale/pt_PT/Luigifab_Versioning.csv index 00293f2..451156f 100644 --- a/src/app/locale/pt_PT/Luigifab_Versioning.csv +++ b/src/app/locale/pt_PT/Luigifab_Versioning.csv @@ -12,7 +12,6 @@ "Text with automatic reload period","Texto com período de recarga automática" "Use [10] for a 10-seconds delay.","Usar [10] por 10 segundos de prazo." "Disable the page from these IP addresses","Desativar a página a partir dos endereços IP seguintes" -"Separate addresses by a space.","Separar os endereços por um espaço." "Your IP address","O seu endereço IP" "Update (upgrade.flag)","Atualização (upgrade.flag)" "Error report","Relatório de erro" diff --git a/src/errors/404.php b/src/errors/404.php index 15aee84..0aa1e46 100644 --- a/src/errors/404.php +++ b/src/errors/404.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -20,7 +20,7 @@ chdir(defined('BP') ? BP.'/errors' : __DIR__); if (!empty($_SERVER['MAGE_IS_DEVELOPER_MODE']) || !empty($_ENV['MAGE_IS_DEVELOPER_MODE'])) { error_reporting(E_ALL); - ini_set('display_errors', 1); + ini_set('display_errors', (PHP_VERSION_ID < 80100) ? '1' : 1); ini_set('error_prepend_string', '
');
 	ini_set('error_append_string', '
'); } diff --git a/src/errors/503.php b/src/errors/503.php index b78161d..e4ade08 100644 --- a/src/errors/503.php +++ b/src/errors/503.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -20,7 +20,7 @@ chdir(defined('BP') ? BP.'/errors' : __DIR__); if (!empty($_SERVER['MAGE_IS_DEVELOPER_MODE']) || !empty($_ENV['MAGE_IS_DEVELOPER_MODE'])) { error_reporting(E_ALL); - ini_set('display_errors', 1); + ini_set('display_errors', (PHP_VERSION_ID < 80100) ? '1' : 1); ini_set('error_prepend_string', '
');
 	ini_set('error_append_string', '
'); } diff --git a/src/errors/config/readme b/src/errors/config/readme index 622326d..381757f 100644 --- a/src/errors/config/readme +++ b/src/errors/config/readme @@ -14,7 +14,7 @@ if (file_exists($maintenanceFile)) { exit; } // by -// https://www.luigifab.fr/openmage/versioning +// @see https://www.luigifab.fr/openmage/versioning if (is_file('./maintenance.flag') && (mb_stripos(getenv('REQUEST_URI'), '/admin/') === false)) { $ips = './errors/config/error503.ip'; $ip = empty(getenv('HTTP_X_FORWARDED_FOR')) ? false : explode(',', getenv('HTTP_X_FORWARDED_FOR')); diff --git a/src/errors/page.php b/src/errors/page.php index 16e4ca7..9f0ce55 100644 --- a/src/errors/page.php +++ b/src/errors/page.php @@ -1,9 +1,9 @@ + * Copyright 2011-2024 | Fabrice Creuzot (luigifab) * https://github.com/luigifab/openmage-versioning * * This program is free software, you can redistribute it or modify @@ -21,6 +21,7 @@ exit(0); $locale = substr($this->getData('locale'), 0, 2); // not mb_substr +$code = (string) $code; // int2string ?> @@ -46,8 +47,9 @@ } h1 { margin-bottom:1em; font-size:1.3em; font-weight:400; } p { margin:1em 0; font-size:0.85em; line-height:140%; } -pre { margin-top:3em; padding:2em; white-space:pre-wrap; word-break:break-all; background-color:#D0D0D0; } -pre span.line { color:#555; } +p.date { font-style:italic; color:#777; } +pre { margin-top:3em; padding:2em; line-height:135%; white-space:pre-wrap; word-break:break-all; background-color:#D0D0D0; } +pre::first-line { font-weight:bold; } @media (max-width:33rem),(max-device-width:33rem) { div.box { margin:0 1em 1em; width:auto; } pre { display:none; } @@ -56,11 +58,12 @@