Extension talk:ContributionCredits/Archive

From mediawiki.org

Not working with MediaWiki 1.22.4[edit]

"Une erreur de requĂȘte de base de donnĂ©es s'est produite. Cela peut provenir d'un bogue dans le logiciel." -> Try to upgrade the database with /mw-config/index.php

Not working on site with FCK Editor installed[edit]

I just installed this extension on a site I am developing that uses MediaWiki 1.13 and the FCK Editor extension (a WYIWYG text editor). Nothing broke when I installed the ContributionCredits extension, but it isn't adding the credits to any pages.

Any ideas?

Well I have it installed in a wiki with FCK and it works fine... May be an error of copy-paste... you can see it on the front page of http://wiki.mangas-tv.com.

I use to put an incremential criteria to remove the "s" if there's only one contributor in the while loop... Kronoxt 03:42, 7 April 2009 (UTC)Reply


First User don't display in the List[edit]

     array("rev_page = $page_id","rev_user > 1"), 

must change to

     array("rev_page = $page_id","rev_user > 0"),

--84.173.67.53 15:49, 7 April 2009 (UTC)Reply

PHP end tag[edit]

bug report[edit]

when I install ContributionCredits , http://en.wikicaptions.org/wiki/Extensions:Discussion:Installation don't display .

thanks .

Custom header isn't working[edit]

I am using WM1.15, and when I have no setting for $wgContributionCreditsHeader, it works properly (the header says "Contributors" with a L2 heading).

However, when I try to change it (see below), I end up with: ==Contributors to this page== instead of the L2 heading!

#Contribution Credits
require_once("$IP/extensions/ContributionCredits/ContributionCredits.php");
# The Section Header for the list of Contributors. Default value = "==Contributors==";
$wgContributionCreditsHeader = "==Contributors to this page==";

Any ideas about what I am doing wrong? -- PhantomSteve/talk|contribs\ 10:10, 17 June 2010 (UTC)Reply


Try adding \n like so:
:$wgContributionCreditsHeader = "==Contributors to this page==\n";
--A2E 05:08, 13 May 2011 (UTC)Reply

Contributors vs ContributionCredits[edit]

Can anyone explain the difference between these two extensions?

We are trying to something very simple (like the first line on this page: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/vtkDistanceWidget )

that simply shows (without users having to go specifically looking for the information) which people have been involved with the creation and maintenance of the page.

Thanks,

David

visual fix[edit]

In my wiki, which uses lots of fancy layout, this broke the pages in some places. Replacing the last text assignement this this:

$text = $text."\n<div class=\"visualClear\"></div><div id=\"ContributionCredits\">$contributorsBlock</div>";

fixed it. This clears floats that you may have used in the page above, and makes sure that the contributors block is really at the bottom of the page.

Custom namespaces[edit]

Does this extension work in custom namespaces?

  • 148.177.1.218 17:36, 28 June 2012 (UTC): Maybe if you update the snippet below:Reply
    • if (($NS==0 or $NS==1) and ($action != 'edit'))
    • 64.134.70.217 01:20, 5 August 2012 (UTC): I've implemented this and it works nicely. I have one custom namespace at 500 and 501 (talk) and I simply extended this conditional to include anything larger than 500. My assumption is that this won't break any other extensions that might, by chance, use a namespace ID of 500 or greater.Reply

real user name[edit]

how to display real user name set in preferences instead of login nickname?

Signature as Contributor Name[edit]

We made some Changes to this extension to use the users signature instead of the username. So you can configure what to show on the contributors list in you preferences, for example your real name.
Here is the new code:

<?php
	/**
	* Contribution Credits extension - Adds contribution credits to the footer
	* @version 2.2 - 2012/05/08
	*
	* @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
	*
	* Configuration:
	*	LocalSettings.php => $wgContributionCreditsShowUserSignature = true;
	*							Default: true
	*							true:	shows user specific user signature (if configured and not empty; else just the username)
								false:	shows only the username instead of the user signature
	*/

	if( !defined( 'MEDIAWIKI' ) ) {
		echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
		die( 1 );
	}

	define ('CONTRIBUTIONCREDITS_VERSION','2.2, 2012-05-08');

	$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;
//	-- DIFFERENCE
		global $wgContributionCreditsShowUserSignature;
		if (is_null($wgContributionCreditsShowUserSignature)) {$wgContributionCreditsShowUserSignature = true;}
//	-------------		

		$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(
//	-- DIFFERENCE			
			//	'revision',
			//	array('distinct rev_user_text'),
			//	array("rev_page = $page_id","rev_user >= 1"),
			//	__METHOD__,
			//	array('ORDER BY' => 'rev_user_text ASC',));
			array('revision', 'user', 'user_properties'),
                        array('distinct user.user_id', 'user.user_real_name', 'user.user_name', 'revision.rev_user_text', 'user_properties.up_value AS signature'),
			array("user.user_name = revision.rev_user_text", "user_properties.up_user = user.user_id", "user_properties.up_property = 'nickname'", "rev_page = $page_id","rev_user >= 1"),
			__METHOD__,
			array('ORDER BY' => 'user.user_name 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) {
//	-- DIFFERENCE							
						//	$list .= "[[User:".$row->rev_user_text."|".$row->rev_user_text."]], ";
							if($row->signature != "" && $wgContributionCreditsShowUserSignature == true ) {
								$list .= "<p>&raquo; " . $row->signature . "</p>";
							} else {
								$list .= "<p>&raquo; [[User:" .  $row->user_name . "|" . $row->user_name . "]]</p>";
							}
//	-------------					
						}
					}
				}
			$dbr->freeResult( $res );
