Ryan Lane has uploaded a new change for review.
https://gerrit.wikimedia.org/r/49402
Change subject: Output sidebar portlet as array
......................................................................
Output sidebar portlet as array
Collections' portlet currently only works properly in skins that
use a sidebar, since it outputs html directly. This change outputs
the portlet as an array, like other portlets, so that skins can
output the portlet as they'd like.
Change-Id: I4157b00421fc97e64e5278f9bc4aa1b3faa51bca
---
M Collection.hooks.php
1 file changed, 21 insertions(+), 58 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection
refs/changes/02/49402/1
diff --git a/Collection.hooks.php b/Collection.hooks.php
index 18da76a..f0089dd 100644
--- a/Collection.hooks.php
+++ b/Collection.hooks.php
@@ -33,9 +33,9 @@
global $wgCollectionPortletForLoggedInUsersOnly;
if ( !$wgCollectionPortletForLoggedInUsersOnly ||
$skin->getUser()->isLoggedIn() ) {
- $html = self::getPortlet( $skin );
- if ( $html ) {
- $bar[ 'coll-print_export' ] = $html;
+ $portlet = self::getPortlet( $skin );
+ if ( $portlet ) {
+ $bar[ 'coll-print_export' ] = $portlet;
}
}
return true;
@@ -86,34 +86,19 @@
return false;
}
- $out = Xml::element( 'ul', array( 'id' =>
'collectionPortletList' ), null );
+ $out = Array();
+ $booktitle = SpecialPage::getTitleFor( 'Book' );
if ( !CollectionSession::isEnabled() ) {
- $out .= Xml::tags( 'li',
- array( 'id' => 'coll-create_a_book' ),
- Linker::linkKnown(
- SpecialPage::getTitleFor( 'Book' ),
- $sk->msg( 'coll-create_a_book'
)->escaped(),
- array(
- 'rel' => 'nofollow',
- 'title' => $sk->msg(
'coll-create_a_book_tooltip' )->text()
- ),
- array( 'bookcmd' => 'book_creator',
'referer' => $title->getPrefixedText() )
- )
- );
+ $out[] = Array( 'text' => $sk->msg(
'coll-create_a_book' )->escaped(),
+ 'id' => 'coll-create_a_book',
+ 'href' => $booktitle->getLocalURL(
array( 'bookcmd' => 'book_creator', 'referer' => $title->getPrefixedText() ) )
+ );
} else {
- $out .= Xml::tags( 'li',
- array( 'id' => 'coll-book_creator_disable' ),
- Linker::linkKnown(
- SpecialPage::getTitleFor( 'Book' ),
- $sk->msg( 'coll-book_creator_disable'
)->escaped(),
- array(
- 'rel' => 'nofollow',
- 'title' => $sk->msg(
'coll-book_creator_disable_tooltip' )->text()
- ),
- array( 'bookcmd' =>
'stop_book_creator', 'referer' => $title->getPrefixedText() )
- )
- );
+ $out[] = Array( 'text' => $sk->msg(
'coll-book_creator_disable' )->escaped(),
+ 'id' => 'coll-book_creator_disable',
+ 'href' => $booktitle->getLocalURL(
array( 'bookcmd' => 'stop_book_creator', 'referer' => $title->getPrefixedText()
) )
+ );
}
$params = array(
@@ -130,43 +115,21 @@
foreach ( $wgCollectionPortletFormats as $writer ) {
$params['writer'] = $writer;
- $out .= Xml::tags( 'li',
- array( 'id' => 'coll-download-as-' . $writer ),
- Linker::linkKnown(
- SpecialPage::getTitleFor( 'Book' ),
- $sk->msg( 'coll-download_as',
$wgCollectionFormats[$writer] )->escaped(),
- // @todo FIXME: No i18n here.
- array(
- 'rel' => 'nofollow',
- 'title' => $sk->msg(
'coll-download_as_tooltip',
- $wgCollectionFormats[$writer]
)->text() // @todo FIXME: No i18n here.
- ),
- $params
- )
- );
+ $out[] = Array( 'text' => $sk->msg( 'coll-download_as',
$wgCollectionFormats[$writer] )->escaped(),
+ 'id' => 'coll-download-as-' . $writer,
+ 'href' => $title->getLocalURL( $params )
+ );
}
// Move the 'printable' link into our section for consistency
if ( $action == 'view' || $action == 'purge' ) {
if ( !$sk->getOutput()->isPrintable() ) {
- $attribs = array(
- 'href' => $title->getLocalUrl(
$sk->getRequest()->appendQueryValue( 'printable', 'yes', true ) ),
- 'title' => Linker::titleAttrib(
't-print', 'withaccess' ),
- 'accesskey' => Linker::accesskey(
't-print' ),
- );
- if ( $attribs['title'] === false ) {
- unset( $attribs['title'] );
- }
- if ( $attribs['accesskey'] === false ) {
- unset( $attribs['accesskey'] );
- }
- $out .= Xml::tags( 'li',
- array( 'id' => 't-print' ),
- Xml::element( 'a', $attribs, $sk->msg(
'printableversion' )->text() ) );
+ $out[] = Array( 'text' => $sk->msg(
'printableversion' )->text(),
+ 'id' => 't-print',
+ 'href' => $title->getLocalURL(
array( 'printable' => 'yes' ) )
+ );
}
}
-
- $out .= Xml::closeElement( 'ul' );
return $out;
}
--
To view, visit https://gerrit.wikimedia.org/r/49402
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4157b00421fc97e64e5278f9bc4aa1b3faa51bca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection
Gerrit-Branch: master
Gerrit-Owner: Ryan Lane <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits