mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-35042 blocks: Allow HTML block advanced setting to be toggled
This commit is contained in:
parent
d71c486507
commit
055cc8353d
@ -29,6 +29,10 @@ class block_html extends block_base {
|
||||
$this->title = get_string('pluginname', 'block_html');
|
||||
}
|
||||
|
||||
function has_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('all' => true);
|
||||
}
|
||||
@ -138,10 +142,14 @@ class block_html extends block_base {
|
||||
* @return array
|
||||
*/
|
||||
function html_attributes() {
|
||||
global $CFG;
|
||||
|
||||
$attributes = parent::html_attributes();
|
||||
|
||||
if (!empty($this->config->classes)) {
|
||||
$attributes['class'] .= ' '.$this->config->classes;
|
||||
if (!empty($CFG->block_html_allowcssclasses)) {
|
||||
if (!empty($this->config->classes)) {
|
||||
$attributes['class'] .= ' '.$this->config->classes;
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
|
@ -31,6 +31,8 @@
|
||||
*/
|
||||
class block_html_edit_form extends block_edit_form {
|
||||
protected function specific_definition($mform) {
|
||||
global $CFG;
|
||||
|
||||
// Fields for editing HTML block title and contents.
|
||||
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
|
||||
|
||||
@ -42,9 +44,11 @@ class block_html_edit_form extends block_edit_form {
|
||||
$mform->addRule('config_text', null, 'required', null, 'client');
|
||||
$mform->setType('config_text', PARAM_RAW); // XSS is prevented when printing the block contents and serving files
|
||||
|
||||
$mform->addElement('text', 'config_classes', get_string('configclasses', 'block_html'));
|
||||
$mform->setType('config_classes', PARAM_TEXT);
|
||||
$mform->addHelpButton('config_classes', 'configclasses', 'block_html');
|
||||
if (!empty($CFG->block_html_allowcssclasses)) {
|
||||
$mform->addElement('text', 'config_classes', get_string('configclasses', 'block_html'));
|
||||
$mform->setType('config_classes', PARAM_TEXT);
|
||||
$mform->addHelpButton('config_classes', 'configclasses', 'block_html');
|
||||
}
|
||||
}
|
||||
|
||||
function set_data($defaults) {
|
||||
|
@ -23,7 +23,9 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['configclasses'] = 'Additional HTML classes';
|
||||
$string['allowadditionalcssclasses'] = 'Allow additional CSS classes';
|
||||
$string['configallowadditionalcssclasses'] = 'Adds a configuration option to HTML block instances allowing additional CSS classes to be set.';
|
||||
$string['configclasses'] = 'Additional CSS classes';
|
||||
$string['configclasses_help'] = 'The purpose of this configuration is to aid with theming by helping distinguish HTML blocks from each other. Any CSS classes entered here (space delimited) will be appended to the block\'s default classes.';
|
||||
$string['configcontent'] = 'Content';
|
||||
$string['configtitle'] = 'Block title';
|
||||
|
10
blocks/html/settings.php
Normal file
10
blocks/html/settings.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configcheckbox('block_html_allowcssclasses', get_string('allowadditionalcssclasses', 'block_html'),
|
||||
get_string('configallowadditionalcssclasses', 'block_html'), 0));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user