r5359 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5358‎ | r5359 | r5360 >
Date:16:56, 21 September 2004
Author:kateturner
Status:old
Tags:
Comment:
forwardport fixes for template section edit links from rel1_3
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -1631,7 +1631,7 @@
16321632 $found = false;
16331633 $nowiki = false;
16341634 $noparse = false;
1635 - $brokenlink = false;
 1635+ $itcamefromthedatabase = false;
16361636
16371637 $title = NULL;
16381638
@@ -1782,6 +1782,7 @@
17831783 if ( $articleContent !== false ) {
17841784 $found = true;
17851785 $text = $articleContent;
 1786+ $itcamefromthedatabase = true;
17861787 }
17871788 }
17881789
@@ -1789,7 +1790,6 @@
17901791 if ( $this->mOutputType == OT_HTML && !$found ) {
17911792 $text = '[['.$title->getPrefixedText().']]';
17921793 $found = true;
1793 - $brokenlink = true;
17941794 }
17951795
17961796 # Template cache array insertion
@@ -1842,13 +1842,12 @@
18431843
18441844 # Empties the template path
18451845 $this->mTemplatePath = array();
1846 -
18471846 if ( !$found ) {
18481847 return $matches[0];
18491848 } else {
18501849 # replace ==section headers==
18511850 # XXX this needs to go away once we have a better parser.
1852 - if ( $this->mOutputType != OT_WIKI && !$brokenlink ) {
 1851+ if ( $this->mOutputType != OT_WIKI && $itcamefromthedatabase ) {
18531852 if( !is_null( $title ) )
18541853 $encodedname = base64_encode($title->getPrefixedDBkey());
18551854 else
@@ -2263,7 +2262,10 @@
22642263
22652264 # Add the edit section span
22662265 if( $rightClickHack ) {
2267 - $headline = $sk->editSectionScript($sectionCount+1,$headline);
 2266+ if( $istemplate )
 2267+ $headline = $sk->editSectionScriptForOther($templatetitle, $templatesection, $headline);
 2268+ else
 2269+ $headline = $sk->editSectionScript($sectionCount+1,$headline);
22682270 }
22692271
22702272 # give headline the correct <h#> tag
Index: trunk/phase3/includes/Skin.php
@@ -2716,6 +2716,12 @@
27172717 * These two do not check for permissions: check $wgTitle->userCanEdit
27182718 * before calling them
27192719 */
 2720+ function editSectionScriptForOther( $title, $section, $head ) {
 2721+ $ttl = Title::newFromText( $title );
 2722+ $url = $ttl->escapeLocalURL( 'action=edit&section='.$section );
 2723+ return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
 2724+ }
 2725+
27202726 function editSectionScript( $section, $head ) {
27212727 global $wgTitle, $wgRequest;
27222728 if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {

Status & tagging log