function Pagination::getToc in Pagination (Node) 6
Same name and namespace in other branches
- 7 includes/Pagination.inc \Pagination::getToc()
@desc Get a themed Table of Contents
Parameters
int nid: @param boolean flag to ignore h4 title when rendered ToC in a block. @return string themed ToC @public
File
- ./
pagination.module, line 650 - 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…
Class
- Pagination
- @desc Handles all the pagination logic
Code
function getToc($nid, $ignore_title = FALSE) {
if (!$nid) {
return;
}
drupal_add_css(drupal_get_path('module', 'pagination') . '/pagination.css');
$toc = array();
$headers = $this
->getHeaders($nid);
$headers[0] = menu_get_active_title();
foreach ($headers as $key => $header) {
$page = $key + 1;
$header = str_replace(array(
'<br />',
'<br>',
), '', $header);
$options = array(
'attributes' => array(
'title' => t('Go to page !page', array(
'!page' => $page,
)),
),
'query' => 'page=' . $page,
);
$toc[] = array(
'data' => $this
->getPageVar() == $key ? check_plain($header) : l($header, $_GET['q'], $options),
'class' => $this
->getPageVar() == $key ? 'pagination-toc-item current' : 'pagination-toc-item',
);
}
$items = theme('item_list', $toc, null, variable_get('pagination_list_type', 'ul'), array(
'class' => 'pagination-toc-list',
));
// Avoid problems with special chars displaying, likely not an exhaustive
// regex.
$items = preg_replace('#&(\\S{2,7}[^;];)#e', "'&\$1'", $items);
$toc_title = $ignore_title ? NULL : t('Table of Contents:');
$toc = theme('pagination_toc', $toc_title, drupal_get_title(), $items);
return $toc;
}