Skip to content

Commit

Permalink
Merge pull request #203 from trema-tech/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rmady authored Oct 8, 2024
2 parents a129f5d + 29a5d86 commit c61e698
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 43 deletions.
46 changes: 34 additions & 12 deletions classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,41 @@ public function favicon() {
global $CFG;
static $favicon;

// Return cached value if available.
if (!empty($favicon)) {
return $favicon;
}

// Use favicon configured in theme's settings.
$favicon = $this->page->theme->setting_file_url('favicon', 'favicon');

// If no favicon set in the theme, see if theme includeds a favicon.ico file.
if (empty($favicon) && (file_exists($this->page->theme->dir . '/pix/favicon.ico'))) {
// Use pix/favicon.ico stored in the theme directory.
$favicon = $this->page->theme->image_url('favicon', 'theme');
}

// If no favicon found yet, check favicon settings in Moodle's Appearance/Logo settings.
// Note: Only available in Moodle 4.1+.
if (empty($favicon) && $CFG->branch >= 401) {
// Use $CFG->themerev to prevent browser caching when the file changes.
$favicon = \moodle_url::make_pluginfile_url(
\context_system::instance()->id,
'core_admin',
'favicon',
'64x64/',
theme_get_revision(),
get_config('core_admin', 'favicon')
);
}

// If still no favicon found, fallback to the webserver's favicon.ico.
if (empty($favicon)) {
if (file_exists($this->page->theme->dir . '/pix/favicon.ico')) {
// Use pix/favicon.ico stored in the theme directory.
$favicon = $this->page->theme->image_url('favicon', 'theme');
} else {
// Fallback to the webserver's favicon.ico.
$parsedurl = parse_url($CFG->wwwroot);
$favicon = $parsedurl['scheme'] . '://' . $parsedurl['host'] . '/favicon.ico';
// If there isn't any, the browser will fallback to its own default favicon.
}
$parsedurl = parse_url($CFG->wwwroot);
$favicon = $parsedurl['scheme'] . '://' . $parsedurl['host'] . '/favicon.ico';
// If there isn't any, the browser will fallback to its own default favicon.
}

return $favicon;
}

Expand Down Expand Up @@ -205,11 +222,16 @@ public function render_login(\core_auth\output\login $form) {
*/
public function standard_head_html() {
global $CFG;

$additionalhtmlhead = $CFG->additionalhtmlhead;
if (strpos($additionalhtmlhead, '}') !== false) {
$CFG->additionalhtmlhead = format_text($CFG->additionalhtmlhead,
FORMAT_HTML, ['noclean' => true, 'context' => $this->page->context]);

// If filtering of the primary custom menu is enabled, apply only the string filters.
if (!empty(get_config('theme_trema', 'navfilter')) && strpos($CFG->additionalhtmlhead, '}') !== false) {
// Apply filters that are enabled for Content and Headings.
$filtermanager = filter_manager::instance();
$CFG->additionalhtmlhead = $filtermanager->filter_string($CFG->additionalhtmlhead, \context_system::instance());
}

$output = parent::standard_head_html();
$CFG->additionalhtmlhead = $additionalhtmlhead;
return $output;
Expand Down
14 changes: 4 additions & 10 deletions classes/output/primary_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,11 @@ protected function get_custom_menu(renderer_base $output): array {

$custommenuitems = $CFG->custommenuitems;

// If setting is enabled, filter custom menu items but don't apply auto-linking filters.
if (!empty(get_config('theme_trema', 'navfilter'))) {
// Include default filters to skip.
$skipfilters = 'activitynames,data,glossary,sectionnames,bookchapters,urltolink,'
. get_config('theme_trema', 'navfiltersexcluded');
// Convert to array, trim all items, and remove duplicates and empty values.
$skipfilters = array_filter(array_unique(array_map('trim', explode(',', $skipfilters))));
$filteroptions = ['originalformat' => FORMAT_HTML, 'noclean' => true];
// If filtering of the primary custom menu is enabled, apply only the string filters.
if (!empty(get_config('theme_trema', 'navfilter')) && strpos($CFG->custommenuitems, '}') !== false) {
// Apply filters that are enabled for Content and Headings.
$filtermanager = filter_manager::instance();
$context = \context_system::instance();
$CFG->custommenuitems = $filtermanager->filter_text($CFG->custommenuitems, $context, $filteroptions, $skipfilters);
$CFG->custommenuitems = $filtermanager->filter_string($CFG->custommenuitems, \context_system::instance());
}
$nodes = parent::get_custom_menu($output);

Expand Down
9 changes: 4 additions & 5 deletions lang/en/theme_trema.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,14 @@
$string['loginshowloginform_desc'] = 'Before disabling the login form, ensure that administrators have an alternate method to Sign in to the site.';
$string['modal'] = 'Modal';
$string['navfilter'] = 'Filter navigation';
$string['navfilter_desc'] = 'Enable to process primary navigation through Moodle filters. Useful for dynamic custom menu items.';
$string['navfiltersexcluded'] = 'Excluded navigation filters';
$string['navfiltersexcluded_desc'] = 'These filters will not be applied to the primary navigation (custom menu). Must be a comma separated list of filter names. By default, the following auto-linking filters are always excluded: activitynames, data, glossary, sectionnames, bookchapters, urltolink.';
$string['navfilter_desc'] = 'Process the custom menu through Moodle filters that are set to apply to <strong>Content and Headings</strong>. Useful for enabling dynamic custom menu items.';
$string['numberofcards'] = 'Number of cards';
$string['numberofcards_desc'] = 'Select the number of cards you want to add then click SAVE to show the input fields.';
$string['numberofimages'] = "Number of images in frontpage banner";
$string['numberofimages_desc'] = "Number of images to show in frontpage banner. If it is more than one, loads the carousel.";
$string['numberofimages_desc'] = 'Select the number of images you want to add then click SAVE to show the input fields. If it is more than one, the carousel will be activated automatically.';
$string['pluginname'] = 'Trema';
$string['popover'] = 'Popover';
$string['primarycolor'] = 'Primary colour';
$string['primarycolor'] = 'Brand colour';
$string['primarycolor_desc'] = 'The main colour.';
$string['privacy:metadata'] = 'The Trema theme does not store any individual user data.';
$string['region-side-admin'] = 'Only admins';
Expand Down
2 changes: 2 additions & 0 deletions scss/preset/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
@import "trema/courselist";
@import "trema/maintenance";
@import "trema/modules";
@import "trema/report";
@import "trema/courseformats";
@import "trema/admin";
@import "trema/message";
@import "trema/user";
@import "trema/noprint";
13 changes: 11 additions & 2 deletions scss/trema/dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,29 @@ body.pagelayout-mydashboard {
}

body#page-message-index {
#page-header {
display: block;
.container-fluid {
padding-right: 0;
}

#mydashboard-admin,
#side-admin-blocks {
display: none;
}

#page-wrapper #page #page-content:before {
content: none;
}

.panel-header-container {
margin-top: 25px;
}

#region-main {
margin-top: 0;
}

.message-app.main {
height: 100%;
min-height: 80vh;
}
}
3 changes: 2 additions & 1 deletion scss/trema/elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ body.path-mod-quiz {
}

// For "Hidden from Student" badge (Moodle 4.4+).
.badge.rounded-pill.bg-secondary.text-dark {
// For "Parent category" when creating a course category.
.bg-secondary.text-dark {
color: white !important;
}
2 changes: 1 addition & 1 deletion scss/trema/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $editmodeon-color: choose-contrast-color($editmodeon-bg-color);
$dropdown-color: choose-contrast-color($dropdown-bg-color);
$drawer-color: choose-contrast-color($drawer-bg-color);

.card {
.card:not(.fp-navbar) {
border: none;
}

Expand Down
10 changes: 10 additions & 0 deletions scss/trema/message.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@ body#page-message-output-popup-notifications {
margin-top: 1rem;
padding: 2rem !important;

&:before {
display: none;
}

#region-main {
background-color: #ffffff;
padding: 0;

&:before,
&:after {
content: none;
}

.notification-area {
background-color: $white;
Expand Down
11 changes: 11 additions & 0 deletions scss/trema/modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ body#page-mod-quiz-review {
}
}

// Fix the width of the quiz report.
body#page-mod-quiz-report #attempts {
width: 100%!important;
}

body.path-mod-assign.pagelayout-embedded {
#page {
padding-top: 0;
Expand Down Expand Up @@ -128,6 +133,12 @@ body.path-mod-assign.pagelayout-embedded {
}
}

body#page-mod-assign-grading {
.gradingtable {
overflow-x: scroll;
}
}

