diff --git a/VERSION b/VERSION index 7fea03c0..1a76ce89 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.11.0.1383 \ No newline at end of file +4.12.0.1384 \ No newline at end of file diff --git a/classes/accessprovider.php b/classes/accessprovider.php index 6e2d6692..b4ceee08 100644 --- a/classes/accessprovider.php +++ b/classes/accessprovider.php @@ -29,9 +29,9 @@ global $CFG; require_once($CFG->dirroot . '/lib/moodlelib.php'); -require_once($CFG->dirroot . '/filter/wiris/integration/lib/com/wiris/plugin/api/AccessProvider.interface.php'); +require_once($CFG->dirroot . '/filter/wiris/integration/lib/com/wiris/util/sys/AccessProvider.interface.php'); -class filter_wiris_accessprovider implements com_wiris_plugin_api_AccessProvider { +class filter_wiris_accessprovider implements com_wiris_util_sys_AccessProvider { /** * This method is called before all service. We use it as a wrapper to call * Moodle require_login() method. Any WIRIS service can't be called without a @@ -47,4 +47,12 @@ function requireAccess() { // user is logged. return true; } + + /** + * Not implemented. + */ + // @codingStandardsIgnoreStart + function isEnabled() { + // @codingStandardsIgnoreEnd + } } diff --git a/integration/lib/VERSION b/integration/lib/VERSION index 7fea03c0..1a76ce89 100644 --- a/integration/lib/VERSION +++ b/integration/lib/VERSION @@ -1 +1 @@ -4.11.0.1383 \ No newline at end of file +4.12.0.1384 \ No newline at end of file diff --git a/integration/lib/com/wiris/plugin/api/AccessProvider.interface.php b/integration/lib/com/wiris/plugin/api/AccessProvider.interface.php deleted file mode 100644 index 67b52e27..00000000 --- a/integration/lib/com/wiris/plugin/api/AccessProvider.interface.php +++ /dev/null @@ -1,5 +0,0 @@ -set("width", intval($f * $metrics->get("width"))); + $metrics->set("height", intval($f * $metrics->get("height"))); + $metrics->set("baseline", intval($f * $metrics->get("baseline"))); + } public function getMetrics($bytes, &$output) { $output = $output; $width = 0; diff --git a/integration/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.class.php b/integration/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.class.php index 763a06a8..efc64b1d 100644 --- a/integration/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.class.php +++ b/integration/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.class.php @@ -3,6 +3,8 @@ class com_wiris_plugin_impl_ImageFormatControllerSvg implements com_wiris_plugin_api_ImageFormatController{ public function __construct() { } + public function scalateMetrics($dpi, $metrics) { + } public function getMetrics($bytes, &$output) { $svg = $bytes->toString(); $svgRoot = _hx_substr($svg, 0, _hx_index_of($svg, ">", null)); diff --git a/integration/lib/com/wiris/plugin/impl/TestImpl.class.php b/integration/lib/com/wiris/plugin/impl/TestImpl.class.php index 1b7fca9d..9804601e 100644 --- a/integration/lib/com/wiris/plugin/impl/TestImpl.class.php +++ b/integration/lib/com/wiris/plugin/impl/TestImpl.class.php @@ -21,7 +21,7 @@ public function createTableRow($testName, $reportText, $solutionLink, $condition return $output; } public function getTestPage() { - $random = "" . _hx_string_rec(Math::floor(Math::random() * 9999), ""); + $random = "" . _hx_string_rec(intval(Math::random() * 9999), ""); $mml = "" . $random . ""; $testName = null; $reportText = null; $solutionLink = null; $this->conf = $this->plugin->getConfiguration(); diff --git a/integration/lib/com/wiris/plugin/impl/TextFilter.class.php b/integration/lib/com/wiris/plugin/impl/TextFilter.class.php index 572531cf..7686ab07 100644 --- a/integration/lib/com/wiris/plugin/impl/TextFilter.class.php +++ b/integration/lib/com/wiris/plugin/impl/TextFilter.class.php @@ -83,16 +83,19 @@ public function math2Img($str, $prop) { } $mml = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$FILTER_OUTPUT_MATHML, "false") === "true"; $f = 96 / $dpi; - $dwidth = $f * Std::parseFloat($width); - $dheight = $f * Std::parseFloat($height); - $dbaseline = $f * Std::parseFloat($baseline); + $imageFormatController = $this->plugin->getImageFormatController(); + $metricsHash = new Hash(); + $metricsHash->set("width", Std::parseInt($width)); + $metricsHash->set("height", Std::parseInt($height)); + $metricsHash->set("baseline", Std::parseInt($baseline)); + $imageFormatController->scalateMetrics($dpi, $metricsHash); $alt = $this->html_entity_encode($alt); $img .= " class=\"Wirisformula\""; $img .= " alt=\"" . $alt . "\""; - $img .= " width=\"" . _hx_string_rec($dwidth, "") . "\""; - $img .= " height=\"" . _hx_string_rec($dheight, "") . "\""; - $d = $dbaseline - $dheight; - $img .= " style=\"vertical-align:" . _hx_string_rec($d, "") . "px\""; + $img .= " width=\"" . _hx_string_rec($metricsHash->get("width"), "") . "\""; + $img .= " height=\"" . _hx_string_rec($metricsHash->get("height"), "") . "\""; + $verticalAlign = $metricsHash->get("baseline") - $metricsHash->get("height"); + $img .= " style=\"vertical-align:" . _hx_string_rec($verticalAlign, "") . "px\""; if($mml) { $tag = $this->plugin->getConfiguration()->getProperty(com_wiris_plugin_api_ConfigurationKeys::$EDITOR_MATHML_ATTRIBUTE, "data-mathml"); $img .= " " . $tag . "='" . $this->save_xml_encode($str) . "'"; diff --git a/integration/lib/com/wiris/plugin/provider/PhpAccessProvider.interface.php b/integration/lib/com/wiris/plugin/provider/PhpAccessProvider.interface.php index 2de67d28..f40e14e3 100644 --- a/integration/lib/com/wiris/plugin/provider/PhpAccessProvider.interface.php +++ b/integration/lib/com/wiris/plugin/provider/PhpAccessProvider.interface.php @@ -1,5 +1,5 @@ match($str); } static function isInteger($str) { - $pattern = new EReg("^(\\d)", ""); + $pattern = new EReg("^[+-]?\\d+\$", ""); return $pattern->match($str); } static function isIdentifierPart($c) { diff --git a/integration/lib/com/wiris/util/json/JSon.class.php b/integration/lib/com/wiris/util/json/JSon.class.php index 1d04df0a..c02b47ab 100644 --- a/integration/lib/com/wiris/util/json/JSon.class.php +++ b/integration/lib/com/wiris/util/json/JSon.class.php @@ -232,6 +232,15 @@ public function encodeString($sb, $s) { $sb->add($s); $sb->add("\""); } + public function encodeArrayInt($sb, $v) { + $v2 = new _hx_array(array()); + $i = 0; + while($i < $v->length) { + $v2->push($v[$i]); + ++$i; + } + $this->encodeArray($sb, $v2); + } public function encodeArray($sb, $v) { $newLines = $this->addNewLines && com_wiris_util_json_JSon::getDepth($v) > 2; $this->depth++; @@ -300,25 +309,29 @@ public function encodeImpl($sb, $o) { if(com_wiris_system_TypeTools::isArray($o)) { $this->encodeArray($sb, $o); } else { - if(Std::is($o, _hx_qtype("String"))) { - $this->encodeString($sb, $o); + if(Std::is($o, _hx_qtype("Array"))) { + $this->encodeArrayInt($sb, $o); } else { - if(Std::is($o, _hx_qtype("Int"))) { - $this->encodeInteger($sb, $o); + if(Std::is($o, _hx_qtype("String"))) { + $this->encodeString($sb, $o); } else { - if(Std::is($o, _hx_qtype("haxe.Int64"))) { - $this->encodeLong($sb, $o); + if(Std::is($o, _hx_qtype("Int"))) { + $this->encodeInteger($sb, $o); } else { - if(Std::is($o, _hx_qtype("com.wiris.util.json.JSonIntegerFormat"))) { - $this->encodeIntegerFormat($sb, $o); + if(Std::is($o, _hx_qtype("haxe.Int64"))) { + $this->encodeLong($sb, $o); } else { - if(Std::is($o, _hx_qtype("Bool"))) { - $this->encodeBoolean($sb, $o); + if(Std::is($o, _hx_qtype("com.wiris.util.json.JSonIntegerFormat"))) { + $this->encodeIntegerFormat($sb, $o); } else { - if(Std::is($o, _hx_qtype("Float"))) { - $this->encodeFloat($sb, $o); + if(Std::is($o, _hx_qtype("Bool"))) { + $this->encodeBoolean($sb, $o); } else { - throw new HException("Impossible to convert to json object of type " . Std::string(Type::getClass($o))); + if(Std::is($o, _hx_qtype("Float"))) { + $this->encodeFloat($sb, $o); + } else { + throw new HException("Impossible to convert to json object of type " . Std::string(Type::getClass($o))); + } } } } diff --git a/integration/lib/com/wiris/util/sys/AccessProvider.interface.php b/integration/lib/com/wiris/util/sys/AccessProvider.interface.php new file mode 100644 index 00000000..a8f4d1c9 --- /dev/null +++ b/integration/lib/com/wiris/util/sys/AccessProvider.interface.php @@ -0,0 +1,6 @@ += 0) { + $data[$length] = $initValue; + --$length; + } + return $data; + } + static function indexOfElement($array, $element) { + $i = 0; + $n = $array->length; + while($i < $n) { + if($array[$i] !== null && $array[$i] == $element) { + return $i; + } + ++$i; + } + return -1; + } + static function fromIterator($iterator) { + $array = new _hx_array(array()); + while($iterator->hasNext()) { + $array->push($iterator->next()); + } + return $array; + } + static function fromCSV($s) { + $words = _hx_explode(",", $s); + $i = 0; + while($i < $words->length) { + $w = trim($words[$i]); + if(strlen($w) > 0) { + $words[$i] = $w; + ++$i; + } else { + $words->splice($i, 1); + } + unset($w); + } + return $words; + } + static function contains($array, $element) { + return com_wiris_util_type_Arrays::indexOfElement($array, $element) >= 0; + } + static function indexOfElementArray($array, $element) { + $i = null; + { + $_g1 = 0; $_g = $array->length; + while($_g1 < $_g) { + $i1 = $_g1++; + if($array[$i1] !== null && _hx_equal($array[$i1], $element)) { + return $i1; + } + unset($i1); + } + } + return -1; + } + static function indexOfElementInt($array, $element) { + $i = null; + { + $_g1 = 0; $_g = $array->length; + while($_g1 < $_g) { + $i1 = $_g1++; + if($array[$i1] === $element) { + return $i1; + } + unset($i1); + } + } + return -1; + } + static function containsArray($array, $element) { + return com_wiris_util_type_Arrays::indexOfElementArray($array, $element) >= 0; + } + static function containsInt($array, $element) { + return com_wiris_util_type_Arrays::indexOfElementInt($array, $element) >= 0; + } + static function clear($a) { + $i = $a->length - 1; + while($i >= 0) { + $a->remove($a[$i]); + $i--; + } + } + static function sort($elements, $comparator) { + com_wiris_util_type_Arrays::quicksort($elements, 0, $elements->length - 1, $comparator); + } + static function insertSorted($a, $e) { + com_wiris_util_type_Arrays::insertSortedImpl($a, $e, false); + } + static function insertSortedSet($a, $e) { + com_wiris_util_type_Arrays::insertSortedImpl($a, $e, true); + } + static function insertSortedImpl($a, $e, $set) { + $imin = 0; + $imax = $a->length; + while($imin < $imax) { + $imid = intval(($imax + $imin) / 2); + $cmp = Reflect::compare($a[$imid], $e); + if($cmp === 0) { + if($set) { + return; + } else { + $imin = $imid; + $imax = $imid; + } + } else { + if($cmp < 0) { + $imin = $imid + 1; + } else { + $imax = $imid; + } + } + unset($imid,$cmp); + } + $a->insert($imin, $e); + } + static function binarySearch($array, $key) { + $imin = 0; + $imax = $array->length; + while($imin < $imax) { + $imid = intval(($imin + $imax) / 2); + $cmp = Reflect::compare($array[$imid], $key); + if($cmp === 0) { + return $imid; + } else { + if($cmp < 0) { + $imin = $imid + 1; + } else { + $imax = $imid; + } + } + unset($imid,$cmp); + } + return -1; + } + static function copyArray($a) { + $b = new _hx_array(array()); + $i = $a->iterator(); + while($i->hasNext()) { + $b->push($i->next()); + } + return $b; + } + static function addAll($baseArray, $additionArray) { + $i = $additionArray->iterator(); + while($i->hasNext()) { + $baseArray->push($i->next()); + } + } + static function quicksort($elements, $lower, $higher, $comparator) { + if($lower < $higher) { + $p = com_wiris_util_type_Arrays::partition($elements, $lower, $higher, $comparator); + com_wiris_util_type_Arrays::quicksort($elements, $lower, $p - 1, $comparator); + com_wiris_util_type_Arrays::quicksort($elements, $p + 1, $higher, $comparator); + } + } + static function partition($elements, $lower, $higher, $comparator) { + $pivot = $elements[$higher]; + $i = $lower - 1; + $j = $lower; + while($j < $higher) { + if($comparator->compare($pivot, $elements[$j]) > 0) { + $i++; + if($i !== $j) { + $swapper = $elements[$i]; + $elements[$i] = $elements[$j]; + $elements[$j] = $swapper; + unset($swapper); + } + } + $j++; + } + if($comparator->compare($elements[$i + 1], $elements[$higher]) > 0) { + $finalSwap = $elements[$i + 1]; + $elements[$i + 1] = $elements[$higher]; + $elements[$higher] = $finalSwap; + } + return $i + 1; + } + static function firstElement($elements) { + return $elements[0]; + } + static function lastElement($elements) { + return $elements[$elements->length - 1]; + } + function __toString() { return 'com.wiris.util.type.Arrays'; } +} diff --git a/integration/lib/com/wiris/util/type/Comparator.interface.php b/integration/lib/com/wiris/util/type/Comparator.interface.php new file mode 100644 index 00000000..0dcaf416 --- /dev/null +++ b/integration/lib/com/wiris/util/type/Comparator.interface.php @@ -0,0 +1,5 @@ +length - 1; do { - $mid = Math::floor(($min + $max) / 2); + $mid = intval(($min + $max) / 2); $cc = $v[$mid]; if($c === $cc) { return true; diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml index 61c04f4d..1385652b 100644 --- a/thirdpartylibs.xml +++ b/thirdpartylibs.xml @@ -3,7 +3,7 @@ integration WIRIS PLUGIN Engine - 4.11.0.1383 + 4.12.0.1384 GPL 3.0+ diff --git a/version.php b/version.php index 367a4417..b23d29a2 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018010200; -$plugin->release = '4.11.0.1383'; +$plugin->version = 2018020100; +$plugin->release = '4.12.0.1384'; $plugin->requires = 2011120511; $plugin->maturity = MATURITY_STABLE; $plugin->component = 'filter_wiris';