Commit 5d1d4172 authored by Camille Tardy's avatar Camille Tardy
Browse files

Fix for Moodle 3.7 and 3.8 + add a column + css for mod_book + css for new course overview block.

parent 776311b0
......@@ -5,7 +5,7 @@ namespace theme_unige\output\core;
defined('MOODLE_INTERNAL') || die();
use moodle_url;
use coursecat;
use core_course_category;
use coursecat_helper;
use html_writer;
use single_select;
......@@ -59,8 +59,8 @@ class course_renderer extends \core_course_renderer {
*/
public function course_category($category) {
global $CFG;
require_once($CFG->libdir. '/coursecatlib.php');
$coursecat = coursecat::get(is_object($category) ? $category->id : $category);
// require_once($CFG->libdir. '/coursecatlib.php');
$coursecat = core_course_category::get(is_object($category) ? $category->id : $category);
$site = get_site();
$output = '';
......@@ -117,9 +117,9 @@ class course_renderer extends \core_course_renderer {
$output .= $this->course_search_form();
if (!$coursecat->id) {
if (coursecat::count_all() == 1) {
if (core_course_category::is_simple_site() == 1) {
// There exists only one category in the system, do not display link to it
$coursecat = coursecat::get_default();
$coursecat = core_course_category::get_default();
$strfulllistofcourses = get_string('fulllistofcourses');
$this->page->set_title("$site->shortname: $strfulllistofcourses");
} else {
......@@ -128,16 +128,16 @@ class course_renderer extends \core_course_renderer {
}
} else {
$title = $site->shortname;
if (coursecat::count_all() > 1) {
if (core_course_category::is_simple_site() > 1) {
$title .= ": ". $coursecat->get_formatted_name();
}
$this->page->set_title($title);
// Print the category selector
if (coursecat::count_all() > 1) {
if (core_course_category::is_simple_site() > 1) {
$output .= html_writer::start_tag('div', array('class' => 'categorypicker'));
$select = new single_select(new moodle_url('/course/index.php'), 'categoryid',
coursecat::make_categories_list(), $coursecat->id, null, 'switchcategory');
core_course_category::make_categories_list(), $coursecat->id, null, 'switchcategory');
$select->set_label(get_string('categories').':');
$output .= $this->render($select);
$output .= html_writer::end_tag('div'); // .categorypicker
......@@ -208,19 +208,11 @@ class course_renderer extends \core_course_renderer {
'data-type' => self::COURSECAT_TYPE_CATEGORY,
));
// category id
$id_category = '0';
if ($this->page->pagetype == "course-index") {
$id_category = $coursecat->id;
} elseif ($this->page->pagetype == "course-index-category") {
$id_category = $_GET['categoryid'];
}
// category name
$categoryname = $coursecat->get_formatted_name();
$categoryname = html_writer::link(new moodle_url('/course/index.php',
array('categoryid' => $coursecat->id)),
$categoryname, array('class' => $this->color_fac_category($id_category)));
$categoryname, array('class' => $this->color_fac_category($coursecat->id)));
if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_COUNT
&& ($coursescount = $coursecat->get_courses_count())) {
$categoryname .= html_writer::tag('span', ' ('. $coursescount.')',
......@@ -382,7 +374,7 @@ class course_renderer extends \core_course_renderer {
* please use {@link core_course_renderer::course_info_box()}
*
* @param coursecat_helper $chelper various display options
* @param course_in_list|stdClass $course
* @param core_course_list_element|stdClass $course
* @param string $additionalclasses additional classes to add to the main <div> tag (usually
* depend on the course position in list - first/last/even/odd)
* @return string
......@@ -396,8 +388,8 @@ class course_renderer extends \core_course_renderer {
return '';
}
if ($course instanceof stdClass) {
require_once($CFG->libdir. '/coursecatlib.php');
$course = new course_in_list($course);
// require_once($CFG->libdir. '/coursecatlib.php');
$course = new core_course_list_element($course);
}
$content = '';
$classes = trim('coursebox clearfix '. $additionalclasses);
......
......@@ -50,7 +50,7 @@ class core_renderer extends \theme_boost\output\core_renderer {
$header->courseheader = $this->course_header();
$header->courseheader .= $this->scroll_header();
return $this->render_from_template('theme_boost/header', $header);
return $this->render_from_template('theme_unige/full_header', $header);
}
/**
......
......@@ -2,6 +2,32 @@
// This line protects the file from being accessed by a URL directly
defined('MOODLE_INTERNAL') || die();
$THEME->layouts = [
// Main course page.
'course' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
'coursecategory' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// My dashboard page.
'mydashboard' => array(
'file' => 'columns2.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// Part of course, typical for modules - default page layout if $cm specified in require_login().
'incourse' => array(
'file' => 'columns3.php',
'regions' => array('side-pre', 'side-left'),
'defaultregion' => 'side-pre',
),
];
// Theme name
$THEME->name = 'unige';
......
<?php
defined('MOODLE_INTERNAL') || die();
user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
require_once($CFG->libdir . '/behat/lib.php');
if (isloggedin()) {
$navdraweropen = (get_user_preferences('drawer-open-nav', 'true') == 'true');
} else {
$navdraweropen = false;
}
$extraclasses = [];
if ($navdraweropen) {
$extraclasses[] = 'drawer-open-left';
}
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
$blockshtml = $OUTPUT->blocks('side-pre');
$blockstoc = $OUTPUT->blocks('side-left');
$hasblocks = strpos($blockshtml, 'data-block=') !== false;
$hastoc = strpos($blockstoc, 'data-block=') !== false;
$regionmainsettingsmenu = $OUTPUT->region_main_settings_menu();
$templatecontext = [
'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
'output' => $OUTPUT,
'sidepreblocks' => $blockshtml,
'sideleftblock' => $blockstoc,
'hasblocks' => $hasblocks,
'hastoc' => $hastoc,
'bodyattributes' => $bodyattributes,
'navdraweropen' => $navdraweropen,
'regionmainsettingsmenu' => $regionmainsettingsmenu,
'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
'arrow-down' => $OUTPUT->image_url('arrow-down', 'theme'),
'unige-logo' => $OUTPUT->image_url('unige-logo', 'theme'),
'moodle-unige-logo' => $OUTPUT->image_url('moodle-unige-logo', 'theme'),
'redirection-menu-square' => $OUTPUT->image_url('redirection-menu-square', 'theme')
];
$templatecontext['flatnavigation'] = $PAGE->flatnav;
echo $OUTPUT->render_from_template('theme_unige/columns3', $templatecontext);
......@@ -463,6 +463,7 @@ select + .btn-group, .btn-group + .btn {
margin-top: -.4em;
margin-right: 1em;
padding-top: 0.35em;
margin-bottom: auto;
}
.modtype_resource {
......@@ -680,6 +681,10 @@ select + .btn-group, .btn-group + .btn {
font-style: italic;
}
[data-region="blocks-column-left"] {
display: block;
}
// ---------------------------------------------------------------------------
// ----- My courses
// ---------------------------------------------------------------------------
......@@ -732,50 +737,38 @@ select + .btn-group, .btn-group + .btn {
}
}
.block_course_overview {
border: none;
//block course overview moodle 3.8
.block_myoverview{
.block-controls {
display: none;
.coursename {
font-size: 1.17rem;
color: $brand-primary;
}
.card-title {
display: none !important;
.categoryname{
font-size: 0.8rem;
}
.card-body {
padding-top: 0;
}
.list-group-item{
border: none;
padding: 0.5em 1.25rem;
.singleselect {
margin-left: 0.4em;
.progress,.progress+.small{
display: none;
}
.course-list {
padding-left: 2.2em;
padding-right: 1em;
.overview-icon {
float: right;
img {
cursor: pointer;
}
}
& > div > div > div {
display: flex;
flex-direction: column;
}
.courseovbox {
border-bottom: none;
.coursename {
order: -1;
}
.alert {
margin-top: 1em;
}
.favourite_icon > i {
color: #000;
}
}
}
// ---------------------------------------------------------------------------
......@@ -1265,3 +1258,11 @@ select + .btn-group, .btn-group + .btn {
max-width: none;
}
}
// Fix Book TOC
@media (min-width: 1199px) {
//Hide Left Column (Book TOC)
[data-region="blocks-column-left"] {
display: none;
}
}
......@@ -40,21 +40,20 @@
{{{ output.standard_top_of_body_html }}}
{{>theme_unige/navbar}}
{{> theme_unige/navbar }}
<div id="page" class="container-fluid">
{{{ output.full_header }}}
<div id="page-content" class="row">
<div id="page-content" class="row pb-3">
<div id="region-main-box" class="col-12">
{{#hasregionmainsettingsmenu}}
<div id="region-main-settings-menu" class="d-print-none {{#hasblocks}}has-blocks{{/hasblocks}}">
<div> {{{ output.region_main_settings_menu }}} </div>
</div>
{{/hasregionmainsettingsmenu}}
<section id="region-main" {{#hasblocks}}class="has-blocks mb-3"{{/hasblocks}}>
<div class="card">
<div class="card-body">
<section id="region-main" {{#hasblocks}}class="has-blocks mb-3"{{/hasblocks}} aria-label="{{#str}}content{{/str}}">
{{#hasregionmainsettingsmenu}}
<div class="region_main_settings_menu_proxy"></div>
{{/hasregionmainsettingsmenu}}
......@@ -62,25 +61,27 @@
{{{ output.main_content }}}
{{{ output.activity_navigation }}}
{{{ output.course_content_footer }}}
</div>
</div>
</section>
{{#hasblocks}}
<section data-region="blocks-column" class="d-print-none">
<section data-region="blocks-column" class="d-print-none" aria-label="{{#str}}blocks{{/str}}">
{{{ sidepreblocks }}}
</section>
{{/hasblocks}}
</div>
</div>
</div>
{{{ output.standard_after_main_region_html }}}
{{> theme_unige/footer }}
</div>
{{> theme_unige/footer }}
</body>
</html>
{{#js}}
require(['theme_boost/loader']);
M.util.js_pending('theme_boost/loader');
require(['theme_boost/loader'], function() {
M.util.js_complete('theme_boost/loader');
});
require(['theme_boost/drawer'], function(mod) {
mod.init();
......
{{!
@template theme_boost/columns2
Admin time setting template.
Boost 2 column layout template.
Context variables required for this template:
* sitename - The name of the site
* output - The core renderer for the page
* bodyattributes - attributes for the body tag as a string of html attributes
* sidepreblocks - HTML for the blocks
* hasblocks - true if there are blocks on this page
* navdraweropen - true if the nav drawer should be open on page load
* regionmainsettingsmenu - HTML for the region main settings menu
* hasregionmainsettingsmenu - There is a region main settings menu on this page.
Example context (json):
{
"sitename": "Moodle",
"output": {
"doctype": "<!DOCTYPE html>",
"page_title": "Test page",
"favicon": "favicon.ico",
"main_content": "<h1>Headings make html validators happier</h1>"
},
"bodyattributes":"",
"sidepreblocks": "<h2>Blocks html goes here</h2>",
"hasblocks":true,
"navdraweropen":true,
"regionmainsettingsmenu": "",
"hasregionmainsettingsmenu": false
}
}}
{{> theme_boost/head }}
<body {{{ bodyattributes }}}>
<div id="page-wrapper">
{{{ output.standard_top_of_body_html }}}
{{> theme_unige/navbar }}
<div id="page" class="container-fluid">
{{{ output.full_header }}}
<div id="page-content" class="row pb-3">
<div id="region-main-box" class="col-12">
{{#hasregionmainsettingsmenu}}
<div id="region-main-settings-menu" class="d-print-none {{#hasblocks}}has-blocks{{/hasblocks}}">
<div> {{{ output.region_main_settings_menu }}} </div>
</div>
{{/hasregionmainsettingsmenu}}
{{#hastoc}}
<section data-region="blocks-column-left" aria-label="{{#str}}blocks{{/str}}">
{{{ sideleftblock }}}
</section>
{{/hastoc}}
<section id="region-main" {{#hasblocks}}class="has-blocks mb-3"{{/hasblocks}} aria-label="{{#str}}content{{/str}}">
{{#hasregionmainsettingsmenu}}
<div class="region_main_settings_menu_proxy"></div>
{{/hasregionmainsettingsmenu}}
{{{ output.course_content_header }}}
{{{ output.main_content }}}
{{{ output.activity_navigation }}}
{{{ output.course_content_footer }}}
</section>
{{#hasblocks}}
<section data-region="blocks-column" class="d-print-none" aria-label="{{#str}}blocks{{/str}}">
{{{ sidepreblocks }}}
</section>
{{/hasblocks}}
</div>
</div>
</div>
{{{ output.standard_after_main_region_html }}}
{{> theme_unige/footer }}
</div>
</body>
</html>
{{#js}}
M.util.js_pending('theme_boost/loader');
require(['theme_boost/loader'], function() {
M.util.js_complete('theme_boost/loader');
});
require(['theme_boost/drawer'], function(mod) {
mod.init();
if ($(document).scrollTop() >= 500)
$('.scroll-top-button').fadeIn(0);
else
$('.scroll-top-button').fadeOut(0);
if ($(document).scrollTop() >= 120)
$('#scroll-header').fadeIn(0);
else
$('#scroll-header').fadeOut(0);
if(document.getElementById("scroll-header")) {
document.getElementById("scroll-header").style.width = document.getElementById("page-header").offsetWidth - 30 + 'px';
}
$(window).resize(function() {
document.getElementById("scroll-header").style.width = document.getElementById("page-header").offsetWidth - 30 + 'px';
});
$(window).scroll(function () {
if ($(document).scrollTop() >= 500)
$('.scroll-top-button').fadeIn(200);
else
$('.scroll-top-button').fadeOut(200);
if ($(document).scrollTop() >= 120)
$('#scroll-header').fadeIn(200);
else
$('#scroll-header').fadeOut(200);
});
});
{{/js}}
{{!
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/>.
}}
{{!
@template boost/header
This template renders the header.
Example context (json):
{
"contextheader": "context_header_html",
"settingsmenu": "settings_html",
"hasnavbar": false,
"navbar": "navbar_if_available",
"courseheader": "course_header_html"
}
Page header.
}}
<header id="page-header" class="row">
<div class="col-12 pt-3 pb-3">
<div class="card {{^contextheader}}border-0 bg-transparent{{/contextheader}}">
<div class="card-body {{^contextheader}}p-2{{/contextheader}}">
<div class="d-flex">
{{#contextheader}}
<div class="mr-auto">
{{{contextheader}}}
</div>
{{/contextheader}}
{{#settingsmenu}}
<div class="context-header-settings-menu">
{{{settingsmenu}}}
</div>
{{/settingsmenu}}
</div>
<div class="d-flex flex-wrap">
{{#hasnavbar}}
<div id="page-navbar">
{{{navbar}}}
</div>
{{/hasnavbar}}
<div class="ml-auto d-flex">
{{{pageheadingbutton}}}
</div>
<div id="course-header">
{{{courseheader}}}
</div>
</div>
</div>
</div>
</div>
</header>
\ No newline at end of file
{{!
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/>.
}}
{{!
secure navbar. // without link to index page in logo in header.
}}
<nav class="fixed-top navbar navbar-light bg-white navbar-expand moodle-has-zindex">
<div class="navbar-brand {{# output.should_display_navbar_logo }}has-logo{{/ output.should_display_navbar_logo }}
{{^ output.should_display_navbar_logo }}
d-none d-sm-inline
{{/ output.should_display_navbar_logo }}
">
{{# output.should_display_navbar_logo }}
<span class="logo d-none d-sm-inline">
<img src="{{output.get_compact_logo_url}}" alt="{{sitename}}">
</span>
{{/ output.should_display_navbar_logo }}
<span class="site-name d-none d-md-inline">{{{ sitename }}}</span>
</div>
<ul class="nav navbar-nav ml-auto">
<li class="nav-item">
{{{ output.secure_login_info }}}
</li>
</ul>
</nav>
\ No newline at end of file
......@@ -3,7 +3,8 @@
defined('MOODLE_INTERNAL') || die();
// This is the version of the plugin
$plugin->version = '2018060100';
$plugin->version = '2019112500';
$plugin->release = '3.7.0';
// This is the version of Moodle this plugin requires
$plugin->requires = '2018051700';
......@@ -13,7 +14,7 @@ $plugin->component = 'theme_unige';
// This is a list of plugins, this plugin depends on (and their versions)
$plugin->dependencies = [
'theme_boost' => '2018051400'
'theme_boost' => '2019052000'
];
......
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