Skip to content

Commit

Permalink
Version 6.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed Jan 1, 2024
1 parent 1929941 commit 0b23294
Show file tree
Hide file tree
Showing 89 changed files with 836 additions and 569 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ Stop russian war. **🇺🇦 Free Ukraine!**

JavaScript pop-ups and slideshow for [OpenMage](https://github.com/OpenMage/magento-lts).

For more information, go to https://www.luigifab.fr/apijs and https://www.luigifab.fr/openmage/apijs (IPv6 is required, it's not a joke). No IPv6? It's possible to get an IPv6 thanks to *Miredo*. Run `sudo apt install miredo` and `sudo service miredo force-start`.
For more information, go to https://www.luigifab.fr/apijs and https://www.luigifab.fr/openmage/apijs (IPv6 is required).

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

- Current version: 6.9.5 (10/10/2023)
- Current version: 6.9.6 (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, Python 3.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.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created V/23/05/2014
* Updated V/20/05/2022
* Updated D/26/11/2023
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://github.com/luigifab/openmage-apijs
*
* This program is free software, you can redistribute it or modify
Expand All @@ -23,13 +23,13 @@ public function render(Varien_Data_Form_Element_Abstract $element) {

$msg = $this->checkRewrites();
if ($msg !== true)
return sprintf('<p class="box">%s %s <span class="right">Stop russian war. <b>🇺🇦 Free Ukraine!</b> | <a href="https://www.%s">%3$s</a> | ⚠ IPv6</span></p><p class="box" style="margin-top:-5px; color:white; background-color:#E60000;"><strong>%s</strong><br />%s</p>',
'Luigifab/Apijs', $this->helper('apijs')->getVersion(), 'luigifab.fr/openmage/apijs',
return sprintf('<p class="box">%s %s <span class="right">Stop russian war. <b>🇺🇦 Free Ukraine!</b> | <a href="https://github.com/luigifab/%3$s">github.com</a> | <a href="https://www.%4$s">%4$s</a> - <a href="https://www.%5$s">%5$s</a> - ⚠ IPv6</span></p><p class="box" style="margin-top:-5px; color:white; background-color:#E60000;"><strong>%6$s</strong><br />%7$s</p>',
'Luigifab/Apijs', $this->helper('apijs')->getVersion(), 'openmage-apijs', 'luigifab.fr/openmage/apijs', 'luigifab.fr/apijs',
$this->__('INCOMPLETE MODULE INSTALLATION'),
$this->__('There is conflict (<em>%s</em>).', $msg));

return sprintf('<p class="box">%s %s <span class="right">Stop russian war. <b>🇺🇦 Free Ukraine!</b> | <a href="https://www.%s">%3$s</a> | <a href="https://www.%4$s">%4$s</a> | ⚠ IPv6</span></p>',
'Luigifab/Apijs', $this->helper('apijs')->getVersion(), 'luigifab.fr/openmage/apijs', 'luigifab.fr/apijs');
return sprintf('<p class="box">%s %s <span class="right">Stop russian war. <b>🇺🇦 Free Ukraine!</b> | <a href="https://github.com/luigifab/%3$s">github.com</a> | <a href="https://www.%4$s">%4$s</a> - <a href="https://www.%5$s">%5$s</a> - ⚠ IPv6</span></p>',
'Luigifab/Apijs', $this->helper('apijs')->getVersion(), 'openmage-apijs', 'luigifab.fr/openmage/apijs', 'luigifab.fr/apijs');
}

protected function checkRewrites() {
Expand All @@ -41,6 +41,8 @@ protected function checkRewrites() {
['block' => 'adminhtml/catalog_product_helper_form_image'],
['block' => 'adminhtml/system_config_form_field_image'],
['helper' => 'catalog/image'],
['model' => 'adminhtml/system_config_backend_image'],
['model' => 'adminhtml/system_config_backend_image_pdf'],
['model' => 'catalog/category_attribute_backend_image'],
['model' => 'catalog/product_attribute_backend_media'],
['model' => 'catalog_resource/product_attribute_backend_image'],
Expand All @@ -54,9 +56,9 @@ protected function checkRewrites() {
foreach ($rewrite as $type => $class) {
if (($type == 'model') && (mb_stripos(Mage::getConfig()->getModelClassName($class), 'luigifab') === false))
return $class;
else if (($type == 'block') && (mb_stripos(Mage::getConfig()->getBlockClassName($class), 'luigifab') === false))
if (($type == 'block') && (mb_stripos(Mage::getConfig()->getBlockClassName($class), 'luigifab') === false))
return $class;
else if (($type == 'helper') && (mb_stripos(Mage::getConfig()->getHelperClassName($class), 'luigifab') === false))
if (($type == 'helper') && (mb_stripos(Mage::getConfig()->getHelperClassName($class), 'luigifab') === false))
return $class;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created D/20/11/2011
* Updated S/03/12/2022
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://github.com/luigifab/openmage-apijs
*
* 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/06/10/2020
* Updated M/06/10/2020
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://github.com/luigifab/openmage-apijs
*
* 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/30/03/2020
* Updated V/28/04/2023
* Updated J/19/10/2023
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2019-2023 | Fabrice Creuzot <fabrice~cellublue~com>
* https://github.com/luigifab/openmage-apijs
*
Expand Down Expand Up @@ -41,7 +41,7 @@ public function getElementHtml() {
$html .= sprintf(' <a href="%s" onclick="apijs.dialog.dialogPhoto(this.href, \'false\', \'false\', \'%s\'); return false;" id="%s_image">%s (%s)</a> ', $link, addslashes($this->getValue()), $this->getHtmlId(), Mage::helper('apijs')->__('Preview'), $this->getValue()); // pas de $this->helper ici
}

return $html.$this->_getDeleteCheckbox().'</div>';
return sprintf('%s <em>(%s)</em> %s</div>', $html, implode(', ', $this->getAllowedExtensions()), $this->_getDeleteCheckbox());
}

return parent::getElementHtml();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
/**
* Created L/26/10/2015
* Updated J/23/12/2021
* Updated J/19/10/2023
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2019-2023 | Fabrice Creuzot <fabrice~cellublue~com>
* https://github.com/luigifab/openmage-apijs
*
* This program is free software, you can redistribute it or modify
Expand All @@ -23,6 +24,17 @@ protected function _construct() {
$this->setModuleName('Mage_Adminhtml');
}

public function getAllowedExtensions() {

$exts = Mage::getSingleton('cms/wysiwyg_images_storage')->getAllowedExtensions('image');

$model = (string) $this->getFieldConfig()->descend('backend_model');
if (!empty($model))
return array_intersect($exts, Mage::getModel($model)->getAllowedExtensions());

return $exts;
}

public function getElementHtml() {

if (Mage::getStoreConfigFlag('apijs/general/backend')) {
Expand All @@ -36,7 +48,7 @@ public function getElementHtml() {
$html .= sprintf(' <a href="%s" onclick="apijs.dialog.dialogPhoto(this.href, \'false\', \'false\', \'%s\'); return false;" id="%s_image">%s (%s)</a> ', $link, addslashes($this->getValue()), $this->getHtmlId(), Mage::helper('apijs')->__('Preview'), $this->getValue()); // pas de $this->helper ici
}

return $html.$this->_getDeleteCheckbox().'</div>';
return sprintf('%s <em>(%s)</em> %s</div>', $html, implode(', ', $this->getAllowedExtensions()), $this->_getDeleteCheckbox());
}

return parent::getElementHtml();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created S/04/10/2014
* Updated V/19/05/2023
* Updated S/02/12/2023
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://github.com/luigifab/openmage-apijs
*
* This program is free software, you can redistribute it or modify
Expand Down Expand Up @@ -52,11 +52,11 @@ public function getImages(bool $sortByStore) {
$defaultValues = [];
$globalValues = [];
$storeValues = [];
$images = [];
$counts = [];

$values = $product->getMediaGallery('images');
$values = empty($values) ? [] : $values;
$images = [];
$counts = [];

foreach ($values as $image) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created J/27/05/2021
* Updated V/28/04/2023
* Updated J/19/10/2023
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2019-2023 | Fabrice Creuzot <fabrice~cellublue~com>
* https://github.com/luigifab/openmage-apijs
*
Expand Down Expand Up @@ -41,7 +41,7 @@ public function getElementHtml() {
$html .= sprintf(' <a href="%s" onclick="apijs.dialog.dialogPhoto(this.href, \'false\', \'false\', \'%s\'); return false;" id="%s_image">%s (%s)</a> ', $link, addslashes($this->getValue()), $this->getHtmlId(), Mage::helper('apijs')->__('Preview'), $this->getValue()); // pas de $this->helper ici
}

return $html.$this->_getDeleteCheckbox().'</div>';
return sprintf('%s <em>(%s)</em> %s</div>', $html, implode(', ', $this->getAllowedExtensions()), $this->_getDeleteCheckbox());
}

return parent::getElementHtml();
Expand Down
2 changes: 1 addition & 1 deletion src/app/code/community/Luigifab/Apijs/Block/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created V/11/10/2019
* Updated V/11/10/2019
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://github.com/luigifab/openmage-apijs
*
* This program is free software, you can redistribute it or modify
Expand Down
60 changes: 35 additions & 25 deletions src/app/code/community/Luigifab/Apijs/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
/**
* Created D/20/11/2011
* Updated J/25/05/2023
* Updated S/16/12/2023
*
* Copyright 2008-2023 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2024 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2019-2023 | Fabrice Creuzot <fabrice~cellublue~com>
* https://github.com/luigifab/openmage-apijs
*
* This program is free software, you can redistribute it or modify
Expand Down Expand Up @@ -75,8 +76,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 = '';
}
Expand Down Expand Up @@ -264,8 +266,9 @@ public function getThumbnail($product, $default, object $image, int $id) {

public function getMaxSizes(bool $dump = false) {

// config admise en Mo, "one file, all files"
if ($dump === true) {
// return "one file, all files"
// config admise en Mo
if ($dump) {
return [
'config.xml one_max_size' => (int) Mage::getStoreConfig('apijs/general/one_max_size'),
'config.xml all_max_size' => (int) Mage::getStoreConfig('apijs/general/all_max_size'),
Expand All @@ -288,11 +291,11 @@ public function getMaxSizes(bool $dump = false) {
public function getTabName($product = null) {

$product = is_object($product) ? $product : Mage::registry('current_product');
$egroups = Mage::getResourceModel('eav/entity_attribute_group_collection')
$groups = Mage::getResourceModel('eav/entity_attribute_group_collection')
->setAttributeSetFilter($product->getData('attribute_set_id'))
->load();

foreach ($egroups as $group) {
foreach ($groups as $group) {
$attributes = $product->getAttributes($group->getId(), true);
foreach ($attributes as $attribute) {
if (in_array($attribute->getData('attribute_code'), ['media_gallery', 'gallery']))
Expand All @@ -319,9 +322,10 @@ protected function searchAndRemoveFiles(string $directory, string $file, array $
// supprime les fichiers
if (!empty($filesCache)) {

// for apijs-clean-images.php
$file = '/'.trim($file, '/');
foreach ($filesCache as $fileCache) {
if ((mb_stripos($fileCache, $file) !== false) && (mb_stripos($fileCache, $directory) !== false) && is_file($fileCache)) {
if ((mb_stripos($fileCache, $file) !== false) && (mb_stripos($fileCache, $directory) !== false)) {
echo ' ',$fileCache,"\n";
unlink($fileCache);
}
Expand All @@ -345,23 +349,27 @@ protected function searchAndRemoveFiles(string $directory, string $file, array $
if (mb_stripos($directory, '/cache') === false)
$directory .= '/cache';

if (!empty($filesCache)) {
if (is_dir($directory)) {

foreach ($filesCache as $fileCache) {
if ((mb_stripos($fileCache, $webp) !== false) && (mb_stripos($fileCache, $directory) !== false) && is_file($fileCache)) {
echo ' ',$fileCache,"\n";
unlink($fileCache);
if (!empty($filesCache)) {

// for apijs-clean-images.php
foreach ($filesCache as $fileCache) {
if ((mb_stripos($fileCache, $webp) !== false) && (mb_stripos($fileCache, $directory) !== false)) {
echo ' ',$fileCache,"\n";
unlink($fileCache);
}
}
}
}
else {
if (mb_stripos($webp, '/') === false)
$cmd = 'find '.escapeshellarg($directory).' -name '.escapeshellarg($webp).' -type f -delete';
else
$cmd = 'find '.escapeshellarg($directory).' -wholename '.escapeshellarg('*/'.trim($webp, '/')).' -type f -delete';

Mage::log($cmd, Zend_Log::DEBUG, 'apijs.log');
exec($cmd);
else {
if (mb_stripos($webp, '/') === false)
$cmd = 'find '.escapeshellarg($directory).' -name '.escapeshellarg($webp).' -type f -delete';
else
$cmd = 'find '.escapeshellarg($directory).' -wholename '.escapeshellarg('*/'.trim($webp, '/')).' -type f -delete';

Mage::log($cmd, Zend_Log::DEBUG, 'apijs.log');
exec($cmd);
}
}
}
}
Expand All @@ -371,12 +379,14 @@ public function removeFiles(string $directory, string $file, bool $now = false,
if (empty($this->_baseMediaDir))
$this->_baseMediaDir = realpath(Mage::getBaseDir('media'));

// when $filesCache is set (from apijs-clean-images.php) $directory is already realpath()
$directory = empty($filesCache) ? realpath($directory) : $directory;

// recherche et supprime tous les fichiers avec la commande find
// si le nom du fichier contient des caractères simples et qu'on est bien dans le dossier media
// search and remove all files with find command
// if the file name contains simple characters and only in the media folder
if (
!empty($directory) && (!empty($filesCache) || is_dir($directory)) &&
($directory != $this->_baseMediaDir) &&
!empty($directory) && is_dir($directory) &&
(mb_stripos($directory, $this->_baseMediaDir) === 0) &&
(preg_match('#[\w\-]+\.\w+$#', $file) === 1)
) {
Expand Down
Loading

0 comments on commit 0b23294

Please sign in to comment.