Index: trunk/extensions/Translate/SpecialManageGroups.php |
— | — | @@ -87,17 +87,6 @@ |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | | - protected function makeSectionElement( $legend, $type, $content ) { |
92 | | - $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" ); |
93 | | - $legendParams = array( 'class' => 'mw-translate-manage-legend' ); |
94 | | - $contentParams = array( 'class' => 'mw-tpt-sp-content' ); |
95 | | - |
96 | | - return Xml::tags( 'div', $containerParams, |
97 | | - Xml::tags( 'div', $legendParams, $legend ) . |
98 | | - Xml::tags( 'div', $contentParams, $content ) |
99 | | - ); |
100 | | - } |
101 | | - |
102 | 91 | public function getTitle() { |
103 | 92 | return SpecialPage::getTitleFor( 'Translate', 'manage' ); |
104 | 93 | } |
— | — | @@ -166,7 +155,7 @@ |
167 | 156 | |
168 | 157 | $text = TranslateUtils::convertWhiteSpaceToHTML( $value ); |
169 | 158 | |
170 | | - $changed[] = $this->makeSectionElement( $name, 'new', $text ); |
| 159 | + $changed[] = MessageWebImporter::makeSectionElement( $name, 'new', $text ); |
171 | 160 | } else { |
172 | 161 | if ( $fuzzy ) { |
173 | 162 | $old = TRANSLATE_FUZZY . $old; |
— | — | @@ -241,7 +230,7 @@ |
242 | 231 | implode( ' ', $act ) |
243 | 232 | ); |
244 | 233 | |
245 | | - $changed[] = $this->makeSectionElement( $name, $type, $text ); |
| 234 | + $changed[] = MessageWebImporter::makeSectionElement( $name, $type, $text ); |
246 | 235 | } |
247 | 236 | } |
248 | 237 | |
— | — | @@ -258,7 +247,7 @@ |
259 | 248 | |
260 | 249 | $text = TranslateUtils::convertWhiteSpaceToHTML( $collection[$s]->translation() ); |
261 | 250 | |
262 | | - $changed[] = $this->makeSectionElement( $name, 'deleted', $text ); |
| 251 | + $changed[] = MessageWebImporter::makeSectionElement( $name, 'deleted', $text ); |
263 | 252 | } |
264 | 253 | } |
265 | 254 | |
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php |
— | — | @@ -4,9 +4,11 @@ |
5 | 5 | * There are two modes 1) list of all pages 2) review mode for one page. |
6 | 6 | * |
7 | 7 | * @author Niklas Laxström |
8 | | - * @copyright Copyright © 2009 Niklas Laxström |
| 8 | + * @author Siebrand Mazeland |
| 9 | + * @copyright Copyright © 2009-2010 Niklas Laxström, Siebrand Mazeland |
9 | 10 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
10 | 11 | */ |
| 12 | + |
11 | 13 | class SpecialPageTranslation extends SpecialPage { |
12 | 14 | function __construct() { |
13 | 15 | SpecialPage::SpecialPage( 'PageTranslation' ); |
— | — | @@ -284,7 +286,17 @@ |
285 | 287 | $text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() ); |
286 | 288 | } |
287 | 289 | |
288 | | - $this->makeSectionElement( $name, $s->type, $text ); |
| 290 | + $type = $s->type; |
| 291 | + $wgOut->addHTML( MessageWebImporter::makeSectionElement( |
| 292 | + $name, |
| 293 | + $type, |
| 294 | + $text, |
| 295 | + array( |
| 296 | + 'container' => 'mw-tpt-sp-section mw-tpt-sp-section-type-{$type}', |
| 297 | + 'legend' => 'mw-tpt-sp-legend', |
| 298 | + 'content' => 'mw-tpt-sp-content' |
| 299 | + ) |
| 300 | + ) ); |
289 | 301 | } |
290 | 302 | |
291 | 303 | $deletedSections = $page->getParse()->getDeletedSections(); |
— | — | @@ -292,8 +304,18 @@ |
293 | 305 | $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-deleted' ); |
294 | 306 | foreach ( $deletedSections as $s ) { |
295 | 307 | $name = wfMsgHtml( 'tpt-section-deleted', htmlspecialchars( $s->id ) ); |
| 308 | + $type = $s->type; |
296 | 309 | $text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() ); |
297 | | - $this->makeSectionElement( $name, $s->type, $text ); |
| 310 | + $wgOut->addHTML( MessageWebImporter::makeSectionElement( |
| 311 | + $name, |
| 312 | + $type, |
| 313 | + $text, |
| 314 | + array( |
| 315 | + 'container' => 'mw-tpt-sp-section mw-tpt-sp-section-type-{$type}', |
| 316 | + 'legend' => 'mw-tpt-sp-legend', |
| 317 | + 'content' => 'mw-tpt-sp-content' |
| 318 | + ) |
| 319 | + ) ); |
298 | 320 | } |
299 | 321 | } |
300 | 322 | |
— | — | @@ -324,21 +346,6 @@ |
325 | 347 | ); |
326 | 348 | } |
327 | 349 | |
328 | | - protected function makeSectionElement( $legend, $type, $content ) { |
329 | | - global $wgOut; |
330 | | - |
331 | | - $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" ); |
332 | | - $legendParams = array( 'class' => 'mw-tpt-sp-legend' ); |
333 | | - $contentParams = array( 'class' => 'mw-tpt-sp-content' ); |
334 | | - |
335 | | - $wgOut->addHTML( |
336 | | - Xml::tags( 'div', $containerParams, |
337 | | - Xml::tags( 'div', $legendParams, $legend ) . |
338 | | - Xml::tags( 'div', $contentParams, $content ) |
339 | | - ) |
340 | | - ); |
341 | | - } |
342 | | - |
343 | 350 | /** |
344 | 351 | * This function does the heavy duty of marking a page. |
345 | 352 | * - Updates the source page with section markers. |
Index: trunk/extensions/Translate/utils/MessageWebImporter.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | '<code style="font-weight:normal;">' . htmlspecialchars( $key ) . '</code>' |
155 | 155 | ); |
156 | 156 | $text = TranslateUtils::convertWhiteSpaceToHTML( $value ); |
157 | | - $changed[] = $this->makeSectionElement( $name, 'new', $text ); |
| 157 | + $changed[] = self::makeSectionElement( $name, 'new', $text ); |
158 | 158 | } else { |
159 | 159 | $diff->setText( $old, $value ); |
160 | 160 | $text = $diff->getDiff( '', '' ); |
— | — | @@ -219,7 +219,7 @@ |
220 | 220 | implode( ' ', $act ) |
221 | 221 | ); |
222 | 222 | |
223 | | - $changed[] = $this->makeSectionElement( $name, $type, $text ); |
| 223 | + $changed[] = self::makeSectionElement( $name, $type, $text ); |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
— | — | @@ -234,7 +234,7 @@ |
235 | 235 | '<code style="font-weight:normal;">' . htmlspecialchars( $s ) . '</code>' |
236 | 236 | ); |
237 | 237 | $text = TranslateUtils::convertWhiteSpaceToHTML( $collection[$s]->translation() ); |
238 | | - $changed[] = $this->makeSectionElement( $name, 'deleted', $text ); |
| 238 | + $changed[] = self::makeSectionElement( $name, 'deleted', $text ); |
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
— | — | @@ -417,14 +417,38 @@ |
418 | 418 | return Title::makeTitleSafe( $ns, $titlekey ); |
419 | 419 | } |
420 | 420 | |
421 | | - protected function makeSectionElement( $legend, $type, $content ) { |
422 | | - $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" ); |
423 | | - $legendParams = array( 'class' => 'mw-translate-manage-legend' ); |
424 | | - $contentParams = array( 'class' => 'mw-tpt-sp-content' ); |
| 421 | + /** |
| 422 | + * Make section elements |
| 423 | + * |
| 424 | + * @param $legend String: contents of legend |
| 425 | + * @param $type String: contents of type class |
| 426 | + * @param $content String: contents of content class |
| 427 | + * @param $params Array: array of key-value pairs to override the standard class names |
| 428 | + * |
| 429 | + * @return section element |
| 430 | + */ |
| 431 | + public static function makeSectionElement( $legend, $type, $content, $params = array() ) { |
| 432 | + if( isset( $params['container'] ) { |
| 433 | + $containerParams = array( 'class' => $params['container'] ); |
| 434 | + } else { |
| 435 | + $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" ); |
| 436 | + } |
425 | 437 | |
426 | | - return Xml::tags( 'div', $containerParams, |
427 | | - Xml::tags( 'div', $legendParams, $legend ) . |
428 | | - Xml::tags( 'div', $contentParams, $content ) |
| 438 | + if( isset( $params['legend'] ) { |
| 439 | + $legendParams = array( 'class' => $params['legend'] ); |
| 440 | + } else { |
| 441 | + $legendParams = array( 'class' => 'mw-translate-manage-legend' ); |
| 442 | + } |
| 443 | + |
| 444 | + if( isset( $params['content'] ) { |
| 445 | + $contentParams = array( 'class' => $params['content'] ); |
| 446 | + } else { |
| 447 | + $contentParams = array( 'class' => 'mw-tpt-sp-content' ); |
| 448 | + } |
| 449 | + |
| 450 | + return Xml::tags( |
| 451 | + 'div', $containerParams, |
| 452 | + Xml::tags( 'div', $legendParams, $legend ) . Xml::tags( 'div', $contentParams, $content ) |
429 | 453 | ); |
430 | 454 | } |
431 | 455 | |