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 wfDebug("Credits: '$s'\n");
45 $wgOut->addHTML( $s );
47 wfProfileOut( $fname );
50 function getCredits($article, $cnt) {
54 if (isset($cnt) && $cnt != 0) {
55 $s = getAuthorCredits($article);
56 if ($cnt > 1 ||
$cnt < 0) {
57 $s .= ' ' . getContributorCredits($article, $cnt - 1);
64 function getAuthorCredits($article) {
68 $last_author = $article->getUser();
70 if ($last_author == 0) {
71 $author_credit = wfMsg('anonymous');
73 $real_name = User
::whoIsReal($last_author);
74 if (!empty($real_name)) {
75 $author_credit = $real_name;
77 $author_credit = wfMsg('siteuser', User
::whoIs($last_author));
81 $timestamp = $article->getTimestamp();
83 $d = $wgLang->timeanddate($article->getTimestamp(), true);
87 return wfMsg('lastmodifiedby', $d, $author_credit);
90 function getContributorCredits($article, $cnt) {
92 global $wgLang, $wgAllowRealName;
94 $contributors = $article->getContributors($cnt);
96 $real_names = array();
97 $user_names = array();
99 # Sift for real versus user names
101 foreach ($contributors as $user_id => $user_parts) {
103 if ($wgAllowRealName && !empty($user_parts[1])) {
104 $real_names[$user_id] = $user_parts[1];
106 $user_names[$user_id] = $user_parts[0];
111 $real = $wgLang->listToText(array_values($real_names));
112 $user = $wgLang->listToText(array_values($user_names));
115 $user = wfMsg('siteusers', $user);
118 if ($contributors[0] && $contributors[0][0] > 0) {
119 $anon = wfMsg('anonymous');
124 $creds = $wgLang->listToText(array($real, $user, $anon));
126 return wfMsg('othercontribs', $creds);