diff --git a/app/code/core/Mage/Adminhtml/Block/Media/Editor.php b/app/code/core/Mage/Adminhtml/Block/Media/Editor.php deleted file mode 100644 index b28181bddcd..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Media/Editor.php +++ /dev/null @@ -1,169 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Media_Editor extends Mage_Adminhtml_Block_Widget -{ - /** - * @var Varien_Object|null - */ - protected $_config; - - /** - * Mage_Adminhtml_Block_Media_Editor constructor. - */ - public function __construct() - { - parent::__construct(); - $this->setTemplate('media/editor.phtml'); - $this->getConfig()->setImage($this->getSkinUrl('images/image.jpg')); - $this->getConfig()->setParams(); - } - - /** - * @inheritDoc - */ - protected function _prepareLayout() - { - $this->setChild( - 'rotatecw_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->addData([ - 'id' => $this->_getButtonId('rotatecw'), - 'label' => Mage::helper('adminhtml')->__('Rotate CW'), - 'onclick' => $this->getJsObjectName() . '.rotateCw()' - ]) - ); - - $this->setChild( - 'rotateccw_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->addData([ - 'id' => $this->_getButtonId('rotateccw'), - 'label' => Mage::helper('adminhtml')->__('Rotate CCW'), - 'onclick' => $this->getJsObjectName() . '.rotateCCw()' - ]) - ); - - $this->setChild( - 'resize_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->addData([ - 'id' => $this->_getButtonId('upload'), - 'label' => Mage::helper('adminhtml')->__('Resize'), - 'onclick' => $this->getJsObjectName() . '.resize()' - ]) - ); - - $this->setChild( - 'image_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->addData([ - 'id' => $this->_getButtonId('image'), - 'label' => Mage::helper('adminhtml')->__('Get Image Base64'), - 'onclick' => $this->getJsObjectName() . '.getImage()' - ]) - ); - - return parent::_prepareLayout(); - } - - /** - * @param string $buttonName - * @return string - */ - protected function _getButtonId($buttonName) - { - return $this->getHtmlId() . '-' . $buttonName; - } - - /** - * @return string - */ - public function getRotatecwButtonHtml() - { - return $this->getChildHtml('rotatecw_button'); - } - - /** - * @return string - */ - public function getImageButtonHtml() - { - return $this->getChildHtml('image_button'); - } - - /** - * @return string - */ - public function getRotateccwButtonHtml() - { - return $this->getChildHtml('rotateccw_button'); - } - - /** - * @return string - */ - public function getResizeButtonHtml() - { - return $this->getChildHtml('resize_button'); - } - - /** - * Retrieve uploader js object name - * - * @return string - */ - public function getJsObjectName() - { - return $this->getHtmlId() . 'JsObject'; - } - - /** - * Retrieve config json - * - * @return string - */ - public function getConfigJson() - { - return Mage::helper('core')->jsonEncode($this->getConfig()->getData()); - } - - /** - * Retrieve config object - * - * @return Varien_Object - */ - public function getConfig() - { - if (is_null($this->_config)) { - $this->_config = new Varien_Object(); - } - - return $this->_config; - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Media/Uploader.php b/app/code/core/Mage/Adminhtml/Block/Media/Uploader.php deleted file mode 100644 index e48adc7439d..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Media/Uploader.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @deprecated - */ -class Mage_Adminhtml_Block_Media_Uploader extends Mage_Uploader_Block_Multiple -{ - public function __construct() - { - parent::__construct(); - $this->getUploaderConfig()->setTarget(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/upload')); - $this->getUploaderConfig()->setFileParameterName('file'); - } -} diff --git a/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php b/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php deleted file mode 100644 index de44a52120e..00000000000 --- a/app/code/core/Mage/Adminhtml/controllers/Media/EditorController.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -class Mage_Adminhtml_Media_EditorController extends Mage_Adminhtml_Controller_Action -{ - /** - * ACL resource - * @see Mage_Adminhtml_Controller_Action::_isAllowed() - */ - public const ADMIN_RESOURCE = 'media'; - - public function indexAction() - { - $this->loadLayout(); - $this->_addContent( - $this->getLayout()->createBlock('adminhtml/media_editor') - ); - $this->renderLayout(); - } -} diff --git a/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php b/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php deleted file mode 100644 index 3990b516e08..00000000000 --- a/app/code/core/Mage/Adminhtml/controllers/Media/UploaderController.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class Mage_Adminhtml_Media_UploaderController extends Mage_Adminhtml_Controller_Action -{ - /** - * ACL resource - * @see Mage_Adminhtml_Controller_Action::_isAllowed() - */ - public const ADMIN_RESOURCE = 'media'; - - public function uploadAction() - { - $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($_REQUEST)); - } - - public function indexAction() - { - $this->loadLayout(); - $this->_addContent( - $this->getLayout()->createBlock('uploader/multiple') - ); - $this->renderLayout(); - } -} diff --git a/app/code/core/Mage/Adminhtml/etc/jstranslator.xml b/app/code/core/Mage/Adminhtml/etc/jstranslator.xml index 36d04040d02..640090d253b 100644 --- a/app/code/core/Mage/Adminhtml/etc/jstranslator.xml +++ b/app/code/core/Mage/Adminhtml/etc/jstranslator.xml @@ -25,40 +25,7 @@ The Special Price is active only when lower than the Actual Price. - - - Complete - - - Upload Security Error - - - Upload HTTP Error - - - Upload I/O Error - - - SSL Error: Invalid or self-signed certificate - - - Tb - - - Gb - - - Mb - - - Kb - - - b - - Add Products - diff --git a/app/design/adminhtml/default/default/template/media/editor.phtml b/app/design/adminhtml/default/default/template/media/editor.phtml deleted file mode 100644 index 0ccdc032afc..00000000000 --- a/app/design/adminhtml/default/default/template/media/editor.phtml +++ /dev/null @@ -1,40 +0,0 @@ - -helper('adminhtml/js')->includeScript('lib/flex.js') ?> -helper('adminhtml/js')->includeScript('lib/FABridge.js') ?> -helper('adminhtml/js')->includeScript('mage/adminhtml/image.js') ?> -
-
- getRotatecwButtonHtml() ?> - getRotateccwButtonHtml() ?> - - x - px - getResizeButtonHtml() ?> - getImageButtonHtml() ?> -
- - -
- - diff --git a/js/lib/FABridge.js b/js/lib/FABridge.js deleted file mode 100644 index a413632442b..00000000000 --- a/js/lib/FABridge.js +++ /dev/null @@ -1,613 +0,0 @@ -/* -Copyright 2006 Adobe Systems Incorporated - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -*/ - - -/* - * The Bridge class, responsible for navigating AS instances - */ -function FABridge(target,bridgeName) -{ - this.target = target; - this.remoteTypeCache = {}; - this.remoteInstanceCache = {}; - this.remoteFunctionCache = {}; - this.localFunctionCache = {}; - this.bridgeID = FABridge.nextBridgeID++; - this.name = bridgeName; - this.nextLocalFuncID = 0; - FABridge.instances[this.name] = this; - FABridge.idMap[this.bridgeID] = this; - - return this; -} - -// type codes for packed values -FABridge.TYPE_ASINSTANCE = 1; -FABridge.TYPE_ASFUNCTION = 2; - -FABridge.TYPE_JSFUNCTION = 3; -FABridge.TYPE_ANONYMOUS = 4; - -FABridge.initCallbacks = {}; -FABridge.userTypes = {}; - -FABridge.addToUserTypes = function() -{ - for (var i = 0; i < arguments.length; i++) - { - FABridge.userTypes[arguments[i]] = { - 'typeName': arguments[i], - 'enriched': false - }; - } -} - -FABridge.argsToArray = function(args) -{ - var result = []; - for (var i = 0; i < args.length; i++) - { - result[i] = args[i]; - } - return result; -} - -function instanceFactory(objID) -{ - this.fb_instance_id = objID; - return this; -} - -function FABridge__invokeJSFunction(args) -{ - var funcID = args[0]; - var throughArgs = args.concat();//FABridge.argsToArray(arguments); - throughArgs.shift(); - - var bridge = FABridge.extractBridgeFromID(funcID); - return bridge.invokeLocalFunction(funcID, throughArgs); -} - -FABridge.addInitializationCallback = function(bridgeName, callback) -{ - var inst = FABridge.instances[bridgeName]; - if (inst != undefined) - { - callback.call(inst); - return; - } - - var callbackList = FABridge.initCallbacks[bridgeName]; - if(callbackList == null) - { - FABridge.initCallbacks[bridgeName] = callbackList = []; - } - - callbackList.push(callback); -} - -// updated for changes to SWFObject2 -function FABridge__bridgeInitialized(bridgeName) { - var objects = document.getElementsByTagName("object"); - var ol = objects.length; - var activeObjects = []; - if (ol > 0) { - for (var i = 0; i < ol; i++) { - if (typeof objects[i].SetVariable != "undefined") { - activeObjects[activeObjects.length] = objects[i]; - } - } - } - var embeds = document.getElementsByTagName("embed"); - var el = embeds.length; - var activeEmbeds = []; - if (el > 0) { - for (var j = 0; j < el; j++) { - if (typeof embeds[j].SetVariable != "undefined") { - activeEmbeds[activeEmbeds.length] = embeds[j]; - } - } - } - var aol = activeObjects.length; - var ael = activeEmbeds.length; - var searchStr = "bridgeName="+ bridgeName; - if ((aol == 1 && !ael) || (aol == 1 && ael == 1)) { - FABridge.attachBridge(activeObjects[0], bridgeName); - } - else if (ael == 1 && !aol) { - FABridge.attachBridge(activeEmbeds[0], bridgeName); - } - else { - var flash_found = false; - if (aol > 1) { - for (var k = 0; k < aol; k++) { - var params = activeObjects[k].childNodes; - for (var l = 0; l < params.length; l++) { - var param = params[l]; - if (param.nodeType == 1 && param.tagName.toLowerCase() == "param" && param["name"].toLowerCase() == "flashvars" && param["value"].indexOf(searchStr) >= 0) { - FABridge.attachBridge(activeObjects[k], bridgeName); - flash_found = true; - break; - } - } - if (flash_found) { - break; - } - } - } - if (!flash_found && ael > 1) { - for (var m = 0; m < ael; m++) { - var flashVars = activeEmbeds[m].attributes.getNamedItem("flashVars").nodeValue; - if (flashVars.indexOf(searchStr) >= 0) { - FABridge.attachBridge(activeEmbeds[m], bridgeName); - break; - } - } - } - } - return true; -} - -// used to track multiple bridge instances, since callbacks from AS are global across the page. - -FABridge.nextBridgeID = 0; -FABridge.instances = {}; -FABridge.idMap = {}; -FABridge.refCount = 0; - -FABridge.extractBridgeFromID = function(id) -{ - var bridgeID = (id >> 16); - return FABridge.idMap[bridgeID]; -} - -FABridge.attachBridge = function(instance, bridgeName) -{ - - // reuse bridge if it exists -// var newBridgeInstance = new FABridge(instance, bridgeName); - - // reuse bridge if it exists -// FABridge[bridgeName] = newBridgeInstance; - - if (typeof FABridge[bridgeName] == 'undefined') { - FABridge[bridgeName] = new FABridge(instance, bridgeName); - } - -/* FABridge[bridgeName] = function() { - return newBridgeInstance.root(); - } -*/ - var callbacks = FABridge.initCallbacks[bridgeName]; - if (callbacks == null) - { - return; - } - for (var i = 0; i < callbacks.length; i++) - { -// callbacks[i].call(newBridgeInstance); - callbacks[i].call(FABridge[bridgeName]); - } - - // reuse bridge if it exists -// delete FABridge.initCallbacks[bridgeName] -} - -// some methods can't be proxied. You can use the explicit get,set, and call methods if necessary. - -FABridge.blockedMethods = -{ - toString: true, - get: true, - set: true, - call: true -}; - -FABridge.prototype = -{ - - -// bootstrapping - - root: function() - { - return this.deserialize(this.target.getRoot()); - }, -//clears all of the AS objects in the cache maps - releaseASObjects: function() - { - return this.target.releaseASObjects(); - }, -//clears a specific object in AS from the type maps - releaseNamedASObject: function(value) - { - if(typeof(value) != "object") - { - return false; - } - else - { - var ret = this.target.releaseNamedASObject(value.fb_instance_id); - return ret; - } - }, -//create a new AS Object - create: function(className) - { - return this.deserialize(this.target.create(className)); - }, - - - // utilities - - makeID: function(token) - { - return (this.bridgeID << 16) + token; - }, - - - // low level access to the flash object - -//get a named property from an AS object - getPropertyFromAS: function(objRef, propName) - { - if (FABridge.refCount > 0) - { - throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); - } - else - { - FABridge.refCount++; - retVal = this.target.getPropFromAS(objRef, propName); - retVal = this.handleError(retVal); - FABridge.refCount--; - return retVal; - } - }, -//set a named property on an AS object - setPropertyInAS: function(objRef,propName, value) - { - if (FABridge.refCount > 0) - { - throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); - } - else - { - FABridge.refCount++; - retVal = this.target.setPropInAS(objRef,propName, this.serialize(value)); - retVal = this.handleError(retVal); - FABridge.refCount--; - return retVal; - } - }, - -//call an AS function - callASFunction: function(funcID, args) - { - if (FABridge.refCount > 0) - { - throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); - } - else - { - FABridge.refCount++; - retVal = this.target.invokeASFunction(funcID, this.serialize(args)); - retVal = this.handleError(retVal); - FABridge.refCount--; - return retVal; - } - }, -//call a method on an AS object - callASMethod: function(objID, funcName, args) - { - if (FABridge.refCount > 0) - { - throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); - } - else - { - FABridge.refCount++; - args = this.serialize(args); - retVal = this.target.invokeASMethod(objID, funcName, args); - retVal = this.handleError(retVal); - FABridge.refCount--; - return retVal; - } - }, - - // responders to remote calls from flash - - //callback from flash that executes a local JS function - //used mostly when setting js functions as callbacks on events - invokeLocalFunction: function(funcID, args) - { - var result; - var func = this.localFunctionCache[funcID]; - - if(func != undefined) - { - result = this.serialize(func.apply(null, this.deserialize(args))); - } - - return result; - }, - - // Object Types and Proxies - - // accepts an object reference, returns a type object matching the obj reference. - getTypeFromName: function(objTypeName) - { - return this.remoteTypeCache[objTypeName]; - }, - //create an AS proxy for the given object ID and type - createProxy: function(objID, typeName) - { - var objType = this.getTypeFromName(typeName); - instanceFactory.prototype = objType; - var instance = new instanceFactory(objID); - this.remoteInstanceCache[objID] = instance; - return instance; - }, - //return the proxy associated with the given object ID - getProxy: function(objID) - { - return this.remoteInstanceCache[objID]; - }, - - // accepts a type structure, returns a constructed type - addTypeDataToCache: function(typeData) - { - newType = new ASProxy(this, typeData.name); - var accessors = typeData.accessors; - for (var i = 0; i < accessors.length; i++) - { - this.addPropertyToType(newType, accessors[i]); - } - - var methods = typeData.methods; - for (var i = 0; i < methods.length; i++) - { - if (FABridge.blockedMethods[methods[i]] == undefined) - { - this.addMethodToType(newType, methods[i]); - } - } - - - this.remoteTypeCache[newType.typeName] = newType; - return newType; - }, - - //add a property to a typename; used to define the properties that can be called on an AS proxied object - addPropertyToType: function(ty, propName) - { - var c = propName.charAt(0); - var setterName; - var getterName; - if(c >= "a" && c <= "z") - { - getterName = "get" + c.toUpperCase() + propName.substr(1); - setterName = "set" + c.toUpperCase() + propName.substr(1); - } - else - { - getterName = "get" + propName; - setterName = "set" + propName; - } - ty[setterName] = function(val) - { - this.bridge.setPropertyInAS(this.fb_instance_id, propName, val); - } - ty[getterName] = function() - { - return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName)); - } - }, - - //add a method to a typename; used to define the methods that can be callefd on an AS proxied object - addMethodToType: function(ty, methodName) - { - ty[methodName] = function() - { - return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id, methodName, FABridge.argsToArray(arguments))); - } - }, - - // Function Proxies - - //returns the AS proxy for the specified function ID - getFunctionProxy: function(funcID) - { - var bridge = this; - if (this.remoteFunctionCache[funcID] == null) - { - this.remoteFunctionCache[funcID] = function() - { - bridge.callASFunction(funcID, FABridge.argsToArray(arguments)); - } - } - return this.remoteFunctionCache[funcID]; - }, - - //reutrns the ID of the given function; if it doesnt exist it is created and added to the local cache - getFunctionID: function(func) - { - if (func.__bridge_id__ == undefined) - { - func.__bridge_id__ = this.makeID(this.nextLocalFuncID++); - this.localFunctionCache[func.__bridge_id__] = func; - } - return func.__bridge_id__; - }, - - // serialization / deserialization - - serialize: function(value) - { - var result = {}; - - var t = typeof(value); - //primitives are kept as such - if (t == "number" || t == "string" || t == "boolean" || t == null || t == undefined) - { - result = value; - } - else if (value instanceof Array) - { - //arrays are serializesd recursively - result = []; - for (var i = 0; i < value.length; i++) - { - result[i] = this.serialize(value[i]); - } - } - else if (t == "function") - { - //js functions are assigned an ID and stored in the local cache - result.type = FABridge.TYPE_JSFUNCTION; - result.value = this.getFunctionID(value); - } - else if (value instanceof ASProxy) - { - result.type = FABridge.TYPE_ASINSTANCE; - result.value = value.fb_instance_id; - } - else - { - result.type = FABridge.TYPE_ANONYMOUS; - result.value = value; - } - - return result; - }, - - //on deserialization we always check the return for the specific error code that is used to marshall NPE's into JS errors - // the unpacking is done by returning the value on each pachet for objects/arrays - deserialize: function(packedValue) - { - - var result; - - var t = typeof(packedValue); - if (t == "number" || t == "string" || t == "boolean" || packedValue == null || packedValue == undefined) - { - result = this.handleError(packedValue); - } - else if (packedValue instanceof Array) - { - result = []; - for (var i = 0; i < packedValue.length; i++) - { - result[i] = this.deserialize(packedValue[i]); - } - } - else if (t == "object") - { - for(var i = 0; i < packedValue.newTypes.length; i++) - { - this.addTypeDataToCache(packedValue.newTypes[i]); - } - for (var aRefID in packedValue.newRefs) - { - this.createProxy(aRefID, packedValue.newRefs[aRefID]); - } - if (packedValue.type == FABridge.TYPE_PRIMITIVE) - { - result = packedValue.value; - } - else if (packedValue.type == FABridge.TYPE_ASFUNCTION) - { - result = this.getFunctionProxy(packedValue.value); - } - else if (packedValue.type == FABridge.TYPE_ASINSTANCE) - { - result = this.getProxy(packedValue.value); - } - else if (packedValue.type == FABridge.TYPE_ANONYMOUS) - { - result = packedValue.value; - } - } - return result; - }, - //increases the reference count for the given object - addRef: function(obj) - { - this.target.incRef(obj.fb_instance_id); - }, - //decrease the reference count for the given object and release it if needed - release:function(obj) - { - this.target.releaseRef(obj.fb_instance_id); - }, - - // check the given value for the components of the hard-coded error code : __FLASHERROR - // used to marshall NPE's into flash - - handleError: function(value) - { - if (typeof(value)=="string" && value.indexOf("__FLASHERROR")==0) - { - var myErrorMessage = value.split("||"); - if(FABridge.refCount > 0 ) - { - FABridge.refCount--; - } - throw new Error(myErrorMessage[1]); - return value; - } - else - { - return value; - } - } -}; - -// The root ASProxy class that facades a flash object - -ASProxy = function(bridge, typeName) -{ - this.bridge = bridge; - this.typeName = typeName; - return this; -}; -//methods available on each ASProxy object -ASProxy.prototype = -{ - get: function(propName) - { - return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName)); - }, - - set: function(propName, value) - { - this.bridge.setPropertyInAS(this.fb_instance_id, propName, value); - }, - - call: function(funcName, args) - { - this.bridge.callASMethod(this.fb_instance_id, funcName, args); - }, - - addRef: function() { - this.bridge.addRef(this); - }, - - release: function() { - this.bridge.release(this); - } -}; diff --git a/js/lib/flex.js b/js/lib/flex.js deleted file mode 100644 index fead2806486..00000000000 --- a/js/lib/flex.js +++ /dev/null @@ -1,422 +0,0 @@ -/** - * OpenMage - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. - * - * @category Mage - * @package js - * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022 The OpenMage Contributors (https://www.openmage.org) - * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -/** - * Flex maintance object - * - * - */ -Flex = {}; -Flex.currentID = 0; -Flex.uniqId = function() { - return 'flexMovieUID'+( ++Flex.currentID ); -}; - -/** - * Check flash player version for required version - * - * @param Number major - * @param Number minor - * @param Number revision - * @return Boolean - */ -Flex.checkFlashPlayerVersion = function(major, minor, revision) { - var version = Flex.getFlashPlayerVersion(); - - if (version === false) { - return false; - } - - var requestedVersion = Flex.transformVersionToFloat([major, minor, revision], 5); - var currentVersion = Flex.transformVersionToFloat(version, 5); - - return requestedVersion <= currentVersion; -}; - -/** - * Get flash player version in internet explorer - * by creating of test ActiveXObjects - * - * @return String|Boolean - */ -Flex._getFlashPlayerVersionAsActiveX = function () { - var versions = [ - {'default': '7.0.0', 'code':'ShockwaveFlash.ShockwaveFlash.7', 'variable':true}, - {'default': '6.0.0', 'code':'ShockwaveFlash.ShockwaveFlash.6', 'variable':true, 'acceess':true}, - {'default': '3.0.0', 'code':'ShockwaveFlash.ShockwaveFlash.3', 'variable':false}, - {'default': '2.0.0', 'code':'ShockwaveFlash.ShockwaveFlash', 'variable':false}, - ]; - - var detector = function (options) { - var activeXObject = new ActiveXObject(options.code); - if (options.access && options.variable) { - activeXObject.AllowScriptAccess = 'always'; - } - - if (options.variable) { - return activeXObject.GetVariable('$version'); - } - - return options['default']; - } - - var version = false; - - for (var i = 0, l = versions.length; i < l; i++) { - try { - version = detector(versions[i]); - return version; - } catch (e) {} - } - - return false; -}; - -/** - * Transforms version string like 1.0.0 to array [1,0,0] - * - * @param String|Array version - * @return Array|Boolean - */ -Flex.transformVersionToArray = function (version) { - if (!Object.isString(version)) { - return false; - } - - var versions = version.match(/[\d]+/g); - - if (versions.length > 3) { - return versions.slice(0,3); - } else if (versions.length) { - return versions; - } - - - - return false; -}; - -/** - * Transforms version string like 1.1.1 to float 1.00010001 - * - * @param String|Array version - * @param Number range - percition range between version digits - * @return Array - */ -Flex.transformVersionToFloat = function (version, range) { - if (Object.isString(version)) { - version = Flex.transformVersionToArray(version) - } - - if (Object.isArray(version)) { - var result = 0; - for (var i =0, l=version.length; i < l; i++) { - result += parseFloat(version[i]) / Math.pow(10, range*i); - } - - return result; - } - - return false; -}; - -/** - * Return flash player version as array of 0=major, 1=minor, 2=revision - * - * @return Array|Boolean - */ -Flex.getFlashPlayerVersion = function () { - if (Flex.flashPlayerVersion) { - return Flex.flashPlayerVersion; - } - - var version = false; - if (navigator.plugins != null && navigator.plugins.length > 0) { - if (navigator.mimeTypes && navigator.mimeTypes.length > 0) { - if (navigator.mimeTypes['application/x-shockwave-flash'] && - !navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) { - return false; - } - } - var flashPlugin = navigator.plugins['Shockwave Flash'] || navigator.plugins['Shockwave Flash 2.0']; - version = Flex.transformVersionToArray(flashPlugin.description); - } else { - version = Flex.transformVersionToArray(Flex._getFlashPlayerVersionAsActiveX()); - } - - Flex.flashPlayerVersion = version; - return version; -}; - -Flex.Object = Class.create({ - /** - * Initialize object from configuration, where configuration keys, - * is set of tag attributes for object or embed - * - * @example - * new Flex.Object({'src':'path/to/flashmovie.swf'}); - * - * @param Object config - * @return void - */ - initialize: function (config) { - this.isIE = Prototype.Browser.IE; - this.isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; - this.attributes = { - quality:"high", - pluginspage: "http://www.adobe.com/go/getflashplayer", - type: "application/x-shockwave-flash", - allowScriptAccess: "always", - classid: "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" - }; - this.bridgeName = ''; - this.bridge = false; - this.setAttributes( config ); - this.applied = false; - - var myTemplatesPattern = /(^|.|\r|\n)(\{(.*?)\})/; - if(this.detectFlashVersion(9, 0, 28)) { - if(this.isIE) { - this.template = new Template( '{objectParameters}', myTemplatesPattern ) - } else { - this.template = new Template( '', myTemplatesPattern ); - } - } else { - this.template = new Template( 'This content requires the Adobe Flash Player. ' - +' Get Flash', myTemplatesPattern ); - } - - this.parametersTemplate = new Template( '', myTemplatesPattern ); - this.attributesTemplate = new Template( ' {name}="{value}" ', myTemplatesPattern ); - }, - /** - * Set object attribute for generation of html tags - * - * @param Sting name - * @param Object value - * @return void - */ - setAttribute : function( name, value ) { - if(!this.applied) { - this.attributes[name] = value; - } - }, - /** - * Retrieve object attribute value used for generation in html tags - * - * @param Sting name - * @return Object - */ - getAttribute : function( name ) { - return this.attributes[name]; - }, - /** - * Set object attributes in one call - * - * @param Object attributesList - * @return void - */ - setAttributes : function( attributesList ) { - $H(attributesList).each(function(pair){ - this.setAttribute(pair.key, pair.value); - }.bind(this)); - }, - /** - * Retrieve all object attributes - * - * @return Object - */ - getAttributes : function( ) { - return this.attributes; - }, - /** - * Applies generated HTML content to specified HTML tag - * - * @param String|DOMELement container - * @return void - */ - apply : function(container) { - if (!this.applied) { - this.setAttribute("id", Flex.uniqId()); - this.preInitBridge(); - var readyHTML = this.template.evaluate(this.generateTemplateValues()); - $(container).update(readyHTML); - } - this.applied = true; - }, - /** - * Applies generated HTML content to window.document - * - * @return void - */ - applyWrite : function( ) { - if (!this.applied) { - this.setAttribute( "id", Flex.uniqId()); - this.preInitBridge(); - var readyHTML = this.template.evaluate( this.generateTemplateValues() ); - document.write( readyHTML ); - } - this.applied = true; - }, - /** - * Preinitialize FABridge values - * - * @return void - */ - preInitBridge: function () { - this.bridgeName = this.getAttribute('id') + 'bridge'; - var flashVars = this.getAttribute('flashVars') || this.getAttribute('flashvars') || ''; - if (flashVars != '') { - flashVars += '&'; - } - flashVars += 'bridgeName=' + this.bridgeName; - this.setAttribute('flashVars', flashVars); - var scopeObj = this; - FABridge.addInitializationCallback( - this.bridgeName, - function () { - scopeObj.bridge = this.root(); - scopeObj.initBridge(); - } - ); - }, - /** - * Initialize bridge callback passed to FABridge, - * calls internal callback if it's presented - * - * @return void - */ - initBridge: function() { - if(this.onBridgeInit) { - this.onBridgeInit(this.getBridge()); - } - }, - /** - * Retrieve FABridge instance for this object - * - * @return Object - */ - getBridge : function() { - return this.bridge; - }, - /** - * Generate temaplate values object for creation of flash player plugin movie HTML - * - * @return Object - */ - generateTemplateValues : function() { - var attributesMap = { - embed: { - 'movie':'src', - 'id':'name', - 'flashvars': 'flashVars', - 'classid':false, - 'codebase':false - }, - object: { - 'pluginspage':false, - 'src':'movie', - 'flashvars': 'flashVars', - 'type':false, - 'inline': [ - 'type', 'classid', 'codebase', 'id', 'width', 'height', - 'align', 'vspace', 'hspace', 'class', 'title', 'accesskey', 'name', - 'tabindex' - ] - } - }; - var embedAttributes = {}; - var objectAttributes = {}; - var parameters = {}; - $H(this.attributes).each(function(pair) { - var attributeName = pair.key.toLowerCase(); - this.attributes[pair.key] = this.escapeAttributes(pair.value); - - // Retrieve mapped attribute names - var attributeNameInObject = (attributesMap.object[attributeName] ? attributesMap.object[attributeName] : attributeName); - var attributeNameInEmbed = (attributesMap.embed[attributeName] ? attributesMap.embed[attributeName] : attributeName); - - if (attributesMap.object[attributeName] !== false) { - if (attributesMap.object.inline.indexOf(attributeNameInObject) !== -1) { // If it included in default object attribute - objectAttributes[attributeNameInObject] = this.attributes[pair.key]; - } else { // otherwise add it to parameters tag list - parameters[attributeNameInObject] = this.attributes[pair.key]; - } - } - - if (attributesMap.embed[attributeName] !== false) { // If this attribute not ignored for flash in Gecko Browsers - embedAttributes[attributeNameInEmbed] = this.attributes[pair.key]; - } - }.bind(this)); - - var result = { - objectAttributes: '', - objectParameters: '', - embedAttributes : '' - }; - - - $H(objectAttributes).each(function(pair){ - result.objectAttributes += this.attributesTemplate.evaluate({ - name:pair.key, - value:pair.value - }); - }.bind(this)); - - $H(embedAttributes).each(function(pair){ - result.embedAttributes += this.attributesTemplate.evaluate({ - name:pair.key, - value:pair.value - }); - }.bind(this)); - - $H(parameters).each(function(pair){ - result.objectParameters += this.parametersTemplate.evaluate({ - name:pair.key, - value:pair.value - }); - }.bind(this)); - - return result; - }, - /** - * Escapes attributes for generation of valid HTML - * - * @return String - */ - escapeAttributes: function (value) { - if(typeof value == 'string') { - return value.escapeHTML(); - } else { - return value; - } - }, - /** - * Detects needed flash player version - * - * @param Number major - * @param Number minor - * @param Number revision - * @return Boolean - */ - detectFlashVersion: function (major, minor, revision) { - return Flex.checkFlashPlayerVersion(major, minor, revision); - } -}); diff --git a/js/mage/adminhtml/flexuploader.js b/js/mage/adminhtml/flexuploader.js deleted file mode 100644 index 91120e0619c..00000000000 --- a/js/mage/adminhtml/flexuploader.js +++ /dev/null @@ -1,367 +0,0 @@ -/** - * OpenMage - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. - * - * @category Mage - * @package Mage_Adminhtml - * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019 The OpenMage Contributors (https://www.openmage.org) - * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) - */ - -if(!window.Flex) { - alert('Flex library not loaded'); -} else { - Flex.Uploader = Class.create(); - Flex.Uploader.prototype = { - flex: null, - uploader:null, - filters:null, - containerId:null, - flexContainerId:null, - container:null, - files:null, - fileRowTemplate:null, - fileProgressTemplate:null, - templatesPattern: /(^|.|\r|\n)(\{\{(.*?)\}\})/, - onFilesComplete: false, - onFileProgress: true, - onFileRemove: false, - onContainerHideBefore:null, - initialize: function(containerId, uploaderSrc, config) { - this.containerId = containerId; - this.container = $(containerId); - - this.container.controller = this; - - this.config = config; - - this.flexContainerId = this.containerId + '-flash'; - Element.insert( - // window.document.body, - this.containerId, - {'before':'
'} - ); - flexWidth = 230; - if (this.config.width) { - flexWidth = this.config.width; - } - this.flex = new Flex.Object({ - left: 100, - top: 300, - width: flexWidth, - height: 20, - src: uploaderSrc, - wmode: 'transparent' - }); - // this.getInnerElement('browse').disabled = true; - // this.getInnerElement('upload').disabled = true; - this.fileRowTemplate = new Template( - this.getInnerElement('template').innerHTML, - this.templatesPattern - ); - - this.fileProgressTemplate = new Template( - this.getInnerElement('template-progress').innerHTML, - this.templatesPattern - ); - - this.flex.onBridgeInit = this.handleBridgeInit.bind(this); - if (this.flex.detectFlashVersion(9, 0, 28)) { - this.flex.apply(this.flexContainerId); - } else { - // this.getInnerElement('browse').hide(); - // this.getInnerElement('upload').hide(); - this.getInnerElement('install-flash').show(); - } - this.onContainerHideBefore = this.handleContainerHideBefore.bind(this); - }, - getInnerElement: function(elementName) { - return $(this.containerId + '-' + elementName); - }, - getFileId: function(file) { - var id; - if(typeof file == 'object') { - id = file.id; - } else { - id = file; - } - return this.containerId + '-file-' + id; - }, - getDeleteButton: function(file) { - return $(this.getFileId(file) + '-delete'); - }, - handleBridgeInit: function() { - this.uploader = this.flex.getBridge().getUpload(); - if (this.config.filters) { - $H(this.config.filters).each(function(pair) { - this.uploader.addTypeFilter(pair.key, pair.value.label, pair.value.files); - }.bind(this)); - delete(this.config.filters); - this.uploader.setUseTypeFilter(true); - } - - this.uploader.setConfig(this.config); - this.uploader.addEventListener('select', this.handleSelect.bind(this)); - this.uploader.addEventListener('complete', this.handleComplete.bind(this)); - this.uploader.addEventListener('progress', this.handleProgress.bind(this)); - this.uploader.addEventListener('error', this.handleError.bind(this)); - this.uploader.addEventListener('removeall', this.handleRemoveAll.bind(this)); - // this.getInnerElement('browse').disabled = false; - // this.getInnerElement('upload').disabled = false; - }, - browse: function() { - this.uploader.browse(); - }, - upload: function() { - this.uploader.upload(); - this.files = this.uploader.getFilesInfo(); - this.updateFiles(); - }, - removeFile: function(id) { - this.uploader.removeFile(id); - $(this.getFileId(id)).remove(); - if (this.onFileRemove) { - this.onFileRemove(id); - } - this.files = this.uploader.getFilesInfo(); - this.updateFiles(); - }, - removeAllFiles: function() { - this.files.each(function(file) { - this.removeFile(file.id); - }.bind(this)); - this.files = this.uploader.getFilesInfo(); - this.updateFiles(); - }, - handleSelect: function (event) { - this.files = event.getData().files; - this.checkFileSize(); - this.updateFiles(); - this.getInnerElement('upload').show(); - if (this.onFileSelect) { - this.onFileSelect(); - } - }, - handleProgress: function (event) { - var file = event.getData().file; - this.updateFile(file); - if (this.onFileProgress) { - this.onFileProgress(file); - } - }, - handleError: function (event) { - this.updateFile(event.getData().file); - }, - handleComplete: function (event) { - this.files = event.getData().files; - this.updateFiles(); - if (this.onFilesComplete) { - this.onFilesComplete(this.files); - } - }, - handleRemoveAll: function (event) { - this.files.each(function(file) { - $(this.getFileId(file.id)).remove(); - }.bind(this)); - if (this.onFileRemoveAll) { - this.onFileRemoveAll(); - } - this.files = this.uploader.getFilesInfo(); - this.updateFiles(); - }, - handleRemove: function (event) { - this.files = this.uploader.getFilesInfo(); - this.updateFiles(); - }, - updateFiles: function () { - this.files.each(function(file) { - this.updateFile(file); - }.bind(this)); - }, - updateFile: function (file) { - if (!$(this.getFileId(file))) { - if (this.config.replace_browse_with_remove) { - $(this.containerId+'-new').show(); - $(this.containerId+'-new').innerHTML = this.fileRowTemplate.evaluate(this.getFileVars(file)); - $(this.containerId+'-old').hide(); - this.flex.getBridge().hideBrowseButton(); - } else { - Element.insert(this.container, {bottom: this.fileRowTemplate.evaluate(this.getFileVars(file))}); - } - } - if (file.status == 'full_complete' && file.response.isJSON()) { - var response = file.response.evalJSON(); - if (typeof response == 'object') { - if (typeof response.cookie == 'object') { - var date = new Date(); - date.setTime(date.getTime()+(parseInt(response.cookie.lifetime)*1000)); - - document.cookie = escape(response.cookie.name) + "=" - + escape(response.cookie.value) - + "; expires=" + date.toUTCString() - + (response.cookie.path.blank() ? "" : "; path=" + response.cookie.path) - + (response.cookie.domain.blank() ? "" : "; domain=" + response.cookie.domain); - } - if (typeof response.error != 'undefined' && response.error != 0) { - file.status = 'error'; - file.errorText = response.error; - } - } - } - - if (file.status == 'full_complete' && !file.response.isJSON()) { - file.status = 'error'; - } - - var progress = $(this.getFileId(file)).getElementsByClassName('progress-text')[0]; - if ((file.status=='progress') || (file.status=='complete')) { - $(this.getFileId(file)).addClassName('progress'); - $(this.getFileId(file)).removeClassName('new'); - $(this.getFileId(file)).removeClassName('error'); - if (file.progress && file.progress.total) { - progress.update(this.fileProgressTemplate.evaluate(this.getFileProgressVars(file))); - } else { - progress.update(''); - } - if (! this.config.replace_browse_with_remove) { - this.getDeleteButton(file).hide(); - } - } else if (file.status=='error') { - $(this.getFileId(file)).addClassName('error'); - $(this.getFileId(file)).removeClassName('progress'); - $(this.getFileId(file)).removeClassName('new'); - var errorText = file.errorText ? file.errorText : this.errorText(file); - if (this.config.replace_browse_with_remove) { - this.flex.getBridge().hideBrowseButton(); - } else { - this.getDeleteButton(file).show(); - } - - progress.update(errorText); - - } else if (file.status=='full_complete') { - $(this.getFileId(file)).addClassName('complete'); - $(this.getFileId(file)).removeClassName('progress'); - $(this.getFileId(file)).removeClassName('error'); - if (this.config.replace_browse_with_remove) { - this.flex.getBridge().hideRemoveButton(); - } - progress.update(this.translate('Complete')); - } - }, - getDebugStr: function(obj) { - return Object.toJSON(obj).replace('&', '&').replace('>', '>').replace('<', '<'); - }, - getFileVars: function(file) { - return { - id : this.getFileId(file), - fileId : file.id, - name : file.name, - size : this.formatSize(file.size) - }; - }, - getFileProgressVars: function(file) { - return { - total : this.formatSize(file.progress.total), - uploaded : this.formatSize(file.progress.loaded), - percent : this.round((file.progress.loaded/file.progress.total)*100) - }; - }, - formatSize: function(size) { - if (size > 1024 * 1024 * 1024 * 1024) { - return this.round(size / (1024 * 1024 * 1024 * 1024)) + ' ' + this.translate('TB'); - } else if (size > 1024 * 1024 * 1024) { - return this.round(size / (1024 * 1024 * 1024)) + ' ' + this.translate('GB'); - } else if (size > 1024 * 1024) { - return this.round(size / (1024 * 1024)) + ' ' + this.translate('MB'); - } else if (size > 1024) { - return this.round(size / (1024)) + ' ' + this.translate('kB'); - } - return size + ' ' + this.translate('B'); - }, - round: function(number) { - return Math.round(number*100)/100; - }, - checkFileSize: function() { - newFiles = []; - hasTooBigFiles = false; - this.files.each(function(file){ - if (file.size > maxUploadFileSizeInBytes) { - hasTooBigFiles = true; - this.uploader.removeFile(file.id); - } else { - newFiles.push(file); - } - }.bind(this)); - this.files = newFiles; - if (hasTooBigFiles) { - alert( - this.translate('Maximum allowed file size for upload is')+' '+maxUploadFileSize+".\n"+this.translate('Please check your server PHP settings.') - ); - } - }, - translate: function(text) { - try { - if(Translator){ - return Translator.translate(text); - } - } - catch(e){} - return text; - }, - errorText: function(file) { - var error = ''; - - switch(file.errorCode) { - case 1: // Size 0 - error = 'File size should be more than 0 bytes'; - break; - case 2: // Http error - error = 'Upload HTTP Error'; - break; - case 3: // I/O error - error = 'Upload I/O Error'; - break; - case 4: // Security error - error = 'Upload Security Error'; - break; - case 5: // SSL self-signed certificate - error = 'SSL Error: Invalid or self-signed certificate'; - break; - } - - if(error) { - return this.translate(error); - } - - return error; - }, - handleContainerHideBefore: function(container) { - if (container && Element.descendantOf(this.container, container) && !this.checkAllComplete()) { - if (! confirm('There are files that were selected but not uploaded yet. After switching to another tab your selections will be lost. Do you wish to continue ?')) { - return 'cannotchange'; - } else { - this.removeAllFiles(); - } - } - }, - checkAllComplete: function() { - if (this.files) { - return !this.files.any(function(file) { - return (file.status !== 'full_complete'); - }); - } - return true; - } - }; -}