Henning Snater has uploaded a new change for review.
https://gerrit.wikimedia.org/r/69633
Change subject: Fixed initialization of site link tables
......................................................................
Fixed initialization of site link tables
For site link groups that have no site, the site link table header is not
displayed anymore.
With that done, the $.tablesorter widget does not cause an error due to being
initialized on
a table with an empty body.
Change-Id: I08d0c822b037c3c7c555d4b48deaeca7689d6861
---
M lib/resources/wikibase.ui.SiteLinksEditTool.js
M repo/includes/ItemView.php
2 files changed, 28 insertions(+), 23 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/33/69633/1
diff --git a/lib/resources/wikibase.ui.SiteLinksEditTool.js
b/lib/resources/wikibase.ui.SiteLinksEditTool.js
index 1059700..5f55eea 100644
--- a/lib/resources/wikibase.ui.SiteLinksEditTool.js
+++ b/lib/resources/wikibase.ui.SiteLinksEditTool.js
@@ -81,7 +81,7 @@
self.refreshView(); // will re-assign even/uneven
classes
} );
- if ( $( 'table.wb-sitelinks thead' ).children().length > 0 ) {
+ if ( this._subject.children( 'thead' ).children().length > 0 ) {
// initially sort on the site id column
this._subject.tablesorter( { sortList: [{1:'asc'}] } );
}
diff --git a/repo/includes/ItemView.php b/repo/includes/ItemView.php
index 9478e88..5a6376b 100644
--- a/repo/includes/ItemView.php
+++ b/repo/includes/ItemView.php
@@ -68,7 +68,25 @@
/**
* @var ItemContent $itemContent
*/
- $siteLinks = $itemContent->getItem()->getSimpleSiteLinks();
+ $siteLinks = $itemContent->getItem()->getSimpleSiteLinks(); //
all site links
+
+ $groupSiteLinks = array(); // site links of the currently
handled site group
+
+ foreach( $siteLinks as $siteLink ) {
+ // FIXME: depracted method usage
+ $site = \Sites::singleton()->getSite(
$siteLink->getSiteId() );
+
+ if ( $site === null ) {
+ $site = new \Site();
+ $site->setGlobalId( $siteLink->getSiteId() );
+ }
+
+ $link = new SiteLink( $site, $siteLink->getPageName() );
+
+ if ( $link->getSite()->getGroup() === $group ) {
+ $groupSiteLinks[] = $link;
+ }
+ }
$html = $thead = $tbody = $tfoot = '';
@@ -79,7 +97,7 @@
// TODO: support entity-id as prefix for element IDs.
);
- if( !empty( $siteLinks ) ) {
+ if( !empty( $groupSiteLinks ) ) {
$thead = wfTemplate( 'wb-sitelinks-thead',
wfMessage(
'wikibase-sitelinks-sitename-columnheading' )->parse(),
wfMessage(
'wikibase-sitelinks-siteid-columnheading' )->parse(),
@@ -93,37 +111,23 @@
$sites = Sites::singleton()->getSites();
// Sort the sitelinks according to their global id
- $safetyCopy = $siteLinks; // keep a shallow copy;
+ $safetyCopy = $groupSiteLinks; // keep a shallow copy;
$sortOk = usort(
- $siteLinks,
- function( SimpleSiteLink $a, SimpleSiteLink $b ) {
- return strcmp( $a->getSiteId(), $b->getSiteId()
);
+ $groupSiteLinks,
+ function( SiteLink $a, SiteLink $b ) {
+ return strcmp( $a->getSite()->getGlobalId(),
$b->getSite()->getGlobalId() );
}
);
if ( !$sortOk ) {
- $siteLinks = $safetyCopy;
+ $groupSiteLinks = $safetyCopy;
}
// Link to SpecialPage
$idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$editLink = $this->getEditUrl( $idFormatter->format(
$itemContent->getEntity()->getId() ), null, 'SetSiteLink' );
- foreach( $siteLinks as $siteLink ) {
- // FIXME: depracted method usage
- $site = \Sites::singleton()->getSite(
$siteLink->getSiteId() );
-
- if ( $site === null ) {
- $site = new \Site();
- $site->setGlobalId( $siteLink->getSiteId() );
- }
-
- $link = new SiteLink( $site, $siteLink->getPageName() );
-
- if ( $link->getSite()->getGroup() !== $group ) {
- continue;
- }
-
+ foreach( $groupSiteLinks as $link ) {
$alternatingClass = ( $i++ % 2 ) ? 'even' : 'uneven';
$site = $link->getSite();
@@ -160,6 +164,7 @@
}
// built table footer with button to add site-links, consider
list could be complete!
+ // TODO: This check needs to be site group specific.
$isFull = count( $siteLinks ) >= count( $sites );
$tfoot = wfTemplate( 'wb-sitelinks-tfoot',
--
To view, visit https://gerrit.wikimedia.org/r/69633
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I08d0c822b037c3c7c555d4b48deaeca7689d6861
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits