Skip to content

Commit

Permalink
V402.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Feb 15, 2024
1 parent 464f93a commit 10b0719
Show file tree
Hide file tree
Showing 49 changed files with 195 additions and 127 deletions.
11 changes: 11 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Change Log in version 402.1.2 (2023092503)
===========================================
1. Fix missing logo in alternative header for header style one.
2. Fix jssection setting value causing breakage.
3. Fix jssectionrestricted setting value not in nofooter layout.
4. Deprecated 'jssection' and 'jssectionrestricted' settings, please copy values to 'customjs' and 'customjsrestricted'
with any 'script' tags removed.
5. Separated 'Custom CSS and JS' into two separate settings tabs, 'Custom CSS' and 'Custom JS', the latter is now in the
'Local Adaptable' plugin.
6. Fix 'btn a' style.

Change Log in version 402.1.1 (2023092502)
===========================================
1. Fix '$OUTPUT is null' - ref: https://moodle.org/mod/forum/discuss.php?d=453194#p1827606.
Expand Down
2 changes: 1 addition & 1 deletion Support.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The Adaptable story
===================
Adaptable is based upon the popular BCU theme, developed for Coventry University. Since the main developer decided to leave the
project, I (Gareth) was asked to assist in maintainance and improvements. Coventry University has now moved away from Moodle and
project, I (Gareth) was asked to assist in maintenance and improvements. Coventry University has now moved away from Moodle and
passed the project onto me to manage as its lead. I will keep the theme alive, maintained and supported for as long as there is a
willingness to fund my time to do so. The theme is complex and takes time, skill, knowledge and talent to develop. This is why
I'm asking for your financial support in my endeavours.
Expand Down
6 changes: 3 additions & 3 deletions classes/admin_settingspage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/

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

