diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/common.php | 2 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 14 | ||||
-rw-r--r-- | inc/parserutils.php | 19 |
3 files changed, 31 insertions, 4 deletions
diff --git a/inc/common.php b/inc/common.php index 74dc13cea..b44255c34 100644 --- a/inc/common.php +++ b/inc/common.php @@ -131,7 +131,7 @@ function breadcrumbs(){ $name = noNS($ID); if ($conf['useheading']) { // get page title - $title = getFirstHeading(io_readFile($file)); + $title = p_get_first_heading($ID); if ($title) { $name = $title; } diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 23e351b84..b85aa911e 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -391,7 +391,7 @@ class Doku_Renderer_XHTML extends Doku_Renderer { function internallink($id, $name = NULL) { global $conf; - $name = $this->__getLinkTitle($name, $this->__simpleTitle($id), $isImage); + $name = $this->__getLinkTitle($name, $this->__simpleTitle($id), $isImage, $id); resolve_pageid($id,$exists); if ( !$isImage ) { @@ -857,11 +857,19 @@ class Doku_Renderer_XHTML extends Doku_Renderer { print '<!-- SECTION ['.$f.'-'.$t.'] -->'; } - function __getLinkTitle($title, $default, & $isImage) { + function __getLinkTitle($title, $default, & $isImage, $id=NULL) { + global $conf; + $isImage = FALSE; if ( is_null($title) ) { - return $this->__xmlEntities($default); + if ($conf['useheading'] && $id) { + $heading = p_get_first_heading($id); + if ($heading) { + return $this->__xmlEntities($heading); + } + } + return $this->__xmlEntities($default); } else if ( is_string($title) ) { diff --git a/inc/parserutils.php b/inc/parserutils.php index e2b4e9feb..e190a0af7 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -235,4 +235,23 @@ function p_render_xhtml($instructions){ return $Renderer->doc; } +/** + * Gets the first heading from a file + * + * @author Jan Decaluwe <jan@jandecaluwe.com> + */ + +function p_get_first_heading($id){ + $file = wikiFN($id); + if (@file_exists($file)) { + $instructions = p_cached_instructions($file); + foreach ( $instructions as $instruction ) { + if ($instruction[0] == 'header') { + return $instruction[1][0]; + } + } + } + return NULL; +} + //Setup VIM: ex: et ts=2 enc=utf-8 : |