//	-- DIFFERENCE			
		//	$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;
	}

you can enable/diable the signature with $wgContributionCreditsShowUserSignature = true/false;
A preview is shown on my wiki --212.21.161.88 12:26, 8 May 2012 (UTC)Reply

There is an updated version 2.3 (2012/05/09) available. Cheers --[[kgh]] (talk) 14:17, 2 May 2013 (UTC)Reply

Add code between page content and contribution credits[edit]

In my skin it seems the contribution credits are outputted with $this->html('bodytext') as part of the main page content. I would like to insert code for a comment section between the page content and the credits. What code can I use to call the credit section separately after the comments code? LTech 23.07.2012

How to sort list of users by number of edits?[edit]

I would like to sort the list of users by number of edits.
Does anyone know how to do that? I'm not familiar with SQL yet...
Thanks for any help!
--Stefahn (talk) 22:28, 22 March 2013 (UTC)Reply

Just for the record: I ended up using Extension:Contributors (tweaking it with some hacks). Stefahn (talk) 15:12, 2 May 2013 (UTC)Reply

Contributor Name and Percentage Score[edit]

Very usefull extension, thank you very much.
I have done a little upgrade to show a bland percentage score after each page contributors. A score is calculated using square root of characters added or removed plus number of revisions done by the contributor, then this score is normalized to 100. You can see an example on http://www.scrimipedia.it. --Ale Bat (talk) 10:34, 13 August 2013 (UTC)Reply
Here is the code if anyone would try it:

<?php
/**
 * Contribution Credits extension - Adds contribution credits to the footer
 * @version 2.0 - 2010/04/30
 *
 * 2013/08/13 added percentage score by Alessandro Battistini
 *
 * @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','2.0');
 
 $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 with percentage score',
        '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(); $struserstat= '';
 
    $res = $dbr->select(
      'revision',
      array('rev_user_text', 'rev_len', 'rev_minor_edit', 'rev_deleted'),
      array("rev_page = $page_id","rev_user >= 1"),
      __METHOD__,
      array('ORDER BY' => 'rev_id ASC',));

    $stat=array();
    if( $res && $dbr->numRows( $res ) > 0 ) {      
      $lastuser="";
      $lastnchars=-1;
      
      while( $row = $dbr->fetchObject( $res ) ) {
        $deletedUser = preg_match("/ZDelete/",$row->rev_user_text); # deleted users are renamed as ZDelete####
        if (!$deletedUser) {
            $user=$row->rev_user_text;
            $nchars=$row->rev_len;
            $minor=$row->rev_minor_edit;
            $deleted=$row->rev_deleted;
            
            if(($deleted)!=0) continue;
            
            if(array_key_exists ( $user , $stat )==false){
                $stat[$user]=array();
                $stat[$user]['revisions']=0;
                $stat[$user]['nchars']=0;
            }
            $stat[$user]['nchars']+=1;
            if($lastuser<>"" && $lastnchars>0){
                $deltachars=$nchars-$lastnchars;
            }
            else{
                $deltachars=$nchars;
            }
            $stat[$user]['nchars']+=abs($deltachars);
            //echo $user.":".$deltachars."<br>";
            $lastuser=$user;
            $lastnchars=$nchars;
        }
      }
    }
    // 
    $dbr->freeResult( $res );
    //print_r($stat);
    $scoreTot=0;
    foreach($stat as $k => $v){
        $score=sqrt(abs($v['nchars']))+$v['revisions'];
        $stat[$k]['score']=$score;
        $scoreTot+=$score;
    }

    $dataarray=array();
    foreach($stat as $k => $v){
        $score=($v['score']/$scoreTot)*100;
        $dataarray[]='[[User:'.$k.'|'.$k.']] ('.sprintf("%01.1f", $score).'%)';
    }
    
    $dataarray=array_reverse($dataarray);
    $struserstat= implode ( ", ",  $dataarray );
    
    $contributorsBlock = '';
    if (!empty($struserstat)) { 
        if (!$wgContributionCreditsHeader) {$wgContributionCreditsHeader = "==Contributors==\n";}
            $contributorsBlock = $wgOut->parse("__NOEDITSECTION__\n" . $wgContributionCreditsHeader . $struserstat); 
        }
    $text = $text."\n<div id=\"ContributionCredits\">$contributorsBlock</div>"; 
  } 
  return false;
}
?>

Had to use older version to work on MW 1.28.2[edit]

I used this version on MW 1.28.2 https://www.mediawiki.org/w/index.php?title=Extension:Contribution_Credits&oldid=683729