http://www.mediawiki.org/wiki/Special:Code/MediaWiki/54452
Revision: 54452 Author: jojo Date: 2009-08-05 13:32:24 +0000 (Wed, 05 Aug 2009) Log Message: ----------- fix download-as-XYZ links Modified Paths: -------------- trunk/extensions/Collection/Collection.body.php trunk/extensions/Collection/Collection.hooks.php Modified: trunk/extensions/Collection/Collection.body.php =================================================================== --- trunk/extensions/Collection/Collection.body.php 2009-08-05 13:15:06 UTC (rev 54451) +++ trunk/extensions/Collection/Collection.body.php 2009-08-05 13:32:24 UTC (rev 54452) @@ -1113,12 +1113,10 @@ $c = curl_init( $url ); curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy); $userAgent = wfGetAgent(); - if ( !$userAgent ) $userAgent = "Unknown user agent"; - $userAgent .= " (via "; - if ( method_exists( Http, 'userAgent' ) ) { - $userAgent .= Http::userAgent() . ', '; + if ( !$userAgent ) { + $userAgent = "Unknown user agent"; } - $userAgent .= "Collection/$wgCollectionVersion)"; + $userAgent .= " (via MediaWiki/$wgVersion, Collection/$wgCollectionVersion)"; curl_setopt( $c, CURLOPT_USERAGENT, $userAgent); curl_setopt( $c, CURLOPT_POST, true ); curl_setopt( $c, CURLOPT_POSTFIELDS, $postFields ); Modified: trunk/extensions/Collection/Collection.hooks.php =================================================================== --- trunk/extensions/Collection/Collection.hooks.php 2009-08-05 13:15:06 UTC (rev 54451) +++ trunk/extensions/Collection/Collection.hooks.php 2009-08-05 13:32:24 UTC (rev 54452) @@ -59,6 +59,8 @@ * Return HTML-code to be inserted as portlet */ static function getPortlet() { + global $wgArticle; + global $wgRequest; global $wgTitle; global $wgUser; global $wgCollectionArticleNamespaces; @@ -69,9 +71,14 @@ if ( !in_array( $namespace, $wgCollectionArticleNamespaces ) && $namespace != NS_CATEGORY ) { - return false; + return false; } + $action = $wgRequest->getVal('action'); + if( $action != '' && $action != 'view' && $action != 'purge' ) { + return false; + } + wfLoadExtensionMessages( 'CollectionCore' ); $sk = $wgUser->getSkin(); @@ -92,17 +99,29 @@ ) ); + $params = array( 'arttitle' => $wgTitle->getPrefixedText() ); + + if( $wgArticle ) { + $oldid = $wgArticle->getOldID(); + if ( $oldid ) { + $params['oldid'] = $oldid; + } else { + $params['oldid'] = $wgArticle->getLatest(); + } + } + foreach ( $wgCollectionFormats as $writer => $name ) { + $params['writer'] = $writer; $out .= Xml::tags( 'li', array( 'id' => 'coll-download-as-' . $writer ), $sk->link( - SpecialPage::getTitleFor( 'Book', 'render_collection/' ), + SpecialPage::getTitleFor( 'Book', 'render_article/' ), wfMsgHtml( 'coll-download_as', htmlspecialchars( $name ) ), array( 'rel' => 'nofollow', 'title' => wfMsg( 'coll-download_as_tooltip', $name ) ), - array( 'writer' => $writer ), + $params, array( 'known', 'noclasses' ) ) ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs