Skip to content

Commit

Permalink
Version 4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed Jan 1, 2022
1 parent 5ab5709 commit dc0c847
Show file tree
Hide file tree
Showing 71 changed files with 382 additions and 286 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ For more information, go to https://www.luigifab.fr/openmage/versioning (IPv6 is

This repository is a releases mirror. To install the module, please use the composer key available in the documentation.

- Current version: 4.2.2 (08/08/2021)
- Compatibility: OpenMage 19.x / 20.x, PHP 7.2 / 7.3 / 7.4 / 8.0
- Current version: 4.4.0 (01/01/2022)
- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1
- 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+

If you like, take some of your time to improve the translations, go to https://bit.ly/2HyCCEc.
If you like, take some of your time to improve the translations, go to https://bit.ly/2HyCCEc.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
["src/errors/", "errors/"]
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created S/30/09/2017
* Updated D/01/10/2017
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created J/07/02/2013
* Updated D/18/07/2021
* Updated V/22/10/2021
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand All @@ -21,14 +21,14 @@ class Luigifab_Versioning_Block_Adminhtml_Config_Heading extends Mage_Adminhtml_

public function render(Varien_Data_Form_Element_Abstract $element) {

$locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $this->getStoreId());
$locale = Mage::getStoreConfig('general/locale/code', $this->getStoreId());

// exemple d'une adresse de base : https://mario/sites/14/web/(xyz/)(index.php/)
// exemple d'une adresse finale : https://mario/sites/14/web/errors/upgrade.php?lang=fr_FR
$url = Mage::app()->getDefaultStoreView()->getBaseUrl();
$url = preg_replace('#/[^/]+\.php\d*/#', '/', $url);

if (Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL))
if (Mage::getStoreConfigFlag('web/url/use_store'))
$url = str_replace('/'.Mage::app()->getDefaultStoreView()->getData('code').'/', '/', $url);

// versioning_downtime_error503.php versioning_downtime_error404.php
Expand All @@ -43,7 +43,17 @@ public function render(Varien_Data_Form_Element_Abstract $element) {
$element->getData('label'), $url, $this->__('Preview in %s', $this->getLocaleName($locale)));
}

