Default roles should be set for core blocks. I achieve this by using variable_set() in accessible_fix.install. Not sure if this is the best way to do it, or if it can cause problems.

Also fixed a bug with accessible_fix_uninstall(). Got a db error because VARIABLES was capitalized in the query.

CommentFileSizeAuthor
add_defaults.patch3.23 KBYaxBalamAhaw

Comments

johnbarclay’s picture

Love the approach. At first I thought it better to put these in the preprocess theme functions. But setting these variables allows authors to see in the gui what aria roles are defaulted to as well as change them.

You might consider a function called accessible_fix_aria_role_defaults that stores the defaults so:
- a user can reset to defaults without reinstalling the module
- the defaults can be repurposed in other ways

the function might look like:

accessible_fix_aria_role_defaults() {

return array(
'block__search_form' => array('search' => 'search'),
'block__blog_recent' =>  array('complementary' => 'complementary')),
);
}

This default aria role to block mapping could also go in /accessible_api/accessible_api.data.inc

The .install module could then read these values and create the variables as you are doing.

also be careful with function names like: _set_default_variables, you never know what they will collide with. use
_accessible_fix_set_default_variables

johnbarclay’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Assigned: Unassigned » johnbarclay
Category: task » feature
Status: Needs work » Needs review

This is in the dev version dated the 13th. The data that drives this is in accessible_fix/module_fixes/block.admin.inc

 $accessibility_data['aria_fixed_roles']['blocks'] = array(
   'aggregator' => array('complementary'),
   'blog' => array('navigation'),
   'book' => array('navigation'),
   'comment' => array('navigation'),
   'forum' => array('navigation'),
   'help' => array('complementary'),
   'locale' => array('complementary'),
   'menu' => array('navigation'),
   'node_syndicate' => array('complementary'),
   'node_recent' => array('navigation'),
   'poll' => array('complementary'),
   'profile' => array('complementary'),
   'search' => array('search'),
   'shortcut' => array('navigation'),
   'statistics' => array('navigation'),
   'system_main' => array('main'),
   'system_powered-by' => array('complementary'),
   'system_help' => array('complementary'),
   'user_login' => array('form'),
   'user_new' => array('complementary'),
   'user_online' => array('complementary'),
   'system_main' => array('main'),
    );

and the code itself is in
accessible_fix/module_fixes/block.inc

  $fixed_aria_roles = array();
  if (isset($conf['fixed_aria_roles']) && (boolean)$conf['fixed_aria_roles']) {
    $aria_fixed_roles_blocks = accessible_api_data('aria_fixed_roles', 'blocks');
    if (isset($aria_fixed_roles_blocks[$storage_id])) {
      $fixed_aria_roles = $aria_fixed_roles_blocks[$storage_id];
    }
    elseif (isset($aria_fixed_roles_blocks[$variables['block']->module])) {
      $fixed_aria_roles = $aria_fixed_roles_blocks[$variables['block']->module];
    }
  }

and it is only applied to blocks.

mgifford’s picture

So is anything missing from core? What about the top 20 or so modules with blocks?

johnbarclay’s picture

Its hard to grep for this since some blocks are generated dynamically. The best way to find this out is on a clean install enable all the core modules and the top 20 contrib and do a query of the blocks table.

mgifford’s picture

True.. That would be a nice way to gather them. Would be nice to have a simple SQL query to dump the data in the format we'd want to use & could easily monitor.

johnbarclay’s picture

We could do this with a join query between csv and the block table, but it wouldn't really show the aria roles. the quickest way to automate this would be block_list and block_load and then do a regex for the aria roles. This could be leveraged in the simpletests in fact to make sure the aria roles were being applied correctly.