Index: extensions/ProofreadPage/ApiQueryProofread.php =================================================================== --- extensions/ProofreadPage/ApiQueryProofread.php (revision ) +++ extensions/ProofreadPage/ApiQueryProofread.php (revision ) @@ -0,0 +1,104 @@ +getPageSet(); + $pages = $pageSet->getGoodTitles(); + if ( !count( $pages ) ) { + return true; + } + + // Only include pages that can use the proofread tag + // Why doesn't it strtolower in getCanonicalIndex? + $pageNamespaceText = strtolower( wfMsgForContent( 'proofreadpage_namespace' ) ); + $pageNamespaceId = MWNamespace::getCanonicalIndex( $pageNamespaceText ); + $pageIds = array(); + foreach ( $pages AS $pageId => $title ) { + if ( $title->getNamespace() == $pageNamespaceId ) { + $pageIds[] = $pageId; + } + } + + if ( !count( $pageIds ) ) { + return true; + } + + // Determine the categories defined in MediaWiki: pages + $qualityCategories = $qualityText = array(); + for ( $i = 0; $i < 5; $i++ ) { + $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( "proofreadpage_quality{$i}_category" ) ); + if ( $cat ) { + $qualityCategories[$i] = $cat->getPrefixedText(); + $qualityText[$i] = $cat->getText(); + } + } + $qualityLevels = array_flip( $qualityCategories ); + + // johnduhart, it'd seem sane rather than duplicating the functionality + $params = new FauxRequest(array( + 'action' => 'query', + 'prop' => 'categories', + 'pageids' => implode( '|', $pageIds ), + 'clcategories' => implode( '|', $qualityCategories ), + 'cllimit' => 'max' + )); + + $api = new ApiMain($params); + $api->execute(); + $data = $api->getResultData(); + unset( $api ); + + $result = $this->getResult(); + foreach ( $data['query']['pages'] as $pageid => $data) { + $pageQuality = $qualityLevels[ $data['categories'][0]['title'] ]; + if ( $pageQuality === null ) { + continue; + } + $val = array( 'quality' => $pageQuality, 'quality_text' => $qualityText[ $pageQuality ] ); + $result->addValue( array( 'query', 'pages', $pageid ), 'proofread', $val ); + } + } + + public function getCacheMode( $params ) { + return 'public'; + } + + public function getAllowedParams() { + return array(); + } + + public function getDescription() { + return 'Returns information about the current proofread status of the given pages.'; + } + + protected function getExamples() { + return array( + 'api.php?action=query&generator=allpages&gapnamespace=104&prop=proofread' + ); + } + + public function getVersion() { + return __CLASS__ . ': $Id$'; + } +} \ No newline at end of file Index: extensions/ProofreadPage/ProofreadPage.php =================================================================== --- extensions/ProofreadPage/ProofreadPage.php (revision 93993) +++ extensions/ProofreadPage/ProofreadPage.php (revision ) @@ -44,6 +44,10 @@ $wgSpecialPages['PagesWithoutScans'] = 'PagesWithoutScans'; $wgSpecialPageGroups['PagesWithoutScans'] = 'maintenance'; +# api prop +$wgAutoloadClasses['ApiQueryProofread'] = $dir . 'ApiQueryProofread.php'; +$wgAPIPropModules['proofread'] = 'ApiQueryProofread'; + # Group allowed to modify pagequality $wgGroupPermissions['user']['pagequality'] = true;