Commit 90092f23 authored by Thomas Fradet's avatar Thomas Fradet

v354plus

parent 29911d20
# 19/02/19
## Vitesse de chargement
La source de la fenêtre modale n'est plus définie en PHP, mais en Javascript à son ouverture. En conséquence, la page se charge plus rapidement lorsqu'il y a de nombreux éléments, et la ressource se charge dans la fenêtre modale lors de son ouverture.
## Affichage
L'affichage du contenu de l'iframe sans les menus de nativation et le footer est réactivé.
L'affichage du contenu de l'iframe sans les menus de nativation et le footer est optimisé pour MOODLE 3.5.4+.
L'affichage du contenu de l'iframe sans les menus de nativation et le footer fait l'objet d'un paramètre du plugin (case à cochée). Il est activé par défaut.
......@@ -31,21 +31,22 @@
class filter_iena extends moodle_text_filter
{
/** @var string This variable is used for delemiter */
/* @var string This variable is used for delemiter */
public $start = "[IENA]";
/** @var string This variable is used for delemiter */
/* @var string This variable is used for delemiter */
public $end = "[/IENA]";
/** @var string Contain button name, the button name is
* automatically the name of resource */
public $btn_name;
/** @var string Contain the type of button */
public $btn_type;
/** @var string Hex color of button is defined in settings ($CFG->color_btn) */
public $color_btn = "#009085";
/** @var string Hex color of button text is defined in settings ($CFG->color_btn_txt) */
public $color_btn_txt = "#ffffff";
/** @var string set empty, if the id does not exist then turn to "disabled" */
public $disabled = "";
/* @var string Contain button name, the button name is automatically the name of resource */
public $btn_name;
/** @var string Contain the type of button */
public $btn_type;
/** @var string Hex color of button is defined in settings ($CFG->color_btn) */
public $color_btn = "#009085";
/** @var string Hex color of button text is defined in settings ($CFG->color_btn_txt) */
public $color_btn_txt = "#ffffff";
/** @var string set empty, if the id does not exist then turn to "disabled" */
public $disabled = "";
/** @var string hide iframe nav and footer, admin setting */
public $iena_filter_iframe = true;
/**
* Get name and type of resource with the id
......@@ -138,13 +139,16 @@ function filter($text, array $options = array())
}
//$PAGE->requires->js('/filter/iena/js/jquery-3.3.1.min.js');
//$PAGE->requires->js('/filter/iena/js/iena.js');
$PAGE->requires->js('/filter/iena/js/iena.js');
//We hide the menus and block if the iframe parameter is a true
// if (isset($_GET['iframe'])) {
// if ($_GET['iframe'] == 'true') {
// $PAGE->requires->js('/filter/iena/js/iframe_true.js');
// }
// }
if (isset($CFG->iena_filter_iframe)) {
$this->iena_filter_iframe = $CFG->iena_filter_iframe;
}
if (isset($_GET['iframe']) && $this->iena_filter_iframe == "1") {
if ($_GET['iframe'] == 'true') {
$PAGE->requires->js('/filter/iena/js/iframe_true.js');
}
}
preg_match_all('/<a href="(.*?)">(.*?)<\/a>/s', $text, $matches);
......@@ -193,26 +197,27 @@ function filter($text, array $options = array())
$pieces[$i] = preg_replace("/(\\S+)\\[\/IENA\\]/",
"<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 type=\"button\" " . $this->disabled . " "
. "<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. "&iframe=true\" type=\"button\" " . $this->disabled . " "
. "class=\"btn iena-filter-modal-btn \" data-toggle=\"modal\" data-target=\"#iena-modal-" . $i . "\" style=\"background-color : " . $this->color_btn . "; "
. "color : $this->color_btn_txt;border-radius:0.15rem;\">"
. "<img class=\"icon icon\" alt=\"\" src=\"" . $CFG->wwwroot . "/theme/image.php/boost/" . $this->btn_type . "/1/icon\">"
. "" . $this->btn_name . " </button>"
. "<div class=\"modal fade iena-filter-modal\" id=\"iena-modal-" . $i . "\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"#iena-modal-btn-" . $i . "\" aria-hidden=\"true\">"
. "<div class=\"modal-dialog\" role=\"document\">"
. '<div class="modal-content">'
. '<div class="modal-header">'
. '<h5 class="modal-title" id="iena-modal-btn-'.$i.'">'.$this->btn_name.'</h5>'
. '<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>'
. "</div>"
. '<div class="modal-body">'
. "<iframe src=\"" . $parsed . "&iframe=true\" frameborder=\"0\" allowfullscreen></iframe>"
. "</div>"
. "</div>"
. "</div>"
. "<div class=\"modal-dialog\" role=\"document\">"
. '<div class="modal-content">'
. '<div class="modal-header">'
. '<h5 class="modal-title" id="iena-modal-btn-'.$i.'">'.$this->btn_name.'</h5>'
. '<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>'
. "</div>"
. '<div class="modal-body">'
// . "<iframe src=\"" . $parsed . "&iframe=true\" frameborder=\"0\" allowfullscreen></iframe>"
. "<iframe src=\"\" frameborder=\"0\" allowfullscreen></iframe>"
. "</div>"
. "</div>"
. "</div>"
. "</div>"
. "</div>"
......
......@@ -2,4 +2,5 @@
$settings->add(new admin_setting_configtext('color_btn', get_string('btn_settings', 'filter_iena'), get_string('setting_btn_settings', 'filter_iena'), "#009085"));
$settings->add(new admin_setting_configtext('color_btn_txt', get_string('btn_txt_settings', 'filter_iena'), get_string('setting_btn_txt_settings', 'filter_iena'), "#ffffff"));
$settings->add(new admin_setting_configcheckbox('iena_filter_iframe', get_string('btn_iframe_setting', 'filter_iena'), get_string('setting_btn_iframe_setting', 'filter_iena'), "1"));
?>
// (function() {
// window.onload = function () {
// $(".iena-filter-modal-btn").each(function(i, el){
// el.click = function (e) {
// console.log(e);
// }
// });
// }
// })()
\ No newline at end of file
;(function ($) {
$('iframe').load(function () {
$('iframe').contents().find("body")
.append($("<style type='text/css'> \n\
#page-header{display:none;}\n\
#page-footer{display:none;} \n\
.hidden-print{display:none;}\n\
#page{margin-top: 15px;padding-left: 10px;padding-right: 15px;} \n\
#card-block{height: 837px;width: 990px;} \n\
</style>"));
$('iframe').contents().find("header")
.append($("<style type='text/css'> \n\
.pos-f-t{display:none;} \n\
.navbar{display:none;} \n\
.navbar-full{display:none;} \n\
.navbar-light{display:none;} \n\
.bg-faded{display:none;} \n\
.navbar-static-top{display:none;} \n\
.moodle-has-zindex{display:none;}\n\
</style>"));
});
})(jQuery);
\ No newline at end of file
;(function () {
var btns = document.querySelectorAll('.iena-filter-modal-btn');
for (var i = 0; i < btns.length; i++) {
document.querySelector(btns[i].dataset.target + " iframe").setAttribute('src', btns[i].dataset.iframe);
}
})()
// ;(function ($) {
// $('iframe').load(function () {
// $('iframe').contents().find("body")
// .append($("<style type='text/css'> \n\
// #page-header{display:none;}\n\
// #page-footer{display:none;} \n\
// .hidden-print{display:none;}\n\
// #page{margin-top: 15px;padding-left: 10px;padding-right: 15px;} \n\
// #card-block{height: 837px;width: 990px;} \n\
// </style>"));
// $('iframe').contents().find("header")
// .append($("<style type='text/css'> \n\
// .pos-f-t{display:none;} \n\
// .navbar{display:none;} \n\
// .navbar-full{display:none;} \n\
// .navbar-light{display:none;} \n\
// .bg-faded{display:none;} \n\
// .navbar-static-top{display:none;} \n\
// .moodle-has-zindex{display:none;}\n\
// </style>"));
// });
// })(jQuery);
\ No newline at end of file
......@@ -4,28 +4,51 @@
* and open the template in the editor.
*/
var elmt = document.getElementById("page-header");
elmt.className = "none_hidden";
var elmt1 = document.getElementById("page-footer");
elmt1.className = "none_hidden";
var elmt2 = document.getElementsByClassName("hidden-print");
elmt2.className = "none_hidden";
var elmt2 = document.getElementsByClassName("hidden-print");
elmt2.className = "none_hidden";
var elmt3 = document.getElementsByClassName("pos-f-t");
elmt3.className = "none_hidden";
var elmt4 = document.getElementsByClassName("navbar");
elmt3.className = "none_hidden";
var elmt5 = document.getElementsByClassName("navbar-full");
elmt3.className = "none_hidden";
var elmt6 = document.getElementsByClassName("navbar-light");
elmt3.className = "none_hidden";
var elmt7 = document.getElementsByClassName("navbar-static-top");
elmt3.className = "none_hidden";
var elmt8 = document.getElementsByClassName("moodle-has-zindex");
elmt3.className = "none_hidden";
/* http://localhost:8888/moodle35/mod/assign/view.php?id=18&iframe=true
&iframe=true
*/
;(function () {
var to_hide = [
"#page-header",
"#page-wrapper > nav",
"#page-footer"
];
for (var i = 0; i < to_hide.length; i++) {
document.querySelector(to_hide[i]).setAttribute('class', 'none-hidden');
}
document.querySelector('#page').setAttribute('class', '');
document.querySelector('#page').style.margin = 0;
document.querySelector('#page-wrapper').setAttribute('class', 'no-after');
document.querySelector('#page-content').setAttribute('class', 'no-margin-l-r');
document.querySelector('#region-main-box').style.padding = 0;
document.querySelector('#region-main>.card').style.minHeight = 0;
})()
// var elmt = document.getElementById("page-header");
// elmt.className = "none_hidden";
// var elmt1 = document.getElementById("page-footer");
// elmt1.className = "none_hidden";
// var elmt2 = document.getElementsByClassName("hidden-print");
// elmt2.className = "none_hidden";
// var elmt2 = document.getElementsByClassName("hidden-print");
// elmt2.className = "none_hidden";
// var elmt3 = document.getElementsByClassName("pos-f-t");
// elmt3.className = "none_hidden";
// var elmt4 = document.getElementsByClassName("navbar");
// elmt3.className = "none_hidden";
// var elmt5 = document.getElementsByClassName("navbar-full");
// elmt3.className = "none_hidden";
// var elmt6 = document.getElementsByClassName("navbar-light");
// elmt3.className = "none_hidden";
// var elmt7 = document.getElementsByClassName("navbar-static-top");
// elmt3.className = "none_hidden";
// var elmt8 = document.getElementsByClassName("moodle-has-zindex");
// elmt3.className = "none_hidden";
......@@ -5,8 +5,10 @@ $string['pluginname'] = "filter_iena";
$string['filter_iena'] = "filter_iena";
$string['btn_settings'] = "Button background color";
$string['btn_txt_settings'] = "Button text color";
$string['btn_iframe_setting'] = "Diplay content only";
$string['setting_btn_settings'] = "The value must be in hexa and start with a #";
$string['setting_btn_txt_settings'] = "The value must be in hexa and start with a #";
$string['setting_btn_iframe_setting'] = "Display only iframe content, without navigation controls and footer.";
$string['erreur_ressource'] = "Ressource not found";
?>
\ No newline at end of file
......@@ -5,8 +5,10 @@ $string['pluginname'] = "filter_iena";
$string['filter_iena'] = "filter_iena";
$string['btn_settings'] = "Couleur du bouton";
$string['btn_txt_settings'] = "Couleur du texte du bouton";
$string['btn_iframe_setting'] = "N'afficher que le contenu";
$string['setting_btn_settings'] = "La valeur doit être en hexadécimal et débuter avec un #";
$string['setting_btn_txt_settings'] = "La valeur doit être en hexadécimal et débuter avec un #";
$string['setting_btn_iframe_setting'] = "N'afficher que le contenu de la page ciblée, sans les menus ou le pied de page.";
$string['erreur_ressource'] = "Ressource non trouvée";
?>
\ No newline at end of file
index.file=index.php
url=http://localhost/wikipediacalls/
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/home/softia/Bureau/wikipediacalls/filtersettings.php</file>
<file>file:/home/softia/Bureau/wikipediacalls/version.php</file>
<file>file:/home/softia/Bureau/wikipediacalls/filter.php</file>
</group>
</open-files>
</project-private>
include.path=${php.global.include.path}
php.version=PHP_56
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>wikipediacalls</name>
</data>
</configuration>
</project>
......@@ -24,7 +24,15 @@
font-size: 3rem;*/
}
.none_hidden {
/*display: none;*/
.none-hidden {
display: none;
}
.no-after:after {
min-height: 0 !important;
}
.no-margin-l-r {
margin-left: 0;
margin-right: 0;
}
......@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018071201; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018071202; // 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";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment