# If the string cannot be used to create a title
if ( is_null( $t ) ) {
$this->showResults( $term );
+
return;
}
# If there's an exact or very near match, jump right there.
if ( !is_null( $t ) ) {
$this->getOutput()->redirect( $t->getFullURL() );
+
return;
}
# No match, generate an edit URL
# If the feature is enabled, go straight to the edit page
if ( $wgGoToEdit ) {
$this->getOutput()->redirect( $t->getFullURL( array( 'action' => 'edit' ) ) );
+
return;
}
}
Xml::closeElement( 'fieldset' )
);
}
+
return;
}
// Sometimes the search engine knows there are too many hits
if ( $titleMatches instanceof SearchResultTooMany ) {
$out->wrapWikiMsg( "==$1==\n", 'toomanymatches' );
+
return;
}
$out->addHTML( $this->formHeader( $term, 0, 0 ) );
$out->addHtml( $this->getProfileForm( $this->profile, $term ) );
$out->addHTML( '</form>' );
+
// Empty query -- straight view of search form
return;
}
// show direct page/create link if applicable
// Check DBkey !== '' in case of fragment link only.
- if ( is_null( $t ) || $t->getDBkey() === '' ||
- ( $titleMatches !== null && $titleMatches->searchContainedSyntax() ) ||
- ( $textMatches !== null && $textMatches->searchContainedSyntax() ) ) {
+ if ( is_null( $t ) || $t->getDBkey() === ''
+ || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
+ || ( $textMatches !== null && $textMatches->searchContainedSyntax() )
+ ) {
// invalid title
// preserve the paragraph for margins etc...
$this->getOutput()->addHtml( '<p></p>' );
+
return;
}
$opt['ns' . $n] = 1;
}
}
+
return $opt + $this->extraParams;
}
$link_t = clone $t;
wfRunHooks( 'ShowSearchHitTitle',
- array( &$link_t, &$titleSnippet, $result, $terms, $this ) );
+ array( &$link_t, &$titleSnippet, $result, $terms, $this ) );
$link = Linker::linkKnown(
$link_t,
/**
* Show results from other wikis
*
- * @param $matches SearchResultSet
+ * @param $matches SearchResultSet|array
* @param $query String
*
* @return string
*/
protected function showInterwiki( $matches, $query ) {
global $wgContLang;
-
$profile = new ProfileSection( __METHOD__ );
- $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
$out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>" .
$this->msg( 'search-interwiki-caption' )->text() . "</div>\n";
}
}
- $prev = null;
- $result = $matches->next();
- while ( $result ) {
- $out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions );
- $prev = $result->getInterwikiPrefix();
- $result = $matches->next();
+ if ( !is_array( $matches ) ) {
+ $matches = array( $matches );
}
+
+ foreach ( $matches as $set ) {
+ $prev = null;
+ $result = $set->next();
+ while ( $result ) {
+ $out .= $this->showInterwikiHit( $result, $prev, $query, $customCaptions );
+ $prev = $result->getInterwikiPrefix();
+ $result = $set->next();
+ }
+ }
+
+
// TODO: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
$out .= "</ul></div>\n";
*
* @param $result SearchResult
* @param $lastInterwiki String
- * @param $terms Array
* @param $query String
* @param array $customCaptions iw prefix -> caption
*
* @return string
*/
- protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions ) {
+ protected function showInterwikiHit( $result, $lastInterwiki, $query, $customCaptions ) {
$profile = new ProfileSection( __METHOD__ );
if ( $result->isBrokenTitle() ) {
}
$out .= "<li>{$link} {$redirect}</li>\n";
+
return $out;
}
} else {
$form = '';
wfRunHooks( 'SpecialSearchProfileForm', array( $this, &$form, $profile, $term, $opts ) );
+
return $form;
}
}
foreach ( $opts as $key => $value ) {
$hidden .= Html::hidden( $key, $value );
}
+
// Return final output
return Xml::openElement(
- 'fieldset',
- array( 'id' => 'mw-searchoptions', 'style' => 'margin:0em;' )
- ) .
+ 'fieldset',
+ array( 'id' => 'mw-searchoptions', 'style' => 'margin:0em;' )
+ ) .
Xml::element( 'legend', null, $this->msg( 'powersearch-legend' )->text() ) .
Xml::tags( 'h4', null, $this->msg( 'powersearch-ns' )->parse() ) .
Html::element( 'div', array( 'id' => 'mw-search-togglebox' ) ) .
$this->msg( 'searchbutton' )->text(),
array( 'class' => array( 'mw-ui-button', 'mw-ui-progressive' ) )
) . "\n";
+
return $out . $this->didYouMeanHtml;
}
if ( count( $p ) > 1 ) {
return $wgContLang->getNsIndex( $p[0] ) == NS_FILE;
}
+
return false;
}
if ( count( $p ) > 1 ) {
return $p[0] == $allkeyword;
}
+
return false;
}
$this->searchEngine = $this->searchEngineType ?
SearchEngine::create( $this->searchEngineType ) : SearchEngine::create();
}
+
return $this->searchEngine;
}
# Backwards compatibility hook
if ( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) {
wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
+
return;
}
$this->showUploadForm( $this->getUploadForm() );
} else {
$this->getOutput()->addHTML( $form );
}
-
}
/**
$status = $this->mUpload->fetchFile();
if ( !$status->isOK() ) {
$this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
+
return;
}
$details = $this->mUpload->verifyUpload();
if ( $details['status'] != UploadBase::OK ) {
$this->processVerificationError( $details );
+
return;
}
if ( $permErrors !== true ) {
$code = array_shift( $permErrors[0] );
$this->showRecoverableUploadError( $this->msg( $code, $permErrors[0] )->parse() );
+
return;
}
$status = $this->mUpload->performUpload( $this->mComment, $pageText, $this->mWatchthis, $this->getUser() );
if ( !$status->isGood() ) {
$this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
+
return;
}
$pageText = $comment;
}
}
+
return $pageText;
}
$success = $this->mUpload->unsaveUploadedFile();
if ( !$success ) {
$this->getOutput()->showFileDeleteError( $this->mUpload->getTempPath() );
+
return false;
} else {
return true;
foreach ( $dupes as $file ) {
$gallery->add( $file->getTitle() );
}
+
return '<li>' .
wfMessage( 'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() .
$gallery->toHtml() . "</li>\n";
public function __construct( array $options = array(), IContextSource $context = null ) {
$this->mWatch = !empty( $options['watch'] );
$this->mForReUpload = !empty( $options['forreupload'] );
- $this->mSessionKey = isset( $options['sessionkey'] )
- ? $options['sessionkey'] : '';
+ $this->mSessionKey = isset( $options['sessionkey'] ) ? $options['sessionkey'] : '';
$this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] );
$this->mDestWarningAck = !empty( $options['destwarningack'] );
$this->mDestFile = isset( $options['destfile'] ) ? $options['destfile'] : '';
$this->mSourceIds[] = $field['id'];
}
}
-
}
/**
'section' => 'source',
'type' => 'file',
'id' => 'wpUploadFile',
+ 'radio-id' => 'wpSourceTypeFile',
'label-message' => 'sourcefilename',
'upload-type' => 'File',
'radio' => &$radio,
'help' => $this->msg( 'upload-maxfilesize',
- $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['file'] ) )
- ->parse() .
+ $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['file'] )
+ )->parse() .
$this->msg( 'word-separator' )->escaped() .
$this->msg( 'upload_source_file' )->escaped(),
'checked' => $selectedSourceType == 'file',
'class' => 'UploadSourceField',
'section' => 'source',
'id' => 'wpUploadFileURL',
+ 'radio-id' => 'wpSourceTypeurl',
'label-message' => 'sourceurl',
'upload-type' => 'url',
'radio' => &$radio,
'help' => $this->msg( 'upload-maxfilesize',
- $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['url'] ) )
- ->parse() .
+ $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['url'] )
+ )->parse() .
$this->msg( 'word-separator' )->escaped() .
$this->msg( 'upload_source_url' )->escaped(),
'checked' => $selectedSourceType == 'url',
'default' => $this->getExtensionsMessage(),
'raw' => true,
);
+
return $descriptor;
}
# Print a list of allowed file extensions, if so configured. We ignore
# MIME type here, it's incomprehensible to most people and too long.
global $wgCheckFileExtensions, $wgStrictFileExtensions,
- $wgFileExtensions, $wgFileBlacklist;
+ $wgFileExtensions, $wgFileBlacklist;
if ( $wgCheckFileExtensions ) {
if ( $wgStrictFileExtensions ) {
# Everything is permitted.
$extensionsList = '';
}
+
return $extensionsList;
}
function trySubmit() {
return false;
}
-
}
/**
* @return string
*/
function getLabelHtml( $cellAttributes = array() ) {
+ $id = $this->mParams['id'];
+ $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel );
+
if ( !empty( $this->mParams['radio'] ) ) {
- $id = "wpSourceType{$this->mParams['upload-type']}";
+ if ( isset( $this->mParams['radio-id'] ) ) {
+ $radioId = $this->mParams['radio-id'];
+ } else {
+ // Old way. For the benefit of extensions that do not define
+ // the 'radio-id' key.
+ $radioId = 'wpSourceType' . $this->mParams['upload-type'];
+ }
+
$attribs = array(
'name' => 'wpSourceType',
'type' => 'radio',
- 'id' => $id,
+ 'id' => $radioId,
'value' => $this->mParams['upload-type'],
);
+
if ( !empty( $this->mParams['checked'] ) ) {
$attribs['checked'] = 'checked';
}
- $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel );
+
$label .= Html::element( 'input', $attribs );
- } else {
- $id = $this->mParams['id'];
- $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel );
}
return Html::rawElement( 'td', array( 'class' => 'mw-label' ) + $cellAttributes, $label );