You are here

function paging_form_alter in Paging 6

Implementation of hook_form_alter().

File

./paging.module, line 304
Allows users to use a tag to break up a node into multiple pages.

Code

function paging_form_alter(&$form, $form_state, $form_id) {

  // Check if paging is enabled for the node type.
  if (isset($form['type']) && isset($form['#node']) && variable_get('paging_enabled_' . $form['#node']->type, 0)) {

    // Load the required variables.
    $separator = variable_get('paging_separator_' . $form['#node']->type, '<!--pagesbreak-->');
    $widget = variable_get('paging_separator_widget_' . $form['#node']->type, 0);
    $page_names = variable_get('paging_names_enabled_' . $form['#node']->type, 0);
    $automatic_paging = variable_get('paging_automatic_method_' . $form['#node']->type, 0);
    $module_path = drupal_get_path('module', 'paging');

    // Expose configuration variables.
    drupal_add_js(array(
      'paging' => array(
        'separator' => $separator,
        'widget' => $widget,
        'page_names' => $page_names && !$automatic_paging,
        // Disable page names UI when automatic paging is enabled.
        'module_path' => $module_path,
      ),
    ), 'setting');

    // Add JS for button and names handling.
    drupal_add_js($module_path . '/paging.js', 'module');

    // Add CSS to adjust button location.
    if ($widget) {
      drupal_add_css($module_path . '/paging.css', 'module');
    }
  }
}