From: Evan Prodromou Date: Mon, 26 Apr 2004 05:14:42 +0000 (+0000) Subject: Beginnings of on-page author credits. Added code to Skin to add credits, X-Git-Tag: 1.3.0beta1~276 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=314aaf6b9eca9ea36bb98dde6d40691b7f1a8a7a;p=lhc%2Fweb%2Fwiklou.git Beginnings of on-page author credits. Added code to Skin to add credits, although it's not everywhere it should be. $wgMaxCredits ignored, except to set max/min credits. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 3532b6e49a..59fb115699 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -343,4 +343,7 @@ $wgCapitalLinks = true; # can be imported, these should be 'trusted'. $wgImportSources = array(); +# For credit to authors. Set to zero to hide attribution block. +$wgMaxCredits = 0; + ?> diff --git a/includes/Skin.php b/includes/Skin.php index 1bb040cf3b..97997f5998 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -707,7 +707,7 @@ class Skin { function pageStats() { global $wgOut, $wgLang, $wgArticle, $wgRequest; - global $wgDisableCounters; + global $wgDisableCounters, $wgMaxCredits; extract( $wgRequest->getValues( 'oldid', 'diff' ) ); if ( ! $wgOut->isArticle() ) { return ""; } @@ -721,10 +721,85 @@ class Skin { $s = wfMsg( "viewcount", $count ); } } - $s .= $this->lastModified(); + if (!isset($wgMaxCredits) || $wgMaxCredits <= 0) { + $s .= $this->lastModified(); + } else { + $s .= " " . $this->getCredits(); + } + return $s . " " . $this->getCopyright(); } - + + function getCredits() { + $s = $this->getAuthorCredits(); + $s .= "
\n " . $this->getContributorCredits(); + return $s; + } + + function getAuthorCredits() { + global $wgLang, $wgArticle; + + $last_author = $wgArticle->getUser(); + + if ($last_author == 0) { + $author_credit = wfMsg("anonymous"); + } else { + $real_name = User::whoIsReal($last_author); + if (!empty($real_name)) { + $author_credit = $real_name; + } else { + $author_credit = wfMsg("siteuser", User::whoIs($last_author)); + } + } + + $timestamp = $wgArticle->getTimestamp(); + if ( $timestamp ) { + $d = $wgLang->timeanddate( $wgArticle->getTimestamp(), true ); + } else { + $d = ""; + } + return wfMsg("lastmodifiedby", $d, $author_credit); + } + + function getContributorCredits() { + + global $wgArticle, $wgMaxCredits, $wgLang; + + $contributors = $wgArticle->getContributors($wgMaxCredits); + + $real_names = array(); + $user_names = array(); + + # Sift for real versus user names + + foreach ($contributors as $user_id => $user_parts) { + if ($user_id != 0) { + if (!empty($user_parts[1])) { + $real_names[$user_id] = $user_parts[1]; + } else { + $user_names[$user_id] = $user_parts[0]; + } + } + } + + $real = $wgLang->listToText(array_values($real_names)); + $user = $wgLang->listToText(array_values($user_names)); + + if (!empty($user)) { + $user = wfMsg("siteusers", $user); + } + + if ($contributors[0] && $contributors[0][0] > 0) { + $anon = wfMsg("anonymous"); + } else { + $anon = ''; + } + + $creds = $wgLang->listToText(array($real, $user, $anon)); + + return wfMsg("contributions", $creds); + } + function getCopyright() { global $wgRightsPage, $wgRightsUrl, $wgRightsText; $out = ""; diff --git a/languages/Language.php b/languages/Language.php index b0e8cd1df6..3c787b17fe 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1564,7 +1564,11 @@ amusement.", # Attribution "anonymous" => "Anonymous user(s) of $wgSitename", -"siteuser" => "$wgSitename user $1" +"siteuser" => "$wgSitename user $1", +"lastmodifiedby" => "This page was last modified $1 by $2.", +"and" => "and", +"contributions" => "Based on work by $1.", +"siteusers" => "$wgSitename user(s) $1", ); #-------------------------------------------------------------------------- @@ -1924,6 +1928,20 @@ class Language { return $number; } + function listToText( $l ) { + $s = ""; + $m = count($l) - 1; + for ($i = $m; $i >= 0; $i--) { + if ($i == $m) { + $s = $l[$i]; + } else if ($i == $m - 1) { + $s = $l[$i] . " " . $this->getMessage("and") . " " . $s; + } else { + $s = $l[$i] . ", " . $s; + } + } + return $s; + } } @include_once( "Language" . ucfirst( $wgLanguageCode ) . ".php" );