Coder Social home page Coder Social logo

Comments (1)

erikatbusteco avatar erikatbusteco commented on August 24, 2024

Mage_Adminhtml_Block_Media_Uploader is deprecated after SUPEE-8788 (and Magento 1.9.3). Thus there are several backward incompatibility changes which breaks module using the uploader.

I've solved the problem by adding a new rewrite in config.xml under the blocks

<uploader>
				<rewrite>
					<multiple>Aoe_FilePicker_Block_FilePicker</multiple>
				</rewrite>
</uploader>	

I've also modified FilePicker.php to the following

if (class_exists("Mage_Uploader_Block_Abstract")) {
// PATCH SUPEE-8788 or Magento 1.9.3	
	
class Aoe_FilePicker_Block_FilePicker extends Mage_Uploader_Block_Multiple {


	/**
	 * Constructor
	 */
		
	
	public function __construct() {
		parent::__construct();
		$this->setTemplate('media/filepicker.phtml');
	}

	/**
	 * Get filepicker.io API key
	 *
	 * @return string
	 */
	public function getApiKey() {
		return Mage::getStoreConfig('admin/aoe_filepicker/apikey');
	}

	/**
	 * Get active filepicker.io services
	 *
	 * @return array
	 */
	public function getServices() {
		return Mage::getStoreConfig('admin/aoe_filepicker/services');
	}

}

}
else {
	
class Aoe_FilePicker_Block_FilePicker extends Mage_Adminhtml_Block_Media_Uploader {

	/**
	 * Constructor
	 */
		
	
	public function __construct() {
		parent::__construct();
		$this->setTemplate('media/filepicker.phtml');
	}

	/**
	 * Get filepicker.io API key
	 *
	 * @return string
	 */
	public function getApiKey() {
		return Mage::getStoreConfig('admin/aoe_filepicker/apikey');
	}

	/**
	 * Get active filepicker.io services
	 *
	 * @return array
	 */
	public function getServices() {
		return Mage::getStoreConfig('admin/aoe_filepicker/services');
	}

}
	
}

in filepicker.phtml I've added also the ckecking and the modifications accordingly

<?php
		
		if (class_exists("Mage_Uploader_Block_Abstract")) {
		// PATCH SUPEE-8788 or Magento 1.9.3
		?>
		
		var _uploads = {
			data: <?php echo $this->getJsonConfig();  ?>,
			removeFile: function() {}
		}
		
   
		Event.observe('<?php echo $this->getHtmlId() ?>-button', 'click', function(event) {
			filepicker.getFile('image/*', {
				'multiple': true,
				'modal': true,
				'services': [<?php echo $this->getServices() ?>]
			}, function(response) {
				// take the response from filepicker.io and pass send it to Magento via Ajax
				new Ajax.Request(_uploads.data.uploaderConfig.target, {
					method: 'post',
					parameters: {fp_response: JSON.stringify(response) },
					onSuccess: function(transport) {
						transport.responseText.evalJSON().each(function(item) {
							media_gallery_contentJsObject.handleUploadComplete([{response: Object.toJSON(item)}])
						});

					},
					onFailure: function() { alert('Something went wrong...') }
				});

			});
			Event.stop(event);
		});
		
		<?php
		}
		else {
			?>
			
			<?php echo $this->getJsObjectName() ?> = {
			data: <?php echo $this->getConfigJson() ?>,
			removeFile: function() {}
		}
		Event.observe('<?php echo $this->getHtmlId() ?>-button', 'click', function(event) {
			filepicker.getFile('image/*', {
				'multiple': true,
				'modal': true,
				'services': [<?php echo $this->getServices() ?>]
			}, function(response) {
				// take the response from filepicker.io and pass send it to Magento via Ajax
				new Ajax.Request(<?php echo $this->getJsObjectName() ?>.data.url, {
					method: 'post',
					parameters: {fp_response: JSON.stringify(response) },
					onSuccess: function(transport) {
						transport.responseText.evalJSON().each(function(item) {
							media_gallery_contentJsObject.handleUploadComplete([{response: Object.toJSON(item)}])
						});
					},
					onFailure: function() { alert('Something went wrong...') }
				});
			});
			Event.stop(event);
		});
			
			<?php
		}
		?>

from aoe_filepicker.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.