Class: WirisPlugin::CasImpl
- Inherits:
-
Object
- Object
- WirisPlugin::CasImpl
- Extended by:
- CasInterface
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/plugin/impl/CasImpl.rb
Instance Attribute Summary collapse
-
#plugin ⇒ Object
Returns the value of attribute plugin.
Class Method Summary collapse
Instance Method Summary collapse
- #cas(mode, language) ⇒ Object
- #createCasImage(imageParameter) ⇒ Object
- #getAvailableCASLanguages(languageString) ⇒ Object
- #htmlentities(input, entQuotes) ⇒ Object
-
#initialize(plugin) ⇒ CasImpl
constructor
A new instance of CasImpl.
- #printCAS(codebase, archive, className) ⇒ Object
- #printCASContainer(config, availableLanguages, lang) ⇒ Object
- #showCasImage(f, provider) ⇒ Object
Methods included from CasInterface
Constructor Details
#initialize(plugin) ⇒ CasImpl
Returns a new instance of CasImpl.
13 14 15 16 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 13 def initialize(plugin) super() self.plugin = plugin end |
Instance Attribute Details
#plugin ⇒ Object
Returns the value of attribute plugin.
12 13 14 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 12 def plugin @plugin end |
Class Method Details
Instance Method Details
#cas(mode, language) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 47 def cas(mode, language) output = StringBuf.new() output::add("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">") config = self.plugin::getConfiguration() availableLanguages = getAvailableCASLanguages(config::getProperty(ConfigurationKeys::CAS_LANGUAGES,nil)) if (language == nil) || !availableLanguages::contains_(language) language = availableLanguages::_(0) end if (mode != nil) && (mode == "applet") codebase = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_CODEBASE,nil),"%LANG",language) archive = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_ARCHIVE,nil),"%LANG",language) className = StringTools::replace(config::getProperty(ConfigurationKeys::CAS_CLASS,nil),"%LANG",language) output::add(printCAS(codebase,archive,className)) else output::add(printCASContainer(config,availableLanguages,language)) end return output::toString() end |
#createCasImage(imageParameter) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 32 def createCasImage(imageParameter) output = "" contextPath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"/") if imageParameter != nil dataDecoded = CasImpl.decodeBase64(imageParameter) digest = Md5::encode(imageParameter) store = self.plugin::getStorageAndCache() store::storeData(digest,"png",dataDecoded::getData()) showImagePath = @plugin::getConfiguration()::getProperty(ConfigurationKeys::SHOWCASIMAGE_PATH,nil) output += RenderImpl::concatPath(contextPath,showImagePath) + StringTools::urlEncode(digest + ".png").to_s else output += RenderImpl::concatPath(contextPath,"core/cas.png") end return output end |
#getAvailableCASLanguages(languageString) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 65 def getAvailableCASLanguages(languageString) langs = Std::split(languageString,",") availableLanguages = Array.new() iter = langs::iterator() while iter::hasNext() elem = iter::next() elem = StringTools::trim(elem) availableLanguages::push(elem) end if availableLanguages::length() == 0 availableLanguages = Array.new() availableLanguages::push("") end return availableLanguages end |
#htmlentities(input, entQuotes) ⇒ Object
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 131 def htmlentities(input, entQuotes) returnValue = StringTools::replace(input,"&","&") returnValue = StringTools::replace(returnValue,"<","<") returnValue = StringTools::replace(returnValue,">","gt;") if entQuotes returnValue = StringTools::replace(returnValue,"\"",""") return returnValue end return returnValue end |
#printCAS(codebase, archive, className) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 80 def printCAS(codebase, archive, className) output = StringBuf.new() output::add("<html><head><style type=\"text/css\">/*<!--*/ html, body { height: 100%; } body { overflow: hidden; margin: 0; } applet { height: 100%; width: 100%; } /*-->*/</style></head>") output::add("<body><applet id=\"applet\" alt=\"WIRIS CAS\" codebase=\"") output::add(htmlentities(codebase,true)) output::add("\" archive=\"") output::add(htmlentities(archive,true)) output::add("\" code=\"") output::add(htmlentities(className,true)) output::add("\"><p>You need JAVA® to use WIRIS tools.<br />FREE download from <a target=\"_blank\" href=\"http://www.java.com\">www.java.com</a></p></applet></body></html>") return output::toString() end |
#printCASContainer(config, availableLanguages, lang) ⇒ Object
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 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 92 def printCASContainer(config, availableLanguages, lang) output = StringBuf.new() output::add("<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/><script>") output::add("var lang =\'") output::add(lang) output::add("/strings.js\';") output::add(" ") output::add(" var scriptsrc = window.opener.path + \'/lang/\' + lang;") output::add(" var script = document.createElement(\'script\'); ") output::add(" script.src = scriptsrc;") output::add(" document.head.appendChild(script);") output::add("</script><script>") output::add("var scriptsrc = window.opener.path + \'/core/cas.js\'; ") output::add(" var script = document.createElement(\'script\'); ") output::add(" script.src = scriptsrc;") output::add(" document.head.appendChild(script);") output::add("</script>") output::add("<title>WIRIS CAS</title><style type=\"text/css\">") output::add("/*<!--*/ html, body, #optionForm { height: 100%; } body { overflow: hidden; margin: 0; } #controls { width: 100%; } /*-->*/</style></head>") output::add("<body><form id=\"optionForm\"><div id=\"appletContainer\"></div><table id=\"controls\"><tr><td>Width</td><td><input name=\"width\" type=\"text\" value=\"") output::add(config::getProperty(ConfigurationKeys::CAS_WIDTH,nil)) output::add("\"/></td><td><input name=\"executeonload\" type=\"checkbox\"/> Calculate on load") output::add("</td><td><input name=\"toolbar\" type=\"checkbox\" checked /> Show toolbar</td><td>Language <select id=\"languageList\">") for i in 0..availableLanguages::length() - 1 language = htmlentities(availableLanguages::_(i),true) output::add("<option value=\"") output::add(language) output::add("\">") output::add(language) output::add("</option>") i+=1 end output::add("</select></td></tr><tr><td>Height</td><td><input name=\"height\" type=\"text\" value=\"") output::add(config::getProperty(ConfigurationKeys::CAS_HEIGHT,nil)) output::add("\"/></td><td><input name=\"focusonload\" type=\"checkbox\"/> Focus on load</td><td><input name=\"level\" type=\"checkbox\"/>") output::add("Elementary mode</td><td></td></tr><tr><td colspan=\"5\"><input id=\"submit\" value=\"Accept\" type=\"button\"/>") output::add("<input id=\"cancel\" value=\"Cancel\" type=\"button\"/></td></tr></table></form></body></html>") return output::toString() end |
#showCasImage(f, provider) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/com/wiris/plugin/impl/CasImpl.rb', line 17 def showCasImage(f, provider) formula = f if formula::endsWith(".png") formula = Std::substr(formula,0,formula::length() - 4) end store = self.plugin::getStorageAndCache() data = store::retreiveData(formula,"png") if data == nil data = Storage::newResourceStorage("cas.png")::readBinary() if data == nil raise Exception,"Missing resource cas.png" end end return data end |