Index: trunk/extensions/DataTransfer/includes/DT_Utils.php |
— | — | @@ -0,0 +1,79 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Utility functions for the Data Transfer extension. |
| 6 | + * |
| 7 | + * @author Yaron Koren |
| 8 | + */ |
| 9 | +class DTUtils { |
| 10 | + |
| 11 | + static function printImportingMessage() { |
| 12 | + return "\t" . Xml::element( 'p', null, wfMsg( 'dt_import_importing' ) ) . "\n"; |
| 13 | + } |
| 14 | + |
| 15 | + static function printFileSelector( $fileType ) { |
| 16 | + $text = "\n\t" . Xml::element( 'p', null, wfMsg( 'dt_import_selectfile', $fileType ) ) . "\n"; |
| 17 | + $text .= <<<END |
| 18 | + <p><input type="file" name="file_name" size="25" /></p> |
| 19 | + |
| 20 | +END; |
| 21 | + $text .= "\t" . '<hr style="margin: 10px 0 10px 0" />' . "\n"; |
| 22 | + return $text; |
| 23 | + } |
| 24 | + |
| 25 | + static function printExistingPagesHandling() { |
| 26 | + $text = "\t" . Xml::element( 'p', null, wfMsg( 'dt_import_forexisting' ) ) . "\n"; |
| 27 | + $existingPagesText = "\n\t" . |
| 28 | + Xml::element( 'input', |
| 29 | + array( |
| 30 | + 'type' => 'radio', |
| 31 | + 'name' => 'pagesThatExist', |
| 32 | + 'value' => 'overwrite', |
| 33 | + 'checked' => 'checked' |
| 34 | + ) ) . "\n" . |
| 35 | + "\t" . wfMsg( 'dt_import_overwriteexisting' ) . "<br />" . "\n" . |
| 36 | + "\t" . Xml::element( 'input', |
| 37 | + array( |
| 38 | + 'type' => 'radio', |
| 39 | + 'name' => 'pagesThatExist', |
| 40 | + 'value' => 'skip', |
| 41 | + ) ) . "\n" . |
| 42 | + "\t" . wfMsg( 'dt_import_skipexisting' ) . "<br />" . "\n" . |
| 43 | + "\t" . Xml::element( 'input', |
| 44 | + array( |
| 45 | + 'type' => 'radio', |
| 46 | + 'name' => 'pagesThatExist', |
| 47 | + 'value' => 'append', |
| 48 | + ) ) . "\n" . |
| 49 | + "\t" . wfMsg( 'dt_import_appendtoexisting' ) . "<br />" . "\n\t"; |
| 50 | + $text .= "\t" . Xml::tags( 'p', null, $existingPagesText ) . "\n"; |
| 51 | + $text .= "\t" . '<hr style="margin: 10px 0 10px 0" />' . "\n"; |
| 52 | + return $text; |
| 53 | + } |
| 54 | + |
| 55 | + static function printImportSummaryInput( $fileType ) { |
| 56 | + $importSummaryText = "\t" . Xml::element( 'input', |
| 57 | + array( |
| 58 | + 'type' => 'text', |
| 59 | + 'id' => 'wpSummary', // ID is necessary for CSS formatting |
| 60 | + 'class' => 'mw-summary', |
| 61 | + 'name' => 'import_summary', |
| 62 | + 'value' => wfMsgForContent( 'dt_import_editsummary', $fileType ) |
| 63 | + ) |
| 64 | + ) . "\n"; |
| 65 | + return "\t" . Xml::tags( 'p', null, |
| 66 | + wfMsg( 'dt_import_summarydesc' ) . "\n" . |
| 67 | + $importSummaryText ) . "\n"; |
| 68 | + } |
| 69 | + |
| 70 | + static function printSubmitButton() { |
| 71 | + $formSubmitText = Xml::element( 'input', |
| 72 | + array( |
| 73 | + 'type' => 'submit', |
| 74 | + 'name' => 'import_file', |
| 75 | + 'value' => wfMsg( 'import-interwiki-submit' ) |
| 76 | + ) |
| 77 | + ); |
| 78 | + return "\t" . Xml::tags( 'p', null, $formSubmitText ) . "\n"; |
| 79 | + } |
| 80 | +} |