summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2005-07-16 13:12:25 +0200
committerAndreas Gohr <andi@splitbrain.org>2005-07-16 13:12:25 +0200
commit87c434ceeeeb15fff4bbada53294c4dd63ecd9f6 (patch)
treed96783ad1c6aac24ec6c68226ffece22e8cf2255
parent42ccccebedab0b07d7f4bad082e82b32a08902ea (diff)
downloadrpg-87c434ceeeeb15fff4bbada53294c4dd63ecd9f6.tar.gz
rpg-87c434ceeeeb15fff4bbada53294c4dd63ecd9f6.tar.bz2
useheading fixes #460 #465
darcs-hash:20050716111225-7ad00-913c36c65ac1a985fea60eed57fc7391328bfacd.gz
-rw-r--r--inc/parserutils.php2
-rw-r--r--inc/template.php22
-rw-r--r--lib/tpl/default/main.php2
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()?>