function paging_settings in Paging 6
Same name and namespace in other branches
- 5 paging.module \paging_settings()
- 7 paging.admin.inc \paging_settings()
Menu callback; display module settings form.
1 string reference to 'paging_settings'
- paging_menu in ./
paging.module - Implementation of hook_menu().
File
- ./
paging.module, line 72 - Allows users to use a tag to break up a node into multiple pages.
Code
function paging_settings() {
$form = array();
// Set the id of the top-level form tag
$form['#id'] = 'paging';
$form['help'] = array(
'#type' => 'markup',
'#value' => '<h3>' . t('Check the boxes at left to enable paging for each desired content type.') . '</h3>',
);
$paging_filter = FALSE;
// Retrieve all input filters.
foreach (filter_formats() as $format) {
// Further retrieve all input formats.
foreach (filter_list_format($format->format) as $filter) {
// Check if any of the input formats have paging filter enabled.
if ($filter->module == 'paging') {
$paging_filter = TRUE;
break;
}
}
}
if (!$paging_filter) {
// Warn if paging filter is not yet enabled for any input format.
drupal_set_message(t('Paging filter has not yet been enabled for any input formats. !link!', array(
'!link' => l(t('Take action'), 'admin/settings/filters'),
)), 'warning paging-warning');
}
// Traverse available node types.
foreach (node_get_types('names') as $type => $name) {
// Container fieldset.
$form[$type]['paging_config'] = array(
'#type' => 'fieldset',
'#title' => $name,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'paging-fieldset',
'id' => 'paging-type-' . $type,
),
);
// Left column fieldset.
$form[$type]['paging_config']['paging_left'] = array(
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'paging-left',
),
);
// Paging toggle checkbox.
$form[$type]['paging_config']['paging_left']['paging_enabled_' . $type] = array(
'#type' => 'checkbox',
'#title' => '',
'#default_value' => variable_get('paging_enabled_' . $type, 0),
'#attributes' => array(
'class' => 'paging-enabled',
),
);
// Paging separator string.
$form[$type]['paging_config']['paging_left']['paging_separator_' . $type] = array(
'#type' => 'textfield',
'#title' => t('Page separator string'),
'#size' => 20,
'#maxlength' => 255,
'#required' => TRUE,
'#default_value' => variable_get('paging_separator_' . $type, '<!--pagebreak-->'),
'#description' => t('Use an HTML tag that will render reasonably when paging is not enabled, such as %pagebreak or %hr.', array(
'%pagebreak' => '<!--pagebreak-->',
'%hr' => '<hr />',
)),
);
// "Paging separator" insertion widget. Can be a normal or image form button.
// Accompanied by paging.js.
$form[$type]['paging_config']['paging_left']['paging_separator_widget_' . $type] = array(
'#type' => 'radios',
'#title' => t('Paging separator widget'),
'#options' => array(
t('Disabled'),
t('Image'),
t('Button'),
),
'#required' => TRUE,
'#description' => t('Choose the style of separator string widget. This widget attaches itself to the body textarea and when clicked, inserts separator at cursor position.'),
'#default_value' => variable_get('paging_separator_widget_' . $type, 0),
'#attributes' => array(
'class' => 'paging-method',
),
);
// Change "Read more" path when first page is greater than or equal to the teaser.
$form[$type]['paging_config']['paging_left']['paging_read_more_enabled_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Link "Read more" to second page'),
'#description' => t('When enabled, the "Read more" link under teasers will link to the second page of the content, iff the teaser is larger than the first page or if they are the same.'),
'#default_value' => variable_get('paging_read_more_enabled_' . $type, 0),
);
// Style/theme of page navigation links. "Custom" option enables a textfield to enter function name.
// Accompanied by paging.js.
$form[$type]['paging_config']['paging_left']['paging_pager_widget_' . $type] = array(
'#type' => 'radios',
'#title' => t('Pager style'),
'#options' => array(
'pager' => t('Default <small>- <code>!pager</code></small>', array(
'!pager' => l('theme_pager()', 'http://api.drupal.org/api/function/theme_pager/6', array(
'attributes' => array(
'target' => '_blank',
),
)),
)),
'paging_drop_down' => t('Drop down list <small>- <code>theme_paging_drop_down()</code></small>'),
'custom' => t('Custom'),
),
'#required' => TRUE,
'#description' => t('Choose style of page navigation. See also: !link.', array(
'!link' => l('Overriding theme output', 'http://drupal.org/node/173880#function-override'),
)),
'#default_value' => variable_get('paging_pager_widget_' . $type, 'pager'),
'#attributes' => array(
'class' => 'paging-pager',
),
);
// Textfield to accept custom pager theme function name.
$form[$type]['paging_config']['paging_left']['paging_pager_widget_custom_' . $type] = array(
'#type' => 'textfield',
'#title' => t('Custom pager theme function'),
'#size' => 20,
'#maxlength' => 255,
'#required' => TRUE,
'#default_value' => variable_get('paging_pager_widget_custom_' . $type, 'pager'),
'#description' => t('Enter the last part of the name of your theme
function (the part after the prefix <em>theme_</em>). Your theme
registry will need to be rebuilt after changing this setting.'),
'#attributes' => array(
'class' => 'paging-pager-custom-' . $type,
),
'#field_prefix' => 'theme_',
);
// Right column fieldset.
$form[$type]['paging_config']['paging_right'] = array(
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#attributes' => array(
'class' => 'paging-right',
),
);
// Positions to place the page navigation links at.
$form[$type]['paging_config']['paging_right']['paging_pager_widget_position_' . $type] = array(
'#type' => 'radios',
'#title' => t('Pager position'),
'#options' => array(
'below' => t('Below content'),
'above' => t('Above content'),
'both' => t('Below and above content'),
'manual' => t('None (No output)'),
),
'#required' => TRUE,
'#description' => t('Choose the position of page navigation. If set to %none, <code>@paging</code> can be used to place it at a customizable location.', array(
'%none' => t('None'),
'@paging' => '$node->paging',
)) . (module_exists('content') ? ' ' . t('Position of enabled pager(s) can further be customized for <a href="@url">content types</a> under <em>Manage fields</em> tab.', array(
'@url' => url('admin/content/types'),
)) : ''),
'#default_value' => variable_get('paging_pager_widget_position_' . $type, 'below'),
'#attributes' => array(
'class' => 'paging-pager',
),
);
// Toggle dynamic loading of pages using AJAX.
$form[$type]['paging_config']['paging_right']['paging_ajax_enabled_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Dynamically load pages using AJAX'),
'#description' => t('Clicking on a pager links will load the page content dynamically. Supports both <em>Default</em> and <em>Drop down list</em> pager styles.'),
'#default_value' => variable_get('paging_ajax_enabled_' . $type, 0),
'#attributes' => array(
'class' => 'paging-ajax',
),
);
// Toggle UI that helps with assigning names to pages. Disabled with automatic paging.
$form[$type]['paging_config']['paging_right']['paging_names_enabled_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Display Page names interface'),
'#description' => t('Add an interface to manage page names, which otherwise is a text format within content body, like <em><!--pagenames:First page||Page no. 2||Page 3--></em>. Disabled when an automatic paging method is selected.'),
'#default_value' => variable_get('paging_names_enabled_' . $type, 0),
'#attributes' => array(
'class' => 'paging-names',
),
);
// Set the browser's title to current page's name.
$form[$type]['paging_config']['paging_right']['paging_name_title_' . $type] = array(
'#type' => 'checkbox',
'#title' => t('Change page title to name of current page'),
'#description' => t("Change the node's and browser window's title into name of the current page."),
'#default_value' => variable_get('paging_name_title_' . $type, 0),
);
// Optional automatic paging method. Each option opens the corresponding character/word length select list.
// Accompanied by paging.admin.js.
$form[$type]['paging_config']['paging_right']['paging_automatic_method_' . $type] = array(
'#type' => 'radios',
'#title' => t('Automatic paging method'),
'#options' => array(
t('Disabled'),
t('Limit by characters <small>(recommended)</small>'),
t('Limit by words'),
),
'#required' => TRUE,
'#description' => t('Choose the method for automatic paging. Automatic paging is ignored where paging separator string is used.'),
'#default_value' => variable_get('paging_automatic_method_' . $type, 0),
'#attributes' => array(
'class' => 'paging-method',
),
);
// Automatic paging method. Select list to choose the number of characters per page.
$form[$type]['paging_config']['paging_right']['paging_automatic_chars_' . $type] = array(
'#type' => 'select',
'#title' => t('Length of each page'),
'#options' => array(
500 => t('500 characters'),
750 => t('750 characters'),
1000 => t('1000 characters'),
1500 => t('1500 characters'),
2000 => t('2000 characters'),
2500 => t('2500 characters'),
3000 => t('3000 characters'),
3500 => t('3500 characters'),
4000 => t('4000 characters'),
4500 => t('4500 characters'),
5000 => t('5000 characters'),
5500 => t('5500 characters'),
6000 => t('6000 characters'),
6500 => t('6500 characters'),
7000 => t('7000 characters'),
7500 => t('7500 characters'),
),
'#required' => TRUE,
'#description' => '<br />' . t('Select the number of characters to display per page.'),
'#default_value' => variable_get('paging_automatic_chars_' . $type, 4000),
'#prefix' => '<div class="container-inline paging-chars paging-chars-' . $type . '">',
'#suffix' => '</div>',
);
// Automatic paging method. Select list to choose the number of words per page.
$form[$type]['paging_config']['paging_right']['paging_automatic_words_' . $type] = array(
'#type' => 'select',
'#title' => t('Length of each page'),
'#options' => array(
50 => t('100 words'),
150 => t('150 words'),
200 => t('200 words'),
250 => t('250 words'),
300 => t('300 words'),
350 => t('350 words'),
400 => t('400 words'),
450 => t('450 words'),
500 => t('500 words'),
550 => t('550 words'),
600 => t('600 words'),
650 => t('650 words'),
700 => t('700 words'),
750 => t('750 words'),
),
'#required' => TRUE,
'#description' => '<br />' . t('Select the number of words to display per page.'),
'#default_value' => variable_get('paging_automatic_words_' . $type, 400),
'#prefix' => '<div class="container-inline paging-words paging-words-' . $type . '">',
'#suffix' => '</div>',
);
}
// Add HTML to setup tabbed interface.
$form['paging_footer'] = array(
'#value' => '<div id="paging-vertical-tabs"><ul class="ui-tabs-nav"></ul></div>',
);
// Vertical tabs for node types. Degrades in absence of JavaScript.
$module_path = drupal_get_path('module', 'paging');
drupal_add_js($module_path . '/admin/jquery.cookie.min.js', 'module');
drupal_add_js($module_path . '/admin/ui.tabs.min.js', 'module');
drupal_add_js($module_path . '/admin/paging.admin.js', 'module');
drupal_add_css($module_path . '/admin/paging.admin.css', 'module');
return system_settings_form($form);
}