Skip to content

Commit

Permalink
Version 6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed Mar 3, 2020
1 parent 49c296e commit 0a7f0d6
Show file tree
Hide file tree
Showing 93 changed files with 3,003 additions and 1,814 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ For more information, go to https://www.luigifab.fr/apijs and https://www.luigif

This repository is a mirror. To install the module, please use the extension key available in the documentation. If you like, take some of your time to improve the translations, go to https://bit.ly/2HyCCEc.

Version 5.3.0 released on 01/01/2017 (repacked and reminified on 16/02/2020).
Version 6.0.0 released on 03/03/2020.
46 changes: 41 additions & 5 deletions app/code/community/Luigifab/Apijs/Block/Adminhtml/Config/Help.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* Created V/23/05/2014
* Updated M/08/11/2016
* Updated S/01/02/2020
*
* Copyright 2008-2017 | Fabrice Creuzot (luigifab) <code~luigifab~info>
* https://redmine.luigifab.info/projects/magento/wiki/apijs
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/magento/apijs
*
* This program is free software, you can redistribute it or modify
* it under the terms of the GNU General Public License (GPL) as published
Expand All @@ -20,7 +20,43 @@
class Luigifab_Apijs_Block_Adminhtml_Config_Help extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface {

public function render(Varien_Data_Form_Element_Abstract $element) {
$url = 'https://redmine.luigifab.info/projects/magento/wiki/apijs';
return sprintf('<p class="box">Luigifab/Apijs %s <a href="%s" onclick="window.open(this.href); return false;" style="float:right;">%2$s</a></p>', $this->helper('apijs')->getVersion(), $url);

$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>',
'Luigifab/Apijs', $this->helper('apijs')->getVersion(), 'luigifab.fr/magento/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>',
'Luigifab/Apijs', $this->helper('apijs')->getVersion(), 'luigifab.fr/magento/apijs', 'luigifab.fr/apijs');
}

private function checkRewrites() {

$rewrites = [
['block' => 'adminhtml/catalog_product_helper_form_gallery_content'],
['block' => 'adminhtml/cms_wysiwyg_images_tree'],
['block' => 'adminhtml/system_config_form_field_image'],
['block' => 'catalog/product_view_media'],
['helper' => 'catalog/image'],
['model' => 'catalog/product_attribute_backend_media'],
['model' => 'catalog_resource/product_attribute_backend_media']
];

foreach ($rewrites as $rewrite) {
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))
return $class;
else if (($type == 'helper') && (mb_stripos(Mage::getConfig()->getHelperClassName($class), 'luigifab') === false))
return $class;
}
}

return true;
}
}
6 changes: 3 additions & 3 deletions app/code/community/Luigifab/Apijs/Block/Adminhtml/Demo.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* Created D/20/11/2011
* Updated M/08/11/2016
* Updated M/28/02/2017
*
* Copyright 2008-2017 | Fabrice Creuzot (luigifab) <code~luigifab~info>
* https://redmine.luigifab.info/projects/magento/wiki/apijs
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/magento/apijs
*
* This program is free software, you can redistribute it or modify
* it under the terms of the GNU General Public License (GPL) as published
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* Created L/26/10/2015
* Updated M/08/11/2016
* Updated M/21/01/2020
*
* Copyright 2008-2017 | Fabrice Creuzot (luigifab) <code~luigifab~info>
* https://redmine.luigifab.info/projects/magento/wiki/apijs
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/magento/apijs
*
* This program is free software, you can redistribute it or modify
* it under the terms of the GNU General Public License (GPL) as published
Expand All @@ -17,7 +17,7 @@
* GNU General Public License (GPL) for more details.
*/

