Skip to content

Commit

Permalink
Merge branch 'MDL-34899b' of git://github.com/srynot4sale/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Aug 21, 2012
2 parents 77dd8ab + 14bcde6 commit dd12051
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions blocks/html/block_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,19 @@ function content_is_trusted() {
public function instance_can_be_docked() {
return (!empty($this->config->title) && parent::instance_can_be_docked());
}

/*
* Add custom html attributes to aid with theming and styling
*
* @return array
*/
function html_attributes() {
$attributes = parent::html_attributes();

if (!empty($this->config->classes)) {
$attributes['class'] .= ' '.$this->config->classes;
}

return $attributes;
}
}
4 changes: 4 additions & 0 deletions blocks/html/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ protected function specific_definition($mform) {
$mform->addElement('editor', 'config_text', get_string('configcontent', 'block_html'), null, $editoroptions);
$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');
}

function set_data($defaults) {
Expand Down
2 changes: 2 additions & 0 deletions blocks/html/lang/en/block_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['configclasses'] = 'Additional HTML 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';
$string['leaveblanktohide'] = 'leave blank to hide the title';
Expand Down

0 comments on commit dd12051

Please sign in to comment.