diff --git a/scheduler.install b/scheduler.install index 484be85..912328d 100644 --- a/scheduler.install +++ b/scheduler.install @@ -64,6 +64,9 @@ function scheduler_uninstall() { $variables[] = "scheduler_unpublish_enable_" . $type_name; $variables[] = "scheduler_unpublish_required_" . $type_name; $variables[] = "scheduler_unpublish_revision_" . $type_name; + $variables[] = "scheduler_use_vertical_tabs_" . $type_name; + $variables[] = "scheduler_options_weight_" . $type_name; + $variables[] = "scheduler_expand_fieldset_" . $type_name; } foreach ($variables as $variable) { diff --git a/scheduler.module b/scheduler.module index d1e9d0e..6d72b89 100644 --- a/scheduler.module +++ b/scheduler.module @@ -271,6 +271,46 @@ function scheduler_form_node_type_form_alter(&$form, $form_state) { '#title' => t('Create a new revision on unpublishing'), '#default_value' => variable_get('scheduler_unpublish_revision_' . $form['#node_type']->type, 0), ); + // The 'node_edit_layout' fieldset contains options to alter the layout of + // node edit pages. + $form['scheduler']['node_edit_layout'] = array( + '#type' => 'fieldset', + '#title' => t('Node edit page layout'), + '#collapsible' => FALSE, + '#weight' => 3, + '#group' => 'scheduler', + ); + $form['scheduler']['node_edit_layout']['scheduler_options_weight'] = array( + '#type' => 'select', + '#title' => t('Scheduling options weight'), + '#options' => drupal_map_assoc(range(-50, 50)), + '#default_value' => variable_get('scheduler_options_weight_' . $form['#node_type']->type, 35), + '#description' => t('A heavier weight will show the scheduling options lower on the page or in a lower vertical tab'), + ); + $form['scheduler']['node_edit_layout']['scheduler_use_vertical_tabs'] = array( + '#type' => 'radios', + '#title' => t('Display scheduling options as'), + '#default_value' => variable_get('scheduler_use_vertical_tabs_' . $form['#node_type']->type, 1), + '#options' => array( + '1' => t('Vertical tab'), + '0' => t('Separate fieldset'), + ), + '#description' => t('Use this option to specify how the scheduling options will be displayed when editing a node'), + ); + $form['scheduler']['node_edit_layout']['scheduler_expand_fieldset'] = array( + '#type' => 'radios', + '#title' => t('Expand fieldset'), + '#default_value' => variable_get('scheduler_expand_fieldset_' . $form['#node_type']->type, 0), + '#options' => array( + '1' => t('Always open the fieldset, even if no dates exist'), + '0' => t('Expand only when a scheduled date exists or when a date is required'), + ), + '#states' => array( + 'visible' => array( + ':input[name="scheduler_use_vertical_tabs"]' => array('value' => '0'), + ), + ), + ); } /** @@ -324,11 +364,15 @@ function scheduler_form_alter(&$form, $form_state) { $publishing_required = variable_get('scheduler_publish_required_' . $form['type']['#value'], 0) == 1 && $node->status == 0; $unpublishing_required = variable_get('scheduler_unpublish_required_' . $form['type']['#value'], 0) == 1 && $node->status == 1; + $use_vertical_tabs = variable_get('scheduler_use_vertical_tabs_' . $form['type']['#value'], 1); + $weight = variable_get('scheduler_options_weight_' . $form['type']['#value'], 35); + $fieldset_extended = ( (isset($defaults->publish_on) && $defaults->publish_on != 0) || (isset($defaults->unpublish_on) && $defaults->unpublish_on != 0) || $publishing_required || $unpublishing_required + || variable_get('scheduler_expand_fieldset_' . $form['type']['#value'], 0) ); $form['scheduler_settings'] = array( @@ -336,14 +380,25 @@ function scheduler_form_alter(&$form, $form_state) { '#title' => t('Scheduling options'), '#collapsible' => TRUE, '#collapsed' => !$fieldset_extended, - '#weight' => 35, - '#group' => 'additional_settings', - '#attached' => array( - 'js' => array( - 'vertical-tabs' => drupal_get_path('module', 'scheduler') . "/scheduler_vertical_tabs.js", - ), - ), + '#weight' => $weight, ); + if (variable_get('scheduler_use_vertical_tabs_' . $form['type']['#value'], 1)) { + // Add to the 'additional_settings' vertical tab. + $form['scheduler_settings'] += array( + '#group' => 'additional_settings', + '#attached' => array( + 'js' => array( + 'vertical-tabs' => drupal_get_path('module', 'scheduler') . "/scheduler_vertical_tabs.js", + ), + ), + ); + } + else { + // Display as a normal fieldset, not in vertical tabs. + $form['scheduler_settings'] += array( + '#group' => FALSE, + ); + } $extra_info = variable_get('scheduler_extra_info', ''); if ($extra_info && $extra_info != '') {