Index: trunk/extensions/ContributorsAddon/ContributorsAddonClass.php |
— | — | @@ -0,0 +1,32 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class SpecialContributorsAddon extends SpecialContributors { |
| 5 | + public function getContributorsText() { |
| 6 | + global $wgUser, $wgLang, $wgTitle; |
| 7 | + $this->target = $wgTitle; |
| 8 | + $contribText = ''; |
| 9 | + |
| 10 | + if( $this->target->exists() ) { |
| 11 | + $total = 0; |
| 12 | + $skin =& $wgUser->getSkin(); |
| 13 | + $link = $skin->makeKnownLinkObj( $this->target ); |
| 14 | + $contribText .= '<h2>' . wfMsgHtml( 'contributors-subtitle', $link ) . '</h2>'; |
| 15 | + list( $contributors, $others ) = $this->getMainContributors(); |
| 16 | + $contribText .= '<ul>'; |
| 17 | + foreach( $contributors as $username => $info ) { |
| 18 | + list( $id, $count ) = $info; |
| 19 | + $line = $skin->userLink( $id, $username ) . $skin->userToolLinks( $id, $username ); |
| 20 | + $line .= ' [' . $wgLang->formatNum( $count ) . ']'; |
| 21 | + $contribText .= '<li>' . $line . '</li>' ; |
| 22 | + } |
| 23 | + $contribText .= '</ul>'; |
| 24 | + if( $others > 0 ) { |
| 25 | + $others = $wgLang->formatNum( $others ); |
| 26 | + $contribText .= wfMsgNoTrans( 'contributors-others-long', $others ) ; |
| 27 | + } |
| 28 | + } else { |
| 29 | + $contribText .= '<p>' . htmlspecialchars( wfMsg( 'contributors-nosuchpage', $this->target->getPrefixedText() ) ) . '</p>'; |
| 30 | + } |
| 31 | + return preg_replace('/"/','\"',$contribText); |
| 32 | + } |
| 33 | +} |
Property changes on: trunk/extensions/ContributorsAddon/ContributorsAddonClass.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 34 | + native |
Index: trunk/extensions/ContributorsAddon/ContributorsAddon.php |
— | — | @@ -0,0 +1,42 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +///Add-on to Contributions Extension by Rob Church |
| 5 | +/** |
| 6 | + * The Contributions extension MUST be installed for |
| 7 | + * this Extension to function. This extension adds |
| 8 | + * JS popup DIVs when the user moves their mouse over |
| 9 | + * the "Main Contributors" link. |
| 10 | + * |
| 11 | + * @addtogroup Extensions |
| 12 | + * @author Tim Laqua <t.laqua@gmail.com> |
| 13 | + */ |
| 14 | + |
| 15 | +if( defined( 'MEDIAWIKI' ) ) { |
| 16 | + $wgExtensionFunctions[] = 'efContributorsAddon'; |
| 17 | + $wgExtensionCredits['other'][] = array( |
| 18 | + 'name' => 'ContributorsAddon', |
| 19 | + 'author' => 'Tim Laqua', |
| 20 | + 'description' => 'Adds JS onMouseOver popups to "Main Contributors" links', |
| 21 | + ); |
| 22 | + |
| 23 | + $wgAutoloadClasses['SpecialContributorsAddon'] = dirname( __FILE__ ) . '/ContributorsAddonClass.php'; |
| 24 | + |
| 25 | + function efContributorsAddon() { |
| 26 | + global $wgMessageCache, $wgHooks; |
| 27 | + $wgHooks['OutputPageParserOutput'][] = 'efContributorsAddonSetup'; |
| 28 | + return true; |
| 29 | + } |
| 30 | + |
| 31 | + function efContributorsAddonSetup(&$out, &$parseroutput) { |
| 32 | + global $wgScriptPath; |
| 33 | + $out->addScript( '<link rel="stylesheet" type="text/css" href="' . $wgScriptPath . '/extensions/ContributorsAddon/ContributorsAddon.css" />' ); |
| 34 | + $out->addScript( '<script type="text/javascript" src="' . $wgScriptPath . '/extensions/ContributorsAddon/ContributorsAddon.js"><!-- ContributorsAddon js --></script>' ); |
| 35 | + $spContribAddon = new SpecialContributorsAddon; |
| 36 | + $out->addScript( "\n<script type=\"text/javascript\">\nvar contributorsText = \"". $spContribAddon->getContributorsText() . "\";\n</script>\n" ); |
| 37 | + return true; |
| 38 | + } |
| 39 | + |
| 40 | +} else { |
| 41 | + echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
| 42 | + exit( 1 ); |
| 43 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ContributorsAddon/ContributorsAddon.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 44 | + native |
Index: trunk/extensions/ContributorsAddon/ContributorsAddon.css |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +#contributorsDiv { |
| 3 | + position: absolute; |
| 4 | + z-index: 1000 !important; |
| 5 | + padding: .2em .2em .2em .5em; |
| 6 | +} |
| 7 | + |
| 8 | +.contributorsDivHide { |
| 9 | + display: none; |
| 10 | + left: 0px; |
| 11 | + top: 0px; |
| 12 | +} |
| 13 | + |
| 14 | +.contributorsDivShow { |
| 15 | + display: block; |
| 16 | + opacity:.90; |
| 17 | + filter: alpha(opacity=90); |
| 18 | + -moz-opacity: 0.90; |
| 19 | +} |
| 20 | + |
| 21 | +#contributorsDiv h2 { |
| 22 | + display: none; |
| 23 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ContributorsAddon/ContributorsAddon.css |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 24 | + native |
Index: trunk/extensions/ContributorsAddon/ContributorsAddon.js |
— | — | @@ -0,0 +1,55 @@ |
| 2 | +//JS file for ContributorsAddon |
| 3 | +/* |
| 4 | +* When JS is supported, it works - when JS is NOT supported, |
| 5 | +* it just does nothing and doesn't interfere with the core |
| 6 | +* Contributors Extension |
| 7 | +* |
| 8 | +* @author Tim Laqua <t.laqua@gmail.com> |
| 9 | +*/ |
| 10 | + |
| 11 | +function setupContributionsAddon() { |
| 12 | + var contributorsLink = document.getElementById('t-contributors').firstChild; |
| 13 | + if (contributorsLink != null) { |
| 14 | + contributorsLink.onmouseover = showContributors; |
| 15 | + contributorsLink.onmouseout = hideContributors; |
| 16 | + var cDiv = document.createElement('div'); |
| 17 | + cDiv.id = 'contributorsDiv'; |
| 18 | + cDiv.className = 'contributorsDivHide'; |
| 19 | + cDiv.innerHTML = contributorsText; |
| 20 | + cDiv.onmouseover = showContributors; |
| 21 | + cDiv.onmouseout = hideContributors; |
| 22 | + var gWrapper = document.getElementById('globalWrapper'); |
| 23 | + document.body.insertBefore(cDiv,gWrapper); |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +function showContributors() { |
| 28 | + var contributorsDiv = document.getElementById('contributorsDiv'); |
| 29 | + if (contributorsDiv != null) { |
| 30 | + contributorsDiv.className = 'contributorsDivShow pBody'; |
| 31 | + var arrCoords = findPos(document.getElementById('t-contributors')); |
| 32 | + contributorsDiv.style.top = (arrCoords[1]-5) + 'px'; |
| 33 | + contributorsDiv.style.left = (arrCoords[0]+40) + 'px'; |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +function hideContributors() { |
| 38 | + var contributorsDiv = document.getElementById('contributorsDiv'); |
| 39 | + if (contributorsDiv != null) { |
| 40 | + contributorsDiv.className = 'contributorsDivHide'; |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +function findPos(obj) { |
| 45 | + var curleft = curtop = 0; |
| 46 | + if (obj.offsetParent) { |
| 47 | + curleft = obj.offsetLeft |
| 48 | + curtop = obj.offsetTop |
| 49 | + while (obj = obj.offsetParent) { |
| 50 | + curleft += obj.offsetLeft |
| 51 | + curtop += obj.offsetTop |
| 52 | + } |
| 53 | + } |
| 54 | + return [curleft,curtop]; |
| 55 | +} |
| 56 | +addOnloadHook(setupContributionsAddon); |
\ No newline at end of file |
Property changes on: trunk/extensions/ContributorsAddon/ContributorsAddon.js |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 57 | + native |