Permalink
Browse files

MDL-30921 blocks: Added a method to inject aria roles into block stru…

…cture
  • Loading branch information...
1 parent 6109f21 commit 697f7bd701e7c01b872904ba5eb763c596758898 Sam Hemelryk committed Oct 10, 2012
@@ -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);
@@ -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';
+ }
}
@@ -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';
+ }
}
@@ -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';
+ }
}
@@ -398,7 +398,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';
@@ -672,6 +673,37 @@ 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:
+ * - region
+ * - alert
+ * - article
+ * - grid
+ * - landmark
+ * - application
+ * - banner
+ * - complementary
+ * - contentinfo
+ * - form
+ * - main
+ * - navigation
+ * - search
+ * - list
+ * - log
+ * - status
+ * - tabpanel
+ *
+ * @return string
+ */
+ public function get_aria_role() {
+ return 'region';
+ }
}
/**
@@ -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';
+ }
}
@@ -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';
+ }
}
@@ -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';
+ }
}
@@ -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)));

0 comments on commit 697f7bd

Please sign in to comment.