Skip to content

Commit

Permalink
Version 6.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed Jan 1, 2022
1 parent c105b6e commit 2cacc24
Show file tree
Hide file tree
Showing 73 changed files with 595 additions and 404 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,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.1 (10/10/2021)
- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0, Python 3.3 - 3.10
- 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
- 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
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"ext-json": "*",
"ext-curl": "*"
},
"replace": {
"fballiano/magento-autodelete-product-images": "*"
},
"minimum-stability": "dev",
"extra": {
"map": [
Expand Down Expand Up @@ -83,4 +86,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,9 +1,9 @@
<?php
/**
* Created V/23/05/2014
* Updated L/24/05/2021
* Updated J/30/09/2021
*
* Copyright 2008-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
*
* This program is free software, you can redistribute it or modify
Expand Down Expand Up @@ -32,20 +32,20 @@ public function render(Varien_Data_Form_Element_Abstract $element) {
'Luigifab/Apijs', $this->helper('apijs')->getVersion(), 'luigifab.fr/openmage/apijs', 'luigifab.fr/apijs');
}

private function checkRewrites() {
protected function checkRewrites() {

$rewrites = [
['block' => 'adminhtml/cache_additional'],
['block' => 'adminhtml/catalog_category_helper_image'],
['block' => 'adminhtml/catalog_product_helper_form_gallery_content'],
['block' => 'adminhtml/catalog_product_helper_form_image'],
['block' => 'adminhtml/cms_wysiwyg_images_tree'],
['block' => 'adminhtml/system_config_form_field_image'],
['helper' => 'catalog/image'],
['model' => 'catalog/category_attribute_backend_image'],
['model' => 'catalog/product_attribute_backend_media'],
['model' => 'catalog_resource/product_attribute_backend_image'],
['model' => 'catalog_resource/product_attribute_backend_media'],
['model' => 'cms/wysiwyg_images_storage'],
['model' => 'core/file_validator_image']
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created D/20/11/2011
* Updated M/28/02/2017
*
* Copyright 2008-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/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-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/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 D/30/05/2021
* Updated J/23/12/2021
*
* Copyright 2008-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
*
* This program is free software, you can redistribute it or modify
Expand Down Expand Up @@ -32,8 +32,8 @@ public function getElementHtml() {

if ($this->getValue()) {
$link = $this->_getUrl();
$link = (mb_stripos($link, 'http') === 0) ? $link : Mage::getBaseUrl('media').$link;
$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
$link = str_replace('category//', 'category/', (mb_stripos($link, 'http') === 0) ? $link : Mage::getBaseUrl('media').$link);
$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>';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created L/26/10/2015
* Updated V/28/05/2021
* Updated J/23/12/2021
*
* Copyright 2008-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
*
* This program is free software, you can redistribute it or modify
Expand All @@ -17,7 +17,7 @@
* GNU General Public License (GPL) for more details.
*/

class Luigifab_Apijs_Block_Adminhtml_Rewrite_Config extends Mage_Adminhtml_Block_System_Config_Form_Field_Image {
class Luigifab_Apijs_Block_Adminhtml_Rewrite_Configimg extends Mage_Adminhtml_Block_System_Config_Form_Field_Image {

protected function _construct() {
$this->setModuleName('Mage_Adminhtml');
Expand All @@ -32,8 +32,8 @@ public function getElementHtml() {

if ($this->getValue()) {
$link = $this->_getUrl();
$link = (mb_stripos($link, 'http') === 0) ? $link : Mage::getBaseUrl('media').$link;
$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
$link = str_replace('wysiwyg//', 'wysiwyg/', (mb_stripos($link, 'http') === 0) ? $link : Mage::getBaseUrl('media').$link);
$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>';
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/03/2021
* Updated V/29/10/2021
*
* Copyright 2008-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
*
* This program is free software, you can redistribute it or modify
Expand Down Expand Up @@ -35,14 +35,19 @@ public function __construct() {
public function getImages(bool $sortByStore) {

$product = Mage::registry('current_product');
$productId = $product->getId();
$storeId = $product->getStoreId();
$attributes = $product->getMediaAttributes();

$defaultValues = [];
$globalValues = [];
$storeValues = [];

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

$images = [];
$counts = [];

foreach ($values as $image) {

$image = is_object($image) ? $image : new Varien_Object($image);
Expand All @@ -64,37 +69,38 @@ public function getImages(bool $sortByStore) {
}

$ids = [];
foreach ($attributes as $attribute) {
if (($attribute->getIsText() !== true) && ($attribute->getIsCheckbox() !== true))
foreach ($attributes as $code => $attribute) {
if (($attribute->getIsText() !== true) && ($attribute->getIsCheckbox() !== true)) {
$ids[] = $attribute->getId();
$globalValues[$code] = $product->getResource()->getAttributeRawValue($productId, $code, 0);
$storeValues[$code] = $product->getResource()->getAttributeRawValue($productId, $code, $storeId);
}
}

$database = Mage::getSingleton('core/resource');
$read = $database->getConnection('core_read');
$reader = $database->getConnection('core_read');
$table = $database->getTableName('catalog_product_entity_varchar');
$values = $read->fetchAll('SELECT store_id, attribute_id, value FROM '.$table.' WHERE entity_id = '.$product->getId().' 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).')');

$defaults = [];
foreach ($values as $value) {

if (!empty($images[$value['value']])) {
$image = $images[$value['value']];
if (floor($image->getData('position') / 100) == $value['store_id'])
$defaults[$value['attribute_id']][$value['store_id']] = $value['value'];
$defaultValues[$value['attribute_id']][$value['store_id']] = $value['value'];
}
}

return [$images, $counts, $defaults];
return ['images' => $images, 'counts' => $counts, 'defaultValues' => $defaultValues, 'storeValues' => $storeValues, 'globalValues' => $globalValues];
}

public function getScopeLabel(object $attribute) {

if ($attribute->isScopeGlobal())
return $this->__('[GLOBAL]');
else if ($attribute->isScopeWebsite())
if ($attribute->isScopeWebsite())
return $this->__('[WEBSITE]');
else
return $this->__('[STORE VIEW]');

return $this->__('[STORE VIEW]');
}

public function isUseGlobal(object $image, string $field, string $value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Created J/27/05/2021
* Updated D/30/05/2021
* Updated J/23/12/2021
*
* Copyright 2008-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
*
* This program is free software, you can redistribute it or modify
Expand Down Expand Up @@ -32,8 +32,8 @@ public function getElementHtml() {

if ($this->getValue()) {
$link = $this->_getUrl();
$link = (mb_stripos($link, 'http') === 0) ? $link : Mage::getBaseUrl('media').$link;
$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
$link = str_replace('product//', 'product/', (mb_stripos($link, 'http') === 0) ? $link : Mage::getBaseUrl('media').$link);
$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>';
Expand Down

This file was deleted.

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-2021 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* Copyright 2008-2022 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/openmage/apijs
*
* This program is free software, you can redistribute it or modify
Expand Down
Loading

0 comments on commit 2cacc24

Please sign in to comment.