From: Sam Reed Date: Sat, 16 Jan 2010 13:07:58 +0000 (+0000) Subject: * (bug 22061) API: add prop=headitems to action=parse X-Git-Tag: 1.31.0-rc.0~38243 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=8e0e8970348b4e9ebc53bc26051274fda1daa03f;p=lhc%2Fweb%2Fwiklou.git * (bug 22061) API: add prop=headitems to action=parse Patch contributed by Paul Copperman --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2f015953db..3879f63fc3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -787,6 +787,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Expand the thumburl to an absolute url to make it consistent with url and descriptionurl * (bug 20233) ApiLogin::execute() doesn't handle LoginForm :: RESET_PASS +* (bug 22061) API: add prop=headitems to action=parse === Languages updated in 1.16 === diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 3090e19903..f1a368f936 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -605,7 +605,7 @@ class OutputPage { $this->enableClientCache( false ); } $this->mNoGallery = $parserOutput->getNoGallery(); - $this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems ); + $this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() ); // Versioning... foreach ( (array)$parserOutput->mTemplateIds as $ns => $dbks ) { if ( isset( $this->mTemplateIds[$ns] ) ) { diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index b6457980fe..ede03a477b 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -157,6 +157,10 @@ class ApiParse extends ApiBase { $result_array['displaytitle'] = $p_result->getDisplayTitle() ? $p_result->getDisplayTitle() : $titleObj->getPrefixedText(); + + if( isset( $prop['headitems'] ) ) + $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() ); + if ( !is_null( $oldid ) ) $result_array['revid'] = intval( $oldid ); @@ -169,6 +173,7 @@ class ApiParse extends ApiBase { 'images' => 'img', 'externallinks' => 'el', 'sections' => 's', + 'headitems' => 'hi' ); $this->setIndexedTagNames( $result_array, $result_mapping ); $result->addValue( null, $this->getModuleName(), $result_array ); @@ -212,6 +217,17 @@ class ApiParse extends ApiBase { return $result; } + private function formatHeadItems( $headItems ) { + $result = array(); + foreach( $headItems as $tag => $content ) { + $entry = array(); + $entry['tag'] = $tag; + $this->getResult()->setContent( $entry, $content ); + $result[] = $entry; + } + return $result; + } + private function setIndexedTagNames( &$array, $mapping ) { foreach ( $mapping as $key => $name ) { if ( isset( $array[$key] ) ) @@ -242,6 +258,7 @@ class ApiParse extends ApiBase { 'sections', 'revid', 'displaytitle', + 'headitems' ) ), 'pst' => false, diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 56fca3ad5b..c7cae737a6 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -50,6 +50,7 @@ class ParserOutput function &getImages() { return $this->mImages; } function &getExternalLinks() { return $this->mExternalLinks; } function getNoGallery() { return $this->mNoGallery; } + function getHeadItems() { return $this->mHeadItems; } function getSubtitle() { return $this->mSubtitle; } function getOutputHooks() { return (array)$this->mOutputHooks; } function getWarnings() { return array_keys( $this->mWarnings ); }