if (!$this->hide_header()) {
$bc->title = $this->title;
}
+ if (empty($bc->title)) {
+ $bc->arialabel = new lang_string('pluginname', get_class($this));
+ }
if ($this->page->user_is_editing()) {
$bc->controls = $this->page->blocks->edit_controls($this);
*/
public $title = '';
+ /**
+ * @var string The label to use when the block does not, or will not have a visible title.
+ * You should never set this as well as title... it will just be ignored.
+ */
+ public $arialabel = '';
+
/**
* @var string HTML for the content
*/
if (empty($bc->blockinstanceid) || !strip_tags($bc->title)) {
$bc->collapsible = block_contents::NOT_HIDEABLE;
}
+ $skiptitle = strip_tags($bc->title);
+ if ($bc->blockinstanceid && !empty($skiptitle)) {
+ $bc->attributes['aria-labelledby'] = 'instance-'.$bc->blockinstanceid.'-header';
+ } else if (!empty($bc->arialabel)) {
+ $bc->attributes['aria-label'] = $bc->arialabel;
+ }
if ($bc->collapsible == block_contents::HIDDEN) {
$bc->add_class('hidden');
}
$bc->add_class('block_with_controls');
}
- $skiptitle = strip_tags($bc->title);
+
if (empty($skiptitle)) {
$output = '';
$skipdest = '';
$title = '';
if ($bc->title) {
- $title = html_writer::tag('h2', $bc->title, null);
+ $attributes = array();
+ if ($bc->blockinstanceid) {
+ $attributes['id'] = 'instance-'.$bc->blockinstanceid.'-header';
+ }
+ $title = html_writer::tag('h2', $bc->title, $attributes);
}
$controlshtml = $this->block_controls($bc->controls);