Extension:ContributionCredits
From MediaWiki.org
|
Release status: stable |
|||
|---|---|---|---|
| Implementation | Page action | ||
| Description | Adds Contribution Credits to the page footer | ||
| Author(s) | Jaime Prilusky | ||
| MediaWiki | 1.11+ | ||
| License | No license specified | ||
| Download | no link | ||
| Example | http://proteopedia.org zulunotes.com | ||
|
|||
|
check usage (experimental) |
|||
The Contribution Credits extension adds an automatically generated list of the page contributors to the end of every page in the wiki.
Contents |
[edit] What can this extension do?
[edit] Usage
Please cut and paste the code found below and place it in $IP/extensions/ContributionCredits/ContributionCredits.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
[edit] Installation
To install this extension, add the following to LocalSettings.php:
require_once("$IP/extensions/ContributionCredits/ContributionCredits.php"); # optional: set this variable to the Section Header for the list of Contributors. Shown the default value. $wgContributionCreditsHeader = "==Contributors==";
[edit] Code
<?php if( !defined( 'MEDIAWIKI' ) ) { echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); die( 1 ); } define ('CONTRIBUTIONCREDITS_VERSION','1.06, 2008-05-19'); $wgHooks['OutputPageBeforeHTML'][] = 'addFooter'; $wgExtensionCredits['other'][] = array( 'name' => 'Contribution Credits', 'version' => CONTRIBUTIONCREDITS_VERSION, 'author' => 'Jaime Prilusky', 'description' => 'adds Contribution Credits to Footer', 'url' => 'http://www.mediawiki.org/wiki/Extension:ContributionCredits' ); function addFooter (&$articleTitle, &$text) { global $wgTitle,$wgOut,$wgRequest; global $wgContributionCreditsHeader; $isSandbox = preg_match("/sandbox/i",$wgTitle->getText()); $action = $wgRequest->getVal('action'); if (!$isSandbox and ($action != 'edit')) { $dbr =& wfGetDB( DB_SLAVE ); $page_id = $wgTitle->getArticleID(); $list= ''; // $page_NS = $wgTitle->getNamespace(); $res = $dbr->select( 'revision', array('distinct rev_user_text'), array("rev_page = $page_id","rev_user >= 1"), __METHOD__, array('ORDER BY' => 'rev_user_text ASC',)); if( $res && $dbr->numRows( $res ) > 0 ) { while( $row = $dbr->fetchObject( $res ) ) { $deletedUser = preg_match("/ZDelete/",$row->rev_user_text); # deleted users are renamed as ZDelete#### if (!$deletedUser) { $list .= "[[User:".$row->rev_user_text."|".$row->rev_user_text."]], "; } } } $dbr->freeResult( $res ); $list = preg_replace('/\,\s*$/','',$list); $contributorsBlock = ''; if (!empty($list)) { if (!$wgContributionCreditsHeader) {$wgContributionCreditsHeader = "==Contributors==\n";} $contributorsBlock = $wgOut->parse("__NOEDITSECTION__\n" . $wgContributionCreditsHeader . $list); } $text = "$text\n<div>$contributorsBlock</div>"; } return true; }