+
+ # Info about this page
+
+ function info()
+ {
+ global $wgUser, $wgTitle, $wgOut, $wgLang, $wgAllowPageInfo;
+ $fname = 'Article::info';
+
+ if ( !$wgAllowPageInfo ) {
+ $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
+ return;
+ }
+
+ $dbr =& wfGetDB( DB_SLAVE );
+
+ $basenamespace = $wgTitle->getNamespace() & (~1);
+ $cur_clause = array( 'cur_title' => $wgTitle->getDBkey(), 'cur_namespace' => $basenamespace );
+ $old_clause = array( 'old_title' => $wgTitle->getDBkey(), 'old_namespace' => $basenamespace );
+ $wl_clause = array( 'wl_title' => $wgTitle->getDBkey(), 'wl_namespace' => $basenamespace );
+ $fullTitle = $wgTitle->makeName($basenamespace, $wgTitle->getDBKey());
+ $wgOut->setPagetitle( $fullTitle );
+ $wgOut->setSubtitle( wfMsg( "infosubtitle" ));
+
+ # first, see if the page exists at all.
+ $exists = $dbr->selectField( 'cur', 'COUNT(*)', $cur_clause, $fname );
+ if ($exists < 1) {
+ $wgOut->addHTML( wfMsg("noarticletext") );
+ } else {
+ $numwatchers = $dbr->selectField( 'watchlist', 'COUNT(*)', $wl_clause, $fname );
+ $wgOut->addHTML( "<ul><li>" . wfMsg("numwatchers", $numwatchers) . "</li>" );
+ $old = $dbr->selectField( 'old', 'COUNT(*)', $old_clause, $fname );
+ $wgOut->addHTML( "<li>" . wfMsg("numedits", $old + 1) . "</li>");
+
+ # to find number of distinct authors, we need to do some
+ # funny stuff because of the cur/old table split:
+ # - first, find the name of the 'cur' author
+ # - then, find the number of *other* authors in 'old'
+
+ # find 'cur' author
+ $cur_author = $dbr->selectField( 'cur', 'cur_user_text', $cur_clause, $fname );
+
+ # find number of 'old' authors excluding 'cur' author
+ $authors = $dbr->selectField( 'old', 'COUNT(DISTINCT old_user_text)',
+ $old_clause + array( 'old_user_text<>' . $dbr->addQuotes( $cur_author ) ), $fname ) + 1;
+
+ # now for the Talk page ...
+ $cur_clause = array( 'cur_title' => $wgTitle->getDBkey(), 'cur_namespace' => $basenamespace+1 );
+ $old_clause = array( 'old_title' => $wgTitle->getDBkey(), 'old_namespace' => $basenamespace+1 );
+
+ # does it exist?
+ $exists = $dbr->selectField( 'cur', 'COUNT(*)', $cur_clause, $fname );
+
+ # number of edits
+ if ($exists > 0) {
+ $old = $dbr->selectField( 'old', 'COUNT(*)', $old_clause, $fname );
+ $wgOut->addHTML( "<li>" . wfMsg("numtalkedits", $old + 1) . "</li>");
+ }
+ $wgOut->addHTML( "<li>" . wfMsg("numauthors", $authors) . "</li>" );
+
+ # number of authors
+ if ($exists > 0) {
+ $cur_author = $dbr->selectField( 'cur', 'cur_user_text', $cur_clause, $fname );
+ $authors = $dbr->selectField( 'cur', 'COUNT(DISTINCT old_user_text)',
+ $old_clause + array( 'old_user_text<>' . $dbr->addQuotes( $cur_author ) ), $fname );
+
+ $wgOut->addHTML( "<li>" . wfMsg("numtalkauthors", $authors) . "</li></ul>" );
+ }
+ }
+ }