(bug 3173) Option to offer exported pages as a download, rather than displaying inlin...
authorRob Church <robchurch@users.mediawiki.org>
Mon, 16 Jul 2007 17:04:39 +0000 (17:04 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 16 Jul 2007 17:04:39 +0000 (17:04 +0000)
RELEASE-NOTES
includes/SpecialExport.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index a2664fa..72a1b92 100644 (file)
@@ -148,6 +148,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   than good.  Proper handheld support will be added at a future date.  For now,
   display should be acceptable either with CSS turned off or when using a so-
   phisticated handheld browser.
+* (bug 3173) Option to offer exported pages as a download, rather than displaying
+  inline, as in most browsers
 
 == Bugfixes since 1.10 ==
 
index d8e767b..9822efa 100644 (file)
@@ -53,7 +53,7 @@ function wfExportGetPagesFromCategory( $title ) {
  *
  */
 function wfSpecialExport( $page = '' ) {
-       global $wgOut, $wgRequest, $wgExportAllowListContributors;
+       global $wgOut, $wgRequest, $wgSitename, $wgExportAllowListContributors;
        global $wgExportAllowHistory, $wgExportMaxHistory;
 
        $curonly = true;
@@ -131,6 +131,11 @@ function wfSpecialExport( $page = '' ) {
                // This should provide safer streaming for pages with history
                wfResetOutputBuffers();
                header( "Content-type: application/xml; charset=utf-8" );
+               if( $wgRequest->getCheck( 'wpDownload' ) ) {
+                       // Provide a sane filename suggestion
+                       $filename = $wgSitename . '-' . wfTimestampNow() . '.xml';
+                       $wgRequest->response()->header( "Content-disposition: attachment;filename={$filename}" );
+               }
                $pages = explode( "\n", $page );
 
                $db = wfGetDB( DB_SLAVE );
@@ -164,25 +169,28 @@ function wfSpecialExport( $page = '' ) {
                return;
        }
 
-       $wgOut->addWikiText( wfMsg( "exporttext" ) );
-       $titleObj = SpecialPage::getTitleFor( "Export" );
+       $self = SpecialPage::getTitleFor( 'Export' );
+       $wgOut->addHtml( wfMsgExt( 'exporttext', 'parse' ) );
+       
+       $form = Xml::openElement( 'form', array( 'method' => 'post',
+               'action' => $self->getLocalUrl( 'action=submit' ) ) );
+       
+       $form .= Xml::inputLabel( wfMsg( 'export-addcattext' )  , 'catname', 'catname', 40 ) . '&nbsp;';
+       $form .= Xml::submitButton( wfMsg( 'export-addcat' ), array( 'name' => 'addcat' ) ) . '<br />';
+       
+       $form .= Xml::openElement( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ) );
+       $form .= htmlspecialchars( $page );
+       $form .= Xml::closeElement( 'textarea' );
+       $form .= '<br />';
        
-       $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalUrl() ) );
-
-       $form .= wfInputLabel( wfMsg( 'export-addcattext' ), 'catname', 'catname', 40 ) . ' ';
-       $form .= wfSubmitButton( wfMsg( 'export-addcat' ), array( 'name' => 'addcat' ) ) . '<br />';
-
-       $form .= wfOpenElement( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ) ) . htmlspecialchars($page). '</textarea><br />';
-
        if( $wgExportAllowHistory ) {
-               $form .= wfCheck( 'curonly', true, array( 'value' => 'true', 'id' => 'curonly' ) );
-               $form .= wfLabel( wfMsg( 'exportcuronly' ), 'curonly' ) . '<br />';
+               $form .= Xml::checkLabel( wfMsg( 'exportcuronly' ), 'curonly', 'curonly', true ) . '<br />';
        } else {
-               $wgOut->addWikiText( wfMsg( 'exportnohistory' ) );
+               $wgOut->addHtml( wfMsgExt( 'exportnohistory', 'parse' ) );
        }
-       $form .= wfHidden( 'action', 'submit' );
-       $form .= wfSubmitButton( wfMsg( 'export-submit' ) ) . '</form>';
+       $form .= Xml::checkLabel( wfMsg( 'export-download' ), 'wpDownload', 'wpDownload', true ) . '<br />';
+       
+       $form .= Xml::submitButton( wfMsg( 'export-submit' ) );
+       $form .= Xml::closeElement( 'form' );
        $wgOut->addHtml( $form );
-}
-
-
+}
\ No newline at end of file
index 5f7aa3e..7d43aad 100644 (file)
@@ -2110,13 +2110,14 @@ To export pages, enter the titles in the text box below, one title per line, and
 select whether you want the current version as well as all old versions, with the page
 history lines, or just the current version with the info about the last edit.
 
-In the latter case you can also use a link, e.g. [[{{ns:Special}}:Export/{{MediaWiki:mainpage}}]] for the page {{MediaWiki:mainpage}}.',
+In the latter case you can also use a link, e.g. [[{{ns:Special}}:Export/{{MediaWiki:mainpage}}]] for the page "[[{{MediaWiki:mainpage}}]]".',
 'exportcuronly'     => 'Include only the current revision, not the full history',
 'exportnohistory'   => "----
 '''Note:''' Exporting the full history of pages through this form has been disabled due to performance reasons.",
 'export-submit'     => 'Export',
 'export-addcattext' => 'Add pages from category:',
 'export-addcat'     => 'Add',
+'export-download' => 'Offer to save as a file',
 
 # Namespace 8 related
 'allmessages'               => 'System messages',
index 439ef53..fa0cfb8 100644 (file)
@@ -1397,6 +1397,7 @@ $wgMessageStructure = array(
                'export-submit',
                'export-addcattext',
                'export-addcat',
+               'export-download',
        ),
        'allmessages' => array(
                'allmessages',