private function getStoreId() {
protected function getLocaleName(string $code) {

$locales = Mage::getSingleton('core/locale')->getOptionLocales();

foreach ($locales as $locale) {
if ($locale['value'] == $code)
return $locale['label'];
}
}

protected function getStoreId() {

$store = $this->getRequest()->getParam('store');
$website = $this->getRequest()->getParam('website');
Expand All @@ -57,14 +67,4 @@ private function getStoreId() {

return $storeId;
}

private function getLocaleName(string $code) {

$locales = Mage::getSingleton('core/locale')->getOptionLocales();

foreach ($locales as $locale) {
if ($locale['value'] == $code)
return $locale['label'];
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created V/23/05/2014
* Updated L/24/05/2021
* Updated J/30/09/2021
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down Expand Up @@ -32,7 +32,7 @@ public function render(Varien_Data_Form_Element_Abstract $element) {
'Luigifab/Versioning', $this->helper('versioning')->getVersion(), 'luigifab.fr/openmage/versioning');
}

private function checkChanges() {
protected function checkChanges() {

$index = file_get_contents(BP.'/index.php');
if (mb_strpos($index, '::f{4}:\\d{1,3}') === false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created S/04/02/2017
* Updated D/20/05/2018
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created V/06/04/2012
* Updated J/30/07/2020
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created V/06/04/2012
* Updated D/07/02/2021
* Updated S/23/10/2021
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down Expand Up @@ -80,7 +80,7 @@ protected function _prepareColumns() {
]);

$this->addColumn('user', [
'header' => $this->__('User'),
'header' => $this->__('User Name'),
'index' => 'user',
'align' => 'center',
'sortable' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created S/03/12/2011
* Updated J/08/10/2020
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created S/03/12/2011
* Updated D/07/02/2021
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created L/13/02/2012
* Updated J/30/07/2020
* Updated J/25/11/2021
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand All @@ -28,19 +28,19 @@ public function __construct() {
$from = $this->getRequest()->getParam('from');
$to = $this->getRequest()->getParam('to');

if (!empty($from)) {
if (empty($from)) {
$this->_controller = 'adminhtml_status';
$this->_blockGroup = 'versioning';
$this->_headerText = empty($branch = $system->getCurrentBranch()) ?
$this->__('Differences between revisions %s and %s (%s)', $from, $to, $type) :
$this->__('Differences between revisions %s and %s (%s, %s)', $from, $to, $type, $branch);
$this->__('Repository status (%s)', $type) :
$this->__('Repository status (%s, %s)', $type, $branch);
}
else {
$this->_controller = 'adminhtml_status';
$this->_blockGroup = 'versioning';
$this->_headerText = empty($branch = $system->getCurrentBranch()) ?
$this->__('Repository status (%s)', $type) :
$this->__('Repository status (%s, %s)', $type, $branch);
$this->__('Differences between revisions %s and %s (%s)', $from, $to, $type) :
$this->__('Differences between revisions %s and %s (%s, %s)', $from, $to, $type, $branch);
}

$this->_removeButton('add');
Expand Down Expand Up @@ -81,7 +81,7 @@ public function getGridHtml() {
return '<pre lang="mul">'.$system->getCurrentDiffStatus($from, $to, $dir, $excl).'</pre>'.
'<pre lang="mul">'.$system->getCurrentDiff($from, $to, $dir, $excl).'</pre>';
else
return '<pre lang="mul">'.$system->getCurrentStatus($dir).'</pre>'.
return '<pre lang="mul">'.$system->getCurrentStatus($dir, $excl).'</pre>'.
'<pre lang="mul">'.$system->getCurrentDiff(null, null, $dir, $excl).'</pre>';
}

Expand Down
124 changes: 96 additions & 28 deletions src/app/code/community/Luigifab/Versioning/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created S/03/12/2011
* Updated J/08/07/2021
* Updated J/04/11/2021
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand All @@ -19,20 +19,6 @@

class Luigifab_Versioning_Helper_Data extends Mage_Core_Helper_Abstract {

public function getSystem() {

$system = Mage::registry('versioning');
if (!is_object($system)) {
$system = Mage::getStoreConfig('versioning/scm/type');
$system = empty($system) ?
new Varien_Object(['type' => 'GIT']) :
Mage::getSingleton((mb_stripos($system, '/') === false) ? 'versioning/scm_'.$system : $system);
Mage::register('versioning', $system);
}

return $system;
}

public function getVersion() {
return (string) Mage::getConfig()->getModuleConfig('Luigifab_Versioning')->version;
}
Expand All @@ -43,26 +29,108 @@ public function _(string $data, ...$values) {
}

public function escapeEntities($data, bool $quotes = false) {
return htmlspecialchars($data, $quotes ? ENT_SUBSTITUTE | ENT_COMPAT : ENT_SUBSTITUTE | ENT_NOQUOTES);
return empty($data) ? $data : htmlspecialchars($data, $quotes ? ENT_SUBSTITUTE | ENT_COMPAT : ENT_SUBSTITUTE | ENT_NOQUOTES);
}

public function getHumanDuration($data) {
public function formatDate($date = null, $format = Zend_Date::DATETIME_LONG, $showTime = false) {
$object = Mage::getSingleton('core/locale');
return str_replace($object->date($date)->toString(Zend_Date::TIMEZONE), '', $object->date($date)->toString($format));
}

$minutes = (int) ($data / 60);
$seconds = $data % 60;
public function getHumanEmailAddress(string $email) {
return $this->escapeEntities(str_replace(['<', '>', ',', '"'], ['(', ')', ', ', ''], $email));
}

if ($data > 599)
$data = ($seconds > 9) ? $minutes.':'.$seconds : $minutes.':0'.$seconds;
else if ($data > 59)
$data = ($seconds > 9) ? '0'.$minutes.':'.$seconds : '0'.$minutes.':0'.$seconds;
else if ($data > 1)
$data = ($seconds > 9) ? '00:'.$data : '00:0'.$data;
else
$data = '⩽&nbsp;1';
public function getHumanDuration($start, $end = null) {

if (is_numeric($start) || (!in_array($start, ['', '0000-00-00 00:00:00', null]) && !in_array($end, ['', '0000-00-00 00:00:00', null]))) {

$data = is_numeric($start) ? $start : strtotime($end) - strtotime($start);
$minutes = (int) ($data / 60);
$seconds = $data % 60;

if ($data > 599)
$data = '<strong>'.(($seconds > 9) ? $minutes.':'.$seconds : $minutes.':0'.$seconds).'</strong>';
else if ($data > 59)
$data = '<strong>'.(($seconds > 9) ? '0'.$minutes.':'.$seconds : '0'.$minutes.':0'.$seconds).'</strong>';
else if ($data > 1)
$data = ($seconds > 9) ? '00:'.$data : '00:0'.$data;
else
$data = '⩽&nbsp;1';
}

return empty($data) ? '' : $data;
}

public function getNumber($value, array $options = []) {
$options['locale'] = Mage::getSingleton('core/translate')->getLocale();
return Zend_Locale_Format::toNumber($value, $options);
}

public function getNumberToHumanSize(int $number) {

if ($number < 1) {
$data = '';
}
else if (($number / 1024) < 1024) {
$data = $number / 1024;
$data = $this->getNumber($data, ['precision' => 2]);
$data = $this->__('%s kB', preg_replace('#[.,]00[[:>:]]#', '', $data));
}
else if (($number / 1024 / 1024) < 1024) {
$data = $number / 1024 / 1024;
$data = $this->getNumber($data, ['precision' => 2]);
$data = $this->__('%s MB', preg_replace('#[.,]00[[:>:]]#', '', $data));
}
else {
$data = $number / 1024 / 1024 / 1024;
$data = $this->getNumber($data, ['precision' => 2]);
$data = $this->__('%s GB', preg_replace('#[.,]00[[:>:]]#', '', $data));
}

return $data;
}

public function getUsername() {

$file = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$file = array_pop($file);
$file = array_key_exists('file', $file) ? basename($file['file']) : '';

// backend
if ((PHP_SAPI != 'cli') && Mage::app()->getStore()->isAdmin() && Mage::getSingleton('admin/session')->isLoggedIn())
$user = sprintf('admin %s', Mage::getSingleton('admin/session')->getData('user')->getData('username'));
// cron
else if (is_object($cron = Mage::registry('current_cron')))
$user = sprintf('cron %d - %s', $cron->getId(), $cron->getData('job_code'));
// xyz.php
else if ($file != 'index.php')
$user = $file;
// full action name
else if (is_object($action = Mage::app()->getFrontController()->getAction()))
$user = $action->getFullActionName();
// frontend
else
$user = sprintf('frontend %d', Mage::app()->getStore()->getData('code'));

return $user;
}


public function getSystem() {

$system = Mage::registry('versioning');
if (!is_object($system)) {
$current = Mage::getStoreConfig('versioning/scm/type');
$config = Mage::getConfig()->getNode('global/models/versioning/adaptators')->asArray();
if (in_array($current, $config))
$system = Mage::getSingleton($current);
else if (!empty($config[$current]))
$system = Mage::getSingleton($config[$current]);
}

return empty($system) ? new Varien_Object(['type' => 'GIT']) : $system;
}

public function getFields() {

Expand Down
2 changes: 1 addition & 1 deletion src/app/code/community/Luigifab/Versioning/Model/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created V/02/11/2012
* Updated D/18/07/2021
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created V/03/08/2012
* Updated S/05/12/2020
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created M/21/01/2020
* Updated D/18/07/2021
*
* Copyright 2011-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2011-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/versioning
*
* This program is free software, you can redistribute it or modify
Expand Down
Loading

0 comments on commit dc0c847

Please sign in to comment.