diff --git a/VERSION b/VERSION index adad0eab..662fc873 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.6.0.1373 +4.7.0.1374 diff --git a/configuration.ini.dist b/configuration.ini.dist index 59e5d6a4..9a1fd751 100644 --- a/configuration.ini.dist +++ b/configuration.ini.dist @@ -1,90 +1,185 @@ -# -# This is a sample configuration file -# You can uncomment any line and rename this file to configuration.ini -# +################################################################################################# +# This is a sample configuration file # +# You can uncomment any line and rename this file to configuration.ini # +# For further information go to http://www.wiris.com/plugins/docs/resources/configuration-table # +################################################################################################# -#wirisdebug = false -#wirisimageserviceversion = 3.0 +######################### +# Connection properties # +######################### + +## Specifies formula image server host. -# -# Connection properties -# #wirisimageservicehost = www.wiris.net + +## Specifies formula image server path. + #wirisimageservicepath = /demo/editor/render + +## Specifies formula image server port. If left blank, it is computed automatically. + #wirisimageserviceport = 80 + +## Specifies formula image server protocol. If left blank, it is computed automatically. + #wirisimageserviceprotocol = http -# Proxy configuration + +####################### +# Proxy configuration # +####################### + +## Specifies if your server is using a proxy connection or not. false by default. + #wirisproxy = false + +## If wirisproxy is true, this value specifies the proxy host.. + #wirisproxy_host = + +## If wirisproxy is true, this value specifies the proxy port. + #wirisproxy_port = -# Basic authentication proxy configuration + +############################################ +# Basic authentication proxy configuration # +############################################ + #wirisproxy_user = #wirisproxy_password = -# -# Folder properties -# -# Place to store the cached images. +##################### +# Folder properties # +##################### + +## Place to store the cached images. + #wiriscachedirectory = /var/cache -# Place to store the formulas. + +## Place to store the formulas. + #wirisformuladirectory = /var/formulas -# -# Class overridables -# +###################### +# Class overridables # +###################### + +## Name of the class that manages the storage of formulas. + #wirisstorageclass = com.wiris.plugin.storage.FileStorageAndCache -#wirisconfigurationclass = -#wirisconfigurationrefreshtime = 10000 -# -# Editor behaviour -# +## Name of the class that updates the loaded configuration. + +#wirisconfigurationclass = + + +#################### +# Editor behaviour # +#################### + +## Specifies if WIRIS Editor is enabled. + #wiriseditorenabled = true + +## Specifies the image attribute to store mathml content. + #wiriseditormathmlattribute = data-mathml + +## Specifies how formulas are stored in the database. MathML by default. http://www.wiris.com/en/plugins/docs/full-mathml-mode + #wiriseditorsavemode = xml + +## Specifies if in base64 save mode, images should be stored as a base64 string or as an image. + #wiriseditoreditmode = default + +## Specifies if LaTeX content generated with WIRIS Editor should be shown as an image outside editing areas. + #wiriseditorparselatex = true + +## Specifies if mathml should be parsed on non-mathml modes (image or base64). + #wiriseditorparsexml = false + +## Specifies WIRIS Editor size attributes. + #wiriseditorwindowattributes = width=570, height=450, scroll=no, resizable=yes + +## On image mode specifies if the vertical align of the image should be calculated instead of add extra space to vertically center the image. + #wiriseditorsetsize = false -#wiriseditormodalwindow = false -#wiriseditormodalwindowfullscreen = true + +## Specifies if WIRIS Editor should be opened on a modal window or in a pop-up window. true by default. + +#wiriseditormodalwindow = true + +## Specifies if the modal window should be opened in full-screen mode. false by default. + +#wiriseditormodalwindowfullscreen = false + +## Specifies if chemistry editor is enabled. true by default. + #wirischemeditorenabled = true -#wirisimageformat = png -# -# Editor inherit parameters -# +## Specifies image format (svg or png). svg by default. + +#wirisimageformat = svg + +############################################################################################### +# Editor inherit parameters # +# The format is a JSON containing WIRIS Editor parameters defined on the following page: # +# http://www.wiris.com/editor/docs/reference/parameters # +# Editor parameter key should be the JSON key and the corresponnding value is the JSON value. # +############################################################################################### + #wiriseditorparameters = {} -# -# Accessibility -# +################# +# Accessibility # +################# + +## Specifies if the accesibility should be included in generated images as "alt" attribute. true by default. + #wirisaccessibilityenabled = true -# -# WIRIS cas -# -#wiriscascodebase = http://www.wiris.net/demo/wiris/wiris-codebase -#wiriscasarchive = wrs_net_%LANG.jar -#wiriscasclass = WirisApplet_net_%LANG -#wiriscaslanguages = en, es, fr, it, nl, et, ca, eu, pt, de -#CAS_width = 450 -#CAS_height = 400 - -# -# External plugin -# +######################### +# Cross-Domain policies # +######################### + +## Enables CORS domains policies. false by default. +wiriscorsenabled = false + +################### +# External plugin # +################### + +## Specifies if the plugin is an external plugin. false by default. + #wirisexternalplugin = false -# -# Experimental settings. -# -#wirispluginperformance = false +######################## +# Performance settings # +######################## + +## Specifies if the response should be a JSON instead of a binary which allows requests be cached. true by default. + +#wirispluginperformance = true + +############################################################################################################################## +# Clean cache service parameters. For further information go to http://www.wiris.com/en/plugins/docs/resources/clean-backup # +############################################################################################################################## + +## Specifies if the delete cache gui is enabled. false by default. + +# wiriscleancachegui = false + +## Token needed to delete cache. + +# wiriscleancachetoken = token + +############################################################################################## +# Deprecated. Editor parameters should be parsed as a Json on wiriseditorparameters variale. # +############################################################################################## -# -# Deprecated. Editor parameters should be parsed as a Json on wiriseditorparameters variale. -# #wiristransparency = true #wirisfontfamily = Arial #wirisimagecolor = #000000 @@ -98,8 +193,10 @@ #wiriseasternarabicindiclanguages = fa, ps, ur #wiriseuropeanlanguages = -# Delete cache parameters. -# wiriscleancachegui = false -# wiriscleancachetoken = token +############################################################################################### +# Debug mode to show extra information on test page. Don't enable in production environments. # +############################################################################################### + +#wirisdebug = false -# End of file +## End of file diff --git a/core/core.js b/core/core.js index 352eaeae..d4a4bbf3 100644 --- a/core/core.js +++ b/core/core.js @@ -120,7 +120,7 @@ if (!(window._wrs_conf_CASClassName)) { if (typeof MutationObserver != 'undefined') { var wrs_observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { - if (mutation.oldValue == _wrs_conf_imageClassName && mutation.attributeName == 'class' && mutation.targetpassName.indexOf(_wrs_conf_imageClassName) == -1 ) { + if (mutation.oldValue == _wrs_conf_imageClassName && mutation.attributeName == 'class' && mutation.target.className.indexOf(_wrs_conf_imageClassName) == -1 ) { mutation.target.className = _wrs_conf_imageClassName; } }); @@ -1855,6 +1855,7 @@ function wrs_mathmlToAccessible(mathml, language, data) { } else { data['service'] = 'mathml2accessible'; + data['lang'] = _wrs_int_langCode; var accesibleJsonResponse = JSON.parse(wrs_getContent(_wrs_conf_servicePath, data)); if (accesibleJsonResponse.status != 'error') { accessibleText = accesibleJsonResponse.result.text; @@ -2227,7 +2228,7 @@ function wrs_openEditorWindow(language, target, isIframe) { } var title = wrs_int_getCustomEditorEnabled() != null ? wrs_int_getCustomEditorEnabled().title : 'WIRIS EDITOR math'; - if (_wrs_conf_modalWindow != 'undefined' && _wrs_conf_modalWindow === false) { + if (typeof _wrs_conf_modalWindow != 'undefined' && _wrs_conf_modalWindow === false) { _wrs_popupWindow = window.open(path, title, _wrs_conf_editorAttributes); return _wrs_popupWindow; } @@ -2702,9 +2703,9 @@ function wrs_loadConfiguration() { // JSON structure: {{jsVariableName, jsVariableValue}}. - variables = Object.keys(jsonConfiguration); + var variables = Object.keys(jsonConfiguration); - for (variable in variables) { + for (var variable in variables) { window[variables[variable]] = jsonConfiguration[variables[variable]]; } @@ -2734,7 +2735,7 @@ _wrs_conf_plugin_loaded = true; function wrs_getCorePath() { var scriptName = "core/core.js"; var col = document.getElementsByTagName("script"); - for (i = 0; i < col.length; i++) { + for (var i = 0; i < col.length; i++) { var d; var src; d = col[i]; @@ -4331,7 +4332,7 @@ ModalWindow.prototype.open = function() { self.lastImageWasNew = true; } else { - this.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute('data-mathml'))); + this.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute(_wrs_conf_imageMathmlAttribute))); this.lastImageWasNew = false; } } @@ -4349,7 +4350,7 @@ ModalWindow.prototype.open = function() { updateMathMLContent(); self.lastImageWasNew = true; } else { - this.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute('data-mathml'))); + this.setMathML(wrs_mathmlDecode(_wrs_temporalImage.getAttribute(_wrs_conf_imageMathmlAttribute))); this.lastImageWasNew = false; } this.focus(); diff --git a/core/editor.js b/core/editor.js index dbac8c5e..d3795cb3 100644 --- a/core/editor.js +++ b/core/editor.js @@ -95,23 +95,23 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl * * @param {String} objectName object name (null to call a wrs_int_opener method). * @param {String} methodName method name. - * @param {Array} arguments method arguments ([arg1,..,argn]) + * @param {Array} argumentss method arguments ([arg1,..,argn]) * @param {Function} callback callback function. */ - function getMethod(objectName, methodName, arguments, callback) { + function getMethod(objectName, methodName, argumentss, callback) { _wrs_callbacks.push({ 'id': _wrs_callId, 'callback': callback }); try { - wrs_int_opener.postMessage({'id': _wrs_callId++, 'objectName': objectName, 'methodName' : methodName, 'arguments': arguments}, '*'); + wrs_int_opener.postMessage({'id': _wrs_callId++, 'objectName': objectName, 'methodName' : methodName, 'arguments': argumentss}, '*'); } catch (err) { // Method postMessage not defined (I.E 7 & 8 ) or not competible with window object (I.E 9). var object = (objectName == null) ? wrs_int_opener : wrs_int_opener[objectName]; if (objectName == null) { - callback(object[methodName].apply(object, arguments)); + callback(object[methodName].apply(object, argumentss)); } else { // Can't call apply method from some objects on old I.E. - var argumentsStrings = arguments.join(','); + var argumentsStrings = argumentss.join(','); var result = object[methodName](argumentsStrings); callback(result); } @@ -175,7 +175,6 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl } // Editor stats. - statEditor = _wrs_conf_editor; statSaveMode = _wrs_conf_saveMode; statVersion = _wrs_conf_version; @@ -183,10 +182,23 @@ var _wrs_isNewElement; // Unfortunately we need this variabels as global variabl script.src = editorUrl + "?lang=" + _wrs_int_langCode + '&stats-editor=' + statEditor + '&stats-mode=' + statSaveMode + '&stats-version=' + statVersion; document.getElementsByTagName('head')[0].appendChild(script); - // Insert strings. var script = document.createElement('script'); script.type = 'text/javascript'; - script.src = "../lang/" + _wrs_int_langCode + "/strings.js"; + script.src = "../"; + // Get lang path + var webScripts = document.getElementsByTagName("script"); + var scriptName = "strings.js"; + var found = false; + var i = 0; + while (!found && i < webScripts.length) { + if (webScripts[i].src.indexOf(scriptName) != -1) { + var pathArray = webScripts[i].src.split("/"); + // We need to get the lang folder name of "../[lang_folder]/[lang_code]/strings.js" + script.src += pathArray[pathArray.length - 3 ] + "/" + _wrs_int_langCode + "/strings.js"; + found = true; + } + i++ + } document.getElementsByTagName('head')[0].appendChild(script); } else { setTimeout(wrs_waitForCore, 200); diff --git a/lib.php b/lib.php index dd1fd2ce..334fdbea 100644 --- a/lib.php +++ b/lib.php @@ -43,15 +43,29 @@ function atto_wiris_strings_for_js() { * Set parameters to be passed to the js plugin constructor. */ function atto_wiris_params_for_js() { - global $COURSE; + global $COURSE, $PAGE; // We need to know if WIRIS filter are active in the context of the course. // If not WIRIS plugin should be disabled. $filterwirisactive = true; + // Filter disabled at course level. if (!get_config('filter_wiris', 'allow_editorplugin_active_course')) { $context = context_course::instance($COURSE->id); $activefilters = filter_get_active_in_context($context); $filterwirisactive = array_key_exists('wiris', $activefilters); + + // Filter disabled at activity level. + if ($filterwirisactive) { + // Check if context is context module. + $pagecontext = $PAGE->context; + // We need to check only module context. Other contexts (like block context) + // shouldn't be checked. + if ($pagecontext instanceof context_module) { + $activefilters = filter_get_active_in_context($PAGE->context); + $filterwirisactive = array_key_exists('wiris', $activefilters); + } + } } + // Atto js plugin checks if the filter is - or not - active. return array('lang' => current_language(), 'filter_enabled' => $filterwirisactive); } diff --git a/version.php b/version.php index 33ba8272..17fb3f34 100644 --- a/version.php +++ b/version.php @@ -25,9 +25,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017080800; -$plugin->release = '4.6.0.1373'; +$plugin->version = 2017090500; +$plugin->release = '4.7.0.1374'; $plugin->requires = 2014050800; $plugin->component = 'atto_wiris'; -$plugin->dependencies = array ('filter_wiris' => 2017080800); +$plugin->dependencies = array ('filter_wiris' => 2017090500); $plugin->maturity = MATURITY_STABLE;