Use WIS::getWatchedItemsForUser in SpecialEditWatchlist
[lhc/web/wiklou.git] / includes / specials / SpecialLinkSearch.php
index dc882d4..2a7046e 100644 (file)
@@ -68,10 +68,9 @@ class LinkSearchPage extends QueryPage {
         * This allows for dependency injection even though we don't control object creation.
         */
        private function initServices() {
-               global $wgLanguageCode;
+               global $wgContLang;
                if ( !$this->linkRenderer ) {
-                       $lang = Language::factory( $wgLanguageCode );
-                       $titleFormatter = new MediaWikiTitleCodec( $lang, GenderCache::singleton() );
+                       $titleFormatter = new MediaWikiTitleCodec( $wgContLang, GenderCache::singleton() );
                        $this->linkRenderer = new MediaWikiPageLinkRenderer( $titleFormatter );
                }
        }
@@ -91,9 +90,9 @@ class LinkSearchPage extends QueryPage {
 
                $request = $this->getRequest();
                $target = $request->getVal( 'target', $par );
-               $namespace = $request->getIntOrNull( 'namespace', null );
+               $namespace = $request->getIntOrNull( 'namespace' );
 
-               $protocols_list = array();
+               $protocols_list = [];
                foreach ( $this->getConfig()->get( 'UrlProtocols' ) as $prot ) {
                        if ( $prot !== '//' ) {
                                $protocols_list[] = $prot;
@@ -121,8 +120,8 @@ class LinkSearchPage extends QueryPage {
                        '<nowiki>' . $this->getLanguage()->commaList( $protocols_list ) . '</nowiki>',
                        count( $protocols_list )
                );
-               $fields = array(
-                       'target' => array(
+               $fields = [
+                       'target' => [
                                'type' => 'text',
                                'name' => 'target',
                                'id' => 'target',
@@ -130,11 +129,11 @@ class LinkSearchPage extends QueryPage {
                                'label-message' => 'linksearch-pat',
                                'default' => $target,
                                'dir' => 'ltr',
-                       )
-               );
+                       ]
+               ];
                if ( !$this->getConfig()->get( 'MiserMode' ) ) {
-                       $fields += array(
-                               'namespace' => array(
+                       $fields += [
+                               'namespace' => [
                                        'type' => 'namespaceselect',
                                        'name' => 'namespace',
                                        'label-message' => 'linksearch-ns',
@@ -142,12 +141,12 @@ class LinkSearchPage extends QueryPage {
                                        'id' => 'namespace',
                                        'all' => '',
                                        'cssclass' => 'namespaceselector',
-                               ),
-                       );
+                               ],
+                       ];
                }
-               $hiddenFields = array(
+               $hiddenFields = [
                        'title' => $this->getPageTitle()->getPrefixedDBkey(),
-               );
+               ];
                $htmlForm = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
                $htmlForm->addHiddenFields( $hiddenFields );
                $htmlForm->setSubmitTextMsg( 'linksearch-ok' );
@@ -158,10 +157,10 @@ class LinkSearchPage extends QueryPage {
                $this->addHelpLink( 'Help:Linksearch' );
 
                if ( $target != '' ) {
-                       $this->setParams( array(
-                               'query' => $target2,
+                       $this->setParams( [
+                               'query' => Parser::normalizeLinkUrl( $target2 ),
                                'namespace' => $namespace,
-                               'protocol' => $protocol ) );
+                               'protocol' => $protocol ] );
                        parent::execute( $par );
                        if ( $this->mungedQuery === false ) {
                                $out->addWikiMsg( 'linksearch-error' );
@@ -191,7 +190,7 @@ class LinkSearchPage extends QueryPage {
 
                if ( $query === '*' && $prot !== '' ) {
                        // Allow queries like 'ftp://*' to find all ftp links
-                       $rv = array( $prot, $dbr->anyString() );
+                       $rv = [ $prot, $dbr->anyString() ];
                } else {
                        $rv = LinkFilter::makeLikeArray( $query, $prot );
                }
@@ -200,16 +199,16 @@ class LinkSearchPage extends QueryPage {
                        // LinkFilter doesn't handle wildcard in IP, so we'll have to munge here.
                        $pattern = '/^(:?[0-9]{1,3}\.)+\*\s*$|^(:?[0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]*\*\s*$/';
                        if ( preg_match( $pattern, $query ) ) {
-                               $rv = array( $prot . rtrim( $query, " \t*" ), $dbr->anyString() );
+                               $rv = [ $prot . rtrim( $query, " \t*" ), $dbr->anyString() ];
                                $field = 'el_to';
                        }
                }
 
-               return array( $rv, $field );
+               return [ $rv, $field ];
        }
 
        function linkParameters() {
-               $params = array();
+               $params = [];
                $params['target'] = $this->mProt . $this->mQuery;
                if ( $this->mNs !== null && !$this->getConfig()->get( 'MiserMode' ) ) {
                        $params['namespace'] = $this->mNs;
@@ -225,25 +224,25 @@ class LinkSearchPage extends QueryPage {
                list( $this->mungedQuery, $clause ) = self::mungeQuery( $this->mQuery, $this->mProt );
                if ( $this->mungedQuery === false ) {
                        // Invalid query; return no results
-                       return array( 'tables' => 'page', 'fields' => 'page_id', 'conds' => '0=1' );
+                       return [ 'tables' => 'page', 'fields' => 'page_id', 'conds' => '0=1' ];
                }
 
                $stripped = LinkFilter::keepOneWildcard( $this->mungedQuery );
                $like = $dbr->buildLike( $stripped );
-               $retval = array(
-                       'tables' => array( 'page', 'externallinks' ),
-                       'fields' => array(
+               $retval = [
+                       'tables' => [ 'page', 'externallinks' ],
+                       'fields' => [
                                'namespace' => 'page_namespace',
                                'title' => 'page_title',
                                'value' => 'el_index',
                                'url' => 'el_to'
-                       ),
-                       'conds' => array(
+                       ],
+                       'conds' => [
                                'page_id = el_from',
                                "$clause $like"
-                       ),
-                       'options' => array( 'USE INDEX' => $clause )
-               );
+                       ],
+                       'options' => [ 'USE INDEX' => $clause ]
+               ];
 
                if ( $this->mNs !== null && !$this->getConfig()->get( 'MiserMode' ) ) {
                        $retval['conds']['page_namespace'] = $this->mNs;
@@ -294,7 +293,7 @@ class LinkSearchPage extends QueryPage {
         * @return array
         */
        function getOrderFields() {
-               return array();
+               return [];
        }
 
        protected function getGroupName() {