Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F7803
proofread.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:34 PM
2014-11-21 23:34:07 (UTC+0)
Size
5 KB
Referenced Files
None
Subscribers
None
proofread.patch
View Options
Index: ProofreadPage_body.php
===================================================================
--- ProofreadPage_body.php (wersja 95122)
+++ ProofreadPage_body.php (kopia robocza)
@@ -25,6 +25,37 @@
/* Parser object for index pages */
private static $index_parser = null;
+ /**
+ * Returns id of Page namespace.
+ *
+ * @return integer namespace id
+ */
+ public static function getPageNamespaceId() {
+ static $namespace = null;
+ if ($namespace != null) {
+ return $namespace;
+ }
+ $namespaceText = strtolower( wfMsgForContent( 'proofreadpage_namespace' ) );
+ $namespace = MWNamespace::getCanonicalIndex( $namespaceText );
+ return $namespace;
+ }
+
+ /**
+ * Returns id of Index namespace.
+ *
+ * @return integer namespace id
+ */
+ public static function getIndexNamespaceId() {
+ static $namespace = null;
+ if ($namespace != null) {
+ return $namespace;
+ }
+ $namespaceText = strtolower( wfMsgForContent( 'proofreadpage_index_namespace' ) );
+ $namespace = MWNamespace::getCanonicalIndex( $namespaceText );
+ return $namespace;
+ }
+
+ /** @deprecated */
private static function getPageAndIndexNamespace() {
static $res = null;
if ( $res === null ) {
Index: ApiQueryProofread.php
===================================================================
--- ApiQueryProofread.php (wersja 95122)
+++ ApiQueryProofread.php (kopia robocza)
@@ -29,10 +29,7 @@
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 );
+ $pageNamespaceId = ProofreadPage::getPageNamespaceId();
$pageIds = array();
foreach ( $pages AS $pageId => $title ) {
if ( $title->getNamespace() == $pageNamespaceId ) {
Index: ApiQueryProofreadInfo.php
===================================================================
--- ApiQueryProofreadInfo.php (wersja 0)
+++ ApiQueryProofreadInfo.php (wersja 0)
@@ -0,0 +1,120 @@
+<?php
+/**
+ * Created on August 21, 2011
+ *
+ * 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
+ */
+
+/**
+ * A query action to return meta information about the proofread extension.
+ *
+ * @ingroup API
+ */
+class ApiQueryProofreadInfo extends ApiQueryBase {
+
+ public function __construct( $query, $moduleName ) {
+ parent::__construct( $query, $moduleName, 'pi' );
+ }
+
+ public function execute() {
+ $params = $this->extractRequestParams();
+ foreach ( $params['prop'] as $p ) {
+ switch ( $p ) {
+ case 'namespaces':
+ $this->appendNamespaces( $p );
+ break;
+ case 'qualitylevels':
+ $this->appendQualityLevels( $p );
+ break;
+ default:
+ ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
+ }
+ }
+ }
+
+ protected function appendNamespaces( $property ) {
+ global $wgContLang;
+ $data = array();
+
+ $index = ProofreadPage::getIndexNamespaceId();
+ if ( $index != null ) {
+ $data['index']['id'] = $index;
+ }
+
+ $page = ProofreadPage::getPageNamespaceId();
+ if ( $page != null ) {
+ $data['page']['id'] = $page;
+ }
+
+ return $this->getResult()->addValue( 'query', 'proofreadnamespaces', $data );
+ }
+
+ protected function appendQualityLevels( $property ) {
+ $data = array();
+ for ( $i = 0; $i < 5; $i++ ) {
+ $level = array();
+ $level['id'] = $i;
+ $level['category'] = wfMsgForContent( "proofreadpage_quality{$i}_category" );
+ $data[$i] = $level;
+ }
+ $this->getResult()->setIndexedTagName( $data, 'level' );
+ return $this->getResult()->addValue( 'query', 'proofreadqualitylevels', $data );
+ }
+
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
+ public function getAllowedParams() {
+ return array(
+ 'prop' => array(
+ ApiBase::PARAM_DFLT => 'namespaces|qualitylevels',
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_TYPE => array(
+ 'namespaces',
+ 'qualitylevels',
+ )
+ ),
+ );
+ }
+
+ public function getParamDescription() {
+ $p = $this->getModulePrefix();
+ return array(
+ 'prop' => array(
+ 'Which proofread properties to get:',
+ ' namespaces - Information about Page and Index namespaces',
+ ' qualitylevels - List of proofread quality levels'
+ )
+ );
+ }
+
+ public function getDescription() {
+ return 'Return information about configuration of ProofreadPage extension';
+ }
+
+ public function getExamples() {
+ return array(
+ 'api.php?action=query&meta=proofreadinfo',
+ 'api.php?action=query&meta=proofreadinfo&piprop=namespaces|qualitylevels',
+ 'api.php?action=query&meta=proofreadinfo&piprop=namespaces',
+ );
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id: $';
+ }
+}
Index: ProofreadPage.php
===================================================================
--- ProofreadPage.php (wersja 95122)
+++ ProofreadPage.php (kopia robocza)
@@ -48,6 +48,11 @@
$wgAutoloadClasses['ApiQueryProofread'] = $dir . 'ApiQueryProofread.php';
$wgAPIPropModules['proofread'] = 'ApiQueryProofread';
+# api proofreadinfo
+$wgAutoloadClasses['ApiQueryProofreadInfo'] = $dir . 'ApiQueryProofreadInfo.php';
+$wgAPIMetaModules['proofreadinfo'] = 'ApiQueryProofreadInfo';
+
+
# 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
7331
Default Alt Text
proofread.patch (5 KB)
Attached To
Mode
T31396: Proofread Page extension needs a way to select index and page namespaces
Attached
Detach File
Event Timeline
Log In to Comment