Index: trunk/extensions/MobileFrontend/HtmlFormatter.php |
— | — | @@ -85,6 +85,13 @@ |
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
| 89 | + * Instructs the formatter to flatten all tags |
| 90 | + */ |
| 91 | + public function flattenAllTags() { |
| 92 | + $this->flatten( '[?!]?[a-z0-9]+' ); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
89 | 96 | * Sets whether red links should be flattened |
90 | 97 | * @param bool $flag |
91 | 98 | */ |
Index: trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php |
— | — | @@ -119,12 +119,16 @@ |
120 | 120 | } |
121 | 121 | } |
122 | 122 | // 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 | + ) ) |
125 | 130 | ); |
126 | | - $apiParse = new ApiParse( $apiMain, 'parse' ); |
127 | | - $apiParse->execute(); |
128 | | - $data = $apiParse->getResultData(); |
| 131 | + $api->execute(); |
| 132 | + $data = $api->getResultData(); |
129 | 133 | wfProfileOut( __METHOD__ ); |
130 | 134 | return $data['parse']['text']['*']; |
131 | 135 | } |
— | — | @@ -138,18 +142,18 @@ |
139 | 143 | */ |
140 | 144 | private function convertText( $text, Title $title, $plainText ) { |
141 | 145 | 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', |
145 | 149 | 'span.geo-multi-punct', 'span.geo-nondefault', '.noexcerpt', '.error' ) |
146 | 150 | ); |
147 | 151 | if ( $plainText ) { |
148 | | - $mf->flatten( '[?!]?[a-z0-9]+' ); |
| 152 | + $fmt->flattenAllTags(); |
149 | 153 | } else { |
150 | | - $mf->flatten( array( 'span', 'a' ) ); |
| 154 | + $fmt->flatten( array( 'span', 'a' ) ); |
151 | 155 | } |
152 | | - $mf->filterContent(); |
153 | | - $text = $mf->getText(); |
| 156 | + $fmt->filterContent(); |
| 157 | + $text = $fmt->getText(); |
154 | 158 | if ( $plainText ) { |
155 | 159 | $text = html_entity_decode( $text ); |
156 | 160 | } |