You are here

function pagination_admin_settings in Pagination (Node) 6

Same name and namespace in other branches
  1. 7 pagination.admin.inc \pagination_admin_settings()

@desc Pagination configuration

1 string reference to 'pagination_admin_settings'
pagination_menu in ./pagination.module
@desc Implementation of hook_menu()

File

./pagination.module, line 95
pagination.module @desc Allow for arbitrary nodes to be paginated. administrators can set which nodes they wish to paginate, and the length of content required to split a node into pages. Alternatively, content creators can set manual break points…

Code

function pagination_admin_settings() {
  $pg =& Pagination::getInstance();
  $options = node_get_types('names');

  // Drupal's theme_table runs values through check_plain, no need to escape
  // HTML here. see: theme_pagination_admin_settings()
  $pagetypes = array(
    0 => t('No pagination'),
    1 => t('Manual break - custom'),
    2 => t('Manual break - <h!num>', array(
      '!num' => variable_get('pagination_header', 3),
    )),
    150 => 150,
    300 => 300,
    450 => 450,
    600 => 600,
    750 => 750,
    1000 => 1000,
  );
  $pagestyles = array(
    0 => t('Default paging'),
    1 => t('Default paging + Table of Contents'),
    2 => t('Table of Contents'),
  );
  $headers = array(
    1 => t('h1'),
    2 => t('h2'),
    3 => t('h3'),
    4 => t('h4'),
    5 => t('h5'),
    6 => t('h6'),
  );
  foreach ($options as $type => $node) {
    $form[$type]['pagination'] = array(
      '#type' => 'select',
      '#name' => "pagination[{$type}]",
      '#default_value' => $pg
        ->getValue($type),
      '#options' => $pagetypes,
    );
    $form[$type]['style'] = array(
      '#type' => 'select',
      '#name' => "style[{$type}]",
      '#default_value' => $pg
        ->getStyle($type),
      '#options' => $pagestyles,
    );
  }
  $form['pagination_ignore'] = array(
    '#type' => 'textfield',
    '#title' => t('Disable pagination for a specific node'),
    '#description' => t('Place the node ids of nodes you wish to avoid pagination. Separate multiple node ids. ex: "1, 5, 7" will ignore nodes 1, 5, and 7'),
    '#default_value' => variable_get('pagination_ignore', ''),
  );
  $form['pagination_header'] = array(
    '#type' => 'select',
    '#title' => t('Header tag'),
    '#description' => t('Alter the header tag to paginate on under manual break (Default: !tag)', array(
      '!tag' => '&lt;h3&gt;',
    )),
    '#options' => $headers,
    '#default_value' => variable_get('pagination_header', 3),
  );
  $form['pagination_list_type'] = array(
    '#type' => 'select',
    '#title' => t('List type'),
    '#description' => t('Alter the list type of the table of contents (Default: unordered list)'),
    '#options' => array(
      'ul' => 'Unordered list',
      'ol' => 'Ordered list',
    ),
    '#default_value' => variable_get('pagination_list_type', 'ul'),
  );
  $form['pagination_showall'] = array(
    '#type' => 'checkbox',
    '#title' => t('Provide a "Show full page" link'),
    '#description' => t('Enable a "Show full page" link below the content.'),
    '#default_value' => variable_get('pagination_showall', 1),
  );
  $form['pagination_onebased'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use 1 based pagers'),
    '#description' => t('Enable 1 based pagers (Drupal by default uses 0 based pagers)'),
    '#default_value' => variable_get('pagination_onebased', 1),
  );
  $form['pagination_collapsed'] = array(
    '#type' => 'checkbox',
    '#title' => t('Collapse "Page Headers" help text'),
    '#description' => t('Collapse "Page Headers" help text by default during node creation / editing (Default collapsed)'),
    '#default_value' => variable_get('pagination_collapsed', 1),
  );
  $form['pagination_filter'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable stale header filtering'),
    '#description' => t('Filters out old manual break pagination syntax. This prevents syntax like "[pagebreak]" from showing up in node types that are no longer paginated. (Default, filter old syntax)'),
    '#default_value' => variable_get('pagination_filter', 1),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Set pagination'),
  );
  return $form;
}