function pagination_form_alter in Pagination (Node) 6
Same name and namespace in other branches
- 7 pagination.module \pagination_form_alter()
@desc Implementation of hook_form_alter()
File
- ./
pagination.module, line 439 - 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_form_alter(&$form, $form_state, $form_id) {
if ($form['#id'] != 'node-form') {
return;
}
$pg =& Pagination::getInstance();
$paging = $pg
->getValue($form['type']['#value']);
$style = $pg
->getStyle($form['type']['#value']);
$help = '';
if ($paging) {
$form['pagination'] = array(
'#type' => 'fieldset',
'#collapsible' => true,
'#collapsed' => (bool) variable_get('pagination_collapsed', 1),
'#title' => t('Page headers'),
'#weight' => -1,
'#attributes' => array(
'class' => 'pagination-item-form',
),
);
if ($paging == PAGINATION_CUSTOM) {
// Add helper text for manual paging (custom headers).
$help .= '<p>' . t('If you would like your article to flow over more than one page, insert a page break within the body of your content at a convenient location:') . '</p>';
$help .= '<p>' . t('<em>ex. <strong>[ pagebreak ]</strong></em>') . '</p>';
$help .= '<p>' . t('In addition, you may set a title for the specific page by using this syntax instead:') . '</p>';
$help .= '<p>' . t('<em>ex. <strong>[ header = My Section Title ]</strong></em>') . '</p>';
}
elseif ($paging == PAGINATION_TAG) {
$help .= '<p>' . t('Your article pages will break according to the presence of @tag tags. The contents of your @tag will be used as the page title.', array(
'@tag' => '<h3>',
)) . '</p>';
}
elseif ($paging > PAGINATION_AUTO and $style > PAGINATION_DEFAULT) {
drupal_add_js(drupal_get_path('module', 'pagination') . '/pagination.js');
// Add helper text for default paging.
$headers = isset($form['nid']['#value']) ? $pg
->getHeaders($form['nid']['#value']) : array();
$form['pagination']['pagination_headers'] = array(
'#type' => 'textarea',
'#title' => t('Page headers'),
'#rows' => 3,
'#description' => t('You may declare page headers here. The first line represents the title of the 2nd page. Note: the page estimate may be underestimated by one page (or so) in certain circumstances.'),
'#default_value' => implode("\n", $headers),
'#suffix' => t('<div>Current page estimate: <span id="pagination-guess">1 page</span> (<span id="pagination-count">%words</span> words per page)</div>', array(
'%words' => $paging,
)),
);
}
else {
$help .= '<p>' . t('Your article will paginate based upon an approximation of !number words per page.', array(
'!number' => $paging,
)) . '</p>';
}
$form['pagination']['#description'] = $help;
}
}