template introduction of the course and tool - refs #2681

pull/2715/head
Alex Aragón 7 years ago
parent 9ff51fa6c2
commit 5ee814a4c1
  1. 119
      main/inc/introductionSection.inc.php
  2. 1
      main/inc/lib/display.lib.php
  3. 25
      main/template/default/auth/introduction_section.html.twig

@ -169,9 +169,7 @@ if ($intro_cmdEdit || $intro_cmdAdd) {
if ($intro_dispForm) {
$default['intro_content'] = $intro_content;
$form->setDefaults($default);
$introduction_section .= '<div id="courseintro" style="width: 98%">';
$introduction_section .= $form->returnForm();
$introduction_section .= '</div>';
}
$thematic_description_html = '';
@ -288,55 +286,75 @@ if (!empty($thematic_advance_info)) {
$introduction_section .= $thematicProgress;
$introduction_section .= '</div>';
}
$editIconButton = '';
$toolbar = [];
if (api_is_allowed_to_edit() && empty($session_id)) {
$editIconButton = Display::url(
'<em class="fa fa-wrench"></em> ',
api_get_path(WEB_CODE_PATH).'course_info/tools.php?'.api_get_cidreq(),
['class' => 'btn btn-default', 'title' => get_lang('CustomizeIcons')]
);
$tool = [
'name' => get_lang('CustomizeIcons'),
'url' => api_get_path(WEB_CODE_PATH).'course_info/tools.php?'.api_get_cidreq(),
'icon' => 'fas fa-cog'
];
$toolbar[]= $tool;
}
$toolbar = '';
$textIntro = '';
if ($intro_dispCommand) {
if (empty($intro_content)) {
// Displays "Add intro" commands
$toolbar .= '<div class="toolbar-edit">';
$toolbar .= '<div class="btn-group pull-right" role="group">';
if (!empty($courseId)) {
$textIntro = '<a class="btn btn-default" title="'.addslashes(get_lang('AddIntro')).'" href="'.api_get_self().'?'.api_get_cidreq().$blogParam.'&intro_cmdAdd=1">';
$textIntro .= '<em class="fa fa-file-text"></em> ';
$textIntro .= "</a>";
$toolbar .= $textIntro.$editIconButton;
$tool = [
'name' => addslashes(get_lang('AddIntro')),
'url' => api_get_self().'?'.api_get_cidreq().$blogParam.'&intro_cmdAdd=1',
'icon' => 'fas fa-pencil-alt',
];
$toolbar[]= $tool;
} else {
$toolbar .= '<a class="btn btn-default" href="'.api_get_self().'?intro_cmdAdd=1">'.get_lang('AddIntro').'</a>';
$toolbar .= $editIconButton;
$tool = [
'name' => get_lang('AddIntro'),
'url' => api_get_self().'?intro_cmdAdd=1',
'icon' => 'fas fa-pencil-alt'
];
$toolbar[]= $tool;
}
$toolbar .= '</div></div>';
} else {
// Displays "edit intro && delete intro" commands
$toolbar .= '<div class="toolbar-edit">';
$toolbar .= '<div class="btn-group pull-right" rol="group">';
if (!empty($courseId)) {
$toolbar .=
'<a class="btn btn-default" href="'.api_get_self().'?'.api_get_cidreq().$blogParam.'&intro_cmdEdit=1" title="'.get_lang('Modify').'">
<em class="fa fa-pencil"></em></a>';
$toolbar .= $editIconButton;
$toolbar .= "<a class=\"btn btn-default\" href=\"".api_get_self()."?".api_get_cidreq().$blogParam."&intro_cmdDel=1\" onclick=\"javascript:
if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).
"')) return false;\"><em class=\"fa fa-trash-o\"></em></a>";
$tool = [
'name' => get_lang('Modify'),
'url' => api_get_self().'?'.api_get_cidreq().$blogParam.'&intro_cmdEdit=1',
'icon' => 'fas fa-pencil-alt'
];
$toolbar[]= $tool;
$tool = [
'name' => get_lang('ConfirmYourChoice'),
'url' => api_get_self()."?".api_get_cidreq().$blogParam."&intro_cmdDel=1",
'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).
"')) return false",
'icon' => 'fas fa-trash-alt'
];
$toolbar[]= $tool;
} else {
$toolbar .=
'<a class="btn btn-default" href="'.api_get_self().'?intro_cmdEdit=1" title="'.get_lang('Modify').'">
<em class="fa fa-pencil"></em>
</a>"';
$toolbar .= $editIconButton;
$toolbar .= "<a class=\"btn btn-default\" href=\"".api_get_self()."?".api_get_cidreq()."&intro_cmdDel=1\" onclick=\"javascript:
if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).
"')) return false;\"><em class=\"fa fa-trash-o\"></em></a>";
$tool=[
'name' => get_lang('Modify'),
'url' => api_get_self().'?intro_cmdEdit=1',
'icon' => 'fas fa-pencil-alt'
];
$toolbar[]= $tool;
$tool=[
'name' => get_lang('ConfirmYourChoice'),
'url' => api_get_self()."?".api_get_cidreq()."&intro_cmdDel=1",
'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_ilang('ConfirmYourChoice'), ENT_QUOTES, $charset)).
"')) return false",
'icon' => 'fas fa-trash-alt'
];
$toolbar[]= $tool;
}
$toolbar .= "</div></div>";
// Fix for chrome XSS filter for videos in iframes - BT#7930
$browser = api_get_navigator();
if (strpos($introduction_section, '<iframe') !== false && $browser['name'] == 'Chrome') {
@ -350,23 +368,26 @@ if ($moduleId != 'course_homepage') {
$nameSection = get_lang('AddCustomToolsIntro');
}
$introduction_section .= '<div class="col-md-12">';
$textContent = [];
if ($intro_dispDefault) {
if (!empty($intro_content)) {
$introduction_section .= '<div class="page-course">';
$introduction_section .= $intro_content;
$introduction_section .= '</div>';
$textContent = [
'name' => 'introduction-course',
'help' => $nameSection,
'text' => $intro_content
];
} else {
if (api_is_allowed_to_edit()) {
$introduction_section .= '<div class="help-course">';
$introduction_section .= $nameSection.' '.$textIntro;
$introduction_section .= '</div>';
$textContent = [
'name' => 'introduction-section',
'help' => $nameSection,
'text' => $intro_content
];
}
}
}
$introduction_section .= $toolbar;
$introduction_section .= '</div>';
//$introduction_section .= $toolbar;
$introduction_section .= '</div>';
$browser = api_get_navigator();
@ -374,3 +395,9 @@ $browser = api_get_navigator();
if (strpos($introduction_section, '<iframe') !== false && $browser['name'] == 'Chrome') {
header("X-XSS-Protection: 0");
}
$data = null;
$tpl = new Template(null);
$tpl->assign('intro',$textContent);
$tpl->assign('toolbar',$toolbar);
$introduction_section .= $tpl->fetch($tpl->get_template('auth/introduction_section.html.twig'));

@ -202,7 +202,6 @@ class Display
if (api_get_setting('enable_tool_introduction') == 'true' || $tool == TOOL_COURSE_HOMEPAGE) {
$introduction_section = null;
require api_get_path(SYS_INC_PATH).'introductionSection.inc.php';
return $introduction_section;
}
}

@ -0,0 +1,25 @@
{% autoescape false %}
<div class="card">
<div class="card-body p-3">
<section id="section-intro">
<div id="{{ intro.name }}" class="section-intro-content">
{% if intro.text !='' %}
{{ intro.text }}
{% else %}
{{ intro.help }}
{% endif %}
</div>
<div class="section-intro-toolbar float-right">
<div class="btn-group btn-group-sm" role="group" aria-label="">
{% for item in toolbar %}
<a href="{{ item.url }}" onclick="{{ (item.onclick!='')? item.onclick : '' }}"
title="{{ item.name }}" class="btn btn-light">
<i class="{{ item.icon }}"></i>
</a>
{% endfor %}
</div>
</div>
</section>
</div>
</div>
{% endautoescape %}
Loading…
Cancel
Save