X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialExport.php;h=39c4d771119579dfd0951ff55d1b655e02d76d16;hp=c30d962a99f70d6dfc2cf8ad7178d2bd4d7ca23e;hb=59ebff658ce912c1b0e7ef8d8f9bfec5a4e17b39;hpb=4834574f631fba4d468183701a198d995b71ce86 diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php index c30d962a99..39c4d77111 100644 --- a/includes/specials/SpecialExport.php +++ b/includes/specials/SpecialExport.php @@ -30,7 +30,6 @@ */ class SpecialExport extends SpecialPage { private $curonly, $doExport, $pageLinkDepth, $templates; - private $images; public function __construct() { parent::__construct( 'Export' ); @@ -46,7 +45,6 @@ class SpecialExport extends SpecialPage { $this->doExport = false; $request = $this->getRequest(); $this->templates = $request->getCheck( 'templates' ); - $this->images = $request->getCheck( 'images' ); // Doesn't do anything yet $this->pageLinkDepth = $this->validateLinkDepth( $request->getIntOrNull( 'pagelink-depth' ) ); @@ -188,113 +186,122 @@ class SpecialExport extends SpecialPage { $categoryName = ''; } - $form = Xml::openElement( 'form', array( 'method' => 'post', - 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ) ) ); - $form .= Xml::inputLabel( - $this->msg( 'export-addcattext' )->text(), - 'catname', - 'catname', - 40, - $categoryName - ) . ' '; - $form .= Xml::submitButton( - $this->msg( 'export-addcat' )->text(), - array( 'name' => 'addcat' ) - ) . '
'; - + $formDescriptor = array( + 'catname' => array( + 'type' => 'textwithbutton', + 'name' => 'catname', + 'horizontal-label' => true, + 'label-message' => 'export-addcattext', + 'default' => $categoryName, + 'size' => 40, + 'buttontype' => 'submit', + 'buttonname' => 'addcat', + 'buttondefault' => $this->msg( 'export-addcat' )->text(), + ), + ); if ( $config->get( 'ExportFromNamespaces' ) ) { - $form .= Html::namespaceSelector( - array( - 'selected' => $nsindex, - 'label' => $this->msg( 'export-addnstext' )->text() - ), array( + $formDescriptor += array( + 'nsindex' => array( + 'type' => 'namespaceselectwithbutton', + 'default' => $nsindex, + 'label-message' => 'export-addnstext', + 'horizontal-label' => true, 'name' => 'nsindex', 'id' => 'namespace', - 'class' => 'namespaceselector', - ) - ) . ' '; - $form .= Xml::submitButton( - $this->msg( 'export-addns' )->text(), - array( 'name' => 'addns' ) - ) . '
'; + 'cssclass' => 'namespaceselector', + 'buttontype' => 'submit', + 'buttonname' => 'addns', + 'buttondefault' => $this->msg( 'export-addns' )->text(), + ), + ); } if ( $config->get( 'ExportAllowAll' ) ) { - $form .= Xml::checkLabel( - $this->msg( 'exportall' )->text(), - 'exportall', - 'exportall', - $request->wasPosted() ? $request->getCheck( 'exportall' ) : false - ) . '
'; + $formDescriptor += array( + 'exportall' => array( + 'type' => 'check', + 'label-message' => 'exportall', + 'name' => 'exportall', + 'id' => 'exportall', + 'default' => $request->wasPosted() ? $request->getCheck( 'exportall' ) : false, + ), + ); } - $form .= Xml::element( - 'textarea', - array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ), - $page, - false + $formDescriptor += array( + 'textarea' => array( + 'class' => 'HTMLTextAreaField', + 'name' => 'pages', + 'nodata' => true, + 'cols' => 40, + 'rows' => 10, + 'default' => $page, + ), ); - $form .= '
'; if ( $config->get( 'ExportAllowHistory' ) ) { - $form .= Xml::checkLabel( - $this->msg( 'exportcuronly' )->text(), - 'curonly', - 'curonly', - $request->wasPosted() ? $request->getCheck( 'curonly' ) : true - ) . '
'; + $formDescriptor += array( + 'curonly' => array( + 'type' => 'check', + 'label-message' => 'exportcuronly', + 'name' => 'curonly', + 'id' => 'curonly', + 'default' => $request->wasPosted() ? $request->getCheck( 'curonly' ) : true, + ), + ); } else { $out->addWikiMsg( 'exportnohistory' ); } - $form .= Xml::checkLabel( - $this->msg( 'export-templates' )->text(), - 'templates', - 'wpExportTemplates', - $request->wasPosted() ? $request->getCheck( 'templates' ) : false - ) . '
'; + $formDescriptor += array( + 'templates' => array( + 'type' => 'check', + 'label-message' => 'export-templates', + 'name' => 'templates', + 'id' => 'wpExportTemplates', + 'default' => $request->wasPosted() ? $request->getCheck( 'templates' ) : false, + ), + ); if ( $config->get( 'ExportMaxLinkDepth' ) || $this->userCanOverrideExportDepth() ) { - $form .= Xml::inputLabel( - $this->msg( 'export-pagelinks' )->text(), - 'pagelink-depth', - 'pagelink-depth', - 20, - 0 - ) . '
'; + $formDescriptor += array( + 'pagelink-depth' => array( + 'type' => 'text', + 'name' => 'pagelink-depth', + 'id' => 'pagelink-depth', + 'label-message' => 'export-pagelinks', + 'default' => '0', + 'size' => 20, + ), + ); } - /* Enable this when we can do something useful exporting/importing image information. - $form .= Xml::checkLabel( - $this->msg( 'export-images' )->text(), - 'images', - 'wpExportImages', - false - ) . '
'; - */ - $form .= Xml::checkLabel( - $this->msg( 'export-download' )->text(), - 'wpDownload', - 'wpDownload', - $request->wasPosted() ? $request->getCheck( 'wpDownload' ) : true - ) . '
'; + $formDescriptor += array( + 'wpDownload' => array( + 'type' => 'check', + 'name' =>'wpDownload', + 'id' => 'wpDownload', + 'default' => $request->wasPosted() ? $request->getCheck( 'wpDownload' ) : true, + 'label-message' => 'export-download', + ), + ); if ( $config->get( 'ExportAllowListContributors' ) ) { - $form .= Xml::checkLabel( - $this->msg( 'exportlistauthors' )->text(), - 'listauthors', - 'listauthors', - $request->wasPosted() ? $request->getCheck( 'listauthors' ) : false - ) . '
'; + $formDescriptor += array( + 'listauthors' => array( + 'type' => 'check', + 'label-message' => 'exportlistauthors', + 'default' => $request->wasPosted() ? $request->getCheck( 'listauthors' ) : false, + 'name' => 'listauthors', + 'id' => 'listauthors', + ), + ); } - $form .= Xml::submitButton( - $this->msg( 'export-submit' )->text(), - Linker::tooltipAndAccesskeyAttribs( 'export' ) - ); - $form .= Xml::closeElement( 'form' ); - - $out->addHTML( $form ); + $htmlForm = HTMLForm::factory( 'div', $formDescriptor, $this->getContext() ); + $htmlForm->setSubmitTextMsg( 'export-submit' ); + $htmlForm->prepareForm()->displayForm( false ); + $this->addHelpLink( 'Help:Export' ); } /** @@ -319,7 +326,6 @@ class SpecialExport extends SpecialPage { if ( $exportall ) { $history = WikiExporter::FULL; } else { - $pageSet = array(); // Inverted index of all pages to look up // Split up and normalize input @@ -344,11 +350,6 @@ class SpecialExport extends SpecialPage { $pageSet = $this->getPageLinks( $inputPages, $pageSet, $linkDepth ); } - // Enable this when we can do something useful exporting/importing image information. - // if( $this->images ) ) { - // $pageSet = $this->getImages( $inputPages, $pageSet ); - // } - $pages = array_keys( $pageSet ); // Normalize titles to the same format and remove dupes, see bug 17374 @@ -371,9 +372,9 @@ class SpecialExport extends SpecialPage { $buffer = WikiExporter::STREAM; // This might take a while... :D - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); set_time_limit( 0 ); - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); } $exporter = new WikiExporter( $db, $history, $buffer ); @@ -534,24 +535,6 @@ class SpecialExport extends SpecialPage { return $pageSet; } - /** - * Expand a list of pages to include images used in those pages. - * - * @param array $inputPages List of titles to look up - * @param array $pageSet Associative array indexed by titles for output - * - * @return array Associative array index by titles - */ - private function getImages( $inputPages, $pageSet ) { - return $this->getLinks( - $inputPages, - $pageSet, - 'imagelinks', - array( 'namespace' => NS_FILE, 'title' => 'il_to' ), - array( 'page_id=il_from' ) - ); - } - /** * Expand a list of pages to include items used in those pages. * @param array $inputPages Array of page titles