body.path-mod-forum {
.forumsearch {
#search {
Expand Down
41 changes: 41 additions & 0 deletions scss/trema/noprint.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@media print {
// Remove underline from all links.
a {
text-decoration: none!important;
}
// Remove margins to maximize space on paper.
body #page #page-content,
#region-main-box,
#page {
margin: 0!important;
}
// Display the page headers so we can show the logo.
#page-header {
display: block!important;
}

// Unsticky the nav-bar so it doesn't repeat on every page.
#page-wrapper nav.navbar {
display: block;
position:relative;
border-bottom: none;
}

// Elements we do not want to appear in print.
#goto-top-link,
#page-footer,
#user-notifications,
#page-navbar,
.btn,
.drawer-toggles,
button,
.navbar-nav,
.navbar-toggler,
.notifications,
.secondary-navigation,
nav.navbar .primary-navigation,
nav.navbar #usernavigation,
ul.nav.nav-tabs {
display: none!important;
}
}
19 changes: 19 additions & 0 deletions scss/trema/report.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body.path-admin-reportbuilder {
#page #page-content {
max-width: none;
padding: 0 2rem;
.reportbuilder-sidebar-settings {
right: 50px;
}
.dynamictabs {
height: 85vh;
.nav-tabs {
width: calc(100% - 70px);
background-color: transparent;
}
}
.reportbuilder-sidebar-menu-cards {
max-height: calc(100vh - 335px);
}
}
}
2 changes: 1 addition & 1 deletion settings/frontpage_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
// Number of cards.
$name = 'theme_trema/numberofcards';
$title = get_string('numberofcards', 'theme_trema');
$description = '';
$description = get_string('numberofcards_desc', 'theme_trema');
$default = 4;
$choices = [
2 => '2',
Expand Down
9 changes: 0 additions & 9 deletions settings/general_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);

// List of filters that should not be applied to the primary navigation (custom menu).
$name = 'theme_trema/navfiltersexcluded';
$title = get_string('navfiltersexcluded', 'theme_trema');
$description = get_string('navfiltersexcluded_desc', 'theme_trema');
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_TEXT);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);

// Hide selected items in the primary navigation (custom menu).
$hideitemsoptions = [];
$hideitemsoptions['home'] = get_string('home');
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024090700;
$plugin->release = '4.4.0.7';
$plugin->version = 2024100700;
$plugin->release = '4.5.0.0';
$plugin->maturity = MATURITY_STABLE;
$plugin->requires = 2022021800; // Moodle 4.0 - Build: 20220218.
$plugin->component = 'theme_trema';
Expand Down

0 comments on commit c61e698

Please sign in to comment.