Merge branch 'wip-MDL-30921-m24' of git://github.com/samhemelryk/moodle

This commit is contained in:
Dan Poltawski 2012-11-07 10:51:06 +08:00
commit e830d6f98e
11 changed files with 119 additions and 6 deletions

View file

@ -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);

View file

@ -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';
}
}

View file

@ -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';
}
}

View file

@ -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';
}
}

View file

@ -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';
}
}
/**

View file

@ -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';
}
}

View file

@ -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';
}
}

View file

@ -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';
}
}

View file

@ -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)));