stylize.php.

This commit is contained in:
Siebrand Mazeland 2012-01-05 09:45:01 +00:00
parent 7467195055
commit eeec962440
3 changed files with 53 additions and 53 deletions

View file

@ -4,9 +4,9 @@
*/
# Not a valid entry point, skip unless MEDIAWIKI is defined
if (!defined('MEDIAWIKI')) {
if ( !defined( 'MEDIAWIKI' ) ) {
echo "Contribution Scores extension";
exit(1);
exit( 1 );
}
$wgExtensionCredits['specialpage'][] = array(
@ -48,44 +48,44 @@ function efContributionScores_LanguageGetMagic( &$magicWords, $langCode ) {
return true;
}
function efContributionScores_Render(&$parser, $usertext, $metric='score') {
function efContributionScores_Render( &$parser, $usertext, $metric = 'score' ) {
global $wgContribScoreDisableCache;
if ($wgContribScoreDisableCache) {
if ( $wgContribScoreDisableCache ) {
$parser->disableCache();
}
$user = User::newFromName($usertext);
$user = User::newFromName( $usertext );
$dbr = wfGetDB( DB_SLAVE );
if ( $user instanceof User && $user->isLoggedIn() ) {
global $wgLang;
if ($metric=='score') {
$res = $dbr->select('revision',
if ( $metric == 'score' ) {
$res = $dbr->select( 'revision',
'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank',
array('rev_user' => $user->getID()));
$row = $dbr->fetchObject($res);
$output = $wgLang->formatNum( round($row->wiki_rank,0) );
} elseif ($metric=='changes') {
$res = $dbr->select('revision',
array( 'rev_user' => $user->getID() ) );
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) );
} elseif ( $metric == 'changes' ) {
$res = $dbr->select( 'revision',
'COUNT(rev_id) AS rev_count',
array('rev_user' => $user->getID()));
$row = $dbr->fetchObject($res);
array( 'rev_user' => $user->getID() ) );
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( $row->rev_count );
} elseif ($metric=='pages') {
$res = $dbr->select('revision',
} elseif ( $metric == 'pages' ) {
$res = $dbr->select( 'revision',
'COUNT(DISTINCT rev_page) AS page_count',
array('rev_user' => $user->getID()));
$row = $dbr->fetchObject($res);
array( 'rev_user' => $user->getID() ) );
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( $row->page_count );
} else {
$output = wfMsg('contributionscores-invalidmetric');
$output = wfMsg( 'contributionscores-invalidmetric' );
}
} else {
$output = wfMsg('contributionscores-invalidusername');
$output = wfMsg( 'contributionscores-invalidusername' );
}
return $parser->insertStripItem($output, $parser->mStripState);
return $parser->insertStripItem( $output, $parser->mStripState );
}

View file

@ -3,7 +3,7 @@
* \brief Contains code for the ContributionScores Class (extends SpecialPage).
*/
///Special page class for the Contribution Scores extension
/// Special page class for the Contribution Scores extension
/**
* Special page that generates a list of wiki contributors based
* on edit diversity (unique pages edited) and edit volume (total
@ -17,7 +17,7 @@ class ContributionScores extends IncludableSpecialPage {
parent::__construct( 'ContributionScores' );
}
///Generates a "Contribution Scores" table for a given LIMIT and date range
/// Generates a "Contribution Scores" table for a given LIMIT and date range
/**
* Function generates Contribution Scores tables in HTML format (not wikiText)
*
@ -33,17 +33,17 @@ class ContributionScores extends IncludableSpecialPage {
$dbr = wfGetDB( DB_SLAVE );
$userTable = $dbr->tableName('user');
$userGroupTable = $dbr->tableName('user_groups');
$revTable = $dbr->tableName('revision');
$ipBlocksTable = $dbr->tableName('ipblocks');
$userTable = $dbr->tableName( 'user' );
$userGroupTable = $dbr->tableName( 'user_groups' );
$revTable = $dbr->tableName( 'revision' );
$ipBlocksTable = $dbr->tableName( 'ipblocks' );
$sqlWhere = "";
$nextPrefix = "WHERE";
if ( $days > 0 ) {
$date = time() - (60*60*24*$days);
$dateString = $dbr->timestamp($date);
$date = time() - ( 60 * 60 * 24 * $days );
$dateString = $dbr->timestamp( $date );
$sqlWhere .= " {$nextPrefix} rev_timestamp > '$dateString'";
$nextPrefix = "AND";
}
@ -90,8 +90,8 @@ class ContributionScores extends IncludableSpecialPage {
$sortable = in_array( 'nosort', $opts ) ? '' : ' sortable';
$output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n".
"<tr class='header'>\n".
$output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n" .
"<tr class='header'>\n" .
Html::element( 'th', array(), wfMsg( 'contributionscores-score' ) ) .
Html::element( 'th', array(), wfMsg( 'contributionscores-pages' ) ) .
Html::element( 'th', array(), wfMsg( 'contributionscores-changes' ) ) .
@ -101,7 +101,7 @@ class ContributionScores extends IncludableSpecialPage {
foreach ( $res as $row ) {
// Use real name if option used and real name present.
if( $wgContribScoresUseRealName && $row->user_real_name !== '' ) {
if ( $wgContribScoresUseRealName && $row->user_real_name !== '' ) {
$userLink = Linker::userLink(
$row->user_id,
$row->user_name,
@ -142,12 +142,12 @@ class ContributionScores extends IncludableSpecialPage {
if ( !empty( $title ) )
$output = Html::rawElement( 'table', array( 'cellspacing' => 0, 'cellpadding' => 0,
'class' => 'contributionscores-wrapper', 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir() ),
"\n".
"<tr>\n".
"<td style='padding: 0px;'>{$title}</td>\n".
"</tr>\n".
"<tr>\n".
"<td style='padding: 0px;'>{$output}</td>\n".
"\n" .
"<tr>\n" .
"<td style='padding: 0px;'>{$title}</td>\n" .
"</tr>\n" .
"<tr>\n" .
"<td style='padding: 0px;'>{$output}</td>\n" .
"</tr>\n" );
return $output;
@ -156,7 +156,7 @@ class ContributionScores extends IncludableSpecialPage {
function execute( $par ) {
$this->setHeaders();
if( $this->including() ) {
if ( $this->including() ) {
$this->showInclude( $par );
} else {
$this->showPage();
@ -178,7 +178,7 @@ class ContributionScores extends IncludableSpecialPage {
$options = 'none';
if ( !empty( $par ) ) {
$params = explode('/', $par );
$params = explode( '/', $par );
$limit = intval( $params[0] );
@ -231,7 +231,7 @@ class ContributionScores extends IncludableSpecialPage {
} else {
$reportTitle = wfMsg( 'contributionscores-allrevisions' );
}
$reportTitle .= " " . wfMsgExt('contributionscores-top', 'parsemag', $wgLang->formatNum( $revs ) );
$reportTitle .= " " . wfMsgExt( 'contributionscores-top', 'parsemag', $wgLang->formatNum( $revs ) );
$title = Xml::element( 'h2', array( 'class' => 'contributionscores-title' ), $reportTitle ) . "\n";
$wgOut->addHTML( $title );
$wgOut->addHTML( $this->genContributionScoreTable( $days, $revs ) );