mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Merge branch 'wip-MDL-30921-m24' of git://github.com/samhemelryk/moodle
This commit is contained in:
commit
e830d6f98e
11 changed files with 119 additions and 6 deletions
|
@ -64,6 +64,17 @@ class block_activity_modules extends block_list {
|
|||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role that best describes this blocks contents.
|
||||
*
|
||||
* This returns 'navigation' as the blocks contents is a list of links to activities and resources.
|
||||
*
|
||||
* @return string 'navigation'
|
||||
*/
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('all' => true, 'mod' => false, 'my' => false, 'admin' => false,
|
||||
'tag' => false);
|
||||
|
|
|
@ -126,6 +126,15 @@ class block_admin_bookmarks extends block_base {
|
|||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role that best describes the admin bookmarks block.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -112,4 +112,13 @@ class block_blog_menu extends block_base {
|
|||
// Return the content object
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role that best describes the blog menu block.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,14 @@ class block_course_list extends block_list {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role that best describes the course list block.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -240,6 +240,9 @@ class block_base {
|
|||
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);
|
||||
|
@ -398,7 +401,8 @@ class block_base {
|
|||
function html_attributes() {
|
||||
$attributes = array(
|
||||
'id' => 'inst' . $this->instance->id,
|
||||
'class' => 'block_' . $this->name(). ' block'
|
||||
'class' => 'block_' . $this->name(). ' block',
|
||||
'role' => $this->get_aria_role()
|
||||
);
|
||||
if ($this->instance_can_be_docked() && get_user_preferences('docked_block_instance_'.$this->instance->id, 0)) {
|
||||
$attributes['class'] .= ' dock_on_load';
|
||||
|
@ -700,6 +704,29 @@ EOD;
|
|||
public static function comment_add(&$comments, $options) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the aria role attribute that best describes this block.
|
||||
*
|
||||
* Region is the default, but this should be overridden by a block is there is a region child, or even better
|
||||
* a landmark child.
|
||||
*
|
||||
* Options are as follows:
|
||||
* - landmark
|
||||
* - application
|
||||
* - banner
|
||||
* - complementary
|
||||
* - contentinfo
|
||||
* - form
|
||||
* - main
|
||||
* - navigation
|
||||
* - search
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_aria_role() {
|
||||
return 'complementary';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -325,4 +325,13 @@ class block_navigation extends block_base {
|
|||
$string = $start.'...'.$end;
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role that best describes the navigation block... 'navigation'
|
||||
*
|
||||
* @return string 'navigation'
|
||||
*/
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,15 @@ class block_search_forums extends block_base {
|
|||
function applicable_formats() {
|
||||
return array('site' => true, 'course' => true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role that best describes the forum search block.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_aria_role() {
|
||||
return 'search';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -148,4 +148,13 @@ class block_settings extends block_base {
|
|||
$this->contentgenerated = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role that best describes the settings block.
|
||||
*
|
||||
* @return string 'navigation'
|
||||
*/
|
||||
public function get_aria_role() {
|
||||
return 'navigation';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class block_settings_renderer extends plugin_renderer_base {
|
|||
}
|
||||
|
||||
public function search_form(moodle_url $formtarget, $searchvalue) {
|
||||
$content = html_writer::start_tag('form', array('class'=>'adminsearchform', 'method'=>'get', 'action'=>$formtarget));
|
||||
$content = html_writer::start_tag('form', array('class'=>'adminsearchform', 'method'=>'get', 'action'=>$formtarget, 'role' => 'search'));
|
||||
$content .= html_writer::start_tag('div');
|
||||
$content .= html_writer::tag('label', s(get_string('searchinsettings', 'admin')), array('for'=>'adminsearchquery', 'class'=>'accesshide'));
|
||||
$content .= html_writer::empty_tag('input', array('id'=>'adminsearchquery', 'type'=>'text', 'name'=>'query', 'value'=>s($searchvalue)));
|
||||
|
|
|
@ -2378,6 +2378,12 @@ class block_contents {
|
|||
*/
|
||||
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
|
||||
*/
|
||||
|
|
|
@ -492,7 +492,13 @@ class core_renderer extends renderer_base {
|
|||
* @return string HTML fragment.
|
||||
*/
|
||||
public function main_content() {
|
||||
return $this->unique_main_content_token;
|
||||
// This is here because it is the only place we can inject the "main" role over the entire main content area
|
||||
// without requiring all theme's to manually do it, and without creating yet another thing people need to
|
||||
// remember in the theme.
|
||||
// This is an unfortunate hack. DO NO EVER add anything more here.
|
||||
// DO NOT add classes.
|
||||
// DO NOT add an id.
|
||||
return '<div role="main">'.$this->unique_main_content_token.'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -914,6 +920,12 @@ class core_renderer extends renderer_base {
|
|||
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');
|
||||
}
|
||||
|
@ -921,7 +933,7 @@ class core_renderer extends renderer_base {
|
|||
$bc->add_class('block_with_controls');
|
||||
}
|
||||
|
||||
$skiptitle = strip_tags($bc->title);
|
||||
|
||||
if (empty($skiptitle)) {
|
||||
$output = '';
|
||||
$skipdest = '';
|
||||
|
@ -955,7 +967,11 @@ class core_renderer extends renderer_base {
|
|||
|
||||
$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);
|
||||
|
@ -2520,7 +2536,7 @@ EOD;
|
|||
|
||||
//accessibility: heading for navbar list (MDL-20446)
|
||||
$navbarcontent = html_writer::tag('span', get_string('pagepath'), array('class'=>'accesshide'));
|
||||
$navbarcontent .= html_writer::tag('ul', join('', $htmlblocks));
|
||||
$navbarcontent .= html_writer::tag('ul', join('', $htmlblocks), array('role'=>'navigation'));
|
||||
// XHTML
|
||||
return $navbarcontent;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue