r61125 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61124‎ | r61125 | r61126 >
Date:13:07, 16 January 2010
Author:reedy
Status:ok
Tags:
Comment:
* (bug 22061) API: add prop=headitems to action=parse

Patch contributed by Paul Copperman
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOutput.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/ParserOutput.php
@@ -50,6 +50,7 @@
5151 function &getImages() { return $this->mImages; }
5252 function &getExternalLinks() { return $this->mExternalLinks; }
5353 function getNoGallery() { return $this->mNoGallery; }
 54+ function getHeadItems() { return $this->mHeadItems; }
5455 function getSubtitle() { return $this->mSubtitle; }
5556 function getOutputHooks() { return (array)$this->mOutputHooks; }
5657 function getWarnings() { return array_keys( $this->mWarnings ); }
Index: trunk/phase3/includes/OutputPage.php
@@ -605,7 +605,7 @@
606606 $this->enableClientCache( false );
607607 }
608608 $this->mNoGallery = $parserOutput->getNoGallery();
609 - $this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems );
 609+ $this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
610610 // Versioning...
611611 foreach ( (array)$parserOutput->mTemplateIds as $ns => $dbks ) {
612612 if ( isset( $this->mTemplateIds[$ns] ) ) {
Index: trunk/phase3/includes/api/ApiParse.php
@@ -157,6 +157,10 @@
158158 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
159159 $p_result->getDisplayTitle() :
160160 $titleObj->getPrefixedText();
 161+
 162+ if( isset( $prop['headitems'] ) )
 163+ $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
 164+
161165 if ( !is_null( $oldid ) )
162166 $result_array['revid'] = intval( $oldid );
163167
@@ -169,6 +173,7 @@
170174 'images' => 'img',
171175 'externallinks' => 'el',
172176 'sections' => 's',
 177+ 'headitems' => 'hi'
173178 );
174179 $this->setIndexedTagNames( $result_array, $result_mapping );
175180 $result->addValue( null, $this->getModuleName(), $result_array );
@@ -212,6 +217,17 @@
213218 return $result;
214219 }
215220
 221+ private function formatHeadItems( $headItems ) {
 222+ $result = array();
 223+ foreach( $headItems as $tag => $content ) {
 224+ $entry = array();
 225+ $entry['tag'] = $tag;
 226+ $this->getResult()->setContent( $entry, $content );
 227+ $result[] = $entry;
 228+ }
 229+ return $result;
 230+ }
 231+
216232 private function setIndexedTagNames( &$array, $mapping ) {
217233 foreach ( $mapping as $key => $name ) {
218234 if ( isset( $array[$key] ) )
@@ -242,6 +258,7 @@
243259 'sections',
244260 'revid',
245261 'displaytitle',
 262+ 'headitems'
246263 )
247264 ),
248265 'pst' => false,
Index: trunk/phase3/RELEASE-NOTES
@@ -787,6 +787,7 @@
788788 * Expand the thumburl to an absolute url to make it consistent with url and
789789 descriptionurl
790790 * (bug 20233) ApiLogin::execute() doesn't handle LoginForm :: RESET_PASS
 791+* (bug 22061) API: add prop=headitems to action=parse
791792
792793 === Languages updated in 1.16 ===
793794

Follow-up revisions

RevisionCommit summaryAuthorDate
r66834bug 18608 done in a fashion much closer to how I should've done it originally....reedy16:35, 24 May 2010
r66856bug 18608 done in a fashion much closer to how I should've done it originally....reedy23:24, 24 May 2010

Status & tagging log