Skip to content

Commit

Permalink
Version 6.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed Dec 12, 2020
1 parent b8f6784 commit 3052d65
Show file tree
Hide file tree
Showing 32 changed files with 491 additions and 196 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For more information, go to https://www.luigifab.fr/apijs or https://www.luigifa

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

- Current version: 6.4.0 (10/10/2020)
- Current version: 6.5.0 (12/12/2020)
- Compatibility: OpenMage 19+, Magento Community 1.9+, PHP 7.2 / 7.3 / 7.4 / 8.0
- Client compatibility: Firefox 36+, Chrome 31+, Opera 19+, Edge 16+, Safari 9+
- Translations: English (en), French (fr-FR/fr-CA), German (de), Italian (it), Portuguese (pt-PT/pt-BR), Spanish (es)
Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
{
"type": "other",
"url": "https://gandi.link/f/4b904048"
},
{
"type": "other",
"url": "https://ekwateur.fr/?parrain=EKW001147103"
}
],
"require": {
Expand Down
22 changes: 17 additions & 5 deletions src/app/code/community/Luigifab/Apijs/Helper/Rewrite/Image.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created J/12/09/2019
* Updated M/06/10/2020
* Updated M/01/12/2020
*
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2019-2020 | Fabrice Creuzot <fabrice~cellublue~com>
Expand Down Expand Up @@ -97,7 +97,7 @@ public function init($product, $attribute, $path = null, $fixed = true) {

$this->_svg = (!empty($path) && (mb_substr($path, -4) == '.svg'));
$this->setImageFile($path);
$this->setBaseFile($model, $path);
$this->trySetBaseFile($model, $path);

if ($this->_config['apijs/general/python']) {
$processor = Mage::getSingleton('apijs/python')->setFilename($model->getBaseFile())->setFixed($fixed);
Expand All @@ -119,11 +119,11 @@ public function getOriginalHeight() {
return empty($this->_svg) ? parent::getOriginalHeight() : 0;
}

public function setBaseFile($model, $path) {
private function trySetBaseFile($model, $path) {

try {
// essaye le fichier source
$model->setBaseFile($path);
$this->wrapSetBaseFile($model, $path);
}
catch (Exception $e) {
try {
Expand All @@ -147,6 +147,18 @@ public function setBaseFile($model, $path) {
}
}

private function wrapSetBaseFile($model, $file) {

$filename = Mage::helper('apijs')->getCatalogProductImageDir().$file;

// pour avoir une url unique
// par exemple, en cas de suppression de l'image a.jpg, puis de l'ajout de l'image a.jpg, même nom mais contenu différent
$old = $model->getWatermarkFile();
$model->setWatermarkFile(is_file($filename) ? $old.filemtime($filename) : $old);
$model->setBaseFile($file);
$model->setWatermarkFile($old);
}

public function validateUploadFile($path) {
return (is_file($path) && in_array(mime_content_type($path), ['image/svg', 'image/svg+xml'])) ? true : parent::validateUploadFile($path);
}
Expand All @@ -166,7 +178,7 @@ public function __toString() {
}

try {
$model->setBaseFile($this->getImageFile());
$this->wrapSetBaseFile($model, $this->getImageFile());

if ($model->getDestinationSubdir() == 'wysiwyg') {
// if ($model->isCached())
Expand Down
6 changes: 3 additions & 3 deletions src/app/code/community/Luigifab/Apijs/Model/Python.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created S/09/05/2020
* Updated V/18/09/2020
* Updated S/07/11/2020
*
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
Expand Down Expand Up @@ -29,7 +29,7 @@ class Luigifab_Apijs_Model_Python extends Varien_Image {

public function __construct($file = null, $adapter = null) {

exec('command -v python3 || command -v python || command -v python2', $cmd);
exec('command -v python3', $cmd);
$this->_python = trim(implode($cmd));

exec('nproc', $core);
Expand All @@ -53,7 +53,7 @@ public function getProgramVersions($helpPil, $helpSco) {

$cmd = $this->_python;

if (empty($cmd)) { // pas de mb_strpos
if (empty($cmd)) {
$pyt = 'not found';
$pil = $pyt;
$sco = $pyt;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created M/07/01/2020
* Updated M/06/10/2020
* Updated J/03/12/2020
*
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2019-2020 | Fabrice Creuzot <fabrice~cellublue~com>
Expand All @@ -22,6 +22,10 @@

class Luigifab_Apijs_Apijs_CacheController extends Mage_Adminhtml_System_ConfigController {

protected function _isAllowed() {
return Mage::getSingleton('admin/session')->isAllowed('system/config/apijs');
}

public function getUsedModuleName() {
return 'Luigifab_Apijs';
}
Expand All @@ -34,36 +38,36 @@ public function clearCacheAction() {
if ($type == 'wysiwyg') {

// thumb
$directory = trim(Mage::helper('apijs')->getWysiwygImageDir(true, true));
$io = new Varien_Io_File();
if (mb_strlen($directory) > 5)
$io->rmdir($directory, true);
$dir = trim(Mage::helper('apijs')->getWysiwygImageDir(true, true));
$iof = new Varien_Io_File();
if (mb_strlen($dir) > 5)
$iof->rmdir($dir, true);

// cache
$directory = trim(Mage::helper('apijs')->getWysiwygImageDir(true));
$io = new Varien_Io_File();
if (mb_strlen($directory) > 5)
$io->rmdir($directory, true);
$dir = trim(Mage::helper('apijs')->getWysiwygImageDir(true));
$iof = new Varien_Io_File();
if (mb_strlen($dir) > 5)
$iof->rmdir($dir, true);

$this->_getSession()->addSuccess($this->__('The image cache was cleaned.'));
}
else if ($type == 'product') {

// cache
$directory = trim(Mage::helper('apijs')->getCatalogProductImageDir(true));
$io = new Varien_Io_File();
if (mb_strlen($directory) > 5)
$io->rmdir($directory, true);
$dir = trim(Mage::helper('apijs')->getCatalogProductImageDir(true));
$iof = new Varien_Io_File();
if (mb_strlen($dir) > 5)
$iof->rmdir($dir, true);

$this->_getSession()->addSuccess($this->__('The image cache was cleaned.'));
}
else if ($type == 'category') {

// cache
$directory = trim(Mage::helper('apijs')->getCatalogCategoryImageDir(true));
$io = new Varien_Io_File();
if (mb_strlen($directory) > 5)
$io->rmdir($directory, true);
$dir = trim(Mage::helper('apijs')->getCatalogCategoryImageDir(true));
$iof = new Varien_Io_File();
if (mb_strlen($dir) > 5)
$iof->rmdir($dir, true);

$this->_getSession()->addSuccess($this->__('The image cache was cleaned.'));
}
Expand Down
Loading

0 comments on commit 3052d65

Please sign in to comment.