3 /* Credits.php -- formats credits for articles
4 * Copyright 2004, Evan Prodromou <evan@wikitravel.org>.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* This is largely cadged from PageHistory::history */
23 function showCreditsPage($article)
27 $fname = "showCreditsPage";
29 wfProfileIn( $fname );
31 $wgOut->setPageTitle( $article->mTitle
->getPrefixedText() );
32 $wgOut->setSubtitle( wfMsg( "creditspage" ) );
33 $wgOut->setArticleFlag( false );
34 $wgOut->setArticleRelated( true );
35 $wgOut->setRobotpolicy( "noindex,nofollow" );
37 if( $article->mTitle
->getArticleID() == 0 ) {
38 $s = wfMsg( "nocredits" );
40 $s = getCredits($article, -1);
43 $wgOut->addHTML( $s );
45 wfProfileOut( $fname );
48 function getCredits($article, $cnt) {
52 if (isset($cnt) && $cnt != 0) {
53 $s = getAuthorCredits($article);
54 if ($cnt > 1 ||
$cnt < 0) {
55 $s .= ' ' . getContributorCredits($article, $cnt - 1);
62 function getAuthorCredits($article) {
66 $last_author = $article->getUser();
68 if ($last_author == 0) {
69 $author_credit = wfMsg('anonymous');
72 $real_name = User
::whoIsReal($last_author);
73 $user_name = User
::whoIs($last_author);
75 if (!empty($real_name)) {
76 $author_credit = creditLink($user_name, $real_name);
78 $author_credit = wfMsg('siteuser', creditLink($user_name));
82 $timestamp = $article->getTimestamp();
84 $d = $wgLang->timeanddate($article->getTimestamp(), true);
88 return wfMsg('lastmodifiedby', $d, $author_credit);
91 function getContributorCredits($article, $cnt) {
93 global $wgLang, $wgAllowRealName;
95 $contributors = $article->getContributors($cnt);
97 $real_names = array();
98 $user_names = array();
100 # Sift for real versus user names
102 foreach ($contributors as $user_id => $user_parts) {
104 if ($wgAllowRealName && !empty($user_parts[1])) {
105 $real_names[$user_id] = creditLink($user_parts[0], $user_parts[1]);
107 $user_names[$user_id] = creditLink($user_parts[0]);
112 $real = $wgLang->listToText(array_values($real_names));
113 $user = $wgLang->listToText(array_values($user_names));
116 $user = wfMsg('siteusers', $user);
119 if ($contributors[0] && $contributors[0][0] > 0) {
120 $anon = wfMsg('anonymous');
125 $creds = $wgLang->listToText(array($real, $user, $anon));
127 return wfMsg('othercontribs', $creds);
130 function creditLink($user_name, $link_text = '') {
131 global $wgUser, $wgLang;
132 $skin = $wgUser->getSkin();
133 return $skin->makeKnownLink($wgLang->getNsText(NS_USER
) . ":" . $user_name,
134 (empty($link_text)) ?
$user_name : $link_text);