diff --git a/template.php b/template.php index ba6ccd7..533c8e3 100644 --- a/template.php +++ b/template.php @@ -373,6 +373,7 @@ function zen_preprocess_region(&$variables, $hook) { * The name of the template being rendered ("block" in this case.) */ function zen_preprocess_block(&$variables, $hook) { + // Use a bare template for the page's main content. if ($variables['block_html_id'] == 'block-system-main') { $variables['theme_hook_suggestions'][] = 'block__bare'; @@ -389,6 +390,98 @@ function zen_preprocess_block(&$variables, $hook) { $variables['classes_array'][] = $variables['block_zebra']; $variables['title_attributes_array']['class'][] = 'block-title'; + + // Add Aria Roles via attributes + if ($variables['block']->module == 'aggregator') { + $variables['attributes_array']['role'] = 'complementary'; + } + if ($variables['block']->module == 'blog') { + $variables['attributes_array']['role'] = 'navigation'; + } + if ($variables['block']->module == 'book') { + $variables['attributes_array']['role'] = 'navigation'; + } + if ($variables['block']->module == 'comment') { + $variables['attributes_array']['role'] = 'navigation'; + } + if ($variables['block']->module == 'forum') { + $variables['attributes_array']['role'] = 'navigation'; + } + if ($variables['block']->module == 'help') { + $variables['attributes_array']['role'] = 'complementary'; + } + if ($variables['block']->module == 'locale') { + $variables['attributes_array']['role'] = 'complementary'; + } + if ($variables['block']->module == 'menu') { + $variables['attributes_array']['role'] = 'navigation'; + } + if ($variables['block']->module == 'poll') { + $variables['attributes_array']['role'] = 'complementary'; + } + if ($variables['block']->module == 'profile') { + $variables['attributes_array']['role'] = 'complementary'; + } + if ($variables['block']->module == 'search') { + $variables['attributes_array']['role'] = 'search'; + } + if ($variables['block']->module == 'shortcut') { + $variables['attributes_array']['role'] = 'navigation'; + } + if ($variables['block']->module == 'statistics') { + $variables['attributes_array']['role'] = 'navigation'; + } + // System module blocks + if ($variables['block']->module == 'system') { + switch ($variables['block']->delta) { + case 'main': + $variables['attributes_array']['role'] = 'main'; + break; + + 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'; + } + } + } + // User module blocks + 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; + } + } + // Node module blocks + 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; + } + } } /**