Skip to content

Commit

Permalink
Merge branch 'wip-MDL-30921-m24' of git://github.com/samhemelryk/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Nov 7, 2012
2 parents 1191881 + 27e3057 commit e830d6f
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 6 deletions.
11 changes: 11 additions & 0 deletions blocks/activity_modules/block_activity_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ function get_content() {
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);
Expand Down
9 changes: 9 additions & 0 deletions blocks/admin_bookmarks/block_admin_bookmarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ function get_content() {

return $this->content;
}

/**
* Returns the role that best describes the admin bookmarks block.
*
* @return string
*/
public function get_aria_role() {
return 'navigation';
}
}


9 changes: 9 additions & 0 deletions blocks/blog_menu/block_blog_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,13 @@ function get_content() {
// 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';
}
}
8 changes: 8 additions & 0 deletions blocks/course_list/block_course_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ function get_remote_courses() {
return false;
}

/**
* Returns the role that best describes the course list block.
*
* @return string
*/
public function get_aria_role() {
return 'navigation';
}
}


29 changes: 28 additions & 1 deletion blocks/moodleblock.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ public function get_content_for_output($output) {
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);
Expand Down Expand Up @@ -398,7 +401,8 @@ function hide_header() {
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';
Expand Down Expand Up @@ -700,6 +704,29 @@ public static function comment_display($comments, $options) {
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';
}
}

/**
Expand Down
9 changes: 9 additions & 0 deletions blocks/navigation/block_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,13 @@ protected function trim_center($string, $length) {
$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';
}
}
9 changes: 9 additions & 0 deletions blocks/search_forums/block_search_forums.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ function get_content() {
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';
}
}


9 changes: 9 additions & 0 deletions blocks/settings/block_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,13 @@ function get_content() {
$this->contentgenerated = true;
return true;
}

/**
* Returns the role that best describes the settings block.
*
* @return string 'navigation'
*/
public function get_aria_role() {
return 'navigation';
}
}
2 changes: 1 addition & 1 deletion blocks/settings/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function navigation_node(navigation_node $node, $attrs=array()) {
}

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)));
Expand Down
6 changes: 6 additions & 0 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
24 changes: 20 additions & 4 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,13 @@ public function standard_footer_html() {
* @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>';
}

/**
Expand Down Expand Up @@ -914,14 +920,20 @@ public function block(block_contents $bc, $region) {
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');
}
if (!empty($bc->controls)) {
$bc->add_class('block_with_controls');
}

$skiptitle = strip_tags($bc->title);

if (empty($skiptitle)) {
$output = '';
$skipdest = '';
Expand Down Expand Up @@ -955,7 +967,11 @@ protected function block_header(block_contents $bc) {

$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);
Expand Down Expand Up @@ -2520,7 +2536,7 @@ public function navbar() {

//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;
}
Expand Down

0 comments on commit e830d6f

Please sign in to comment.