From 87c434ceeeeb15fff4bbada53294c4dd63ecd9f6 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Sat, 16 Jul 2005 13:12:25 +0200 Subject: [PATCH] useheading fixes #460 #465 darcs-hash:20050716111225-7ad00-913c36c65ac1a985fea60eed57fc7391328bfacd.gz --- inc/parserutils.php | 2 +- inc/template.php | 22 ++++++++++++++++++++++ lib/tpl/default/main.php | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/inc/parserutils.php b/inc/parserutils.php index 1dbc1430f..349e83725 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -321,7 +321,7 @@ function p_get_first_heading($id){ $instructions = p_cached_instructions($file,true); foreach ( $instructions as $instruction ) { if ($instruction[0] == 'header') { - return $instruction[1][0]; + return trim($instruction[1][0]); } } } diff --git a/inc/template.php b/inc/template.php index b635f6093..1ee995b5c 100644 --- a/inc/template.php +++ b/inc/template.php @@ -676,5 +676,27 @@ function tpl_mediauploadform(){ ptln('</form>',2); } +/** + * Prints the name of the given page (current one if none given). + * + * If useheading is enabled this will use the first headline else + * the given ID is printed. + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tpl_pagetitle($id=null){ + global $conf; + if(is_null($id)){ + global $ID; + $id = $ID; + } + + $name = $id; + if ($conf['useheading']) { + $title = p_get_first_heading($id); + if ($title) $name = $title; + } + print hsc($name); +} //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/lib/tpl/default/main.php b/lib/tpl/default/main.php index b3b0d5de1..7d3c1c46f 100644 --- a/lib/tpl/default/main.php +++ b/lib/tpl/default/main.php @@ -17,7 +17,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang']?>" lang="<?php echo $conf['lang']?>" dir="<?php echo $lang['direction']?>"> <head> - <title><?php echo $ID?> [<?php echo hsc($conf['title'])?>]</title> + <title><?php tpl_pagetitle()?> [<?php echo hsc($conf['title'])?>]</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php tpl_metaheaders()?> -- GitLab