function spaces_menu_items_validate in Spaces 6.3
Same name and namespace in other branches
- 7.3 spaces.module \spaces_menu_items_validate()
- 7 spaces.module \spaces_menu_items_validate()
Validate callback for spaces menu editor.
1 string reference to 'spaces_menu_items_validate'
File
- ./
spaces.module, line 894
Code
function spaces_menu_items_validate($element, &$form_state) {
$base_path = base_path();
$items = array();
// @TODO: Split out spaces_json_decode() into a library.
// Ideally, this would either be part of Drupal core or split out into a
// utility module/library.
$weight = -20;
if (!empty($form_state['values']['space_menu_items'])) {
foreach (spaces_json_decode($form_state['values']['space_menu_items']) as $i) {
if (strpos($i, $base_path) === 0) {
$path = substr($i, strlen($base_path));
$path = array_shift(explode('#', $path));
$path = drupal_get_normal_path($path);
$items[$path] = $weight;
$weight++;
}
}
}
if (empty($items)) {
form_set_error('space_menu_items', t('Invalid submission'));
}
else {
$form_state['values']['space_menu_items'] = $items;
}
// Remove button values.
unset($form_state['values']['edit']);
unset($form_state['values']['cancel']);
}