Skip to content

Commit

Permalink
test 3
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-web committed Dec 18, 2023
1 parent c7ad759 commit 28023f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
17 changes: 3 additions & 14 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,13 @@ class filter_jsxgraph extends moodle_text_filter {
*
* @return String
*/
public function filter($text, array $options = []) {
public function filter($text, $options = []) {
// To optimize speed, search for a <jsxgraph> tag (avoiding to parse everything on every text).
if (!is_int(strpos($text, '<' . static::TAG))) {
return $text;
}

// 0. STEP: Do some initial stuff.
//////////////////////////////////

$this->settings = $this->get_adminsettings();
$this->set_versions();
Expand All @@ -183,7 +182,6 @@ public function filter($text, array $options = []) {
}

// 1. STEP: Convert HTML string to a dom object.
////////////////////////////////////////////////

// Create a new dom object.
$this->document = new domDocument('1.0', static::ENCODING);
Expand All @@ -204,12 +202,10 @@ public function filter($text, array $options = []) {
$this->document->recover = true;

// 2. STEP: Get tag elements.
/////////////////////////////

$this->taglist = $this->document->getElementsByTagname(static::TAG);

// 3.+4. STEP: Load library (if needed) and iterate backwards through the <jsxgraph> tags.
//////////////////////////////////////////////////////////////////////////////////////////

if (!empty($this->taglist)) {
$this->load_jsxgraph();
Expand All @@ -227,7 +223,6 @@ public function filter($text, array $options = []) {
}

// 5. STEP: Paste new div node in web page.
///////////////////////////////////////////

// Remove DOCTYPE.
$this->document->removeChild($this->document->firstChild);
Expand Down Expand Up @@ -320,8 +315,7 @@ private function apply_js($node) {
$attributes = $this->get_tagattributes($node);
$code = "";

// Let's load global JavaScript code from administrator settings.
/////////////////////////////////////////////////////////////////
// Load global JavaScript code from administrator settings.

if ($this->settings['globalJS'] !== '' && $attributes['useGlobalJS'][0]) {
$code .=
Expand All @@ -331,8 +325,7 @@ private function apply_js($node) {
"\n\n";
}

// Define the BOARDID constants and some attributes for accessibility.
//////////////////////////////////////////////////////////////////////
// Define BOARDID constants and some attributes for accessibility.

$code .=
"// Define BOARDID constants.\n" .
Expand All @@ -358,7 +351,6 @@ private function apply_js($node) {
"}\n";

// Load the code from <jsxgraph>-node.
//////////////////////////////////////

$usercode = $this->document->saveHTML($node);
// Remove <jsxgraph> tags.
Expand All @@ -372,20 +364,17 @@ private function apply_js($node) {
$code .= $usercode;

// Surround the code with version-specific strings, e.g. "require".
///////////////////////////////////////////////////////////////////

$surroundings = $this->get_code_surroundings();
$code = $surroundings["pre"] . "\n\n" . $code . $surroundings["post"];

// Convert the HTML-entities in the variable $code.
///////////////////////////////////////////////////

if ($this->settings['HTMLentities'] && $attributes['entities']) {
$code = html_entity_decode($code);
}

// Paste the code.
//////////////////

// POI: Version differences.
if ($this->versionmoodle["is_newer_version"]) {
Expand Down
15 changes: 15 additions & 0 deletions thirdpartylibs.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<?xml version="1.0"?>
<libraries>
<library>
<location>/amd/build/jsxgraphcore-v1.6.2-lazy.js</location>
<name>JSXGraph 1.6.2</name>
<version>1.6.2</version>
<license>LGPL</license>
<licenseversion>3.0+</licenseversion>
</library>

<library>
<location>amd/build/jsxgraphcore-v1.6.1-lazy.js</location>
<name>JSXGraph 1.6.1</name>
<version>1.6.1</version>
<license>LGPL</license>
<licenseversion>3.0+</licenseversion>
</library>

<library>
<location>amd/build/jsxgraphcore-v1.6.0-lazy.js</location>
Expand Down

0 comments on commit 28023f5

Please sign in to comment.