From: umherirrender Date: Tue, 4 Feb 2014 19:16:59 +0000 (+0100) Subject: Add prop 'limitreportdata' and 'limitreporthtml' to action=parse X-Git-Tag: 1.31.0-rc.0~16979 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=57551f4252246fa5843fc1306f7323d1106ea792;p=lhc%2Fweb%2Fwiklou.git Add prop 'limitreportdata' and 'limitreporthtml' to action=parse This allows the get the limit report in provided uselang and not only the english version out of the parsed html. Change-Id: I2efc606623190756f5c993f48ef29bb0d384a95b --- diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index e1ceb91590..660869c259 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -162,6 +162,7 @@ production. * (bug 23005) Added action=revisiondelete. * Added siprop=restrictions to API action=query&meta=siteinfo for querying possible page restriction (protection) levels and types. +* Added prop 'limitreportdata' and 'limitreporthtml' to action=parse. === Languages updated in 1.23 === diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 9963edad1c..495071abef 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -362,6 +362,15 @@ class ApiParse extends ApiBase { $result_array['properties'] = $this->formatProperties( $p_result->getProperties() ); } + if ( isset( $prop['limitreportdata'] ) ) { + $result_array['limitreportdata'] = $this->formatLimitReportData( $p_result->getLimitReportData() ); + } + if ( isset( $prop['limitreporthtml'] ) ) { + $limitreportHtml = EditPage::getPreviewLimitReport( $p_result ); + $result_array['limitreporthtml'] = array(); + ApiResult::setContent( $result_array['limitreporthtml'], $limitreportHtml ); + } + if ( $params['generatexml'] ) { if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) { $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" ); @@ -390,6 +399,7 @@ class ApiParse extends ApiBase { 'sections' => 's', 'headitems' => 'hi', 'properties' => 'pp', + 'limitreportdata' => 'lr', ); $this->setIndexedTagNames( $result_array, $result_mapping ); $result->addValue( null, $this->getModuleName(), $result_array ); @@ -645,6 +655,25 @@ class ApiParse extends ApiBase { return $result; } + private function formatLimitReportData( $limitReportData ) { + $result = array(); + $apiResult = $this->getResult(); + + foreach ( $limitReportData as $name => $value ) { + $entry = array(); + $entry['name'] = $name; + if ( !is_array( $value ) ) { + $value = array( $value ); + } + $apiResult->setIndexedTagName( $value, 'param' ); + $apiResult->setIndexedTagName_recursive( $value, 'param' ); + $entry = array_merge( $entry, $value ); + $result[] = $entry; + } + + return $result; + } + private function setIndexedTagNames( &$array, $mapping ) { foreach ( $mapping as $key => $name ) { if ( isset( $array[$key] ) ) { @@ -688,6 +717,8 @@ class ApiParse extends ApiBase { 'iwlinks', 'wikitext', 'properties', + 'limitreportdata', + 'limitreporthtml', ) ), 'pst' => false, @@ -741,6 +772,10 @@ class ApiParse extends ApiBase { ' iwlinks - Gives interwiki links in the parsed wikitext', ' wikitext - Gives the original wikitext that was parsed', ' properties - Gives various properties defined in the parsed wikitext', + ' limitreportdata - Gives the limit report in a structured way.', + " Gives no data, when {$p}disablepp is set.", + ' limitreporthtml - Gives the HTML version of the limit report.', + " Gives no data, when {$p}disablepp is set.", ), 'effectivelanglinks' => array( 'Includes language links supplied by extensions',