Merge "SpecialNewFiles: Swap from/to date serverside"
[lhc/web/wiklou.git] / includes / specials / SpecialUndelete.php
index dc5f877..1a2153d 100644 (file)
@@ -45,6 +45,10 @@ class SpecialUndelete extends SpecialPage {
 
        /** @var Title */
        private $mTargetObj;
+       /**
+        * @var string Search prefix
+        */
+       private $mSearchPrefix;
 
        function __construct() {
                parent::__construct( 'Undelete', 'deletedhistory' );
@@ -235,6 +239,7 @@ class SpecialUndelete extends SpecialPage {
                        Xml::openElement( 'form', [ 'method' => 'get', 'action' => wfScript() ] ) .
                                Xml::fieldset( $this->msg( 'undelete-search-box' )->text() ) .
                                Html::hidden( 'title', $this->getPageTitle()->getPrefixedDBkey() ) .
+                               Html::hidden( 'fuzzy', $this->getRequest()->getVal( 'fuzzy' ) ) .
                                Html::rawElement(
                                        'label',
                                        [ 'for' => 'prefix' ],
@@ -245,15 +250,25 @@ class SpecialUndelete extends SpecialPage {
                                        20,
                                        $this->mSearchPrefix,
                                        [ 'id' => 'prefix', 'autofocus' => '' ]
-                               ) . ' ' .
-                               Xml::submitButton( $this->msg( 'undelete-search-submit' )->text() ) .
+                               ) .
+                               ' ' .
+                               Xml::submitButton(
+                                       $this->msg( 'undelete-search-submit' )->text(),
+                                       [ 'id' => 'searchUndelete' ]
+                               ) .
                                Xml::closeElement( 'fieldset' ) .
                                Xml::closeElement( '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 ( $this->getRequest()->getVal( "fuzzy", false ) ) {
+                               $result = PageArchive::listPagesBySearch( $this->mSearchPrefix );
+                       } else {
+                               $result = PageArchive::listPagesByPrefix( $this->mSearchPrefix );
+                       }
                        $this->showList( $result );
                }
        }
@@ -277,7 +292,7 @@ class SpecialUndelete extends SpecialPage {
 
                $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 ) {
@@ -300,7 +315,7 @@ class SpecialUndelete extends SpecialPage {
                                );
                        }
                        $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" );
@@ -1084,9 +1099,11 @@ class SpecialUndelete extends SpecialPage {
                // 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>'
                        );
                }