function menu_position_rules_form in Menu Position 6
Same name and namespace in other branches
- 7.2 menu_position.admin.inc \menu_position_rules_form()
- 7 menu_position.admin.inc \menu_position_rules_form()
Form definition: orders rules.
1 string reference to 'menu_position_rules_form'
- menu_position_rules_form_callback in ./
menu_position.admin.inc - Menu callback: orders rules.
File
- ./
menu_position.admin.inc, line 185 - Provides infrequently used functions and hooks for menu_position.
Code
function menu_position_rules_form($form_state) {
// We're re-using classes from the menu module.
drupal_add_css(drupal_get_path('module', 'menu') . '/menu.css');
$rules = db_query('SELECT rid, admin_title, menu_name, enabled, weight FROM {menu_position_rules} ORDER BY weight, rid');
$delta = db_affected_rows();
$menus = menu_get_menus();
// Default message if no rules.
if ($delta == 0) {
$form['rules'] = array(
'#value' => '<p>' . t('No rules have been created yet.') . '</p>',
);
}
else {
$form['rules'] = array(
'#tree' => TRUE,
'#theme' => 'menu_position_rules_order',
);
while ($rule = db_fetch_object($rules)) {
$form['rules'][$rule->rid] = array(
'title' => array(
'#value' => check_plain($rule->admin_title),
),
'menu_name' => array(
'#value' => check_plain($menus[$rule->menu_name]),
),
'enabled' => array(
'#type' => 'checkbox',
'#default_value' => $rule->enabled,
),
'weight' => array(
'#type' => 'weight',
'#default_value' => $rule->weight,
'#delta' => max($delta, 5),
'#id' => 'edit-rule-' . $rule->rid,
),
'operations' => array(
'edit-link' => array(
'#value' => l(t('edit'), 'admin/build/menu-position/edit/' . $rule->rid),
),
'delete-link' => array(
'#value' => l(t('delete'), 'admin/build/menu-position/delete/' . $rule->rid),
),
),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
return $form;
}