Skip to content

Commit

Permalink
Version 6.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed Jul 7, 2022
1 parent 2cacc24 commit 0df779f
Show file tree
Hide file tree
Showing 75 changed files with 559 additions and 225 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Stop russian war. **🇺🇦 Free Ukraine!**

# apijs

JavaScript pop-ups and slideshow for [OpenMage](https://github.com/OpenMage/magento-lts).
Expand All @@ -6,8 +8,8 @@ For more information, go to https://www.luigifab.fr/apijs and https://www.luigif

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

- Current version: 6.8.2 (01/01/2022)
- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1, Python 3.3 - 3.10
- Current version: 6.9.0 (07/07/2022)
- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1, 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+
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"require": {
"php": ">=7.2.0",
"openmage/magento-lts": ">=19.4.0",
"symfony/polyfill-php80": "*",
"ext-mbstring": "*",
"ext-json": "*",
"ext-curl": "*"
Expand Down Expand Up @@ -86,4 +87,4 @@
["src/skin/frontend/base/default/js/luigifab/apijs/", "skin/frontend/base/default/js/luigifab/apijs/"]
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created V/23/05/2014
* Updated J/30/09/2021
* Updated V/20/05/2022
*
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
Expand All @@ -23,12 +23,12 @@ 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"><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>',
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',
$this->__('INCOMPLETE MODULE INSTALLATION'),
$this->__('There is conflict (<em>%s</em>).', $msg));

return sprintf('<p class="box">%s %s <span class="right"><a href="https://www.%s">%3$s</a> | <a href="https://www.%4$s">%4$s</a> | ⚠ IPv6</span></p>',
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');
}

Expand All @@ -46,7 +46,7 @@ protected function checkRewrites() {
['model' => 'catalog_resource/product_attribute_backend_image'],
['model' => 'catalog_resource/product_attribute_backend_media'],
['model' => 'cms/wysiwyg_images_storage'],
['model' => 'core/file_validator_image']
['model' => 'core/file_validator_image'],
];

foreach ($rewrites as $rewrite) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created S/04/10/2014
* Updated V/29/10/2021
* Updated M/31/05/2022
*
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
Expand Down Expand Up @@ -68,20 +68,36 @@ public function getImages(bool $sortByStore) {
$counts[$image->getData('apijs_group')] = 1;
}

$database = Mage::getSingleton('core/resource');
$writer = $database->getConnection('core_write');
$reader = $database->getConnection('core_read');
$table = $database->getTableName('catalog_product_entity_varchar');

$ids = [];
foreach ($attributes as $code => $attribute) {

if (($attribute->getIsText() !== true) && ($attribute->getIsCheckbox() !== true)) {

$ids[] = $attribute->getId();
$globalValues[$code] = $product->getResource()->getAttributeRawValue($productId, $code, 0);

// bug de merde, quand la valeur par défaut est non présente, la lecture de la valeur par vue ne marche pas
if ($globalValues[$code] === false) {
try {
$writer->fetchAll('INSERT INTO '.$table.' (entity_type_id, attribute_id, store_id, entity_id, value) VALUES
(4, '.$attribute->getId().', 0, '.$productId.', "no_selection")');
$globalValues[$code] = 'no_selection';
}
catch (Throwable $t) {
Mage::logException($t);
}
}

$storeValues[$code] = $product->getResource()->getAttributeRawValue($productId, $code, $storeId);
}
}

$database = Mage::getSingleton('core/resource');
$reader = $database->getConnection('core_read');
$table = $database->getTableName('catalog_product_entity_varchar');
$values = $reader->fetchAll('SELECT store_id, attribute_id, value FROM '.$table.' WHERE entity_id = '.$productId.' AND attribute_id IN ('.implode(',', $ids).')');

$values = $reader->fetchAll('SELECT store_id, attribute_id, value FROM '.$table.' WHERE entity_id = '.$productId.' AND attribute_id IN ('.implode(',', $ids).')');
foreach ($values as $value) {
if (!empty($images[$value['value']])) {
$image = $images[$value['value']];
Expand Down
26 changes: 21 additions & 5 deletions src/app/code/community/Luigifab/Apijs/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created D/20/11/2011
* Updated J/25/11/2021
* Updated L/06/06/2022
*
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
Expand Down Expand Up @@ -37,8 +37,8 @@ public function formatDate($date = null, $format = Zend_Date::DATETIME_LONG, $sh
return str_replace($object->date($date)->toString(Zend_Date::TIMEZONE), '', $object->date($date)->toString($format));
}

public function getHumanEmailAddress(string $email) {
return $this->escapeEntities(str_replace(['<', '>', ',', '"'], ['(', ')', ', ', ''], $email));
public function getHumanEmailAddress($email) {
return empty($email) ? '' : $this->escapeEntities(str_replace(['<', '>', ',', '"'], ['(', ')', ', ', ''], $email));
}

public function getHumanDuration($start, $end = null) {
Expand Down Expand Up @@ -138,9 +138,9 @@ public function getWysiwygImageDir(bool $cache = false, bool $old = false) {
}


public function resizeImage($product, $type, $path, int $width, int $height, bool $fixed) {
public function resizeImage($product, $type, $path, int $width, int $height, bool $fixed, bool $webp = false) {

$resource = Mage::helper('catalog/image')->init($product, $type, $path, $fixed);
$resource = Mage::helper('catalog/image')->init($product, $type, $path, $fixed, $webp);

if (Mage::getStoreConfigFlag('apijs/general/python'))
$resource->resize($width, $height);
Expand Down Expand Up @@ -312,6 +312,22 @@ protected function searchAndRemoveFiles(string $dir, string $file) {

Mage::log($cmd, Zend_Log::DEBUG, 'apijs.log');
exec($cmd);

// supprime aussi les éventuels fichiers webp, uniquement dans le dossier cache
$webp = str_ireplace(['.jpg', '.jpeg', '.png', '.gif'], '.webp', $file);
if ($file != $webp) {

if (mb_stripos($dir, '/cache') === false)
$dir .= '/cache';

if (mb_stripos($webp, '/') === false)
$cmd = 'find '.escapeshellarg($dir).' -name '.escapeshellarg($webp).' | xargs rm';
else
$cmd = 'find '.escapeshellarg($dir).' -wholename '.escapeshellarg('*/'.trim($webp, '/')).' | xargs rm';

Mage::log($cmd, Zend_Log::DEBUG, 'apijs.log');
exec($cmd);
}
}

public function removeFiles(string $dir, string $file, bool $now = false) {
Expand Down
Loading

0 comments on commit 0df779f

Please sign in to comment.