class Luigifab_Apijs_Block_Adminhtml_Rewrite_Field extends Mage_Adminhtml_Block_System_Config_Form_Field_Image {
class Luigifab_Apijs_Block_Adminhtml_Rewrite_Config extends Mage_Adminhtml_Block_System_Config_Form_Field_Image {

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

if (Mage::getStoreConfigFlag('apijs/general/backend')) {

$this->setData('class', 'input-file');
$html = '';

if ($this->getValue()) {

$url = $this->_getUrl();
if (!preg_match('/^http\:\/\/|https\:\/\//', $url))
$url = Mage::getBaseUrl('media').$url;

$html .= '<a href="'.$url.'" onclick="apijs.dialog.dialogPhoto(this.href, this.firstChild.getAttribute(\'alt\'), \'false\', \'\'); return false;"><img src="'.$url.'" id="'.$this->getHtmlId().'_image" width="22" height="22" alt="'.$this->getValue().'" class="small-image-preview v-middle" /></a> ';
$url = $this->_getUrl();
$url = (mb_stripos($url, 'http') === 0) ? $url : Mage::getBaseUrl('media').$url;
$html .= sprintf(' <a href="%s" onclick="apijs.dialog.dialogPhoto(this.href, \'false\', \'false\', \'%s\'); return false;" id="%s_image">%s</a> ', $url, addslashes($this->getValue()), $this->getHtmlId(), $this->helper('apijs')->__('Preview'));
}

$this->setClass('input-file');

$html .= Varien_Data_Form_Element_Abstract::getElementHtml();
$html .= $this->_getDeleteCheckbox();

return $html;
}
else {
return parent::getElementHtml();
}

return parent::getElementHtml();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* Created S/04/10/2014
* Updated M/08/11/2016
* Updated M/07/01/2020
*
* Copyright 2008-2017 | Fabrice Creuzot (luigifab) <code~luigifab~info>
* https://redmine.luigifab.info/projects/magento/wiki/apijs
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/magento/apijs
*
* This program is free software, you can redistribute it or modify
* it under the terms of the GNU General Public License (GPL) as published
Expand All @@ -26,64 +26,41 @@ protected function _construct() {
public function __construct() {

parent::__construct();
$id = Mage::registry('current_product')->getId();
$product = Mage::registry('current_product');

if (Mage::getStoreConfigFlag('apijs/general/backend') && ($id > 0) && ($this->getRequest()->getParam('old', false) === false))
$this->setTemplate('luigifab/apijs/gallery.phtml');
if (!empty($product) && !empty($product->getId()) && Mage::getStoreConfigFlag('apijs/general/backend'))
$this->setTemplate('luigifab/apijs/gallery.phtml'); // catalog/product/helper/gallery.phtml
}

public function _toHtml() {

$id = Mage::registry('current_product')->getId();

if (Mage::getStoreConfigFlag('apijs/general/backend') && ($id > 0)) {

if ($this->getRequest()->getParam('old', false) === false) {
$url = $this->helper('apijs')->getDirectTabLink($id, true);
$text = $this->__('Back to Magento default gallery');
}
else {
$url = $this->helper('apijs')->getDirectTabLink($id);
$text = $this->__('See the apijs gallery');
}

return '<a href="'.$url.'" class="apijslink">'.$text.'</a>'.parent::_toHtml();
}
else {
return parent::_toHtml();
}
}

public function getMaxSize() {
$max = min(intval(ini_get('upload_max_filesize')), intval(ini_get('post_max_size')));
return ($max > 9) ? 9 : $max;
}
public function getScopeLabel($attribute) {

public function getAddUrl($productId, $storeId) {
$key = Mage::getSingleton('core/session')->getFormKey();
return $this->getUrl('*/apijs_media/uploadProduct', array('product' => $productId, 'store' => $storeId, 'form_key' => $key));
if ($attribute->isScopeGlobal())
return $this->__('[GLOBAL]');
else if ($attribute->isScopeWebsite())
return $this->__('[WEBSITE]');
else
return $this->__('[STORE VIEW]');
}

public function getSaveUrl($productId, $storeId, $imageId) {
$key = Mage::getSingleton('core/session')->getFormKey();
return $this->getUrl('*/apijs_media/save', array('product' => $productId, 'image' => $imageId, 'store' => $storeId, 'form_key' => $key));
public function isUseGlobal($image, $field, $value) {
return empty($image->getData($field.'_global')) ? '' : $value.'="'.$value.'"';
}

public function getDownloadUrl($productId, $imageId) {
return $this->getUrl('*/apijs_media/download', array('product' => $productId, 'image' => $imageId));
public function getAddUrl() {
$product = Mage::registry('current_product');
return $this->getUrl('*/apijs_media/uploadProduct',
['product' => $product->getId(), 'store' => $product->getStoreId(), 'form_key' => $this->getFormKey()]);
}

public function getDeleteUrl($productId, $imageId) {
return $this->getUrl('*/apijs_media/delete', array('product' => $productId, 'image' => $imageId));
public function getSaveUrl() {
$product = Mage::registry('current_product');
return $this->getUrl('*/apijs_media/save',
['product' => $product->getId(), 'store' => $product->getStoreId(), 'form_key' => $this->getFormKey()]);
}

public function getScopeLabel($attribute) {

if ($attribute->isScopeGlobal())
return $this->__('[GLOBAL]');
else if ($attribute->isScopeWebsite())
return $this->__('[WEBSITE]');
else
return $this->__('[STORE VIEW]');
public function getDeleteUrl($imageId) {
$product = Mage::registry('current_product');
return $this->getUrl('*/apijs_media/delete',
['product' => $product->getId(), 'store' => $product->getStoreId(), 'image' => $imageId]);
}
}
42 changes: 42 additions & 0 deletions app/code/community/Luigifab/Apijs/Block/Adminhtml/Rewrite/Tree.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Created S/04/01/2020
* Updated M/21/01/2020
*
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/magento/apijs
*
* This program is free software, you can redistribute it or modify
* it under the terms of the GNU General Public License (GPL) as published
* by the free software foundation, either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but without any warranty, without even the implied warranty of
* merchantability or fitness for a particular purpose. See the
* GNU General Public License (GPL) for more details.
*/

class Luigifab_Apijs_Block_Adminhtml_Rewrite_Tree extends Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Tree {

public function getTreeJson() {

$helper = $this->helper('cms/wysiwyg_images');
$helper->getStorageRoot(); // très important

$collection = Mage::registry('storage')->getDirsCollection($helper->getCurrentPath());
$items = [];

foreach ($collection as $item) {
if ($item->getBasename() != 'cache') {
$items[] = [
'text' => $helper->getShortFilename($item->getBasename(), 20),
'id' => $helper->convertPathToId($item->getFilename()),
'cls' => 'folder'
];
}
}

return Zend_Json::encode($items);
}
}

This file was deleted.

41 changes: 41 additions & 0 deletions app/code/community/Luigifab/Apijs/Block/Browser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Created V/11/10/2019
* Updated V/11/10/2019
*
* Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
* https://www.luigifab.fr/magento/apijs
*
* This program is free software, you can redistribute it or modify
* it under the terms of the GNU General Public License (GPL) as published
* by the free software foundation, either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but without any warranty, without even the implied warranty of
* merchantability or fitness for a particular purpose. See the
* GNU General Public License (GPL) for more details.
*/

class Luigifab_Apijs_Block_Browser extends Mage_Core_Block_Template {

public function getBrowserData() {
return Mage::getSingleton('apijs/useragentparser')->parse();
}

public function getCacheKeyInfo() {
return null;
}

public function getCacheKey() {
return null;
}

public function getCacheTags() {
return null;
}

public function getCacheLifetime() {
return null;
}
}
Loading

0 comments on commit 0a7f0d6

Please sign in to comment.