/**
* Adaptable admin_settingpage
*/
class theme_adaptable_admin_settingspage extends admin_settingpage {
class admin_settingspage extends \admin_settingpage {
/** @var boolean disabled. */
private $disabled = false;

Expand All @@ -51,7 +51,7 @@ public function __construct($name, $visiblename, $local = false, $reqcapability
', which is available to sponsors only. Please consider sponsoring, see the \'Information\' tab.';

$this->disabled = true;
$this->add(new admin_setting_heading(
$this->add(new \admin_setting_heading(
'theme_adaptable_sponsor'.$name,
$localadaptableheading,
format_text($localadaptableheadingdesc, FORMAT_MARKDOWN)
Expand Down
10 changes: 5 additions & 5 deletions classes/admin_settingspage_tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/

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

/**
* Admin settings page tabs.
*/
class theme_adaptable_admin_settingspage_tabs extends theme_boost_admin_settingspage_tabs {
class admin_settingspage_tabs extends \theme_boost_admin_settingspage_tabs {
/** @var int The branch this Adaptable is for. */
protected $mbranch;

Expand Down Expand Up @@ -71,7 +71,7 @@ public function output_html() {
}

$disabled = false;
if ($tab instanceof theme_adaptable_admin_settingspage) {
if ($tab instanceof admin_settingspage) {
$disabled = $tab->get_disabled();
}
$context['tabs'][] = [
Expand All @@ -87,11 +87,11 @@ public function output_html() {
return '';
}

$themes = core_plugin_manager::instance()->get_present_plugins('theme');
$themes = \core_plugin_manager::instance()->get_present_plugins('theme');
if (!empty($themes['adaptable'])) {
$plugininfo = $themes['adaptable'];
} else {
$plugininfo = core_plugin_manager::instance()->get_plugin_info('theme_adaptable');
$plugininfo = \core_plugin_manager::instance()->get_plugin_info('theme_adaptable');
$plugininfo->version = $plugininfo->versiondisk;
}

Expand Down
36 changes: 8 additions & 28 deletions classes/output/core_renderer_layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,33 +622,10 @@ public function yesfooter() {
}
}

$context->jssection = $themesettings->jssection;

// Conditional javascript based on a user profile field.
if (!empty($themesettings->jssectionrestrictedprofilefield)) {
// Get custom profile field setting. (e.g. faculty=fbl).
$fields = explode('=', $themesettings->jssectionrestrictedprofilefield);
$ftype = $fields[0];
$setvalue = $fields[1];

// Get user profile field (if it exists).
require_once($CFG->dirroot . '/user/profile/lib.php');
require_once($CFG->dirroot . '/user/lib.php');
profile_load_data($USER);
$ftype = "profile_field_$ftype";
if (isset($USER->$ftype)) {
if ($USER->$ftype == $setvalue) {
// Match between user profile field value and value in setting.

if (!empty($themesettings->jssectionrestricteddashboardonly)) {
// If this is set to restrict to dashboard only, check if we are on dashboard page.
if ($this->page->pagelayout == 'mydashboard') {
$context->jssectionrestricted = $themesettings->jssectionrestricted;
}
} else {
$context->jssectionrestricted = $themesettings->jssectionrestricted;
}
}
$localtoolbox = \theme_adaptable\toolbox::get_local_toolbox();
if (is_object($localtoolbox)) {
if (method_exists($localtoolbox, 'supported_methods')) { // TODO - Temporary until such time as not.
$context->customjs = $localtoolbox->get_custom_js($themesettings, $this->page, $this);
}
}

Expand All @@ -660,7 +637,10 @@ public function nofooter() {

$context = new stdClass;
$context->output = $this;
$context->jssection = $themesettings->jssection;
$localtoolbox = \theme_adaptable\toolbox::get_local_toolbox();
if (is_object($localtoolbox)) {
$context->customjs = $localtoolbox->get_custom_js($themesettings, $this->page, $this);
}

echo $this->render_from_template('theme_adaptable/nofooter', $context);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/output/core_renderer_toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ protected function get_course_title() {
(!empty($themesettings->coursetitlemaxwidth) ? $themesettings->coursetitlemaxwidth : 0);
// Check max width of course title and trim if appropriate.
if (($coursetitlemaxwidth > 0) && ($coursetitle <> '')) {
if (strlen($coursetitle) > $coursetitlemaxwidth) {
if (\core_text::strlen($coursetitle) > $coursetitlemaxwidth) {
$coursetitle = \core_text::substr($coursetitle, 0, $coursetitlemaxwidth) . " ...";
}
}
Expand Down
13 changes: 13 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,18 @@ function xmldb_theme_adaptable_upgrade($oldversion = 0) {
// Automatic 'Purge all caches'....
purge_all_caches();

// Method check after purge to reload updated local_toolbox if needed.
$localtoolbox = \theme_adaptable\toolbox::get_local_toolbox();
if (is_object($localtoolbox)) {
if (method_exists($localtoolbox, 'supported_methods')) {
// Method check. Will throw upgrade_exception if one or more are missing.
$methods = ['get_custom_js'];
$unsupportedmethods = $localtoolbox->supported_methods($methods, '401.0.4 - 2023102203');
if (!empty($unsupportedmethods)) {
echo $unsupportedmethods;
}
}
}

return true;
}
18 changes: 13 additions & 5 deletions lang/en/theme_adaptable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1630,21 +1630,29 @@
$string['piwiktrackadmindesc'] = 'Enable tracking of admin users (not recommended).';

// Custom CSS and Javascript.
$string['customcssjssettings'] = 'Custom CSS & JS';
$string['genericsettingsheading'] = 'Apply your own modifications';
$string['genericsettingsdescription'] = 'Here you can find various settings to add your own CSS and JavaScript code to the theme.';
$string['customcsssettings'] = 'Custom CSS';
$string['customjssettings'] = 'Custom JS';
$string['customcssjssettingsheading'] = 'Apply your own modifications';
$string['customcsssettingsdescription'] = 'Here you can find various settings to add your own CSS to the theme.';
$string['customjssettingsdescription'] = 'Here you can find various settings to add your own JavaScript to the theme. Note: Script tags are automatically added, do not add yourself.';

$string['customcss'] = 'Custom CSS';
$string['customcssdesc'] = 'Whatever CSS rules you add to this textarea will be reflected in every page, making for easier customization of this theme.';

$string['hvpcustomcss'] = 'H5P Custom CSS';
$string['hvpcustomcssdesc'] = 'Custom CSS for the H5P module.';

$string['customjs'] = 'Custom JavaScript';
$string['customjsdesc'] = 'Add JavaScript to the site.';

$string['jssection'] = 'Javascript section';
$string['jssectiondesc'] = 'Add javascript code to the site.';
$string['jssectiondesc'] = 'DEPRECATED, use \'customjs\' instead.';

$string['customjsrestricted'] = 'Conditional JavaScript';
$string['customjsrestricteddesc'] = 'Add JavaScript to the site conditionally based on a custom profile field. This JavaScript will only appear if this condition is met.';

$string['jssectionrestricted'] = 'Conditional javascript section';
$string['jssectionrestricteddesc'] = 'Add javascript code to the site conditionally based on a custom profile field. This javascript will only appear if this condition is met.';
$string['jssectionrestricteddesc'] = 'DEPRECATED, use \'customjsrestricted\' instead.';

$string['jssectionrestrictedprofilefield'] = 'Javascript section custom profile field';
$string['jssectionrestrictedprofilefielddesc'] = 'Show the javascript above ONLY when user matches this custom profile field value, eg: faculty=fbl.';
Expand Down
8 changes: 4 additions & 4 deletions scss/settings/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
//

// Default style for all the buttons.
.btn,
.btn a {
.btn {
background-image: none;
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-bottom-color: #b3b3b3;
Expand All @@ -40,9 +39,7 @@
padding: 6px 12px 6px;
text-align: center;
text-shadow: none;
}

.btn {
&.btn-icon {
@include hover-focus {
background-color: [[setting:buttonhovercolor]];
Expand Down Expand Up @@ -402,6 +399,9 @@ a.btn-link {
background-color: [[setting:buttoncolor]];
box-shadow: none;
color: [[setting:buttontextcolor]] !important;
a {
color: [[setting:buttontextcolor]] !important;
}

&:hover,
:focus {
Expand Down
3 changes: 2 additions & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$ADMIN->add('themes', new admin_category('theme_adaptable', get_string('configtitle', 'theme_adaptable')));

// Adaptable theme settings page.
$asettings = new theme_adaptable_admin_settingspage_tabs(
$asettings = new \theme_adaptable\admin_settingspage_tabs(
'themesettingadaptable',
get_string('configtabtitle', 'theme_adaptable'),
402
Expand Down Expand Up @@ -76,6 +76,7 @@
include(dirname(__FILE__) . '/settings/templates.php');
include(dirname(__FILE__) . '/settings/user.php');
include(dirname(__FILE__) . '/settings/custom_css.php');
include(dirname(__FILE__) . '/settings/custom_js.php');
}
$ADMIN->add('theme_adaptable', $asettings);
require(dirname(__FILE__) . '/settings/importexport_settings.php');
2 changes: 1 addition & 1 deletion settings/alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Alert Section.
if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage(
$page = new \theme_adaptable\admin_settingspage(
'theme_adaptable_alerts',
get_string('settingspagealertsettings', 'theme_adaptable'),
true
Expand Down
2 changes: 1 addition & 1 deletion settings/analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Analytics section.
if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage('theme_adaptable_analytics', get_string('analyticssettings', 'theme_adaptable'), true);
$page = new \theme_adaptable\admin_settingspage('theme_adaptable_analytics', get_string('analyticssettings', 'theme_adaptable'), true);

$page->add(new admin_setting_heading(
'theme_adaptable_analytics',
Expand Down
2 changes: 1 addition & 1 deletion settings/block_regions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Frontpage Block Regions Section.
if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage(
$page = new \theme_adaptable\admin_settingspage(
'theme_adaptable_frontpage_block_regions',
get_string('frontpageblockregionsettings', 'theme_adaptable')
);
Expand Down
2 changes: 1 addition & 1 deletion settings/block_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die;

if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage('theme_adaptable_blocks', get_string('settingspageblocksettings', 'theme_adaptable'));
$page = new \theme_adaptable\admin_settingspage('theme_adaptable_blocks', get_string('settingspageblocksettings', 'theme_adaptable'));

// General.
$name = 'theme_adaptable/settingsblocksgeneral';
Expand Down
2 changes: 1 addition & 1 deletion settings/buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Buttons Section.
if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage('theme_adaptable_buttons', get_string('buttonsettings', 'theme_adaptable'));
$page = new \theme_adaptable\admin_settingspage('theme_adaptable_buttons', get_string('buttonsettings', 'theme_adaptable'));

$page->add(new admin_setting_heading(
'theme_adaptable_header',
Expand Down
2 changes: 1 addition & 1 deletion settings/category_headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// Category headers heading.
if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage(
$page = new \theme_adaptable\admin_settingspage(
'theme_adaptable_categoryheaders',
get_string('categoryheaderssettings', 'theme_adaptable'),
true
Expand Down
2 changes: 1 addition & 1 deletion settings/colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Colors section.
if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage('theme_adaptable_color', get_string('colorsettings', 'theme_adaptable'));
$page = new \theme_adaptable\admin_settingspage('theme_adaptable_color', get_string('colorsettings', 'theme_adaptable'));

$page->add(new admin_setting_heading(
'theme_adaptable_color',
Expand Down
2 changes: 1 addition & 1 deletion settings/course_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// Course index.
if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage(
$page = new \theme_adaptable\admin_settingspage(
'theme_adaptable_course_index',
get_string('courseindexsettings', 'theme_adaptable')
);
Expand Down
2 changes: 1 addition & 1 deletion settings/courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die;

if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage('theme_adaptable_course', get_string('coursesettings', 'theme_adaptable'));
$page = new \theme_adaptable\admin_settingspage('theme_adaptable_course', get_string('coursesettings', 'theme_adaptable'));

$page->add(new admin_setting_heading(
'theme_adaptable_course',
Expand Down
39 changes: 5 additions & 34 deletions settings/custom_css.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@

defined('MOODLE_INTERNAL') || die;

// Custom CSS and JS section.
// Custom CSS section.
if ($ADMIN->fulltree) {
$page = new theme_adaptable_admin_settingspage('theme_adaptable_generic', get_string('customcssjssettings', 'theme_adaptable'));
$page = new \theme_adaptable\admin_settingspage('theme_adaptable_customcss', get_string('customcsssettings', 'theme_adaptable'));

$page->add(new admin_setting_heading(
'theme_adaptable_generic',
get_string('genericsettingsheading', 'theme_adaptable'),
format_text(get_string('genericsettingsdescription', 'theme_adaptable'), FORMAT_MARKDOWN)
'theme_adaptable_customcss',
get_string('customcssjssettingsheading', 'theme_adaptable'),
format_text(get_string('customcsssettingsdescription', 'theme_adaptable'), FORMAT_MARKDOWN)
));

// Custom CSS.
Expand All @@ -56,34 +56,5 @@
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);

// Section for javascript to be added e.g. Google Analytics.
$name = 'theme_adaptable/jssection';
$title = get_string('jssection', 'theme_adaptable');
$description = get_string('jssectiondesc', 'theme_adaptable');
$default = '';
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$page->add($setting);

// Section for custom javascript, restricted by profile field.
$name = 'theme_adaptable/jssectionrestricted';
$title = get_string('jssectionrestricted', 'theme_adaptable');
$description = get_string('jssectionrestricteddesc', 'theme_adaptable');
$default = '';
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$page->add($setting);

$name = 'theme_adaptable/jssectionrestrictedprofilefield';
$title = get_string('jssectionrestrictedprofilefield', 'theme_adaptable');
$description = get_string('jssectionrestrictedprofilefielddesc', 'theme_adaptable');
$setting = new admin_setting_configtext($name, $title, $description, '', PARAM_RAW);
$page->add($setting);

$name = 'theme_adaptable/jssectionrestricteddashboardonly';
$title = get_string('jssectionrestricteddashboardonly', 'theme_adaptable');
$description = get_string('jssectionrestricteddashboardonlydesc', 'theme_adaptable');
$default = true;
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
$page->add($setting);

$asettings->add($page);
}
Loading

0 comments on commit 10b0719

Please sign in to comment.