* (bug 22061) API: add prop=headitems to action=parse
Patch contributed by Paul Copperman
This commit is contained in:
parent
001b4fe211
commit
8e0e897034
4 changed files with 20 additions and 1 deletions
|
|
@ -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 ===
|
||||
|
||||
|
|
|
|||
|
|
@ -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] ) ) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 ); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue