Skip to content

Commit

Permalink
Tidy (Special:Browse), refs 1756 (#2272)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames committed Feb 18, 2017
1 parent b9b0afb commit b944a3c
Show file tree
Hide file tree
Showing 12 changed files with 554 additions and 236 deletions.
4 changes: 3 additions & 1 deletion i18n/en.json
Expand Up @@ -235,9 +235,11 @@
"smw_browse_hide_incoming": "hide properties that link here",
"smw_browse_no_outgoing": "This page has no properties.",
"smw_browse_no_incoming": "No properties link to this page.",
"smw-browse-from-backend": "Information are currently retrieved from the backend.",
"smw-browse-intro": "This page provides details about a subject or entity instance, please enter the name of an object to be inspected.",
"smw-browse-invalid-subject": "The subject validation returned with a \"$1\" error.",
"smw-browse-api-subject-serialization-invalid" : "The subject has an invalid serialization format.",
"smw-browse-js-disabled": "It is suspected that JavaScript is disabled or not available and we recommend to use a browser where this is supported. Other options can be discussed on the [https://www.semantic-mediawiki.org/wiki/Help:$smwgBrowseByApi $smwgBrowseByApi] settings page.",
"smw-browse-js-disabled": "It is suspected that JavaScript is disabled or not available and we recommend to use a browser where this is supported. Other options are discussed on the [https://www.semantic-mediawiki.org/wiki/Help:$smwgBrowseByApi $smwgBrowseByApi] settings page.",
"smw_inverse_label_default": "$1 of",
"smw_inverse_label_property": "Inverse property label",
"pageproperty": "Page property search",
Expand Down
8 changes: 7 additions & 1 deletion res/smw/special/ext.smw.special.browse.js
Expand Up @@ -47,7 +47,7 @@
subject = self.context.data( 'subject' ),
options = JSON.stringify( self.context.data( 'options' ) );

// Expect format generated from DIWikiPage::getHash
// Expect a serialization format (see DIWikiPage::getHash)
if ( subject.indexOf( "#" ) == -1 ) {
return self.reportError( mw.msg( 'smw-browse-api-subject-serialization-invalid' ) );
}
Expand All @@ -68,6 +68,10 @@

var text = 'Unknown API error';

if ( status.hasOwnProperty( 'xhr' ) ) {
text = status.xhr.responseText.replace(/\<br \/\>/g," ");
}

if ( status.hasOwnProperty( 'error' ) ) {
text = status.error.code + ': ' + status.error.info;
}
Expand Down Expand Up @@ -108,6 +112,8 @@

// Re-apply JS-component instances on new content
// Trigger an event
mw.hook( 'smw.browse.apiparsecomplete' ).fire( self.context );

$( document ).trigger( 'SMW::Browse::ApiParseComplete' , {
'context': self.context
} );
Expand Down
4 changes: 2 additions & 2 deletions res/smw/util/ext.smw.util.tooltip.js
Expand Up @@ -259,8 +259,8 @@
var self = this;

// Listen to the Special:Browse event
$ ( document ).on( 'SMW::Browse::ApiParseComplete', function( event, opts ) {
self.initFromContext( opts.context );
mw.hook( 'smw.browse.apiparsecomplete' ).add( function( context ) {
self.initFromContext( context );
} );

// SemanticForms/PageForms instance trigger
Expand Down
8 changes: 4 additions & 4 deletions src/MediaWiki/Api/BrowseBySubject.php
Expand Up @@ -5,7 +5,7 @@
use ApiBase;
use SMW\ApplicationFactory;
use SMW\DIWikiPage;
use SMW\MediaWiki\Specials\Browse\HtmlContentsBuilder;
use SMW\MediaWiki\Specials\Browse\ContentsBuilder;

/**
* Browse a subject api module
Expand Down Expand Up @@ -54,14 +54,14 @@ protected function getHtmlFormat( $params ) {
$params['subobject']
);

$HtmlContentsBuilder = new HtmlContentsBuilder(
$contentsBuilder = new ContentsBuilder(
ApplicationFactory::getInstance()->getStore(),
$subject
);

$HtmlContentsBuilder->setOptionsFromJsonFormat( $params['options'] );
$contentsBuilder->importOptionsFromJson( $params['options'] );

return $HtmlContentsBuilder->getHtml();
return $contentsBuilder->getHtml();
}

protected function getRawFormat( $params ) {
Expand Down

0 comments on commit b944a3c

Please sign in to comment.