/** @var Title */
private $mTargetObj;
+ /**
+ * @var string Search prefix
+ */
+ private $mSearchPrefix;
function __construct() {
parent::__construct( 'Undelete', 'deletedhistory' );
function showSearchForm() {
$out = $this->getOutput();
$out->setPageTitle( $this->msg( 'undelete-search-title' ) );
- $out->addHTML(
- Xml::openElement( 'form', [ 'method' => 'get', 'action' => wfScript() ] ) .
- Xml::fieldset( $this->msg( 'undelete-search-box' )->text() ) .
+ $fuzzySearch = $this->getRequest()->getVal( 'fuzzy', false );
+
+ $out->enableOOUI();
+
+ $fields[] = new OOUI\ActionFieldLayout(
+ new OOUI\TextInputWidget( [
+ 'name' => 'prefix',
+ 'inputId' => 'prefix',
+ 'infusable' => true,
+ 'value' => $this->mSearchPrefix,
+ 'autofocus' => true,
+ ] ),
+ new OOUI\ButtonInputWidget( [
+ 'label' => $this->msg( 'undelete-search-submit' )->text(),
+ 'flags' => [ 'primary', 'progressive' ],
+ 'inputId' => 'searchUndelete',
+ 'type' => 'submit',
+ ] ),
+ [
+ 'label' => new OOUI\HtmlSnippet(
+ $this->msg(
+ $fuzzySearch ? 'undelete-search-full' : 'undelete-search-prefix'
+ )->parse()
+ ),
+ 'align' => 'left',
+ ]
+ );
+
+ $fieldset = new OOUI\FieldsetLayout( [
+ 'label' => $this->msg( 'undelete-search-box' )->text(),
+ 'items' => $fields,
+ ] );
+
+ $form = new OOUI\FormLayout( [
+ 'method' => 'get',
+ 'action' => wfScript(),
+ ] );
+
+ $form->appendContent(
+ $fieldset,
+ new OOUI\HtmlSnippet(
Html::hidden( 'title', $this->getPageTitle()->getPrefixedDBkey() ) .
- Html::rawElement(
- 'label',
- [ 'for' => 'prefix' ],
- $this->msg( 'undelete-search-prefix' )->parse()
- ) .
- Xml::input(
- 'prefix',
- 20,
- $this->mSearchPrefix,
- [ 'id' => 'prefix', 'autofocus' => '' ]
- ) . ' ' .
- Xml::submitButton( $this->msg( 'undelete-search-submit' )->text() ) .
- Xml::closeElement( 'fieldset' ) .
- Xml::closeElement( 'form' )
+ Html::hidden( 'fuzzy', $this->getRequest()->getVal( 'fuzzy' ) )
+ )
+ );
+
+ $out->addHTML(
+ new OOUI\PanelLayout( [
+ 'expanded' => false,
+ 'padded' => true,
+ 'framed' => true,
+ 'content' => $form,
+ ] )
);
# List undeletable articles
if ( $this->mSearchPrefix ) {
- $result = PageArchive::listPagesByPrefix( $this->mSearchPrefix );
+ // For now, we enable search engine match only when specifically asked to
+ // by using fuzzy=1 parameter.
+ if ( $fuzzySearch ) {
+ $result = PageArchive::listPagesBySearch( $this->mSearchPrefix );
+ } else {
+ $result = PageArchive::listPagesByPrefix( $this->mSearchPrefix );
+ }
$this->showList( $result );
}
}
$linkRenderer = $this->getLinkRenderer();
$undelete = $this->getPageTitle();
- $out->addHTML( "<ul>\n" );
+ $out->addHTML( "<ul id='undeleteResultsList'>\n" );
foreach ( $result as $row ) {
$title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
if ( $title !== null ) {
);
}
$revs = $this->msg( 'undeleterevisions' )->numParams( $row->count )->parse();
- $out->addHTML( "<li>{$item} ({$revs})</li>\n" );
+ $out->addHTML( "<li class='undeleteResult'>{$item} ({$revs})</li>\n" );
}
$result->free();
$out->addHTML( "</ul>\n" );
// Show revision undeletion warnings and errors
$status = $archive->getRevisionStatus();
if ( $status && !$status->isGood() ) {
- $out->wrapWikiMsg(
- "<div class=\"error\" id=\"mw-error-cannotundelete\">\n$1\n</div>",
- 'cannotundelete'
+ $out->addWikiText( '<div class="error" id="mw-error-cannotundelete">' .
+ $status->getWikiText(
+ 'cannotundelete',
+ 'cannotundelete'
+ ) . '</div>'
);
}