' . DOKU_LF;
if ($opt['showcount'] === true) {
$render .= '
' . $count . '
' . DOKU_LF;
}
if ($opt['label'] !== '') {
$render .= '
' . $opt['label'] . '
' . DOKU_LF;
}
if ($multi_col) {
$render .= '
' . DOKU_LF;
}
// now render the pagequery list
foreach ($sorted_results as $line) {
[$level, $name, $id, $_, $abstract, $display] = $line;
$heading = '';
$is_heading = ($level > 0);
if ($is_heading) {
$heading = $name;
}
// is it time to start a new column?
if ($can_start_col === false && $col < $opt['cols'] && $cur_height >= $col_height) {
$can_start_col = true;
$col++;
}
// no need for indenting if there is no grouping
if ($can_indent) {
$indent = ($is_heading) ? $level - 1 : $cont_level - 1;
$indent_style = 'margin-left:' . $indent * 10 . 'px;';
}
// Begin new column if: 1) we are at the start, 2) last item was not a heading or 3) if there is no grouping
if (
$can_start_col
&& $prev_was_heading === false
) {
$jump_tip = sprintf($this->lang['jump_section'], $heading);
// close the previous column if necessary; also adds a 'jump to anchor'
$col_close = ($is_heading) ?
'' : '' . "";
$col_close = ($is_first) ? '' : $col_close . '' . DOKU_LF;
$col_open = (!$is_first && !$is_heading) ? ''
. $heading . '...' : '';
$td = ($multi_col) ? '' : '';
$render .= $col_close . $td . $col_open . DOKU_LF;
$can_start_col = false;
// needed to correctly style page link lists ...
$prev_was_heading = true;
$cur_height = 0;
}
// finally display the appropriate heading or page link(s)
if ($is_heading) {
// close previous sub list if necessary
if (!$prev_was_heading) {
$render .= ' ' . DOKU_LF;
}
if ($opt['nstitle'] && !empty($display)) {
$heading = $display;
}
if ($opt['proper'] === 'header' || $opt['proper'] === 'both') {
$heading = $this->proper($heading);
}
if (!empty($id)) {
$heading = $this->htmlWikilink($id, $heading, '', $opt, false, true);
}
$render .= '
' . $heading
. '' . DOKU_LF;
$prev_was_heading = true;
$cont_level = $level + 1;
} else {
// open a new sub list if necessary
if ($prev_was_heading || $is_first) {
$render .= '';
}
// deal with normal page links
if ($opt['proper'] === 'name' || $opt['proper'] === 'both') {
$display = $this->proper($display);
}
$link = $this->htmlWikilink($id, $display, $abstract, $opt);
$render .= $link;
$prev_was_heading = false;
}
$cur_height += $ratios[$level];
$is_first = false;
}
$render .= ' ' . DOKU_LF;
if ($multi_col) {
$render .= ' |
' . DOKU_LF;
}
if ($opt['hidejump'] === false) {
$render .= '
' . $this->lang['link_to_top'] . '' . DOKU_LF;
}
$render .= '
' . DOKU_LF;
return $render;
}
/**
* Used by the render_as_html_table function below
* **DEPRECATED**
*
* @param $sorted_results
* @param $ratios
*/
private function adjustedHeight($sorted_results, $ratios): int
{
// ratio of different heading heights (%), to ensure more even use of columns (h1 -> h6)
$adjusted_height = 0;
foreach ($sorted_results as $row) {
$adjusted_height += $ratios[$row[0]];
}
return $adjusted_height;
}
/**
* Changes a wiki page id into proper case (allowing for :'s etc...)
* @param string $id page id
*/
private function proper(string $id): string
{
$id = str_replace(':', ': ', $id); // make a little whitespace before words so ucwords can work!
$id = str_replace('_', ' ', $id);
$id = ucwords($id);
return str_replace(': ', ':', $id);
}
/**
* Renders the page link, plus tooltip, abstract, casing, etc...
* @param string $id
* @param string $display
* @param string $abstract
* @param array $opt
* @param bool $track_snippets
* @param bool $raw non-formatted (no html)
*/
private function htmlWikilink(
string $id,
string $display,
string $abstract,
array $opt,
bool $track_snippets = true,
bool $raw = false
): string {
$id = (strpos($id, ':') === false) ? ':' . $id : $id; // : needed for root pages (root level)
$link = html_wikilink($id, $display);
$type = $opt['snippet']['type'];
$inline = '';
$after = '';
if ($type === 'tooltip') {
$tooltip = str_replace("\n\n", "\n", $abstract);
$tooltip = htmlentities($tooltip, ENT_QUOTES, 'UTF-8');
$link = $this->addTooltip($link, $tooltip);
} elseif (in_array($type, ['quoted', 'plain', 'inline']) && $this->snippet_cnt > 0) {
$short = $this->shorten($abstract, $opt['snippet']['extent']);
$short = htmlentities($short, ENT_QUOTES, 'UTF-8');
if (!empty($short)) {
if ($type === 'quoted' || $type === 'plain') {
$more = html_wikilink($id, 'more');
$after = trim($short);
$after = str_replace("\n\n", "\n", $after);
$after = str_replace("\n", '' . $after . $more . '
' . DOKU_LF;
} elseif ($type === 'inline') {
$inline .= '' . $count . ' ā
' . DOKU_LF : '';
$label = ($opt['label'] !== '') ? '