forwardport fixes for template section edit links from rel1_3
authorRiver Tarnell <kateturner@users.mediawiki.org>
Tue, 21 Sep 2004 16:56:48 +0000 (16:56 +0000)
committerRiver Tarnell <kateturner@users.mediawiki.org>
Tue, 21 Sep 2004 16:56:48 +0000 (16:56 +0000)
includes/Parser.php
includes/Skin.php

index 7ce3b15..1b27441 100644 (file)
@@ -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 <h#> tag
index bb14409..a4cb8f4 100644 (file)
@@ -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&section='.$section );
+               return '<span oncontextmenu=\'document.location="'.$url.'";return false;\'>'.$head.'</span>';
+       }
+
        function editSectionScript( $section, $head ) {
                global $wgTitle, $wgRequest;
                if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {