function quickbar_help_form_alter in Quickbar 7.2
Implements hook_form_alter().
File
- modules/
quickbar_help/ quickbar_help.module, line 30
Code
function quickbar_help_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'quickbar_configure_form') {
// We need to make the submit button heavy
$form['submit']['#weight'] = 1000;
$form['help'] = array(
'#type' => 'fieldset',
'#title' => t('Help Settings'),
'#collapsible' => 1,
'#collapsed' => 0,
);
$current_help = array();
$result = db_select('quickbar_help', 'qh')
->fields('qh')
->condition('rid', arg(4))
->execute();
while ($record = $result
->fetchAssoc()) {
$current_help[$record['path']] = $record;
}
$menus = variable_get('quickbar_role_menus', array());
$menu_used = $menus[arg(4)];
// Pulls all menu links from the database
//...excludes menu_item_container "links" since there's nothing to display anyway
$result = db_query("SELECT link_path, link_title FROM {menu_links}\n WHERE menu_name = :menu\n AND module <> 'menu_item_container'\n AND hidden = 0\n AND link_path NOT LIKE '%\\%%'\n GROUP BY link_path\n ORDER BY depth ASC, weight ASC", array(
':menu' => $menu_used,
));
$menu_found = 0;
while ($record = $result
->fetchAssoc()) {
$path = str_replace('<front>', '/', $record['link_path']);
$title = $record['link_title'];
$form['help'][$path] = array(
'#type' => 'fieldset',
'#title' => $title,
'#description' => t('Enter the text that will be linked to %path', array(
'%path' => $path == '/' ? '<front>' : '/' . $path,
)),
'#collapsible' => 1,
'#collapsed' => 1,
);
$form['help'][$path]['text'] = array(
'#type' => 'text_format',
'#title' => t('Help Text'),
'#default_value' => isset($current_help[$path]['text']) ? $current_help[$path]['text'] : '',
'#format' => isset($current_help[$path]['format']) ? $current_help[$path]['format'] : NULL,
);
$menu_found = 1;
}
if (!$menu_found) {
$form['help']['text'] = array(
'#type' => 'item',
'#value' => t('<em>There is not a menu associated with this role.</em>'),
);
}
$form['#submit'][] = 'quickbar_help_configure_form_submit';
}
}