| 1 |
<?php
|
| 2 |
// $Id: accessible.admin.inc,v 1.1 2009/02/04 23:33:58 johnbarclay Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* The accessible module admininstration interface.
|
| 7 |
*
|
| 8 |
*/
|
| 9 |
|
| 10 |
define('ACCESSIBLE_GOOGLE_CSE_LABEL_DEFAULT', 'Search');
|
| 11 |
define('ACCESSIBLE_GOOGLE_CSE_LABEL_POSITION_OFF_SCREEN_DEFAULT', 1);
|
| 12 |
|
| 13 |
define('ACCESSIBLE_SEARCH_LABEL_DEFAULT', 'Search');
|
| 14 |
define('ACCESSIBLE_SEARCH_LABEL_POSITION_OFF_SCREEN_DEFAULT', 0);
|
| 15 |
|
| 16 |
define('ACCESSIBLE_OFFSCREEN_BLOCK_HEADINGS_DEFAULT', 1);
|
| 17 |
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Admin form for Accessible module.
|
| 21 |
*
|
| 22 |
* @param $form_state
|
| 23 |
* A form state array.
|
| 24 |
* @param $sid
|
| 25 |
* A LDAP server ID.
|
| 26 |
*
|
| 27 |
* @return
|
| 28 |
* The form structure.
|
| 29 |
*/
|
| 30 |
function accessible_admin_edit(&$form_state, $op) {
|
| 31 |
|
| 32 |
if ($op == "edit" || $op == NULL) {
|
| 33 |
|
| 34 |
$form['accessible']['general'] = array(
|
| 35 |
'#type' => 'fieldset',
|
| 36 |
'#title' => t('General Settings'),
|
| 37 |
'#collapsible' => TRUE,
|
| 38 |
'#collapsed' => ! ($edit['accessible_google_cse_label'] != ACCESSIBLE_GOOGLE_CSE_LABEL_DEFAULT
|
| 39 |
|| $edit['accessible_google_cse_label_position_off_screen'] != ACCESSIBLE_GOOGLE_CSE_LABEL_POSITION_OFF_SCREEN_DEFAULT),
|
| 40 |
);
|
| 41 |
|
| 42 |
$form['accessible']['general']['accessible_offscreen_block_headings'] = array(
|
| 43 |
'#type' => 'checkbox',
|
| 44 |
'#title' => 'Offscreen Block Headings ',
|
| 45 |
'#size' => 10,
|
| 46 |
'#description' => t('Allow block administrators to class block heading (h2,h3, etc) as "offscreen". This will only work if block theming template is modified.
|
| 47 |
Sample block.tpl.php file(s) are available in the accessible/examples folder.'),
|
| 48 |
'#default_value' => variable_get('accessible_offscreen_block_headings', ACCESSIBLE_OFFSCREEN_BLOCK_HEADINGS_DEFAULT)
|
| 49 |
);
|
| 50 |
|
| 51 |
|
| 52 |
if (module_exists("google_cse")) {
|
| 53 |
$form['accessible']['google_cse'] = array(
|
| 54 |
'#type' => 'fieldset',
|
| 55 |
'#title' => t('Google CSE Additional Configuration'),
|
| 56 |
'#collapsible' => TRUE,
|
| 57 |
'#collapsed' => ! ($edit['accessible_google_cse_label'] != ACCESSIBLE_GOOGLE_CSE_LABEL_DEFAULT
|
| 58 |
|| $edit['accessible_google_cse_label_position_off_screen'] != ACCESSIBLE_GOOGLE_CSE_LABEL_POSITION_OFF_SCREEN_DEFAULT),
|
| 59 |
);
|
| 60 |
|
| 61 |
$form['accessible']['google_cse']['accessible_google_cse_label'] = array(
|
| 62 |
'#type' => 'textfield',
|
| 63 |
'#title' => 'Label to use on Google CSE search input. ',
|
| 64 |
'#size' => 10,
|
| 65 |
'#description' => t('If you are using it Google CSE. May be positioned off screen for accessibility. Defaults is: ' ) . ACCESSIBLE_GOOGLE_CSE_LABEL_DEFAULT,
|
| 66 |
'#default_value' => variable_get('accessible_google_cse_label', ACCESSIBLE_GOOGLE_CSE_LABEL_DEFAULT)
|
| 67 |
);
|
| 68 |
|
| 69 |
$form['accessible']['google_cse']['accessible_google_cse_label_position_off_screen'] = array(
|
| 70 |
'#type' => 'checkbox',
|
| 71 |
'#title' => t('Position Google CSE Label off screen'),
|
| 72 |
'#description' => t('If you are using Google CSE, should label be positioned off screen.'),
|
| 73 |
'#default_value' => variable_get('accessible_google_cse_label_position_off_screen', ACCESSIBLE_GOOGLE_CSE_LABEL_POSITION_OFF_SCREEN_DEFAULT)
|
| 74 |
);
|
| 75 |
}
|
| 76 |
|
| 77 |
|
| 78 |
if (module_exists("search")) {
|
| 79 |
$form['accessible']['search'] = array(
|
| 80 |
'#type' => 'fieldset',
|
| 81 |
'#title' => t('Search Block Additional Configuration'),
|
| 82 |
'#collapsible' => TRUE,
|
| 83 |
'#collapsed' => ! ($edit['accessible_search_label'] != ACCESSIBLE_SEARCH_LABEL_DEFAULT
|
| 84 |
|| $edit['accessible_search_label_position_off_screen'] != ACCESSIBLE_SEARCH_LABEL_POSITION_OFF_SCREEN_DEFAULT),
|
| 85 |
);
|
| 86 |
|
| 87 |
$form['accessible']['search']['accessible_search_label'] = array(
|
| 88 |
'#type' => 'textfield',
|
| 89 |
'#title' => 'Label to use on search input. ',
|
| 90 |
'#size' => 10,
|
| 91 |
'#description' => t('If you are using search module. May be positioned off screen for accessibility. Defaults is: ' ) . ACCESSIBLE_SEARCH_LABEL_DEFAULT,
|
| 92 |
'#default_value' => variable_get('accessible_search_label', ACCESSIBLE_SEARCH_LABEL_DEFAULT)
|
| 93 |
);
|
| 94 |
|
| 95 |
$form['accessible']['search']['accessible_search_label_position_off_screen'] = array(
|
| 96 |
'#type' => 'checkbox',
|
| 97 |
'#title' => t('Position Search Label off screen'),
|
| 98 |
'#description' => t('If you are using search, should label be positioned off screen.'),
|
| 99 |
'#default_value' => variable_get('accessible_search_label_position_off_screen', ACCESSIBLE_SEARCH_LABEL_POSITION_OFF_SCREEN_DEFAULT)
|
| 100 |
);
|
| 101 |
}
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
$form['buttons']['submit'] = array(
|
| 106 |
'#type' => 'submit',
|
| 107 |
'#value' => t('Update'),
|
| 108 |
);
|
| 109 |
|
| 110 |
return $form;
|
| 111 |
}
|
| 112 |
else {
|
| 113 |
drupal_goto('admin/settings/accessible');
|
| 114 |
}
|
| 115 |
}
|
| 116 |
|
| 117 |
/**
|
| 118 |
* Submit hook for the admin settings form.
|
| 119 |
*/
|
| 120 |
function accessible_admin_edit_submit($form, &$form_state) {
|
| 121 |
$values = $form_state['values'];
|
| 122 |
|
| 123 |
if ($values['op'] == t('Reset') && $values['confirm'] == 1) {
|
| 124 |
variable_set('accessible_google_cse_label', ACCESSIBLE_GOOGLE_CSE_LABEL_DEFAULT);
|
| 125 |
variable_set('accessible_google_cse_label_position_off_screen', ACCESSIBLE_GOOGLE_CSE_LABEL_POSITION_OFF_SCREEN_DEFAULT);
|
| 126 |
variable_set('accessible_search_label', ACCESSIBLE_SEARCH_LABEL_DEFAULT);
|
| 127 |
variable_set('accessible_search_label_position_off_screen', ACCESSIBLE_SEARCH_LABEL_POSITION_OFF_SCREEN_DEFAULT);
|
| 128 |
|
| 129 |
drupal_set_message(t('The configuration options have been reset to their default values.'));
|
| 130 |
}
|
| 131 |
else {
|
| 132 |
|
| 133 |
$values = $form_state['values'];
|
| 134 |
variable_set('accessible_offscreen_block_headings', $values['accessible_offscreen_block_headings']);
|
| 135 |
|
| 136 |
if (module_exists("google_cse")) {
|
| 137 |
variable_set('accessible_google_cse_label', $values['accessible_google_cse_label']);
|
| 138 |
variable_set('accessible_google_cse_label_position_off_screen', $values['accessible_google_cse_label_position_off_screen']);
|
| 139 |
}
|
| 140 |
|
| 141 |
if (module_exists("search")) {
|
| 142 |
variable_set('accessible_search_label', $values['accessible_search_label']);
|
| 143 |
variable_set('accessible_search_label_position_off_screen', $values['accessible_search_label_position_off_screen']);
|
| 144 |
}
|
| 145 |
|
| 146 |
drupal_set_message(t('The configuration options have been saved.'));
|
| 147 |
}
|
| 148 |
|
| 149 |
$form_state['redirect'] = 'admin/settings/accessible';
|
| 150 |
}
|
| 151 |
|