r113902 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113901‎ | r113902 | r113903 >
Date:10:04, 15 March 2012
Author:maxsem
Status:ok
Tags:
Comment:
Refactoring
Modified paths:
  • /trunk/extensions/MobileFrontend/HtmlFormatter.php (modified) (history)
  • /trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/HtmlFormatter.php
@@ -85,6 +85,13 @@
8686 }
8787
8888 /**
 89+ * Instructs the formatter to flatten all tags
 90+ */
 91+ public function flattenAllTags() {
 92+ $this->flatten( '[?!]?[a-z0-9]+' );
 93+ }
 94+
 95+ /**
8996 * Sets whether red links should be flattened
9097 * @param bool $flag
9198 */
Index: trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php
@@ -119,12 +119,16 @@
120120 }
121121 }
122122 // in case of cache miss, render just the needed section
123 - $apiMain = new ApiMain( new FauxRequest(
124 - array( 'page' => $page->getTitle()->getPrefixedText(), 'section' => 0, 'prop' => 'text' ) )
 123+ $api = new ApiMain( new FauxRequest(
 124+ array(
 125+ 'action' => 'parse',
 126+ 'page' => $page->getTitle()->getPrefixedText(),
 127+ 'section' => 0,
 128+ 'prop' => 'text'
 129+ ) )
125130 );
126 - $apiParse = new ApiParse( $apiMain, 'parse' );
127 - $apiParse->execute();
128 - $data = $apiParse->getResultData();
 131+ $api->execute();
 132+ $data = $api->getResultData();
129133 wfProfileOut( __METHOD__ );
130134 return $data['parse']['text']['*'];
131135 }
@@ -138,18 +142,18 @@
139143 */
140144 private function convertText( $text, Title $title, $plainText ) {
141145 wfProfileIn( __METHOD__ );
142 - $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text, false ), $title, 'XHTML' );
143 - $mf->removeImages();
144 - $mf->remove( array( 'table', 'div', 'sup.reference', 'span.coordinates',
 146+ $fmt = new HtmlFormatter( HtmlFormatter::wrapHTML( $text, false ), $title, 'XHTML' );
 147+ $fmt->removeImages();
 148+ $fmt->remove( array( 'table', 'div', 'sup.reference', 'span.coordinates',
145149 'span.geo-multi-punct', 'span.geo-nondefault', '.noexcerpt', '.error' )
146150 );
147151 if ( $plainText ) {
148 - $mf->flatten( '[?!]?[a-z0-9]+' );
 152+ $fmt->flattenAllTags();
149153 } else {
150 - $mf->flatten( array( 'span', 'a' ) );
 154+ $fmt->flatten( array( 'span', 'a' ) );
151155 }
152 - $mf->filterContent();
153 - $text = $mf->getText();
 156+ $fmt->filterContent();
 157+ $text = $fmt->getText();
154158 if ( $plainText ) {
155159 $text = html_entity_decode( $text );
156160 }

Status & tagging log