Merge the iwtransclusion branch back into trunk
[lhc/web/wiklou.git] / includes / EditPage.php
index 28032da..20a1f48 100644 (file)
@@ -1313,7 +1313,7 @@ class EditPage {
         *     during form output near the top, for captchas and the like.
         */
        function showEditForm( $formCallback = null ) {
-               global $wgOut, $wgUser;
+               global $wgOut, $wgUser, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking;
 
                wfProfileIn( __METHOD__ );
 
@@ -1347,7 +1347,6 @@ class EditPage {
                        $toolbar = '';
                }
 
-
                $wgOut->addHTML( $this->editFormPageTop );
 
                if ( $wgUser->getOption( 'previewontop' ) ) {
@@ -1359,6 +1358,9 @@ class EditPage {
                $templates = $this->getTemplates();
                $formattedtemplates = Linker::formatTemplates( $templates, $this->preview, $this->section != '');
 
+               $distantTemplates = $this->getDistantTemplates();
+               $formattedDistantTemplates = Linker::formatDistantTemplates( $distantTemplates, $this->preview, $this->section != '' );
+
                $hiddencats = $this->mArticle->getHiddenCategories();
                $formattedhiddencats = Linker::formatHiddenCategories( $hiddencats );
 
@@ -1457,6 +1459,21 @@ HTML
 <div class='templatesUsed'>
 {$formattedtemplates}
 </div>
+HTML
+);
+
+               if ( $wgEnableInterwikiTranscluding && $wgEnableInterwikiTemplatesTracking ) {
+                                       $wgOut->addHTML( <<<HTML
+{$this->editFormTextAfterTools}
+<div class='distantTemplatesUsed'>
+{$formattedDistantTemplates}
+</div>
+HTML
+);
+               }
+
+               $wgOut->addHTML( <<<HTML
+{$this->editFormTextAfterTools}
 <div class='hiddencats'>
 {$formattedhiddencats}
 </div>
@@ -2118,6 +2135,28 @@ HTML
                }
        }
 
+       function getDistantTemplates() {
+               global $wgEnableInterwikiTemplatesTracking;
+               if ( !$wgEnableInterwikiTemplatesTracking ) {
+                       return array( );
+               }
+               if ( $this->preview || $this->section != '' ) {
+                       $templates = array();
+                       if ( !isset( $this->mParserOutput ) ) return $templates;
+                       $templatesList = $this->mParserOutput->getDistantTemplates();
+                       foreach( $templatesList as $prefix => $templatesbyns ) {
+                               foreach( $templatesbyns as $ns => $template ) {
+                                       foreach( array_keys( $template ) as $dbk ) {
+                                               $templates[] = Title::makeTitle( $ns, $dbk, null, $prefix );
+                                       }
+                               }
+                       }
+                       return $templates;
+               } else {
+                       return $this->mArticle->getUsedDistantTemplates();
+               }
+       }
+
        /**
         * Call the stock "user is blocked" page
         */