function menu_position_rules_form in Menu Position 7
Same name and namespace in other branches
- 6 menu_position.admin.inc \menu_position_rules_form()
- 7.2 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 183 - Provides infrequently used functions and hooks for menu_position.
Code
function menu_position_rules_form($form, &$form_state) {
// We're re-using classes from the menu module.
$form['#attached']['css'] = array(
drupal_get_path('module', 'menu') . '/menu.css',
);
$rules = db_query('SELECT rid, admin_title, plid, menu_name, enabled, weight FROM {menu_position_rules} ORDER BY weight, rid')
->fetchAll();
$delta = count($rules);
$menus = menu_get_menus();
// Default message if no rules.
if ($delta == 0) {
$form['rules'] = array(
'#markup' => '<p>' . t('No rules have been created yet.') . '</p>',
);
}
else {
$form['rules'] = array(
'#tree' => TRUE,
'#theme' => 'menu_position_rules_order',
);
foreach ($rules as $rule) {
$menu_link = menu_link_load($rule->plid);
if ($menu_link === FALSE) {
$menu_link = array(
'title' => '[' . t('deleted menu item') . ']',
);
}
$form['rules'][$rule->rid] = array(
'title' => array(
'#markup' => '<strong>' . check_plain($rule->admin_title) . '</strong> (' . t('Positioned under: %title', array(
'%title' => check_plain($menu_link['title']),
)) . ')',
),
'menu_name' => array(
'#markup' => 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(
'#type' => 'link',
'#title' => t('edit'),
'#href' => 'admin/structure/menu-position/edit/' . $rule->rid,
),
'delete-link' => array(
'#type' => 'link',
'#title' => t('delete'),
'#href' => 'admin/structure/menu-position/delete/' . $rule->rid,
),
),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
return $form;
}