/** * */ function getContributorCredits($article, $cnt, $showIfMax) { global $wgLang, $wgAllowRealName; $contributors = $article->getContributors(); $others_link = ''; # Hmm... too many to fit! if ($cnt > 0 && count($contributors) > $cnt) { $others_link = creditOthersLink($article); if (!$showIfMax) { return wfMsg('othercontribs', $others_link); } else { $contributors = array_slice($contributors, 0, $cnt); } } $real_names = array(); $user_names = array(); $anon = ''; # Sift for real versus user names foreach ($contributors as $user_parts) { if ($user_parts[0] != 0) { if ($wgAllowRealName && !empty($user_parts[2])) { $real_names[] = creditLink($user_parts[1], $user_parts[2]); } else { $user_names[] = creditLink($user_parts[1]); } } else { $anon = wfMsg('anonymous'); } } # Two strings: real names, and user names $real = $wgLang->listToText($real_names); $user = $wgLang->listToText($user_names); # "ThisSite user(s) A, B and C" if (!empty($user)) { $user = wfMsg('siteusers', $user); } # This is the big list, all mooshed together. We sift for blank strings $fulllist = array(); foreach (array($real, $user, $anon, $others_link) as $s) { if (!empty($s)) { array_push($fulllist, $s); } } # Make the list into text... $creds = $wgLang->listToText($fulllist); # "Based on work by ..." return empty($creds) ? '' : wfMsg('othercontribs', $creds); }
function UW_Authors_List ( &$out, &$text ) { global $wgTitle, $wgRequest, $wgShowAuthorsNamespaces, $wgShowAuthors; /* do nothing if the option is disabled * (but why would the extension be enabled?) */ if ( !$wgShowAuthors ) return true; // only build authors on namespaces in $wgShowAuthorsNamespaces if ( !in_array ( $wgTitle->getNamespace(), $wgShowAuthorsNamespaces ) ) return true; /* get the contribs from the database (don't use the default * MediaWiki one since it ignores the current user) */ $article = new Article ( $wgTitle ); $contribs = array(); $db = wfGetDB ( DB_MASTER ); $rev_table = $db->tableName ( "revision" ); $user_table = $db->tableName ( "user" ); $sql = "SELECT rev_user, rev_user_text, user_real_name, MAX(rev_timestamp) as timestamp FROM $rev_table LEFT JOIN $user_table ON rev_user = user_id WHERE rev_page = {$article->getID()} GROUP BY rev_user, rev_user_text, user_real_name ORDER BY timestamp DESC"; $results = $db->query ( $sql, __METHOD__ ); while ( $line = $db->fetchObject ( $results ) ) { $contribs[] = array( $line->rev_user, $line->rev_user_text, $line->user_real_name ); } $db->freeResult ( $results ); // return if there are no authors if ( sizeof ( $results ) <= 0 ) return true; // now build a sensible authors display in HTML require_once ( "includes/Credits.php" ); $authors = "\n<div class='authors'>" . "<h4>" . wfMsg( 'authors_authors' ) . "</h4>" . "<ul>"; $anons = 0; foreach ( $contribs as $author ) { $id = $author[0]; $username = $author[1]; $realname = $author[2]; if ( $id != "0" ) { // user with an id // FIME: broken. Incompatible with 1.14. Method creditLink() was renamed and changed. $author_link = $realname ? creditLink( $username, $realname ) : creditLink( $username ); $authors .= "<li>$author_link</li>"; } else { // anonymous $anons++; } } // add the anonymous entries if ( $anons > 0 ) $authors .= "<li>" . wfMsg( 'authors_anonymous' ) . "</li>"; $authors .= "</ul></div>"; $text .= $authors; return true; }