From: Brion Vibber Date: Mon, 28 Feb 2005 04:52:37 +0000 (+0000) Subject: Fix page info for new schema, use localized digits, de-confusify the code. X-Git-Tag: 1.5.0alpha1~690 X-Git-Url: http://git.cyclocoop.org/geomaker.php?a=commitdiff_plain;h=fb2452173350f5c52ad9b1a1f317951d43f9396c;p=lhc%2Fweb%2Fwiklou.git Fix page info for new schema, use localized digits, de-confusify the code. --- diff --git a/includes/Article.php b/includes/Article.php index 6c35655151..62f3129b18 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -2072,78 +2072,91 @@ class Article { /** * Info about this page + * Called for ?action=info when $wgAllowPageInfo is on. + * + * @access public */ function info() { - global $wgUser, $wgTitle, $wgOut, $wgAllowPageInfo; + global $wgLang, $wgOut, $wgAllowPageInfo; $fname = 'Article::info'; -wfDebugDieBacktrace( 'This function is apparently not called by any other PHP file and might be obsolete.' ); - if ( !$wgAllowPageInfo ) { $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' ); return; } - $dbr =& $this->getDB(); - - $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 ); + $page = $this->mTitle->getSubjectPage(); + + $wgOut->setPagetitle( $page->getPrefixedText() ); $wgOut->setSubtitle( wfMsg( 'infosubtitle' )); # first, see if the page exists at all. - $exists = $dbr->selectField( 'cur', 'COUNT(*)', $cur_clause, $fname, $this->getSelectOptions() ); - if ($exists < 1) { + $exists = $page->getArticleId() != 0; + if( !$exists ) { $wgOut->addHTML( wfMsg('noarticletext') ); } else { - $numwatchers = $dbr->selectField( 'watchlist', 'COUNT(*)', $wl_clause, $fname, + $dbr =& $this->getDB( DB_SLAVE ); + $wl_clause = array( + 'wl_title' => $page->getDBkey(), + 'wl_namespace' => $page->getNamespace() ); + $numwatchers = $dbr->selectField( + 'watchlist', + 'COUNT(*)', + $wl_clause, + $fname, $this->getSelectOptions() ); - $wgOut->addHTML( "' ); + + } + } + + /** + * Return the total number of edits and number of unique editors + * on a given page. If page does not exist, returns false. + * + * @param Title $title + * @return array + * @access private + */ + function pageCountInfo( $title ) { + $id = $title->getArticleId(); + if( $id == 0 ) { + return false; } + + $dbr =& $this->getDB( DB_SLAVE ); + + $rev_clause = array( 'rev_page' => $id ); + $fname = 'Article::pageCountInfo'; + + $edits = $dbr->selectField( + 'revision', + 'COUNT(rev_page)', + $rev_clause, + $fname, + $this->getSelectOptions() ); + + $authors = $dbr->selectField( + 'revision', + 'COUNT(DISTINCT rev_user_text)', + $rev_clause, + $fname, + $this->getSelectOptions() ); + + return array( 'edits' => $edits, 'authors' => $authors ); } }