From 4b9457fcacbe44d127000cb5e60761e9c1327300 Mon Sep 17 00:00:00 2001 From: Myriam Delaruelle <myriam.delaruelle@univ-lorraine.fr> Date: Fri, 24 Mar 2023 14:12:42 +0100 Subject: [PATCH] bugfix + small css change --- filter.php | 34 ++++++++-------------------------- version.php | 2 +- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/filter.php b/filter.php index a9329db..b54c793 100644 --- a/filter.php +++ b/filter.php @@ -152,12 +152,11 @@ public function filter_iena_add_delimiters_new($pieces, $flagiframe) function filter($text, array $options = array()) { //Solution intermédiaire : on met un flag s'il y a déjà une iframe dans le code - global $CFG; global $PAGE; - if(strpos($PAGE->url, '/mod/') || strpos($PAGE->url, '/question/')){ + /*if(strpos($PAGE->url, '/question/') || strpos($PAGE->url, '/quiz/')){ return $text; - } + }*/ if ($CFG->color_btn) { $this->color_btn = $CFG->color_btn; } @@ -183,28 +182,11 @@ function filter($text, array $options = array()) $flagiframe=true; } - //À quoi ça sert ?? - //On récupère tous les liens de la page - preg_match_all('/<a href="(.*?)">(.*?)<\/a>/s', $text, $matches); - for ($i = 0; $i < count($matches[0]); $i++) { - if (strcmp($matches[1][$i], $matches[2][$i]) == 0) { - $text = str_replace($matches[0][$i], $matches[1][$i], $text); - } - } - - - /*if ((strpos($text, '</iframe>') !== false)) { - $flagiframe=true; - }*/ - $test=str_replace('/', "\/", $CFG->wwwroot); - - //On veut une regex qui ne capture que les première balises, pas celles d'avant ou d'après - preg_match_all('/(<[\w|\s| |"|;|:|=|-]*>[\w|\s| ]*'.$test.'\/mod\/.*[\r|\n| ]*<\/[a-z]*>)/', $text, $pieces); - + //On veut une regex qui ne capture que les première balises, pas celles d'avant ou d'après. On accepte également les <br> + //Final + preg_match_all('/(<[\w|\s| |\.|"|;|:|=|\-|]*>[\w|\s| ]*'.$test.'\/mod\/[^<]*[\r|\n| |<br>]*<\/[a-z]*>)/', $text, $pieces); for ($i = 0; $i < count($pieces[0]); $i++) { - - $piecesToExamine=$pieces[0][$i]; if(isset($piecesToExamine) && strpos($piecesToExamine, '/mod/')){ @@ -212,13 +194,13 @@ function filter($text, array $options = array()) continue; } - //Quoi faire de ça ? capturer toutes les balises ? + //Si c'est un lien classique, on le laisse tranquille, on ne veut pas le transformer if ((strpos($piecesToExamine, '</a>') !== false)) { continue; } $newElem=trim(strip_tags($piecesToExamine)); $newElem = $this->filter_iena_add_delimiters_new($newElem, $flagiframe); - + //$newElem = ' ' . $newElem; $ini = strpos($newElem, $this->start); @@ -252,7 +234,7 @@ function filter($text, array $options = array()) $newElem="<div>" . "<a class=\"sr-only\" target=\"_blank\" href=\"".$parsed."\">Ouvrir dans un nouvel onglet au lieu d'utiliser la modale : $this->btn_name.</a><button data-iframe=\"" .$parsed. "&ienaiframe=true&iframe=true\" type=\"button\" " . $this->disabled . " " . "class=\"btn iena-filter-modal-btn \" data-toggle=\"modal\" data-target=\"#iena-modal-" . $modal_id . "\" style=\"background-color : " . $this->color_btn . "; " - . "color : $this->color_btn_txt;border-radius:0.15rem;\">" + . "color : $this->color_btn_txt;border-radius:0.15rem;margin-bottom: 5px;\">" . "<img class=\"icon icon\" alt=\"\" src=\"" . $CFG->wwwroot . "/theme/image.php/boost/" . $this->btn_type . "/1/icon\">" . "" . $this->btn_name . " </button>" diff --git a/version.php b/version.php index 0339b6e..f9dd282 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); - $plugin->version = 2022062700; // The current plugin version (Date: YYYYMMDDXX) + $plugin->version = 2023032400; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2011120500; // Requires this Moodle version $plugin->component = 'filter_iena'; // Full name of the plugin (used for diagnostics) $plugin->release = "1.0"; -- GitLab