function Pagination::parseText in Pagination (Node) 6
Same name and namespace in other branches
- 7 includes/Pagination.inc \Pagination::parseText()
@desc Handle pagination depending on pagination style
Parameters
string text to paginate: @param int size of text to make breaks at @return string section of text @private
1 call to Pagination::parseText()
- Pagination::paginate in ./
pagination.module - @desc Paginate text
File
- ./
pagination.module, line 730 - 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 parseText(&$text, $cutoff) {
$page_count = empty($this->headers) ? count($this->headers) + 1 : count($this->headers);
$section = '';
switch ($cutoff) {
case 1:
// Manual breaks w/custom headers, for [ header = random ] we expect:
// 0: [ header = HEADER TEXT ]
// 4: HEADER TEXT
// for [ pagebreak ] we expect:
// 0: [ pagebreak ]
preg_match($this->re_custom, $text, $matches);
if (isset($matches[0])) {
$header = isset($matches[4]) && $matches[4] ? $matches[4] : t('Page !num', array(
'!num' => $page_count + 1,
));
$this
->setHeader($header);
$section = $this
->parseSection($text, $matches, 1, 5);
}
else {
// No matches, send back full text
$section = $text;
$text = '';
}
break;
case 2:
// Manual breaks w/h3 tags, we except:
// 0: <h3>HEADER TEXT</h3>
// 2: HEADER TEXT
$tag = 'h' . variable_get('pagination_header', 3);
if ('h3' !== $tag) {
$this->re_tag = str_replace('h3', $tag, $this->re_tag);
}
preg_match($this->re_tag, $text, $matches);
if (isset($matches[0])) {
$header = isset($matches[2]) ? $matches[2] : t('Page !num', array(
'!num' => $page_count + 1,
));
$this
->setHeader($header);
$section = $this
->parseSection($text, $matches, 1, 3);
}
else {
// No matches, send back full text
$section = $text;
$text = '';
}
break;
default:
// Paging by words, we'll use the english approximate 5 chars per word
// + space.
$header = t('Page !num', array(
'!num' => $page_count + 1,
));
$this
->setHeader($header);
$section = $this
->parseChunk($text, $cutoff * 6);
$text = substr($text, strlen($section));
break;
}
return $section;
}