Gitlab CSE Unil

Commit 89a18811 authored by M. Chardon's avatar M. Chardon
Browse files

- mise à niveau des boutons sur bootstrap4

- chemin vers fontawesome
parent 4df2bfe6
......@@ -63,13 +63,12 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
/**
* Render a single colour button.
*
* @param string $icon - The key for the icon
* @param string $tool - The key for the lang string.
* @param string $accesskey Optional - The access key for the button.
* @param bool $disabled Optional - Is this button disabled.
* @return string
*/
private function render_toolbar_button($icon, $tool, assignfeedback_editpdfplus\tool $fulltool = null, $accesskey = null, $disabled = false) {
private function render_toolbar_button($tool, assignfeedback_editpdfplus\tool $fulltool = null, $accesskey = null, $disabled = false) {
if (!$fulltool) {
// Build button alt text.
......@@ -113,7 +112,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
}
$iconhtml = html_writer::tag("i", "", array('class' => 'fa ' . $class,
'aria-hidden' => 'true'));
$iconparams = array('data-tool' => $tool, 'class' => $tool . 'button btn', 'type' => 'button');
$iconparams = array('data-tool' => $tool, 'class' => $tool . 'button btn btn-secondary', 'type' => 'button');
if ($disabled) {
$iconparams['disabled'] = 'true';
}
......@@ -161,7 +160,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
break;
}
$iconparams = array('data-tool' => $datatool,
'class' => $class . 'button btn costumtoolbarbutton',
'class' => $class . 'btn costumtoolbarbutton btn btn-secondary',
'id' => 'ctbutton' . $fulltool->id,
'type' => 'button');
}
......@@ -185,26 +184,35 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
* @return string
*/
public function render_assignfeedback_editpdfplus_widget(assignfeedback_editpdfplus_widget $widget) {
global $CFG;
$html = '';
//JS declaration
$html .= html_writer::div(get_string('jsrequired', 'assignfeedback_editpdfplus'), 'hiddenifjs');
//Random id for plugin identification
$linkid = html_writer::random_id();
if ($widget->readonly) {
$launcheditorlink = html_writer::tag('a', get_string('viewfeedbackonline', 'assignfeedback_editpdfplus'), array('id' => $linkid, 'class' => 'btn', 'href' => '#'));
$launcheditorlink = html_writer::tag('a', get_string('viewfeedbackonline', 'assignfeedback_editpdfplus'), array('id' => $linkid, 'class' => 'btn btn-secondary', 'href' => '#'));
} else {
$launcheditorlink = html_writer::tag('a', get_string('launcheditor', 'assignfeedback_editpdfplus'), array('id' => $linkid, 'class' => 'btn', 'href' => '#'));
$launcheditorlink = html_writer::tag('a', get_string('launcheditor', 'assignfeedback_editpdfplus'), array('id' => $linkid, 'class' => 'btn btn-secondary', 'href' => '#'));
}
$links = $launcheditorlink;
$html .= '<input type="hidden" name="assignfeedback_editpdfplus_haschanges" value="false"/>';
$html .= html_writer::div($links, 'visibleifjs');
//html header
$header = get_string('pluginname', 'assignfeedback_editpdfplus');
$body = '';
// Create the page navigation.
$navigation1 = '';
$tooglenavigation = html_writer::tag("button", '<span class="navbar-toggler-icon"></span>', array('class' => 'navbar-toggler',
'type' => 'button',
'data-toggle' => "collapse",
'data-target' => "#navbarSupportedContent",
'aria-expanded' => "Toggle navigation"));
// Create the page navigation.
$navigation = '';
// Pick the correct arrow icons for right to left mode.
if (right_to_left()) {
$nav_prev = 'nav_next';
......@@ -213,49 +221,45 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$nav_prev = 'nav_prev';
$nav_next = 'nav_next';
}
$iconhtmlP = html_writer::tag("i", "", array('class' => 'fa fa-caret-left fa-2x',
$iconhtmlP = html_writer::tag("i", "", array('class' => 'fa fa-caret-left fa-2x',
'aria-hidden' => 'true'));
$navigation1 .= html_writer::tag('button', $iconhtmlP, array('disabled' => 'true',
'class' => 'btn navigate-previous-button',
$navigation .= html_writer::tag('button', $iconhtmlP, array('disabled' => 'true',
'class' => 'btn btn-secondary navigate-previous-button',
'type' => 'button',
'accesskey' => $this->get_shortcut('navigate-previous-button')));
$navigation1 .= html_writer::tag('select', null, array('disabled' => 'true',
$navigation .= html_writer::tag('select', null, array('disabled' => 'true',
'aria-label' => get_string('gotopage', 'assignfeedback_editpdfplus'), 'class' => 'navigate-page-select',
'accesskey' => $this->get_shortcut('navigate-page-select')));
$iconhtmlN = html_writer::tag("i", "", array('class' => 'fa fa-caret-right fa-2x',
'aria-hidden' => 'true'));
$navigation1 .= html_writer::tag('button', $iconhtmlN, array('disabled' => 'true',
'class' => 'btn navigate-next-button',
$navigation .= html_writer::tag('button', $iconhtmlN, array('disabled' => 'true',
'class' => 'btn btn-secondary navigate-next-button',
'type' => 'button',
'accesskey' => $this->get_shortcut('navigate-next-button')));
$divnavigation1 = html_writer::div($navigation1, 'navigation', array('role' => 'navigation'));
$navigationBlock = html_writer::div($navigation, "btn-group btn-group-sm mr-auto", array('role' => 'group'));
$toolbar001 = '';
$toolbar002 = '';
$toolbar003 = '';
$toolbarBaseBlock = '';
$toolbarDrawBlock = '';
$toolbarAdminBlock = '';
$toolbarCostumdiv = '';
$toolbaraxis = '';
$clearfix = html_writer::div('', 'clearfix');
$toolbarAxis = '';
if (!$widget->readonly) {
/** Toolbar n°0 : basic tools * */
// Select Tool.
$toolbar001 .= $this->render_toolbar_button('drag', 'drag', null, $this->get_shortcut('drag'));
$toolbar001 .= $this->render_toolbar_button('select', 'select', null, $this->get_shortcut('select'));
$toolbar001 = html_writer::div($toolbar001, 'toolbar', array('role' => 'toolbar'));
$toolbarBase = $this->render_toolbar_button('drag', null, $this->get_shortcut('drag'));
$toolbarBase .= $this->render_toolbar_button('select', null, $this->get_shortcut('select'));
$toolbarBaseBlock = html_writer::div($toolbarBase, "btn-group btn-group-sm mr-3", array('role' => 'group'));
// Other Tools.
$toolbar002 .= $this->render_toolbar_button('pen', 'pen', null, $this->get_shortcut('pen'));
$toolbar002 .= $this->render_toolbar_button('line', 'line', null, $this->get_shortcut('line'));
$toolbar002 .= $this->render_toolbar_button('rectangle', 'rectangle', null, $this->get_shortcut('rectangle'));
$toolbar002 .= $this->render_toolbar_button('oval', 'oval', null, $this->get_shortcut('oval'));
$toolbar002 .= $this->render_toolbar_button('highlight', 'highlight', null, $this->get_shortcut('highlight'));
$toolbar002 .= $this->render_toolbar_button('background_colour_clear', 'annotationcolour', null, $this->get_shortcut('annotationcolour'));
$toolbar002 = html_writer::div($toolbar002, 'toolbar', array('role' => 'toolbar'));
$toolbarDraw = $this->render_toolbar_button('pen', null, $this->get_shortcut('pen'));
$toolbarDraw .= $this->render_toolbar_button('line', null, $this->get_shortcut('line'));
$toolbarDraw .= $this->render_toolbar_button('rectangle', null, $this->get_shortcut('rectangle'));
$toolbarDraw .= $this->render_toolbar_button('oval', null, $this->get_shortcut('oval'));
$toolbarDraw .= $this->render_toolbar_button('highlight', null, $this->get_shortcut('highlight'));
$toolbarDraw .= $this->render_toolbar_button('annotationcolour', null, $this->get_shortcut('annotationcolour'));
$toolbarDrawBlock = html_writer::div($toolbarDraw, "btn-group btn-group-sm", array('role' => 'group'));
/** Costum toolbars * */
$toolbarCostum = array();
......@@ -265,52 +269,66 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$toolbartmp = '';
foreach ($toolbar['tool'] as $tool) {
if ($tool->enabled) {
$toolbartmp .= $this->render_toolbar_button('', '', $tool);
$toolbartmp .= $this->render_toolbar_button('', $tool);
}
}
$toolbarCostum[] = html_writer::div($toolbartmp, 'toolbar customtoolbar', array('role' => 'toolbar', 'id' => 'toolbaraxis' . $toolbar['axeid'], 'style' => 'display:none;'));
$toolbarCostum[] = html_writer::div($toolbartmp, "btn-group btn-group-sm mr-3", array('role' => 'group', 'id' => 'toolbaraxis' . $toolbar['axeid'], 'style' => 'display:none;'));
}
$axischoice = html_writer::div(html_writer::select($axis, 'axisselection', 0, FALSE), 'toolbar ', array('role' => 'toolbar'));
foreach ($toolbarCostum as $toolbarCostumUnit) {
$toolbarCostumdiv .= $toolbarCostumUnit;
}
$toolbarCostumdiv .= $axischoice;
$axischoice = html_writer::div(html_writer::select($axis, 'axisselection', 0, FALSE), "btn-group btn-group-sm mr-0", array('role' => 'group'));
$toolbarAxis = $axischoice;
// Toolbar pour lien creation palette
$courseid = $this->page->course->id;
$lienAdmin = new moodle_url('/mod/assign/feedback/editpdfplus/view_admin.php', array('id' => $courseid));
$toolbar003 .= html_writer::tag('button',
html_writer::tag("i", "", array('class' => 'fa fa-wrench','aria-hidden' => 'true')),
array('class' => 'button btn', 'type' => 'button'));
$toolbar003 = html_writer::link($lienAdmin, $toolbar003);
$toolbar003 = html_writer::div($toolbar003, 'toolbar', array('role' => 'toolbar'));
//$url = new moodle_url('/mod/assign/feedback/editpdfplus/view_admin.php', array('id' => $course->id));
$toolbarAdmin = html_writer::tag('button', html_writer::tag("i", "", array('class' => 'fa fa-wrench', 'aria-hidden' => 'true')), array(
'class' => 'btn btn-info',
'type' => 'button',
'onclick' => "document.location='" . $lienAdmin->out() . "';"));
$toolbarAdminBlock = html_writer::div($toolbarAdmin, "btn-group btn-group-sm mr-3", array('role' => 'group'));
} else {
$toolbaraxis = "<div class='navigation' style='padding-left:10px;'><div style='display:inline;margin-right:5px;text-align:left;'>";
//TODO
$toolbarAxis = "<div class='navigation' style='padding-left:10px;'><div style='display:inline;margin-right:5px;text-align:left;'>";
$axis = $widget->axis;
foreach ($axis as $ax) {
$toolbaraxis .= $this->render_toolbar_axis($ax);
$toolbaraxis .= "</div><div style='display:inline;margin-left:5px;text-align:left;'>";
$toolbarAxis .= $this->render_toolbar_axis($ax);
$toolbarAxis .= "</div><div style='display:inline;margin-left:5px;text-align:left;'>";
}
$toolbaraxis .= "</div></div>";
$toolbarAxis .= "</div></div>";
$questionchoice = html_writer::select(
[get_string('question_select', 'assignfeedback_editpdfplus'), get_string('question_select_without', 'assignfeedback_editpdfplus'), get_string('question_select_with', 'assignfeedback_editpdfplus')], 'questionselection', 0, FALSE, array('class' => 'form-control'));
$axischoice = html_writer::select(
[get_string('statut_select', 'assignfeedback_editpdfplus'), get_string('statut_select_nc', 'assignfeedback_editpdfplus'), get_string('statut_select_ok', 'assignfeedback_editpdfplus'), get_string('statut_select_ko', 'assignfeedback_editpdfplus')], 'statutselection', 0, FALSE, array('class' => 'form-control'));
$validatebutton = html_writer::tag('button', get_string('send_pdf_update', 'assignfeedback_editpdfplus'), array('class' => 'button btn', 'id' => 'student_valide_button'));
$toolbaraxis .= html_writer::div($validatebutton, 'toolbar ', array('role' => 'toolbar'));
$toolbaraxis .= html_writer::div($axischoice, 'toolbar ', array('role' => 'toolbar'));
$toolbaraxis .= html_writer::div($questionchoice, 'toolbar ', array('role' => 'toolbar'));
$validatebutton = html_writer::tag('button', get_string('send_pdf_update', 'assignfeedback_editpdfplus'), array('class' => 'btn btn-secondary', 'id' => 'student_valide_button'));
$toolbarAxis .= html_writer::div($validatebutton, 'toolbar ', array('role' => 'toolbar'));
$toolbarAxis .= html_writer::div($axischoice, 'toolbar ', array('role' => 'toolbar'));
$toolbarAxis .= html_writer::div($questionchoice, 'toolbar ', array('role' => 'toolbar'));
}
//$navigationcontent = html_writer::div(, "collapse navbar-collapse", array('id' => 'navbarSupportedContent'));
$pageheadercontent = $navigationBlock
. $toolbarAdminBlock
. $toolbarBaseBlock
. $toolbarAxis
. $toolbarCostumdiv
. $toolbarDrawBlock;
$mainnavigation = html_writer::div($pageheadercontent, "btn-toolbar btn-group-sm bg-light p-1", array('role' => 'toolbar', 'style' => 'min-height:50px;'));
// Toobars written in reverse order because they are floated right.
$pageheader = html_writer::div($divnavigation1 .
$toolbar002 .
$toolbaraxis .
$toolbarCostumdiv .
$toolbar001 .
$toolbar003 .
$clearfix, 'pageheader', array('style' => 'padding:0'));
$pageheader = $mainnavigation; //html_writer::div($mainnavigation, 'pageheader', array('style' => 'padding:0'));
/* html_writer::div($divnavigation1 .
$toolbar002 .
$toolbaraxis .
$toolbarCostumdiv .
$toolbar001 .
$toolbar003 .
$clearfix, 'pageheader', array('style' => 'padding:0')); */
$body .= $pageheader;
......
......@@ -41,13 +41,13 @@ use \assignfeedback_editpdfplus\utils_color;
class utils_stamp {
/** Path of fontawesome font scss */
const FA_SCSS_PATH = '/lib/fonts/font-awesome-4.7.0/scss/_variables.scss';
const FA_SCSS_PATH = "/mod/assign/feedback/editpdfplus/fonts/fa/_variables.scss";
/** Path of fontawesome font */
const FA_PATH = '/lib/fonts/fontawesome-webfont.ttf';
/** File area for the stamps */
const STAMPS_FILEAREA = '/temp/assignfeedback_editpdfplus/stamps/';
const STAMPS_FILEAREA = '/assignfeedback_editpdfplus/stamps/';
/**
* Convert a FontAwesome icon into a PNG file
......@@ -68,7 +68,7 @@ class utils_stamp {
}
//create final file
$outputDirectory = $CFG->dataroot . self::STAMPS_FILEAREA;
$outputDirectory = $CFG->tempdir . self::STAMPS_FILEAREA;
$fileName = sprintf("%s%s.png", $outputDirectory, $iconName);
$dirPath = dirname($fileName);
......@@ -125,6 +125,9 @@ class utils_stamp {
imagealphablending($imageTmp, true);
// Add the text using the Font
if (!file_exists($CFG->dirroot . self::FA_PATH)) {
return null;
}
$fontPath = $CFG->dirroot . self::FA_PATH;
list($fontX, $fontY) = self::imageTTFCenter($imageTmp, $charFACode, $fontPath, $fontSize);
imagettftext($imageTmp, $fontSize, 0, $fontX, $fontY, $fontColor, $fontPath, $charFACode);
......@@ -310,6 +313,9 @@ class utils_stamp {
global $CFG;
//open scss file
if (!file_exists($CFG->dirroot . self::FA_SCSS_PATH)) {
return null;
}
$readBuffer = file_get_contents($CFG->dirroot . self::FA_SCSS_PATH);
$lines = explode("\n", $readBuffer);
......
This diff is collapsed.
......@@ -5055,7 +5055,7 @@ EDITOR.prototype = {
button.one('i').setStyle('color', this.currentedit.annotationcolour);
break;
}
button.setStyle('background-color', 'transparent');
button.setStyle('background-color', '');
}
},
......
......@@ -5055,7 +5055,7 @@ EDITOR.prototype = {
button.one('i').setStyle('color', this.currentedit.annotationcolour);
break;
}
button.setStyle('background-color', 'transparent');
button.setStyle('background-color', '');
}
},
......
......@@ -275,7 +275,7 @@ EDITOR.prototype = {
button.one('i').setStyle('color', this.currentedit.annotationcolour);
break;
}
button.setStyle('background-color', 'transparent');
button.setStyle('background-color', '');
}
},
......
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