function node_recur_node_recur_confirm in Node recur 7.2
Same name and namespace in other branches
- 7 node_recur.pages.inc \node_recur_node_recur_confirm()
Confirm form for node recur
1 call to node_recur_node_recur_confirm()
- node_recur_node_recur_form in ./
node_recur.pages.inc - The node recur form
File
- ./
node_recur.pages.inc, line 132
Code
function node_recur_node_recur_confirm($form, $form_state, $node) {
$field_name = node_recur_get_date_field_name($node->type);
$node_type = strtolower(node_type_get_name($node));
// Store dates in the form
$date_values = $form_state['values'][$field_name][LANGUAGE_NONE];
// Remove the first start date, to prevent dupe node creation
unset($date_values[0]);
// Do we have dates to work with?
// Date repeat returns the dates on success or the rule definition if errors occure during generation
if (empty($date_values) || !empty($date_values) && isset($date_values['FREQ'])) {
drupal_set_message(t('No dates were generated with the information provided.'), 'warning');
return _node_recur_node_recur_form($node, $form, $form_state);
}
else {
// Instructions/Warning
$count = count($date_values);
$form['node_recur_title']['#type'] = 'item';
$form['node_recur_title']['#markup'] = '<h4>' . t('The following dates will be generated. Please review before continuing.') . '</h4>';
$vars = array(
'!count' => $count,
'!node_type' => $node_type,
);
$form['node_recur_instruction']['#type'] = 'item';
$form['node_recur_instruction']['#markup'] = t('<b>!count</b> new !plural will be generated.', $vars + array(
'!plural' => format_plural($count, $node_type, "{$node_type}s"),
));
// Display the dates to the user
$max_default = variable_get('node_recur_max_confirm_display', 10);
$screen_max = $count > $max_default ? $max_default - 1 : $count;
$display_dates = array_slice($date_values, 0, $screen_max);
foreach ($display_dates as $val) {
// Remove rrule to prevent rule description from printing
// which gets long and wonky when exclude weekends is selected
unset($val['rrule']);
$view = field_view_value('node', $node, $field_name, $val);
$items[] = $view['#markup'];
}
// Display the last date if not on screen
if ($count > $max_default) {
$items[] = t('… <b>!remaining</b> additional …', $vars + array(
'!remaining' => $count - $screen_max - 1,
));
$end = $date_values[$count];
unset($end['rrule']);
$view = field_view_value('node', $node, $field_name, $end);
$items[] = $view['#markup'];
}
$item_list = array(
'title' => '',
'type' => 'ul',
'items' => $items,
'attributes' => array(
'id' => 'node-recur-date-list',
),
);
$form['node_recur_date_verify']['#type'] = 'item';
$form['node_recur_date_verify']['#markup'] = theme_item_list($item_list);
$form['node_recur_date_values']['#type'] = 'value';
$form['node_recur_date_values']['#value'] = $date_values;
// Clean up the output
$form['#attached']['css'][] = drupal_get_path('module', 'node_recur') . '/node_recur.css';
// Store the node
$form['#node'] = $node;
// Add the submit handler
$form['#submit'][] = 'node_recur_node_recur_confirm_submit';
// Node type name
$msg = t('This action cannot be undone. Please confirm that the dates above are accurate and that the !node_type information is correct. Editing this !node_type afterwards will not edit every !node_type generated here.', $vars);
// Supply the confirm form
return confirm_form($form, t('Are you sure you want to generate these items?'), "node/{$node->nid}/recur", '<strong>' . $msg . '</strong>', t('Submit'));
}
}