Skip to content

Commit

Permalink
Special:Browse / Check for empty request (#1998)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames committed Nov 6, 2016
1 parent ad51c78 commit 6f99c82
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/MediaWiki/Specials/SpecialBrowse.php
Expand Up @@ -53,6 +53,7 @@ public function execute( $query ) {

// get the GET parameters
$articletext = $webRequest->getVal( 'article' );
$isEmptyRequest = $query === null && $webRequest->getVal( 'article' ) === '';

// @see SMWInfolink::encodeParameters
if ( $query === null && $this->getRequest()->getCheck( 'x' ) ) {
Expand Down Expand Up @@ -84,27 +85,33 @@ public function execute( $query ) {
) );

$out->addHTML(
$this->getHtml( $webRequest )
$this->getHtml( $webRequest, $isEmptyRequest )
);

$this->addExternalHelpLinks();
}

private function getHtml( $webRequest ) {
private function getHtml( $webRequest, $isEmptyRequest ) {

if ( $isEmptyRequest ) {
return HtmlContentBuilder::getPageSearchQuickForm();
}

if ( !$this->subjectDV->isValid() ) {

foreach ( $this->subjectDV->getErrors() as $error ) {
$error = Message::decode( $error );
}

return Html::rawElement(
'div',
array(
'class' => 'smw-callout smw-callout-error'
),
Message::get( array( 'smw-browse-invalid-subject', $error ) )
) . HtmlContentBuilder::getPageSearchQuickForm();
$html = Html::rawElement(
'div',
array(
'class' => 'smw-callout smw-callout-error'
),
Message::get( array( 'smw-browse-invalid-subject', $error ) )
);

return $html . HtmlContentBuilder::getPageSearchQuickForm();
}

$htmlContentBuilder = $this->newHtmlContentBuilder( $webRequest );
Expand Down

0 comments on commit 6f99c82

Please sign in to comment.