Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F7469
b28893a.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 11:25 PM
2014-11-21 23:25:44 (UTC+0)
Size
4 KB
Referenced Files
None
Subscribers
None
b28893a.patch
View Options
Index: extensions/ProofreadPage/ApiQueryProofread.php
===================================================================
--- extensions/ProofreadPage/ApiQueryProofread.php (revision )
+++ extensions/ProofreadPage/ApiQueryProofread.php (revision )
@@ -0,0 +1,104 @@
+<?php
+/*
+ * Created on August 8, 2011
+ *
+ * API module for MediaWiki's Proofread extension
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+class ApiQueryProofread extends ApiQueryBase {
+
+ public function execute() {
+ $pageSet = $this->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 );
+
+ // <Reedy> 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;
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6999
Default Alt Text
b28893a.patch (4 KB)
Attached To
Mode
T30893: Proofread Page extension needs an API module to retrieve page status
Attached
Detach File
Event Timeline
Log In to Comment