Skip to content
Snippets Groups Projects
Commit eec1ec9a authored by Thomas Fradet's avatar Thomas Fradet
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
## Filtre fenêtre modales
Ce plugin Moodle est un filtre transformant un lien vers une activité ou une ressource Moodle en bouton qui affichera cette activité dans une fenêtre modale (popup) afin de ne pas avoir besoin de changer de page pour la consulter.
## Auteurs
- Vrignaud Camille cvrignaud@softia.fr
- Lebeau Michaël mlebeau@softia.fr
- Thomas Fradet thomas.fradet@univ-lorraine.fr
## Compatibility
MOODLE 3.5
Stabilité : stable.
## Contribution
Contributors are welcom ! Please contact iena-contact@univ-lorraine.fr.
## Contact
Pour assistance interne (Univesité de Lorraine) : https://helpdesk.univ-lorraine.fr.
Pour tout autre question : iena-contact@univ-lorraine.fr.
Other : iena-contact@univ-lorraine.fr.
## Fonctionnalités
Transforme un lien vers une ressource ou activité du cours en bouton. Cliquer sur le bouton ouvre une fenêtre modale (une "popup" en surimpression de la page) qui montre le contenu de la ressource ou activité en iframe.
Ceci permet d'ouvrir d'autres éléments du cours depuis la page du cours, une ressource page ou livre ou encore un exercice, sans pour autant changer de page. A la fin de la consultation, l'étudiant peut fermer la fenêtre modale et continuer son travail.
## Paramétrage
L'administrateur peut configurer la couleur du bloc et du texte. Il doit par ailleurs activer le filtre et le placer après celui créant des liens automatiques des activités.
## Problèmes connus
- Il semble qu'il faille positionner le filtre de lien automatique des activité sur "Activé" et non pas "Activé (défaut)" sur certaines installations. Il doit être activé quoi qu'il en soit et placé avant ce filtre Activité modale dans l'ordre d'application des filtres (administration).
- Les menus de Moodle s'affichent également dans l'iFrame de la fenêtre modale et pourraient être supprimés pour un meilleur affichage, bien que ceci soit par nature instable et dépendant du thème utilisé.
<?php
// $id$
//////////////////////////////////////////////////////////////
//
// This filter allows making calls to moodle.
//
//////////////////////////////////////////////////////////////
/// This is the filtering function itself. It accepts the
/// courseid and the text to be filtered (in HTML form).
/**
* The iena filter plugin transforms the moodle resource links
* into a button that opens the resource in a modal
*
* @package filter_iena
* @category filter
* @copyright 2018 Softia/Université lorraine
* @author vrignaud camille
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* filter_iena
*
*
* @package filter_iena
* @copyright 2018 Softia/Université lorraine
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class filter_iena extends moodle_text_filter
{
/** @var string This variable is used for delemiter */
public $start = "[IENA]";
/** @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 = "";
/**
* Get name and type of resource with the id
* Set the $btn_name and $btn_type
* Set $disabled (if $disabled is empty the button is active)
* @param array $id_btn
*
* @return void
*/
public function filter_iena_get_info($id_btn)
{
global $DB;
$this->btn_name = get_string('erreur_ressource', 'filter_iena');
$this->disabled = "";
$id_course_modules = $id_btn[0][0];
if ($id_course_modules) {
$requete = $DB->get_record_sql('SELECT * FROM {course_modules} WHERE id = ?', array($id_course_modules));
$id_instance = $requete->instance;
$id_module = $requete->module;
if ($id_module) {
$modules = $DB->get_record_sql('SELECT * FROM {modules} WHERE id = ?', array($id_module));
}
if ($modules->name) {
$instance = $DB->get_record_sql('SELECT * FROM {' . $modules->name . '} WHERE id = ?', array($id_instance));
}
if ($instance->name) {
$this->btn_name = $instance->name;
} else {
$this->disabled = "disabled";
}
$this->btn_type = $modules->name;
}
}
/**
* add $start and $end on each ressource link
* @param array $pieces
*
* @return array $pieces
*/
public function filter_iena_add_delimiters($pieces)
{
global $CFG;
for ($i = 1; $i < count($pieces); $i++) {
// If the link is in iframe then it is not tranformer
if ((strpos($pieces[$i], '</iframe>') !== false)) {
$pieces[$i] = $CFG->wwwroot . '/mod' . $pieces[$i];
continue;
}
if ((strpos($pieces[$i], '</a>') !== false)) {
$pieces[$i] = $CFG->wwwroot . '/mod' . $pieces[$i];
continue;
}
$pieces[$i] = $this->start . $CFG->wwwroot . '/mod' . $pieces[$i];
$temp = strpos($pieces[$i], "id=") + 3;
$nb_temp = '';
while (is_numeric($pieces[$i][$temp])) {
$nb_temp = $nb_temp . $pieces[$i][$temp];
$temp++;
}
$pieces[$i] = substr_replace($pieces[$i], $nb_temp . $this->end, strpos($pieces[$i], "id=") + 3, strlen($nb_temp));
$pieces[$i] = str_replace('&amp;iframe=true', '', $pieces[$i]);
$pieces[$i] = str_replace('&amp;iframe=false', '', $pieces[$i]);
$pieces[$i] = str_replace('&iframe=true', '', $pieces[$i]);
$pieces[$i] = str_replace('&iframe=false', '', $pieces[$i]);
}
return $pieces;
}
/**
* @param $text
* @param array $options
* @return string
*/
function filter($text, array $options = array())
{
global $CFG;
global $PAGE;
if ($CFG->color_btn) {
$this->color_btn = $CFG->color_btn;
}
if ($CFG->color_btn_txt) {
$this->color_btn_txt = $CFG->color_btn_txt;
}
//$PAGE->requires->js('/filter/iena/js/jquery-3.3.1.min.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');
// }
// }
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);
}
}
$pieces = explode($CFG->wwwroot . '/mod', $text);
$pieces = $this->filter_iena_add_delimiters($pieces);
for ($i = 0; $i < count($pieces); $i++) {
$pieces[$i] = ' ' . $pieces[$i];
$ini = strpos($pieces[$i], $this->start);
$ini += strlen($this->start);
if (strlen($pieces[$i]) <= $ini) {
continue;
}
$len = strpos($pieces[$i], $this->end, $ini) - $ini;
$parsed = substr($pieces[$i], $ini, $len);
preg_match_all('/id=[\d]*/', $parsed, $matches);
if ($matches[0]) {
preg_match_all('/[\d]+/', $matches[0][0], $id_btn);
}
if (isset($id_btn[0])) {
$this->filter_iena_get_info($id_btn);
}
// $PAGE->requires->js('/filter/iena/js/iena-filter-accessibility.js');
// $pieces[$i] = preg_replace("/(\\S+)\\[\/IENA\\]/", "<a class=\"sr-only\" target=\"_blank\" href=\"$parsed\">Ouvrir dans un nouvel onglet au lieu d'utiliser la modale : $this->btn_name.</a><button id=\"iena-modal-btn-" . $i . "\" 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\">"
// . "<button type=\"button\" class=\"close\" data-dismiss=\"modal\" onclick=\"$('#iena-modal-" . $i . "').modal('hide');\"><span class=\"sr-only\">Fermer la modale</span><span aria-hidden=\"true\">&times;</span></button>"
// . "<iframe src=\"" . $parsed . "&iframe=true\" frameborder=\"0\" allowfullscreen></iframe>"
// . "</div>"
// . "</div>"
// , $pieces[$i]);
$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 . " "
. "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>"
. "</div>"
, $pieces[$i]);
}
return implode($pieces);
}
}
// $pieces[$i] = preg_replace("/(\\S+)\\[\/IENA\\]/", "<button id=\"iena-modal-btn-" . $i . "\" type=\"button\" " . $this->disabled . " "
// . "class=\"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 role=\"document\" class=\"modal-dialog modal-lg\">"
// . "<div class=\"modal-content\" id=\"iena-modal-content\" >"
// . "<div class=\"modal-header\">"
// . "<button type=\"button\" class=\"close\" data-dismiss=\"modal\">&times;</button>"
// . "<h4 class=\"modal-title\">"
// . "<img class=\"icon icon\" alt=\"\" src=\"" . $CFG->wwwroot . "/theme/image.php/boost/" . $this->btn_type . "/1/icon\">" . $this->btn_name . "</h4>"
// . "</div>"
// . "<div class=\"modal-body\" id=\"iena-modal-body\">"
// . "<iframe width=\"100%\" height=\"85vh\" src=\"" . $parsed . "&iframe=true\" frameborder=\"0\" allowfullscreen></iframe>"
// . "</div>"
// . "</div>"
// . "</div>"
// . "</div>"
// , $pieces[$i]);
\ No newline at end of file
<?php
$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"));
?>
// (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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* 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";
This diff is collapsed.
This diff is collapsed.
<?php // $Id$
$string['filtername'] = 'iENA iframe button filter';
$string['pluginname'] = "filter_iena";
$string['filter_iena'] = "filter_iena";
$string['btn_settings'] = "Button background color";
$string['btn_txt_settings'] = "Button text color";
$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['erreur_ressource'] = "Ressource not found";
?>
\ No newline at end of file
<?php // $Id$
$string['filtername'] = 'Filtre bouton iframe iENA';
$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['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['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>
pix/icon.jpg

1.14 KiB

pix/logo.jpg

29.1 KiB

.iena-filter-modal .modal-dialog {
/*display: block;*/
width: 80%;
max-width: unset;
/*margin: auto;*/
/*border-radius: 0.15rem;*/
}
.iena-filter-modal .modal-body {
height: 80vh;
padding: 0;
}
.iena-filter-modal iframe {
width: 100%;
height: 80vh;
/*margin-top: 5vh;*/
/*border-radius: 0.15rem;*/
}
.iena-filter-modal button.close {
/*position: fixed;
top: 2vh;
right: -5%;
color: #ffffff;
font-size: 3rem;*/
}
.none_hidden {
/*display: none;*/
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details
*
* The iena filter plugin transforms the moodle resource links
* into a button that opens the resource in a modal
*
* @package filter_iena
* @category filter
* @copyright 2018 Softia/Université lorraine
* @author vrignaud camille
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018071201; // 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";
$plugin->maturity = MATURITY_STABLE;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment