Class: WirisPlugin::ConfigurationImpl
- Inherits:
-
Object
- Object
- WirisPlugin::ConfigurationImpl
- Extended by:
- ConfigurationInterface
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/plugin/impl/ConfigurationImpl.rb
Instance Attribute Summary collapse
-
#initialized ⇒ Object
Returns the value of attribute initialized.
-
#initObject ⇒ Object
Returns the value of attribute initObject.
-
#plugin ⇒ Object
Returns the value of attribute plugin.
-
#props ⇒ Object
Returns the value of attribute props.
Instance Method Summary collapse
- #appendElement2JavascriptArray(array, value) ⇒ Object
- #appendVarJs(sb, varName, value, comment) ⇒ Object
- #getFullConfiguration ⇒ Object
- #getFullConfigurationAsJson ⇒ Object
- #getJavaScriptConfiguration ⇒ Object
- #getJsonConfiguration(configurationKeys) ⇒ Object
- #getProperty(key, dflt) ⇒ Object
-
#initialize ⇒ ConfigurationImpl
constructor
A new instance of ConfigurationImpl.
- #initialize0 ⇒ Object
- #initialize_(cu) ⇒ Object
- #setConfigurations(configurationKeys, configurationValues) ⇒ Object
- #setInitObject(context) ⇒ Object
- #setPluginBuilderImpl(plugin) ⇒ Object
- #setProperty(key, value) ⇒ Object
Methods included from ConfigurationInterface
Constructor Details
#initialize ⇒ ConfigurationImpl
17 18 19 20 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 17 def initialize() super() @props = PropertiesTools::newProperties() end |
Instance Attribute Details
#initialized ⇒ Object
Returns the value of attribute initialized.
16 17 18 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 16 def initialized @initialized end |
#initObject ⇒ Object
Returns the value of attribute initObject.
14 15 16 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 14 def initObject @initObject end |
#plugin ⇒ Object
Returns the value of attribute plugin.
13 14 15 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 13 def plugin @plugin end |
#props ⇒ Object
Returns the value of attribute props.
15 16 17 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 15 def props @props end |
Instance Method Details
#appendElement2JavascriptArray(array, value) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 69 def appendElement2JavascriptArray(array,value) arrayOpen = array::indexOf("[") arrayClose = array::indexOf("]") if (arrayOpen==-1)||(arrayClose==-1) raise Exception,"Array not valid" end return ((("["+"\'")+value)+"\'")+(array::length()==2 ? "]" : ","+Std::substr(array,arrayOpen+1,arrayClose-arrayOpen).to_s) end |
#appendVarJs(sb, varName, value, comment) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 60 def appendVarJs(sb,varName,value,comment) sb::add("var ") sb::add(varName) sb::add(" = ") sb::add(value) sb::add("; // ") sb::add(comment) sb::add("\r\n") end |
#getFullConfiguration ⇒ Object
21 22 23 24 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 21 def getFullConfiguration() initialize0() return @props end |
#getFullConfigurationAsJson ⇒ Object
25 26 27 28 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 25 def getFullConfigurationAsJson() initialize0() return nil end |
#getJavaScriptConfiguration ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 77 def getJavaScriptConfiguration() sb = StringBuf.new() arrayParse = "[]" appendVarJs(sb,"_wrs_conf_editorEnabled",getProperty("wiriseditorenabled",nil),"Specifies if fomula editor is enabled") appendVarJs(sb,"_wrs_conf_imageMathmlAttribute",("\'"+getProperty("wiriseditormathmlattribute",nil))+"\'","Specifies the image tag where we should save the formula editor mathml code") appendVarJs(sb,"_wrs_conf_saveMode",("\'"+getProperty("wiriseditorsavemode",nil))+"\'","This value can be \'xml\', \'safeXml\', \'image\' or \'base64\'") appendVarJs(sb,"_wrs_conf_editMode",("\'"+getProperty("wiriseditoreditmode",nil))+"\'","This value can be \'default\' or \'image\'") if (getProperty("wiriseditorparselatex",nil)=="true") arrayParse = appendElement2JavascriptArray(arrayParse,"latex") end if (getProperty("wiriseditorparsexml",nil)=="true") arrayParse = appendElement2JavascriptArray(arrayParse,"xml") end appendVarJs(sb,"_wrs_conf_parseModes",arrayParse,"This value can contain \'latex\' and \'xml)") appendVarJs(sb,"_wrs_conf_editorAttributes",("\'"+getProperty("wiriseditorwindowattributes",nil))+"\'","Specifies formula editor window options") appendVarJs(sb,"_wrs_conf_editorUrl",("\'"+@plugin::getImageServiceURL("editor",false))+"\'","WIRIS editor") appendVarJs(sb,"_wrs_conf_modalWindow",getProperty("wiriseditormodalwindow",nil),"Editor modal window") appendVarJs(sb,"_wrs_conf_CASEnabled",getProperty("wiriscasenabled",nil),"Specifies if WIRIS cas is enabled") appendVarJs(sb,"_wrs_conf_CASMathmlAttribute",("\'"+getProperty("wiriscasmathmlattribute",nil))+"\'","Specifies the image tag where we should save the WIRIS cas mathml code") appendVarJs(sb,"_wrs_conf_CASAttributes",("\'"+getProperty("wiriscaswindowattributes",nil))+"\'","Specifies WIRIS cas window options") appendVarJs(sb,"_wrs_conf_hostPlatform",("\'"+getProperty("wirishostplatform",nil))+"\'","Specifies host platform") appendVarJs(sb,"_wrs_conf_versionPlatform",("\'"+getProperty("wirisversionplatform","unknown"))+"\'","Specifies host version platform") appendVarJs(sb,"_wrs_conf_enableAccessibility",getProperty("wirisaccessibilityenabled",nil),"Specifies whether accessibility is enabled") appendVarJs(sb,"_wrs_conf_setSize",getProperty("wiriseditorsetsize",nil),"Specifies whether to set the size of the images at edition time") appendVarJs(sb,"_wrs_conf_editorToolbar",("\'"+getProperty(ConfigurationKeys::EDITOR_TOOLBAR,nil))+"\'","Toolbar definition") appendVarJs(sb,"_wrs_conf_chemEnabled",getProperty("wirischemeditorenabled",nil),"Specifies if WIRIS chem editor is enabled") appendVarJs(sb,"_wrs_conf_imageFormat",("\'"+getProperty("wirisimageformat","png"))+"\'","WIRIS Plugin image format") if getProperty(ConfigurationKeys::EDITOR_PARAMS,nil)!=nil appendVarJs(sb,"_wrs_conf_editorParameters",getProperty(ConfigurationKeys::EDITOR_PARAMS,nil),"Editor parameters") else h = ConfigurationKeys::imageConfigPropertiesInv attributes = StringBuf.new() confVal = "" i = 0 it = h::keys() while it::hasNext() value = it::next() if getProperty(value,nil)!=nil if i!=0 attributes::add(",") end i+=1 confVal = getProperty(value,nil) StringTools::replace(confVal,"-","_") StringTools::replace(confVal,"-","_") attributes::add("\'") attributes::add(ConfigurationKeys::imageConfigPropertiesInv::get(value)) attributes::add("\' : \'") attributes::add(confVal) attributes::add("\'") end end appendVarJs(sb,"_wrs_conf_editorParameters",("{"+attributes::toString().to_s)+"}","Editor parameters") end appendVarJs(sb,"_wrs_conf_wirisPluginPerformance",getProperty("wirispluginperformance",nil),"Experimental settings to improve performance") sb::add("var _wrs_conf_configuration_loaded = true;\r\n") sb::add("if (typeof _wrs_conf_core_loaded != \'undefined\') _wrs_conf_plugin_loaded = true;\r\n") begin version = Storage::newResourceStorage("VERSION")::read() end sb::add(("var _wrs_conf_version = \'"+version)+"\';\r\n") return sb::toString() end |
#getJsonConfiguration(configurationKeys) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 140 def getJsonConfiguration(configurationKeys) configurationKeysArray = Std::split(configurationKeys,",") iterator = configurationKeysArray::iterator() jsonOutput = Hash.new() jsonVariables = Hash.new() thereIsNullValue = false while iterator::hasNext() key = iterator::next() value = getProperty(key,"null") if (value=="null") thereIsNullValue = true end jsonVariables::set(key,value) end if !thereIsNullValue jsonOutput::set("status","ok") else jsonOutput::set("status","warning") end jsonOutput::set("result",jsonVariables) return JSon::encode(jsonOutput) end |
#getProperty(key, dflt) ⇒ Object
29 30 31 32 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 29 def getProperty(key,dflt) initialize0() return PropertiesTools::getProperty(@props,key,dflt) end |
#initialize0 ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 39 def initialize0() if @initialized return end @initialized = true @plugin::addConfigurationUpdater(FileConfigurationUpdater.new()) @plugin::addConfigurationUpdater(CustomConfigurationUpdater.new(self)) a = @plugin::getConfigurationUpdaterChain() iter = a::iterator() while iter::hasNext() cu = iter::next() initialize_(cu) cu::updateConfiguration(@props) end end |
#initialize_(cu) ⇒ Object
54 55 56 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 54 def initialize_(cu) cu::init(@initObject) end |
#setConfigurations(configurationKeys, configurationValues) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 162 def setConfigurations(configurationKeys,configurationValues) configurationKeysArray = Std::split(configurationKeys,",") configurationValuesArray = Std::split(configurationValues,",") keysIterator = configurationKeysArray::iterator() valuesIterator = configurationValuesArray::iterator() while keysIterator::hasNext()&&valuesIterator::hasNext() key = keysIterator::next() value = valuesIterator::next() if getProperty(key,nil)!=nil setProperty(key,value) end end end |
#setInitObject(context) ⇒ Object
36 37 38 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 36 def setInitObject(context) @initObject = context end |
#setPluginBuilderImpl(plugin) ⇒ Object
57 58 59 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 57 def setPluginBuilderImpl(plugin) @plugin = plugin end |
#setProperty(key, value) ⇒ Object
33 34 35 |
# File 'lib/com/wiris/plugin/impl/ConfigurationImpl.rb', line 33 def setProperty(key,value) PropertiesTools::setProperty(@props,key,value) end |