Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -2271,6 +2271,7 @@ |
2272 | 2272 | 'export' => array( |
2273 | 2273 | 'export', |
2274 | 2274 | 'exporttext', |
| 2275 | + 'exportall', |
2275 | 2276 | 'exportcuronly', |
2276 | 2277 | 'exportnohistory', |
2277 | 2278 | 'exportlistauthors', |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -4773,6 +4773,11 @@ |
4774 | 4774 | */ |
4775 | 4775 | $wgExportFromNamespaces = false; |
4776 | 4776 | |
| 4777 | +/** |
| 4778 | +* Whether to allow exporting the entire wiki into a single file |
| 4779 | +*/ |
| 4780 | +$wgExportAllowAll = false; |
| 4781 | + |
4777 | 4782 | /** @} */ # end of import/export } |
4778 | 4783 | |
4779 | 4784 | /*************************************************************************//** |
Index: trunk/phase3/includes/specials/SpecialExport.php |
— | — | @@ -40,6 +40,7 @@ |
41 | 41 | public function execute( $par ) { |
42 | 42 | global $wgSitename, $wgExportAllowListContributors, $wgExportFromNamespaces; |
43 | 43 | global $wgExportAllowHistory, $wgExportMaxHistory, $wgExportMaxLinkDepth; |
| 44 | + global $wgExportAllowAll; |
44 | 45 | |
45 | 46 | $this->setHeaders(); |
46 | 47 | $this->outputHeader(); |
— | — | @@ -88,6 +89,10 @@ |
89 | 90 | } |
90 | 91 | } |
91 | 92 | } |
| 93 | + elseif( $request->getCheck( 'exportall' ) && $wgExportAllowAll ) { |
| 94 | + $this->doExport = true; |
| 95 | + $exportall = true; |
| 96 | + } |
92 | 97 | elseif( $request->wasPosted() && $par == '' ) { |
93 | 98 | $page = $request->getText( 'pages' ); |
94 | 99 | $this->curonly = $request->getCheck( 'curonly' ); |
— | — | @@ -165,7 +170,7 @@ |
166 | 171 | $request->response()->header( "Content-disposition: attachment;filename={$filename}" ); |
167 | 172 | } |
168 | 173 | |
169 | | - $this->doExport( $page, $history, $list_authors ); |
| 174 | + $this->doExport( $page, $history, $list_authors, $exportall ); |
170 | 175 | |
171 | 176 | return; |
172 | 177 | } |
— | — | @@ -183,6 +188,15 @@ |
184 | 189 | $form .= Xml::submitButton( wfMsg( 'export-addns' ), array( 'name' => 'addns' ) ) . '<br />'; |
185 | 190 | } |
186 | 191 | |
| 192 | + if ( $wgExportAllowAll ) { |
| 193 | + $form .= Xml::checkLabel( |
| 194 | + wfMsg( 'exportall' ), |
| 195 | + 'exportall', |
| 196 | + 'exportall', |
| 197 | + $request->wasPosted() ? $request->getCheck( 'exportall' ) : false |
| 198 | + ) . '<br />'; |
| 199 | + } |
| 200 | + |
187 | 201 | $form .= Xml::element( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ), $page, false ); |
188 | 202 | $form .= '<br />'; |
189 | 203 | |
— | — | @@ -245,50 +259,58 @@ |
246 | 260 | * @param $history Mixed: one of the WikiExporter history export constants |
247 | 261 | * @param $list_authors Boolean: Whether to add distinct author list (when |
248 | 262 | * not returning full history) |
| 263 | + * @param $exportall Boolean: Whether to export everything |
249 | 264 | */ |
250 | | - private function doExport( $page, $history, $list_authors ) { |
251 | | - $pageSet = array(); // Inverted index of all pages to look up |
| 265 | + private function doExport( $page, $history, $list_authors, $exportall ) { |
252 | 266 | |
253 | | - // Split up and normalize input |
254 | | - foreach( explode( "\n", $page ) as $pageName ) { |
255 | | - $pageName = trim( $pageName ); |
256 | | - $title = Title::newFromText( $pageName ); |
257 | | - if( $title && $title->getInterwiki() == '' && $title->getText() !== '' ) { |
258 | | - // Only record each page once! |
259 | | - $pageSet[$title->getPrefixedText()] = true; |
| 267 | + // If we are grabbing everything, enable full history and ignore the rest |
| 268 | + if ($exportall) { |
| 269 | + $history = WikiExporter::FULL; |
| 270 | + } else { |
| 271 | + |
| 272 | + $pageSet = array(); // Inverted index of all pages to look up |
| 273 | + |
| 274 | + // Split up and normalize input |
| 275 | + foreach( explode( "\n", $page ) as $pageName ) { |
| 276 | + $pageName = trim( $pageName ); |
| 277 | + $title = Title::newFromText( $pageName ); |
| 278 | + if( $title && $title->getInterwiki() == '' && $title->getText() !== '' ) { |
| 279 | + // Only record each page once! |
| 280 | + $pageSet[$title->getPrefixedText()] = true; |
| 281 | + } |
260 | 282 | } |
261 | | - } |
262 | 283 | |
263 | | - // Set of original pages to pass on to further manipulation... |
264 | | - $inputPages = array_keys( $pageSet ); |
| 284 | + // Set of original pages to pass on to further manipulation... |
| 285 | + $inputPages = array_keys( $pageSet ); |
265 | 286 | |
266 | | - // Look up any linked pages if asked... |
267 | | - if( $this->templates ) { |
268 | | - $pageSet = $this->getTemplates( $inputPages, $pageSet ); |
269 | | - } |
270 | | - $linkDepth = $this->pageLinkDepth; |
271 | | - if( $linkDepth ) { |
272 | | - $pageSet = $this->getPageLinks( $inputPages, $pageSet, $linkDepth ); |
273 | | - } |
| 287 | + // Look up any linked pages if asked... |
| 288 | + if( $this->templates ) { |
| 289 | + $pageSet = $this->getTemplates( $inputPages, $pageSet ); |
| 290 | + } |
| 291 | + $linkDepth = $this->pageLinkDepth; |
| 292 | + if( $linkDepth ) { |
| 293 | + $pageSet = $this->getPageLinks( $inputPages, $pageSet, $linkDepth ); |
| 294 | + } |
274 | 295 | |
275 | | - /* |
276 | | - // Enable this when we can do something useful exporting/importing image information. :) |
277 | | - if( $this->images ) ) { |
278 | | - $pageSet = $this->getImages( $inputPages, $pageSet ); |
279 | | - } |
280 | | - */ |
| 296 | + /* |
| 297 | + // Enable this when we can do something useful exporting/importing image information. :) |
| 298 | + if( $this->images ) ) { |
| 299 | + $pageSet = $this->getImages( $inputPages, $pageSet ); |
| 300 | + } |
| 301 | + */ |
281 | 302 | |
282 | | - $pages = array_keys( $pageSet ); |
| 303 | + $pages = array_keys( $pageSet ); |
283 | 304 | |
284 | | - // Normalize titles to the same format and remove dupes, see bug 17374 |
285 | | - foreach( $pages as $k => $v ) { |
286 | | - $pages[$k] = str_replace( " ", "_", $v ); |
| 305 | + // Normalize titles to the same format and remove dupes, see bug 17374 |
| 306 | + foreach( $pages as $k => $v ) { |
| 307 | + $pages[$k] = str_replace( " ", "_", $v ); |
| 308 | + } |
| 309 | + |
| 310 | + $pages = array_unique( $pages ); |
287 | 311 | } |
288 | 312 | |
289 | | - $pages = array_unique( $pages ); |
290 | | - |
291 | 313 | /* Ok, let's get to it... */ |
292 | | - if( $history == WikiExporter::CURRENT ) { |
| 314 | + if( $history == WikiExporter::CURRENT && ! $exportall ) { |
293 | 315 | $lb = false; |
294 | 316 | $db = wfGetDB( DB_SLAVE ); |
295 | 317 | $buffer = WikiExporter::BUFFER; |
— | — | @@ -308,7 +330,10 @@ |
309 | 331 | $exporter->list_authors = $list_authors; |
310 | 332 | $exporter->openStream(); |
311 | 333 | |
312 | | - foreach( $pages as $page ) { |
| 334 | + if ( $exportall ) { |
| 335 | + $exporter->allPages(); |
| 336 | + } else { |
| 337 | + foreach( $pages as $page ) { |
313 | 338 | /* |
314 | 339 | if( $wgExportMaxHistory && !$this->curonly ) { |
315 | 340 | $title = Title::newFromText( $page ); |
— | — | @@ -322,15 +347,16 @@ |
323 | 348 | } |
324 | 349 | }*/ |
325 | 350 | #Bug 8824: Only export pages the user can read |
326 | | - $title = Title::newFromText( $page ); |
327 | | - if( is_null( $title ) ) { |
328 | | - continue; #TODO: perhaps output an <error> tag or something. |
| 351 | + $title = Title::newFromText( $page ); |
| 352 | + if( is_null( $title ) ) { |
| 353 | + continue; #TODO: perhaps output an <error> tag or something. |
| 354 | + } |
| 355 | + if( !$title->userCan( 'read', $this->getUser() ) ) { |
| 356 | + continue; #TODO: perhaps output an <error> tag or something. |
| 357 | + } |
| 358 | + |
| 359 | + $exporter->pageByTitle( $title ); |
329 | 360 | } |
330 | | - if( !$title->userCan( 'read', $this->getUser() ) ) { |
331 | | - continue; #TODO: perhaps output an <error> tag or something. |
332 | | - } |
333 | | - |
334 | | - $exporter->pageByTitle( $title ); |
335 | 361 | } |
336 | 362 | |
337 | 363 | $exporter->closeStream(); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -3310,6 +3310,7 @@ |
3311 | 3311 | To export pages, enter the titles in the text box below, one title per line, and select whether you want the current revision as well as all old revisions, with the page history lines, or the current revision with the info about the last edit. |
3312 | 3312 | |
3313 | 3313 | In the latter case you can also use a link, for example [[{{#Special:Export}}/{{MediaWiki:Mainpage}}]] for the page "[[{{MediaWiki:Mainpage}}]]".', |
| 3314 | +'exportall' => 'Export all pages', |
3314 | 3315 | 'exportcuronly' => 'Include only the current revision, not the full history', |
3315 | 3316 | 'exportnohistory' => "---- |
3316 | 3317 | '''Note:''' Exporting the full history of pages through this form has been disabled due to performance reasons.", |