Extension:Contribution Credits

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Contribution Credits

Release status: stable

Implementation Page action
Description Adds Contribution Credits to the page footer
Author(s) Jaime PriluskyTalk
Last version 2.0 (2010-04-30)
MediaWiki 1.11+
Database changes no
License GPL 2.0 or later
Download see here
Example http://proteopedia.org zulunotes.com
Parameters

wgContributionCreditsHeader

Hooks used
OutputPageBeforeHTML

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.

[edit] Installation

  1. Download the extension (copy/paste the file from below)
  2. Create a directory ContributionCredits in your $IP/extensions directory.
  3. Add the files to that $IP/extensions/ContributionCredits directory.
  4. Add to the end of LocalSettings.php (MW 1.17+):
    require_once("$IP/extensions/ContributionCredits/ContributionCredits.php");
  5. Specifiy optionally this variable to set the Section Header for the list of Contributors (default value is shown).
    $wgContributionCreditsHeader = "==Contributors==/n";
    just after that line.
  6. Installation can now be verified through Special:Version on your wiki

[edit] Code

ContributionCredits.php
<?php
/**
 * Contribution Credits extension - Adds contribution credits to the footer
 * @version 2.0 - 2010/04/30
 *
 * @link http://www.mediawiki.org/wiki/Extension:Contribution_Credits Documentation
 *
 * @file ContributionCredits.php
 * @ingroup Extensions
 * @package MediaWiki
 * @author Jaime Prilusky
 * @author Al Maghi
 * @copyright © 2008 Jaime Prilusky
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 */
 
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' => array( 'Jaime Prilusky', 'Al Maghi' ),
        'description' => 'Adds contribution credits to the footer',
        'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Credits'
        );
 
function addFooter (&$articleTitle, &$text) {
  global $wgTitle,$wgOut,$wgRequest;
  global $wgContributionCreditsHeader;
 
  $NS = $wgTitle->getNamespace();
  $action = $wgRequest->getVal('action');
 
  if (($NS==0 or $NS==1) and ($action != 'edit')) {
    $dbr =& wfGetDB( DB_SLAVE );
    $page_id = $wgTitle->getArticleID(); $list= '';
 
    $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 id=\"ContributionCredits\">$contributorsBlock</div>"; 
  } 
  return true;
}

[edit] See also

Language: English
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox