Commit dd1f6d34 authored by catch's avatar catch

Issue #1183042 by Everett Zufelt, Rob Loach: Add WAI-ARIA roles to Core blocks.

parent 1fe62f2a
......@@ -786,3 +786,12 @@ function aggregator_sanitize_configuration() {
function _aggregator_items($count) {
return format_plural($count, '1 item', '@count items');
}
/**
* Implements hook_preprocess_block().
*/
function aggregator_preprocess_block(&$variables) {
if ($variables['block']->module == 'aggregator') {
$variables['attributes_array']['role'] = 'complementary';
}
}
......@@ -1058,6 +1058,15 @@ function _book_link_defaults($nid) {
return array('original_bid' => 0, 'menu_name' => '', 'nid' => $nid, 'bid' => 0, 'router_path' => 'node/%', 'plid' => 0, 'mlid' => 0, 'has_children' => 0, 'weight' => 0, 'module' => 'book', 'options' => array());
}
/**
* Implements hook_preprocess_block().
*/
function book_preprocess_block(&$variables) {
if ($variables['block']-> module == 'book') {
$variables['attributes_array']['role'] = 'navigation';
}
}
/**
* Processes variables for book-all-books-block.tpl.php.
*
......
......@@ -2089,6 +2089,15 @@ function comment_form_submit($form, &$form_state) {
cache_clear_all();
}
/**
* Implements hook_preprocess_block().
*/
function comment_preprocess_block(&$variables) {
if ($variables['block']->module == 'comment') {
$variables['attributes_array']['role'] = 'navigation';
}
}
/**
* Preprocesses variables for comment.tpl.php.
*
......
......@@ -961,6 +961,15 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
return $topics;
}
/**
* Implements hook_preprocess_block().
*/
function forum_preprocess_block(&$variables) {
if ($variables['block']->module == 'forum') {
$variables['attributes_array']['role'] = 'navigation';
}
}
/**
* Process variables for forums.tpl.php
*
......
......@@ -64,3 +64,12 @@ function help_help($path, $arg) {
return $output;
}
}
/**
* Implements hook_preprocess_block().
*/
function help_preprocess_block(&$variables) {
if ($variables['block']->module == 'help') {
$variables['attributes_array']['role'] = 'complementary';
}
}
......@@ -992,6 +992,15 @@ function locale_block_view($type) {
}
}
/**
* Implements hook_preprocess_block().
*/
function locale_preprocess_block(&$variables) {
if ($variables['block']->module == 'locale') {
$variables['attributes_array']['role'] = 'navigation';
}
}
/**
* Implements hook_url_outbound_alter().
*
......
......@@ -793,3 +793,12 @@ function menu_get_menus($all = TRUE) {
}
return $custom_menus;
}
/**
* Implements hook_preprocess_block().
*/
function menu_preprocess_block(&$variables) {
if ($variables['block']->module == 'menu') {
$variables['attributes_array']['role'] = 'navigation';
}
}
......@@ -1480,6 +1480,22 @@ function node_is_page($node) {
return (!empty($page_node) ? $page_node->nid == $node->nid : FALSE);
}
/**
* Implements hook_preprocess_block().
*/
function node_preprocess_block(&$variables) {
if ($variables['block']->module == 'node') {
switch ($variables['block']->delta) {
case 'syndicate':
$variables['attributes_array']['role'] = 'complementary';
break;
case 'recent':
$variables['attributes_array']['role'] = 'navigation';
break;
}
}
}
/**
* Processes variables for node.tpl.php.
*
......
......@@ -789,6 +789,15 @@ function poll_vote($form, &$form_state) {
// Return the user to whatever page they voted from.
}
/**
* Implements hook_preprocess_block().
*/
function poll_preprocess_block(&$variables) {
if ($variables['block']->module == 'poll') {
$variables['attributes_array']['role'] = 'complementary';
}
}
/**
* Themes the voting form for a poll.
*
......
......@@ -158,6 +158,7 @@ function search_block_view($delta = '') {
*/
function search_preprocess_block(&$variables) {
if ($variables['block']->module == 'search' && $variables['block']->delta == 'form') {
$variables['attributes_array']['role'] = 'search';
$variables['content_attributes_array']['class'][] = 'container-inline';
}
}
......@@ -1325,4 +1326,3 @@ function search_forms() {
);
return $forms;
}
......@@ -639,6 +639,15 @@ function shortcut_renderable_links($shortcut_set = NULL) {
return menu_tree($shortcut_set->set_name);
}
/**
* Implements hook_preprocess_block().
*/
function shortcut_preprocess_block(&$variables) {
if ($variables['block']->module == 'shortcut') {
$variables['attributes_array']['role'] = 'navigation';
}
}
/**
* Implements hook_preprocess_page().
*/
......
......@@ -428,3 +428,11 @@ function statistics_ranking() {
function statistics_update_index() {
variable_set('node_cron_views_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
}
/**
* Implements hook_preprocess_block().
*/
function statistics_preprocess_block(&$variables) {
if ($variables['block']->module == 'statistics') {
$variables['attributes_array']['role'] = 'navigation';
}
}
......@@ -2089,9 +2089,23 @@ function system_block_view($delta = '') {
* Implements hook_preprocess_block().
*/
function system_preprocess_block(&$variables) {
// System menu blocks should get the same class as menu module blocks.
if ($variables['block']->module == 'system' && in_array($variables['block']->delta, array_keys(menu_list_system_menus()))) {
$variables['classes_array'][] = 'block-menu';
if ($variables['block']->module == 'system') {
switch ($variables['block']->delta) {
case 'powered-by':
$variables['attributes_array']['role'] = 'complementary';
break;
case 'help':
$variables['attributes_array']['role'] = 'complementary';
break;
// System menu blocks should get the same class as menu module blocks.
default:
if (in_array($variables['block']->delta, array_keys(menu_list_system_menus()))) {
$variables['attributes_array']['role'] = 'navigation';
$variables['classes_array'][] = 'block-menu';
}
}
}
}
......
......@@ -1352,6 +1352,25 @@ function user_block_view($delta = '') {
}
}
/**
* Implements hook_preprocess_block().
*/
function user_preprocess_block(&$variables) {
if ($variables['block']->module == 'user') {
switch ($variables['block']->delta) {
case 'login':
$variables['attributes_array']['role'] = 'form';
break;
case 'new':
$variables['attributes_array']['role'] = 'complementary';
break;
case 'online':
$variables['attributes_array']['role'] = 'complementary';
break;
}
}
}
/**
* Format a username.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment