* 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 );
}
}
$target = $request->getVal( 'target', $par );
$namespace = $request->getIntOrNull( 'namespace' );
- $protocols_list = array();
+ $protocols_list = [];
foreach ( $this->getConfig()->get( 'UrlProtocols' ) as $prot ) {
if ( $prot !== '//' ) {
$protocols_list[] = $prot;
'<nowiki>' . $this->getLanguage()->commaList( $protocols_list ) . '</nowiki>',
count( $protocols_list )
);
- $fields = array(
- 'target' => array(
+ $fields = [
+ 'target' => [
'type' => 'text',
'name' => 'target',
'id' => 'target',
'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',
'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' );
$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' );
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 );
}
// 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;
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;
* @return array
*/
function getOrderFields() {
- return array();
+ return [];
}
protected function getGroupName() {