From de6c1e033011a4b2c1e69255771062213080efd8 Mon Sep 17 00:00:00 2001 From: River Tarnell Date: Tue, 21 Sep 2004 16:56:48 +0000 Subject: [PATCH] forwardport fixes for template section edit links from rel1_3 --- includes/Parser.php | 12 +++++++----- includes/Skin.php | 6 ++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 7ce3b1595e..1b27441469 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1631,7 +1631,7 @@ class Parser $found = false; $nowiki = false; $noparse = false; - $brokenlink = false; + $itcamefromthedatabase = false; $title = NULL; @@ -1782,6 +1782,7 @@ class Parser if ( $articleContent !== false ) { $found = true; $text = $articleContent; + $itcamefromthedatabase = true; } } @@ -1789,7 +1790,6 @@ class Parser if ( $this->mOutputType == OT_HTML && !$found ) { $text = '[['.$title->getPrefixedText().']]'; $found = true; - $brokenlink = true; } # Template cache array insertion @@ -1842,13 +1842,12 @@ class Parser # Empties the template path $this->mTemplatePath = array(); - if ( !$found ) { return $matches[0]; } else { # replace ==section headers== # XXX this needs to go away once we have a better parser. - if ( $this->mOutputType != OT_WIKI && !$brokenlink ) { + if ( $this->mOutputType != OT_WIKI && $itcamefromthedatabase ) { if( !is_null( $title ) ) $encodedname = base64_encode($title->getPrefixedDBkey()); else @@ -2263,7 +2262,10 @@ class Parser # Add the edit section span if( $rightClickHack ) { - $headline = $sk->editSectionScript($sectionCount+1,$headline); + if( $istemplate ) + $headline = $sk->editSectionScriptForOther($templatetitle, $templatesection, $headline); + else + $headline = $sk->editSectionScript($sectionCount+1,$headline); } # give headline the correct tag diff --git a/includes/Skin.php b/includes/Skin.php index bb14409bb0..a4cb8f4e37 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -2716,6 +2716,12 @@ class Skin { * These two do not check for permissions: check $wgTitle->userCanEdit * before calling them */ + function editSectionScriptForOther( $title, $section, $head ) { + $ttl = Title::newFromText( $title ); + $url = $ttl->escapeLocalURL( 'action=edit§ion='.$section ); + return ''.$head.''; + } + function editSectionScript( $section, $head ) { global $wgTitle, $wgRequest; if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) { -- 2.20.1