r24172 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24171‎ | r24172 | r24173 >
Date:17:04, 16 July 2007
Author:robchurch
Status:old
Tags:
Comment:
(bug 3173) Option to offer exported pages as a download, rather than displaying inline, as in most browsers; set Content-disposition: attachment with a filename incorporating the site name and timestamp. Defaults to being checked. Also rewrote the Export form generator to use Xml class methods; tweaked spacing on the existing check box. Tweaked English default for "exporttext".
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialExport.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1397,6 +1397,7 @@
13981398 'export-submit',
13991399 'export-addcattext',
14001400 'export-addcat',
 1401+ 'export-download',
14011402 ),
14021403 'allmessages' => array(
14031404 'allmessages',
Index: trunk/phase3/includes/SpecialExport.php
@@ -53,7 +53,7 @@
5454 *
5555 */
5656 function wfSpecialExport( $page = '' ) {
57 - global $wgOut, $wgRequest, $wgExportAllowListContributors;
 57+ global $wgOut, $wgRequest, $wgSitename, $wgExportAllowListContributors;
5858 global $wgExportAllowHistory, $wgExportMaxHistory;
5959
6060 $curonly = true;
@@ -131,6 +131,11 @@
132132 // This should provide safer streaming for pages with history
133133 wfResetOutputBuffers();
134134 header( "Content-type: application/xml; charset=utf-8" );
 135+ if( $wgRequest->getCheck( 'wpDownload' ) ) {
 136+ // Provide a sane filename suggestion
 137+ $filename = $wgSitename . '-' . wfTimestampNow() . '.xml';
 138+ $wgRequest->response()->header( "Content-disposition: attachment;filename={$filename}" );
 139+ }
135140 $pages = explode( "\n", $page );
136141
137142 $db = wfGetDB( DB_SLAVE );
@@ -164,25 +169,28 @@
165170 return;
166171 }
167172
168 - $wgOut->addWikiText( wfMsg( "exporttext" ) );
169 - $titleObj = SpecialPage::getTitleFor( "Export" );
 173+ $self = SpecialPage::getTitleFor( 'Export' );
 174+ $wgOut->addHtml( wfMsgExt( 'exporttext', 'parse' ) );
170175
171 - $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalUrl() ) );
172 -
173 - $form .= wfInputLabel( wfMsg( 'export-addcattext' ), 'catname', 'catname', 40 ) . ' ';
174 - $form .= wfSubmitButton( wfMsg( 'export-addcat' ), array( 'name' => 'addcat' ) ) . '<br />';
175 -
176 - $form .= wfOpenElement( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ) ) . htmlspecialchars($page). '</textarea><br />';
177 -
 176+ $form = Xml::openElement( 'form', array( 'method' => 'post',
 177+ 'action' => $self->getLocalUrl( 'action=submit' ) ) );
 178+
 179+ $form .= Xml::inputLabel( wfMsg( 'export-addcattext' ) , 'catname', 'catname', 40 ) . '&nbsp;';
 180+ $form .= Xml::submitButton( wfMsg( 'export-addcat' ), array( 'name' => 'addcat' ) ) . '<br />';
 181+
 182+ $form .= Xml::openElement( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ) );
 183+ $form .= htmlspecialchars( $page );
 184+ $form .= Xml::closeElement( 'textarea' );
 185+ $form .= '<br />';
 186+
178187 if( $wgExportAllowHistory ) {
179 - $form .= wfCheck( 'curonly', true, array( 'value' => 'true', 'id' => 'curonly' ) );
180 - $form .= wfLabel( wfMsg( 'exportcuronly' ), 'curonly' ) . '<br />';
 188+ $form .= Xml::checkLabel( wfMsg( 'exportcuronly' ), 'curonly', 'curonly', true ) . '<br />';
181189 } else {
182 - $wgOut->addWikiText( wfMsg( 'exportnohistory' ) );
 190+ $wgOut->addHtml( wfMsgExt( 'exportnohistory', 'parse' ) );
183191 }
184 - $form .= wfHidden( 'action', 'submit' );
185 - $form .= wfSubmitButton( wfMsg( 'export-submit' ) ) . '</form>';
 192+ $form .= Xml::checkLabel( wfMsg( 'export-download' ), 'wpDownload', 'wpDownload', true ) . '<br />';
 193+
 194+ $form .= Xml::submitButton( wfMsg( 'export-submit' ) );
 195+ $form .= Xml::closeElement( 'form' );
186196 $wgOut->addHtml( $form );
187 -}
188 -
189 -
 197+}
\ No newline at end of file
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2110,13 +2110,14 @@
21112111 select whether you want the current version as well as all old versions, with the page
21122112 history lines, or just the current version with the info about the last edit.
21132113
2114 -In the latter case you can also use a link, e.g. [[{{ns:Special}}:Export/{{MediaWiki:mainpage}}]] for the page {{MediaWiki:mainpage}}.',
 2114+In the latter case you can also use a link, e.g. [[{{ns:Special}}:Export/{{MediaWiki:mainpage}}]] for the page "[[{{MediaWiki:mainpage}}]]".',
21152115 'exportcuronly' => 'Include only the current revision, not the full history',
21162116 'exportnohistory' => "----
21172117 '''Note:''' Exporting the full history of pages through this form has been disabled due to performance reasons.",
21182118 'export-submit' => 'Export',
21192119 'export-addcattext' => 'Add pages from category:',
21202120 'export-addcat' => 'Add',
 2121+'export-download' => 'Offer to save as a file',
21212122
21222123 # Namespace 8 related
21232124 'allmessages' => 'System messages',
Index: trunk/phase3/RELEASE-NOTES
@@ -148,6 +148,8 @@
149149 than good. Proper handheld support will be added at a future date. For now,
150150 display should be acceptable either with CSS turned off or when using a so-
151151 phisticated handheld browser.
 152+* (bug 3173) Option to offer exported pages as a download, rather than displaying
 153+ inline, as in most browsers
152154
153155 == Bugfixes since 1.10 ==
154156

Follow-up revisions

RevisionCommit summaryAuthorDate
r24215Merged revisions 24095-24212 via svnmerge from...david21:19, 17 July 2007

Status & tagging log