| 1 |
<?php
|
| 2 |
// $Id: accessible.module,v 1.1 2009/02/04 23:33:58 johnbarclay Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* The accessible module to make accessiblity tweaks not yet integrated
|
| 7 |
* into core or other modules.
|
| 8 |
*
|
| 9 |
*/
|
| 10 |
|
| 11 |
define('ACCESSIBLE_OFFSCREEN_BLOCK_HEADINGS', variable_get('accessible_offscreen_block_headings', FALSE));
|
| 12 |
|
| 13 |
function accessible_init() {
|
| 14 |
drupal_add_css(drupal_get_path('module', 'accessible') .'/accessible.css', 'module', 'all', FALSE);
|
| 15 |
}
|
| 16 |
|
| 17 |
function accessible_perm() {
|
| 18 |
return array('administer accessible module');
|
| 19 |
}
|
| 20 |
|
| 21 |
/**
|
| 22 |
* Implements hook_menu().
|
| 23 |
*/
|
| 24 |
function accessible_menu() {
|
| 25 |
$items = array();
|
| 26 |
|
| 27 |
$items['admin/settings/accessible'] = array(
|
| 28 |
'title' => t('Accessible Settings'),
|
| 29 |
'description' => t('Configure setting relevant to accessible conventions.'),
|
| 30 |
'page callback' => 'drupal_get_form',
|
| 31 |
'page arguments' => array('accessible_admin_edit', "edit"),
|
| 32 |
'access arguments' => array('administer accessible module'),
|
| 33 |
'file' => 'accessible.admin.inc',
|
| 34 |
);
|
| 35 |
|
| 36 |
return $items;
|
| 37 |
}
|
| 38 |
|
| 39 |
|
| 40 |
/**
|
| 41 |
* Implements hook_form_FORM_ID_alter()
|
| 42 |
* search form commonly uses 2 different ids:
|
| 43 |
* search_theme_form and search_block_form, so 2 functions exist
|
| 44 |
*/
|
| 45 |
function accessible_form_search_theme_form_alter(&$form, $form_state) {
|
| 46 |
accessible_form_search_block_form_alter($form, $form_state);
|
| 47 |
}
|
| 48 |
|
| 49 |
function accessible_form_search_block_form_alter(&$form, $form_state) {
|
| 50 |
|
| 51 |
if (variable_get('accessible_search_label_position_off_screen', 0)) {
|
| 52 |
$form['#attributes'] = array('class' => 'offscreen-labels');
|
| 53 |
};
|
| 54 |
if (variable_get('accessible_search_label', NULL)) {
|
| 55 |
$form['search_block_form']['#title'] = variable_get('accessible_search_label', NULL);
|
| 56 |
}
|
| 57 |
if (variable_get('accessible_search_button_text', NULL)) {
|
| 58 |
$form['search_block_form']['#value'] = variable_get('accessible_search_button_text', NULL);
|
| 59 |
}
|
| 60 |
}
|
| 61 |
|
| 62 |
/**
|
| 63 |
* Implements hook_form_FORM_ID_alter()
|
| 64 |
*/
|
| 65 |
function accessible_form_google_cse_searchbox_form_alter(&$form, $form_state) {
|
| 66 |
|
| 67 |
if (variable_get('accessible_google_cse_label_position_off_screen', 0)) {
|
| 68 |
$form['#attributes'] = array('class' => 'offscreen-labels');
|
| 69 |
};
|
| 70 |
if (variable_get('accessible_google_cse_label', NULL)) {
|
| 71 |
$form['query']['#title'] = variable_get('accessible_google_cse_label', NULL);
|
| 72 |
}
|
| 73 |
if (variable_get('accessible_google_cse_button_text', NULL)) {
|
| 74 |
$form['query']['#value'] = variable_get('accessible_google_cse_button_text', NULL);
|
| 75 |
}
|
| 76 |
}
|
| 77 |
/**
|
| 78 |
* Implements hook_form_FORM_ID_alter()
|
| 79 |
*/
|
| 80 |
function accessible_form_block_admin_configure_alter(&$form, $form_state) {
|
| 81 |
|
| 82 |
if (ACCESSIBLE_OFFSCREEN_BLOCK_HEADINGS) {
|
| 83 |
|
| 84 |
$block = db_fetch_array(db_query("SELECT offscreen FROM {blocks} WHERE module = '%s'
|
| 85 |
AND delta = '%s'", $form['module']['#value'], $form['delta']['#value']));
|
| 86 |
|
| 87 |
$form['user_vis_settings']['accessible_offscreen'] = array(
|
| 88 |
'#type' => 'checkbox',
|
| 89 |
'#title' => 'Class the blocks header tag as "offscreen"',
|
| 90 |
'#default_value' => $block['offscreen'],
|
| 91 |
'#description' => t('If accessible module is enabled, this will position the header
|
| 92 |
off screen making it accessible without showing it. Provided the block template file has been modified correctly.'),
|
| 93 |
);
|
| 94 |
|
| 95 |
$form['#submit'][] = 'accessible_block_form_submit';
|
| 96 |
}
|
| 97 |
}
|
| 98 |
|
| 99 |
function accessible_block_form_submit($form_id, $form_state) {
|
| 100 |
db_query("UPDATE {blocks} SET offscreen = %d WHERE module = '%s' AND delta = '%s'",
|
| 101 |
$form_state['values']['accessible_offscreen'], $form_state['values']['module'], $form_state['values']['delta']);
|
| 102 |
}
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|