Index: trunk/extensions/Translate/tag/TranslatablePage.php |
— | — | @@ -60,7 +60,9 @@ |
61 | 61 | |
62 | 62 | public static function newFromRevision( Title $title, $revision ) { |
63 | 63 | $rev = Revision::newFromTitle( $title, $revision ); |
64 | | - if ( $rev === null ) throw new MWException( 'Revision is null' ); |
| 64 | + if ( $rev === null ) { |
| 65 | + throw new MWException( 'Revision is null' ); |
| 66 | + } |
65 | 67 | |
66 | 68 | $obj = new self( $title ); |
67 | 69 | $obj->source = 'revision'; |
— | — | @@ -104,8 +106,12 @@ |
105 | 107 | } |
106 | 108 | } |
107 | 109 | |
108 | | - if ( !is_string( $this->text ) ) throw new MWException( 'We have no text' ); |
| 110 | + if ( !is_string( $this->text ) ) { |
| 111 | + throw new MWException( 'We have no text' ); |
| 112 | + } |
| 113 | + |
109 | 114 | $this->init = true; |
| 115 | + |
110 | 116 | return $this->text; |
111 | 117 | } |
112 | 118 | |
— | — | @@ -135,7 +141,9 @@ |
136 | 142 | * page. |
137 | 143 | */ |
138 | 144 | public function getParse() { |
139 | | - if ( isset( $this->cachedParse ) ) return $this->cachedParse; |
| 145 | + if ( isset( $this->cachedParse ) ) { |
| 146 | + return $this->cachedParse; |
| 147 | + } |
140 | 148 | |
141 | 149 | $text = $this->getText(); |
142 | 150 | |
— | — | @@ -149,8 +157,11 @@ |
150 | 158 | $re = '~(<translate>)\s*(.*?)(</translate>)~s'; |
151 | 159 | $matches = array(); |
152 | 160 | $ok = preg_match_all( $re, $text, $matches, PREG_OFFSET_CAPTURE ); |
153 | | - if ( $ok === 0 ) break; // No matches |
154 | 161 | |
| 162 | + if ( $ok === 0 ) { |
| 163 | + break; // No matches |
| 164 | + } |
| 165 | + |
155 | 166 | // Do-placehold for the whole stuff |
156 | 167 | $ph = self::getUniq(); |
157 | 168 | $start = $matches[0][0][1]; |
— | — | @@ -183,6 +194,7 @@ |
184 | 195 | foreach ( $tagPlaceHolders as $ph => $value ) { |
185 | 196 | $prettyTemplate = str_replace( $ph, '[...]', $prettyTemplate ); |
186 | 197 | } |
| 198 | + |
187 | 199 | if ( strpos( $text, '<translate>' ) !== false ) { |
188 | 200 | throw new TPException( array( 'pt-parse-open', $prettyTemplate ) ); |
189 | 201 | } elseif ( strpos( $text, '</translate>' ) !== false ) { |
— | — | @@ -209,11 +221,13 @@ |
210 | 222 | |
211 | 223 | public static function armourNowiki( &$holders, $text ) { |
212 | 224 | $re = '~(<nowiki>)(.*?)(</nowiki>)~'; |
| 225 | + |
213 | 226 | while ( preg_match( $re, $text, $matches ) ) { |
214 | 227 | $ph = self::getUniq(); |
215 | 228 | $text = str_replace( $matches[0], $ph, $text ); |
216 | 229 | $holders[$ph] = $matches[0]; |
217 | 230 | } |
| 231 | + |
218 | 232 | return $text; |
219 | 233 | } |
220 | 234 | |
— | — | @@ -221,6 +235,7 @@ |
222 | 236 | foreach ( $holders as $ph => $value ) { |
223 | 237 | $text = str_replace( $ph, $value, $text ); |
224 | 238 | } |
| 239 | + |
225 | 240 | return $text; |
226 | 241 | } |
227 | 242 | |
— | — | @@ -229,6 +244,7 @@ |
230 | 245 | */ |
231 | 246 | protected static function getUniq() { |
232 | 247 | static $i = 0; |
| 248 | + |
233 | 249 | return "\x7fUNIQ" . dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) ) . '|' . $i++; |
234 | 250 | } |
235 | 251 | |
— | — | @@ -247,7 +263,7 @@ |
248 | 264 | protected function sectionise( &$sections, $text ) { |
249 | 265 | $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE; |
250 | 266 | $parts = preg_split( '~(\s*\n\n\s*|\s*$)~', $text, -1, $flags ); |
251 | | - |
| 267 | + |
252 | 268 | $template = ''; |
253 | 269 | foreach ( $parts as $_ ) { |
254 | 270 | if ( trim( $_ ) === '' ) { |
— | — | @@ -258,6 +274,7 @@ |
259 | 275 | $template .= $ph; |
260 | 276 | } |
261 | 277 | } |
| 278 | + |
262 | 279 | return $template; |
263 | 280 | } |
264 | 281 | |
— | — | @@ -275,6 +292,7 @@ |
276 | 293 | $re = '~<!--T:(.*?)-->~'; |
277 | 294 | $matches = array(); |
278 | 295 | $count = preg_match_all( $re, $content, $matches, PREG_SET_ORDER ); |
| 296 | + |
279 | 297 | if ( $count > 1 ) { |
280 | 298 | throw new TPException( array( 'pt-shake-multiple', $content ) ); |
281 | 299 | } |
— | — | @@ -291,6 +309,7 @@ |
292 | 310 | $rer2 = '~\s*<!--T:(.*?)-->\n~'; // Sections with title |
293 | 311 | $content = preg_replace( $rer1, '', $content ); |
294 | 312 | $content = preg_replace( $rer2, '', $content ); |
| 313 | + |
295 | 314 | if ( preg_match( $re, $content ) === 1 ) { |
296 | 315 | throw new TPException( array( 'pt-shake-position', $content ) ); |
297 | 316 | } elseif ( trim( $content ) === '' ) { |
— | — | @@ -316,12 +335,13 @@ |
317 | 336 | } |
318 | 337 | |
319 | 338 | protected function addTag( $tag, $revision, $value = null ) { |
320 | | - |
321 | 339 | $dbw = wfGetDB( DB_MASTER ); |
322 | 340 | |
323 | 341 | $id = $this->getTagId( $tag ); |
324 | 342 | |
325 | | - if ( is_object( $revision ) ) throw new MWException( 'Got object, excepted id' ); |
| 343 | + if ( is_object( $revision ) ) { |
| 344 | + throw new MWException( 'Got object, excepted id' ); |
| 345 | + } |
326 | 346 | |
327 | 347 | $conds = array( |
328 | 348 | 'rt_page' => $this->getTitle()->getArticleId(), |
— | — | @@ -329,13 +349,18 @@ |
330 | 350 | 'rt_revision' => $revision |
331 | 351 | ); |
332 | 352 | $dbw->delete( 'revtag', $conds, __METHOD__ ); |
333 | | - if ( $value !== null ) $conds['rt_value'] = serialize( implode( '|', $value ) ); |
| 353 | + |
| 354 | + if ( $value !== null ) { |
| 355 | + $conds['rt_value'] = serialize( implode( '|', $value ) ); |
| 356 | + } |
| 357 | + |
334 | 358 | $dbw->insert( 'revtag', $conds, __METHOD__ ); |
335 | 359 | } |
336 | 360 | |
337 | 361 | public function getMarkedTag( $db = DB_SLAVE ) { |
338 | 362 | return $this->getTag( 'tp:mark' ); |
339 | 363 | } |
| 364 | + |
340 | 365 | public function getReadyTag( $db = DB_SLAVE ) { |
341 | 366 | return $this->getTag( 'tp:tag' ); |
342 | 367 | } |
— | — | @@ -359,14 +384,18 @@ |
360 | 385 | |
361 | 386 | $id = $this->getTagId( $tag ); |
362 | 387 | |
363 | | - if ( !$this->getTitle()->exists() ) return false; |
| 388 | + if ( !$this->getTitle()->exists() ) { |
| 389 | + return false; |
| 390 | + } |
364 | 391 | |
365 | 392 | $fields = 'rt_revision'; |
366 | 393 | $conds = array( |
367 | 394 | 'rt_page' => $this->getTitle()->getArticleId(), |
368 | 395 | 'rt_type' => $id, |
369 | 396 | ); |
| 397 | + |
370 | 398 | $options = array( 'ORDER BY' => 'rt_revision DESC' ); |
| 399 | + |
371 | 400 | return $db->selectField( 'revtag', $fields, $conds, __METHOD__, $options ); |
372 | 401 | } |
373 | 402 | |
— | — | @@ -377,7 +406,10 @@ |
378 | 407 | 'group' => 'page|' . $this->getTitle()->getPrefixedText(), |
379 | 408 | 'task' => 'view' |
380 | 409 | ); |
381 | | - if ( $code ) $params['language'] = $code; |
| 410 | + if ( $code ) { |
| 411 | + $params['language'] = $code; |
| 412 | + } |
| 413 | + |
382 | 414 | return $translate->getFullURL( $params ); |
383 | 415 | } |
384 | 416 | |
— | — | @@ -394,6 +426,7 @@ |
395 | 427 | 'rt_type' => $id, |
396 | 428 | ); |
397 | 429 | $options = array( 'ORDER BY' => 'rt_revision DESC' ); |
| 430 | + |
398 | 431 | return $db->select( 'revtag', $fields, $conds, __METHOD__, $options ); |
399 | 432 | } |
400 | 433 | |
— | — | @@ -407,9 +440,12 @@ |
408 | 441 | array( |
409 | 442 | 'page_namespace' => $this->getTitle()->getNamespace(), |
410 | 443 | "page_title LIKE '$likePattern'" |
411 | | - ), __METHOD__ ); |
| 444 | + ), |
| 445 | + __METHOD__ |
| 446 | + ); |
412 | 447 | |
413 | 448 | $titles = TitleArray::newFromResult( $res ); |
| 449 | + |
414 | 450 | return $titles; |
415 | 451 | } |
416 | 452 | |
— | — | @@ -418,19 +454,23 @@ |
419 | 455 | global $wgMemc, $wgRequest; |
420 | 456 | $memcKey = wfMemcKey( 'pt', 'status', $this->getTitle()->getPrefixedText() ); |
421 | 457 | $cache = $wgMemc->get( $memcKey ); |
| 458 | + |
422 | 459 | if ( !$force && $wgRequest->getText( 'action' ) !== 'purge' ) { |
423 | | - if ( is_array( $cache ) ) return $cache; |
| 460 | + if ( is_array( $cache ) ) { |
| 461 | + return $cache; |
| 462 | + } |
424 | 463 | } |
425 | 464 | |
426 | 465 | $titles = $this->getTranslationPages(); |
427 | 466 | |
428 | 467 | // Calculate percentages for the available translations |
429 | 468 | $group = MessageGroups::getGroup( 'page|' . $this->getTitle()->getPrefixedText() ); |
430 | | - if ( !$group instanceof WikiPageMessageGroup ) return null; |
| 469 | + if ( !$group instanceof WikiPageMessageGroup ) { |
| 470 | + return null; |
| 471 | + } |
431 | 472 | |
432 | 473 | $markedRevs = $this->getMarkedRevs( 'tp:mark' ); |
433 | 474 | |
434 | | - |
435 | 475 | $temp = array(); |
436 | 476 | foreach ( $titles as $t ) { |
437 | 477 | list( , $code ) = TranslateUtils::figureMessage( $t->getText() ); |
— | — | @@ -439,19 +479,22 @@ |
440 | 480 | $percent = $this->getPercentageInternal( $collection, $markedRevs ); |
441 | 481 | // To avoid storing 40 decimals of inaccuracy, truncate to two decimals |
442 | 482 | $temp[$collection->code] = sprintf( '%.2f', $percent ); |
443 | | - |
444 | 483 | } |
| 484 | + |
445 | 485 | // Content language is always up-to-date |
446 | 486 | global $wgContLang; |
447 | 487 | $temp[$wgContLang->getCode()] = 1.00; |
448 | 488 | |
449 | 489 | $wgMemc->set( $memcKey, $temp, 60 * 60 * 12 ); |
| 490 | + |
450 | 491 | return $temp; |
451 | 492 | } |
452 | 493 | |
453 | 494 | protected function getPercentageInternal( $collection, $markedRevs ) { |
454 | 495 | $count = count( $collection ); |
455 | | - if ( $count === 0 ) return 0; |
| 496 | + if ( $count === 0 ) { |
| 497 | + return 0; |
| 498 | + } |
456 | 499 | |
457 | 500 | // We want to get fuzzy though |
458 | 501 | $collection->filter( 'hastranslation', false ); |
— | — | @@ -463,7 +506,9 @@ |
464 | 507 | $score = 1; |
465 | 508 | |
466 | 509 | // Fuzzy halves score |
467 | | - if ( $message->hasTag( 'fuzzy' ) ) $score *= 0.5; |
| 510 | + if ( $message->hasTag( 'fuzzy' ) ) { |
| 511 | + $score *= 0.5; |
| 512 | + } |
468 | 513 | |
469 | 514 | // Reduce 20% for every newer revision than what is translated against |
470 | 515 | $rev = $this->getTransrev( $key . '/' . $collection->code ); |
— | — | @@ -498,8 +543,8 @@ |
499 | 544 | 'rt_type' => $id, |
500 | 545 | ); |
501 | 546 | $options = array( 'ORDER BY' => 'rt_revision DESC' ); |
| 547 | + |
502 | 548 | return $db->selectField( 'revtag', $fields, $conds, __METHOD__, $options ); |
503 | | - |
504 | 549 | } |
505 | 550 | |
506 | 551 | protected function getTagId( $tag ) { |
— | — | @@ -509,7 +554,7 @@ |
510 | 555 | } |
511 | 556 | |
512 | 557 | global $wgTranslateStaticTags; |
513 | | - if ( is_array($wgTranslateStaticTags) ) { |
| 558 | + if ( is_array( $wgTranslateStaticTags ) ) { |
514 | 559 | return $wgTranslateStaticTags[$tag]; |
515 | 560 | } |
516 | 561 | |
— | — | @@ -524,21 +569,34 @@ |
525 | 570 | array( 'rtt_name' => $validTags ), |
526 | 571 | __METHOD__ |
527 | 572 | ); |
| 573 | + |
528 | 574 | foreach ( $res as $r ) { |
529 | 575 | $tagcache[$r->rtt_name] = $r->rtt_id; |
530 | 576 | } |
531 | 577 | } |
| 578 | + |
532 | 579 | return $tagcache[$tag]; |
533 | 580 | } |
534 | 581 | |
535 | 582 | public static function isTranslationPage( Title $title ) { |
536 | 583 | list( $key, $code ) = TranslateUtils::figureMessage( $title->getText() ); |
537 | | - if ( $key === '' || $code === '' ) return false; |
| 584 | + |
| 585 | + if ( $key === '' || $code === '' ) { |
| 586 | + return false; |
| 587 | + } |
| 588 | + |
538 | 589 | $newtitle = self::changeTitleText( $title, $key ); |
539 | | - if ( !$newtitle ) return false; |
| 590 | + |
| 591 | + if ( !$newtitle ) { |
| 592 | + return false; |
| 593 | + } |
| 594 | + |
540 | 595 | $page = TranslatablePage::newFromTitle( $newtitle ); |
541 | 596 | |
542 | | - if ( $page->getMarkedTag() === false ) return false; |
| 597 | + if ( $page->getMarkedTag() === false ) { |
| 598 | + return false; |
| 599 | + } |
| 600 | + |
543 | 601 | return $page; |
544 | 602 | } |
545 | 603 | |
— | — | @@ -561,4 +619,3 @@ |
562 | 620 | return $this->msg; |
563 | 621 | } |
564 | 622 | } |
565 | | - |
Index: trunk/extensions/Translate/tag/RenderJob.php |
— | — | @@ -1,5 +1,4 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * Job for updating translation pages. |
6 | 5 | * |
— | — | @@ -19,6 +18,7 @@ |
20 | 19 | $job->setUser( $wgTranslateFuzzyBotName ); |
21 | 20 | $job->setFlags( EDIT_FORCE_BOT ); |
22 | 21 | $job->setSummary( wfMsgForContent( 'tpt-render-summary' ) ); |
| 22 | + |
23 | 23 | return $job; |
24 | 24 | } |
25 | 25 | |
— | — | @@ -83,7 +83,6 @@ |
84 | 84 | return $this->params['flags']; |
85 | 85 | } |
86 | 86 | |
87 | | - |
88 | 87 | public function setSummary( $summary ) { |
89 | 88 | $this->params['summary'] = $summary; |
90 | 89 | } |
— | — | @@ -92,7 +91,6 @@ |
93 | 92 | return $this->params['summary']; |
94 | 93 | } |
95 | 94 | |
96 | | - |
97 | 95 | public function setUser( $user ) { |
98 | 96 | if ( $user instanceof User ) { |
99 | 97 | $this->params['user'] = $user->getName(); |
— | — | @@ -100,6 +98,7 @@ |
101 | 99 | $this->params['user'] = $user; |
102 | 100 | } |
103 | 101 | } |
| 102 | + |
104 | 103 | /** |
105 | 104 | * Get a user object for doing edits. |
106 | 105 | */ |
— | — | @@ -107,4 +106,3 @@ |
108 | 107 | return User::newFromName( $this->params['user'], false ); |
109 | 108 | } |
110 | 109 | } |
111 | | - |
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | |
13 | 13 | class SpecialPageTranslation extends SpecialPage { |
14 | 14 | function __construct() { |
15 | | - SpecialPage::SpecialPage( 'PageTranslation' ); |
| 15 | + parent::__construct( 'PageTranslation' ); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function execute( $parameters ) { |
— | — | @@ -31,6 +31,7 @@ |
32 | 32 | } else { |
33 | 33 | $this->listPages(); |
34 | 34 | } |
| 35 | + |
35 | 36 | return; |
36 | 37 | } |
37 | 38 | |
— | — | @@ -41,7 +42,7 @@ |
42 | 43 | } |
43 | 44 | |
44 | 45 | // Check permissions |
45 | | - if (!$this->user->matchEditToken( $wgRequest->getText( 'token' ) ) ) { |
| 46 | + if ( !$this->user->matchEditToken( $wgRequest->getText( 'token' ) ) ) { |
46 | 47 | $wgOut->permissionRequired( 'pagetranslation' ); |
47 | 48 | return; |
48 | 49 | } |
— | — | @@ -63,6 +64,7 @@ |
64 | 65 | // Get the latest revision |
65 | 66 | $revision = $title->getLatestRevID(); |
66 | 67 | } |
| 68 | + |
67 | 69 | $page = TranslatablePage::newFromRevision( $title, $revision ); |
68 | 70 | if ( !$page instanceof TranslatablePage ) { |
69 | 71 | $wgOut->addWikiMsg( 'tpt-notsuitable', $title->getPrefixedText(), $revision ); |
— | — | @@ -85,6 +87,7 @@ |
86 | 88 | // This will modify the sections to include name property |
87 | 89 | $error = false; |
88 | 90 | $sections = $this->checkInput( $page, $error ); |
| 91 | + |
89 | 92 | // Non-fatal error which prevents saving |
90 | 93 | if ( $error === false && $wgRequest->wasPosted() ) { |
91 | 94 | $err = $this->markForTranslation( $page, $sections ); |
— | — | @@ -94,8 +97,10 @@ |
95 | 98 | $this->showSuccess( $page ); |
96 | 99 | $this->listPages(); |
97 | 100 | } |
| 101 | + |
98 | 102 | return; |
99 | 103 | } |
| 104 | + |
100 | 105 | $this->showPage( $page, $sections ); |
101 | 106 | } |
102 | 107 | |
— | — | @@ -106,6 +111,7 @@ |
107 | 112 | $num = $wgLang->formatNum( $page->getParse()->countSections() ); |
108 | 113 | $link = SpecialPage::getTitleFor( 'Translate' )->getFullUrl( |
109 | 114 | array( 'group' => 'page|' . $page->getTitle()->getPrefixedText() ) ); |
| 115 | + |
110 | 116 | $wgOut->addWikiMsg( 'tpt-saveok', $titleText, $num, $link ); |
111 | 117 | } |
112 | 118 | |
— | — | @@ -123,6 +129,7 @@ |
124 | 130 | 'GROUP BY' => 'page_id, rtt_id', |
125 | 131 | ); |
126 | 132 | $res = $dbr->select( $tables, $vars, $conds, __METHOD__, $options ); |
| 133 | + |
127 | 134 | return $res; |
128 | 135 | } |
129 | 136 | |
— | — | @@ -141,22 +148,32 @@ |
142 | 149 | $pages[$r->page_id] = array(); |
143 | 150 | $pages[$r->page_id]['title'] = Title::newFromRow( $r ); |
144 | 151 | } |
| 152 | + |
145 | 153 | $pages[$r->page_id][$r->rtt_name] = $r->rt_revision; |
146 | 154 | } |
147 | 155 | |
148 | 156 | // Pages where mark <= tag |
149 | 157 | $items = array(); |
150 | 158 | foreach ( $pages as $index => $page ) { |
151 | | - if ( !isset( $page['tp:mark'] ) ) continue; |
152 | | - if ( !isset( $page['tp:tag'] ) ) continue; |
153 | | - if ( $page['tp:mark'] > $page['tp:tag'] ) continue; |
| 159 | + if ( !isset( $page['tp:mark'] ) ) { |
| 160 | + continue; |
| 161 | + } |
| 162 | + |
| 163 | + if ( !isset( $page['tp:tag'] ) ) { |
| 164 | + continue; |
| 165 | + } |
| 166 | + |
| 167 | + if ( $page['tp:mark'] > $page['tp:tag'] ) { |
| 168 | + continue; |
| 169 | + } |
| 170 | + |
154 | 171 | $link = $this->user->getSkin()->link( $page['title'] ); |
155 | 172 | $acts = $this->actionLinks( $page['title'], $page['tp:mark'], 'old' ); |
156 | 173 | $items[] = "<li>$link ($acts) </li>"; |
157 | 174 | unset( $pages[$index] ); |
158 | 175 | } |
159 | 176 | |
160 | | - if ( count($items) ) { |
| 177 | + if ( count( $items ) ) { |
161 | 178 | $wgOut->addWikiMsg( 'tpt-old-pages', count( $items ) ); |
162 | 179 | $wgOut->addHtml( Html::rawElement( 'ol', null, implode( "\n", $items ) ) ); |
163 | 180 | $wgOut->addHtml( '<hr />' ); |
— | — | @@ -165,15 +182,22 @@ |
166 | 183 | // Pages which are never marked |
167 | 184 | $items = array(); |
168 | 185 | foreach ( $pages as $index => $page ) { |
169 | | - if ( isset( $page['tp:mark'] ) ) continue; |
170 | | - if ( !isset( $page['tp:tag'] ) ) continue; |
| 186 | + if ( isset( $page['tp:mark'] ) ) { |
| 187 | + continue; |
| 188 | + } |
| 189 | + |
| 190 | + if ( !isset( $page['tp:tag'] ) ) { |
| 191 | + continue; |
| 192 | + } |
| 193 | + |
171 | 194 | $link = $this->user->getSkin()->link( $page['title'] ); |
172 | 195 | $acts = $this->actionLinks( $page['title'], $page['tp:tag'], 'old' ); |
173 | 196 | $items[] = "<li>$link ($acts) </li>"; |
| 197 | + |
174 | 198 | unset( $pages[$index] ); |
175 | 199 | } |
176 | 200 | |
177 | | - if ( count($items) ) { |
| 201 | + if ( count( $items ) ) { |
178 | 202 | $wgOut->addWikiMsg( 'tpt-new-pages', count( $items ) ); |
179 | 203 | $wgOut->addHtml( Html::rawElement( 'ol', null, implode( "\n", $items ) ) ); |
180 | 204 | $wgOut->addHtml( '<hr />' ); |
— | — | @@ -186,15 +210,15 @@ |
187 | 211 | $link = $this->user->getSkin()->link( $page['title'] ); |
188 | 212 | $acts = $this->actionLinks( $page['title'], $page['tp:tag'], 'stuck' ); |
189 | 213 | $items[] = "<li>$link ($acts) </li>"; |
| 214 | + |
190 | 215 | unset( $pages[$index] ); |
191 | 216 | } |
192 | 217 | |
193 | | - if ( count($items) ) { |
| 218 | + if ( count( $items ) ) { |
194 | 219 | $wgOut->addWikiMsg( 'tpt-other-pages', count( $items ) ); |
195 | 220 | $wgOut->addHtml( Html::rawElement( 'ol', null, implode( "\n", $items ) ) ); |
196 | 221 | $wgOut->addHtml( '<hr />' ); |
197 | 222 | } |
198 | | - |
199 | 223 | } |
200 | 224 | |
201 | 225 | protected function actionLinks( $title, $rev, $old = 'old' ) { |
— | — | @@ -220,8 +244,10 @@ |
221 | 245 | if ( $this->user->isAllowed( 'pagetranslation' ) ) { |
222 | 246 | $token = $this->user->editToken(); |
223 | 247 | |
224 | | - if ( ( $old === 'new' && $latest === $rev ) || |
225 | | - ( $old === 'old' && $latest !== $rev ) ) { |
| 248 | + if ( |
| 249 | + ( $old === 'new' && $latest === $rev ) || |
| 250 | + ( $old === 'old' && $latest !== $rev ) |
| 251 | + ) { |
226 | 252 | $actions[] = $this->user->getSkin()->link( |
227 | 253 | $this->getTitle(), |
228 | 254 | wfMsgHtml( 'tpt-rev-mark-new' ), |
— | — | @@ -270,7 +296,9 @@ |
271 | 297 | // the new id only after it is saved into db and the page. |
272 | 298 | // Do not allow changing names for old sections |
273 | 299 | $s->name = $s->id; |
274 | | - if ( $s->type !== 'new' ) continue; |
| 300 | + if ( $s->type !== 'new' ) { |
| 301 | + continue; |
| 302 | + } |
275 | 303 | |
276 | 304 | $name = $wgRequest->getText( 'tpt-sect-' . $s->id, $s->id ); |
277 | 305 | |
— | — | @@ -279,6 +307,7 @@ |
280 | 308 | NS_TRANSLATIONS, |
281 | 309 | $page->getTitle()->getPrefixedText() . '/' . $name . '/foo' |
282 | 310 | ); |
| 311 | + |
283 | 312 | if ( trim( $name ) === '' || !$sectionTitle ) { |
284 | 313 | $wgOut->addWikiMsg( 'tpt-badsect', $name, $s->id ); |
285 | 314 | $error = true; |
— | — | @@ -340,6 +369,7 @@ |
341 | 370 | $deletedSections = $page->getParse()->getDeletedSections(); |
342 | 371 | if ( count( $deletedSections ) ) { |
343 | 372 | $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-deleted' ); |
| 373 | + |
344 | 374 | foreach ( $deletedSections as $s ) { |
345 | 375 | $name = wfMsgHtml( 'tpt-section-deleted', htmlspecialchars( $s->id ) ); |
346 | 376 | $text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() ); |
— | — | @@ -349,7 +379,6 @@ |
350 | 380 | |
351 | 381 | // Display template changes if applicable |
352 | 382 | if ( $page->getMarkedTag() !== false ) { |
353 | | - |
354 | 383 | $newTemplate = $page->getParse()->getTemplatePretty(); |
355 | 384 | $oldPage = TranslatablePage::newFromRevision( $page->getTitle(), $page->getMarkedTag() ); |
356 | 385 | $oldTemplate = $oldPage->getParse()->getTemplatePretty(); |
— | — | @@ -383,7 +412,6 @@ |
384 | 413 | * - Invalidates caches |
385 | 414 | */ |
386 | 415 | public function markForTranslation( TranslatablePage $page, Array $sections ) { |
387 | | - |
388 | 416 | // Add the section markers to the source page |
389 | 417 | $article = new Article( $page->getTitle() ); |
390 | 418 | $status = $article->doEdit( |
— | — | @@ -393,7 +421,9 @@ |
394 | 422 | $page->getRevision() // Based-on revision |
395 | 423 | ); |
396 | 424 | |
397 | | - if ( !$status->isOK() ) return array( 'tpt-edit-failed', $status->getWikiText() ); |
| 425 | + if ( !$status->isOK() ) { |
| 426 | + return array( 'tpt-edit-failed', $status->getWikiText() ); |
| 427 | + } |
398 | 428 | |
399 | 429 | $newrevision = $status->value['revision']; |
400 | 430 | |
— | — | @@ -411,6 +441,7 @@ |
412 | 442 | |
413 | 443 | $inserts = array(); |
414 | 444 | $changed = array(); |
| 445 | + |
415 | 446 | foreach ( $sections as $s ) { |
416 | 447 | if ( $s->type === 'changed' ) $changed[] = $s->name; |
417 | 448 | $inserts[] = array( |
— | — | @@ -421,7 +452,9 @@ |
422 | 453 | } |
423 | 454 | |
424 | 455 | // Don't add stuff is no changes, use the plain null instead for prettiness |
425 | | - if ( !count( $changed ) ) $changed = null; |
| 456 | + if ( !count( $changed ) ) { |
| 457 | + $changed = null; |
| 458 | + } |
426 | 459 | |
427 | 460 | $dbw = wfGetDB( DB_MASTER ); |
428 | 461 | $dbw->delete( 'translate_sections', array( 'trs_page' => $page->getTitle()->getArticleId() ), __METHOD__ ); |
— | — | @@ -442,10 +475,14 @@ |
443 | 476 | } |
444 | 477 | |
445 | 478 | public function addFuzzyTags( $page, $changed ) { |
446 | | - if ( !count( $changed ) ) return; |
| 479 | + if ( !count( $changed ) ) { |
| 480 | + return; |
| 481 | + } |
| 482 | + |
447 | 483 | $titles = array(); |
448 | 484 | $prefix = $page->getTitle()->getPrefixedText(); |
449 | 485 | $db = wfGetDB( DB_MASTER ); |
| 486 | + |
450 | 487 | foreach ( $changed as $c ) { |
451 | 488 | $title = Title::makeTitleSafe( NS_TRANSLATIONS, "$prefix/$c" ); |
452 | 489 | if ( $title ) { |
— | — | @@ -470,6 +507,7 @@ |
471 | 508 | 'rt_revision' => $r->page_latest, |
472 | 509 | ); |
473 | 510 | } |
| 511 | + |
474 | 512 | if ( count( $inserts ) ) { |
475 | 513 | $db->replace( 'revtag', array( 'rt_type_page_revision' ), $inserts, __METHOD__ ); |
476 | 514 | } |
— | — | @@ -478,16 +516,18 @@ |
479 | 517 | public function setupRenderJobs( TranslatablePage $page ) { |
480 | 518 | $titles = $page->getTranslationPages(); |
481 | 519 | $jobs = array(); |
| 520 | + |
482 | 521 | foreach ( $titles as $t ) { |
483 | 522 | $jobs[] = RenderJob::newJob( $t ); |
484 | 523 | } |
485 | 524 | |
486 | 525 | if ( count( $jobs ) < 10 ) { |
487 | | - foreach ( $jobs as $j ) $j->run(); |
| 526 | + foreach ( $jobs as $j ) { |
| 527 | + $j->run(); |
| 528 | + } |
488 | 529 | } else { |
489 | 530 | // Use the job queue |
490 | 531 | Job::batchInsert( $jobs ); |
491 | 532 | } |
492 | 533 | } |
493 | | - |
494 | 534 | } |
Index: trunk/extensions/Translate/tag/TPParse.php |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | * @copyright Copyright © 2009-2010 Niklas Laxström |
9 | 9 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
10 | 10 | */ |
| 11 | + |
11 | 12 | class TPParse { |
12 | 13 | protected $title = null; |
13 | 14 | |
— | — | @@ -32,8 +33,8 @@ |
33 | 34 | foreach ( $sections as $ph => $s ) { |
34 | 35 | $text = str_replace( $ph, "<!--T:{$s->id}-->", $text ); |
35 | 36 | } |
| 37 | + |
36 | 38 | return $text; |
37 | | - |
38 | 39 | } |
39 | 40 | |
40 | 41 | public function getSectionsForSave() { |
— | — | @@ -45,7 +46,10 @@ |
46 | 47 | $highest = max( $highest, $key ); |
47 | 48 | } |
48 | 49 | |
49 | | - foreach ( $sections as $_ ) $highest = max( $_->id, $highest ); |
| 50 | + foreach ( $sections as $_ ) { |
| 51 | + $highest = max( $_->id, $highest ); |
| 52 | + } |
| 53 | + |
50 | 54 | foreach ( $sections as $s ) { |
51 | 55 | $s->type = 'old'; |
52 | 56 | |
— | — | @@ -68,17 +72,21 @@ |
69 | 73 | |
70 | 74 | public function getDeletedSections() { |
71 | 75 | $sections = $this->getSectionsForSave(); |
| 76 | + $deleted = $this->dbSections; |
72 | 77 | |
73 | | - $deleted = $this->dbSections; |
74 | 78 | foreach ( $sections as $s ) { |
75 | | - if ( isset( $deleted[$s->id] ) ) |
| 79 | + if ( isset( $deleted[$s->id] ) ) { |
76 | 80 | unset( $deleted[$s->id] ); |
| 81 | + } |
77 | 82 | } |
| 83 | + |
78 | 84 | return $deleted; |
79 | 85 | } |
80 | 86 | |
81 | 87 | protected function loadFromDatabase() { |
82 | | - if ( $this->dbSections !== null ) return; |
| 88 | + if ( $this->dbSections !== null ) { |
| 89 | + return; |
| 90 | + } |
83 | 91 | |
84 | 92 | $this->dbSections = array(); |
85 | 93 | |
— | — | @@ -99,9 +107,11 @@ |
100 | 108 | |
101 | 109 | public function getSourcePageText() { |
102 | 110 | $text = $this->template; |
| 111 | + |
103 | 112 | foreach ( $this->sections as $ph => $s ) { |
104 | 113 | $text = str_replace( $ph, $s->getMarkedText(), $text ); |
105 | 114 | } |
| 115 | + |
106 | 116 | return $text; |
107 | 117 | } |
108 | 118 | |
— | — | @@ -156,10 +166,11 @@ |
157 | 167 | foreach ( $variables as $key => $value ) { |
158 | 168 | $text = str_replace( $key, $value, $text ); |
159 | 169 | } |
| 170 | + |
160 | 171 | return $text; |
161 | 172 | } |
162 | 173 | |
163 | 174 | protected static function replaceTagCb( $matches ) { |
164 | 175 | return $matches[2]; |
165 | 176 | } |
166 | | -} |
\ No newline at end of file |
| 177 | +} |
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php |
— | — | @@ -1,12 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class PageTranslationHooks { |
5 | | - |
6 | 5 | // Uuugly hack |
7 | 6 | static $allowTargetEdit = false; |
8 | 7 | |
9 | 8 | public static function renderTagPage( $parser, &$text, $state ) { |
10 | 9 | $title = $parser->getTitle(); |
| 10 | + |
11 | 11 | if ( strpos( $text, '<translate>' ) !== false ) { |
12 | 12 | $nowiki = array(); |
13 | 13 | $text = TranslatablePage::armourNowiki( $nowiki, $text ); |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | list( , $code ) = TranslateUtils::figureMessage( $title->getText() ); |
25 | 25 | $parser->mOptions->setTargetLanguage( Language::factory( $code ) ); |
26 | 26 | } |
| 27 | + |
27 | 28 | return true; |
28 | 29 | } |
29 | 30 | |
— | — | @@ -40,6 +41,7 @@ |
41 | 42 | $namespace = $title->getNamespace(); |
42 | 43 | $text = $title->getDBkey(); |
43 | 44 | list( $key, ) = TranslateUtils::figureMessage( $text ); |
| 45 | + |
44 | 46 | return TranslateUtils::messageKeyToGroup( $namespace, $key ); |
45 | 47 | } |
46 | 48 | |
— | — | @@ -50,14 +52,21 @@ |
51 | 53 | // Some checks |
52 | 54 | |
53 | 55 | // We are only interested in the translations namespace |
54 | | - if ( $title->getNamespace() != NS_TRANSLATIONS ) return true; |
| 56 | + if ( $title->getNamespace() != NS_TRANSLATIONS ) { |
| 57 | + return true; |
| 58 | + } |
| 59 | + |
55 | 60 | // Do not trigger renders for fuzzy |
56 | | - if ( strpos( $text, TRANSLATE_FUZZY ) !== false ) return true; |
| 61 | + if ( strpos( $text, TRANSLATE_FUZZY ) !== false ) { |
| 62 | + return true; |
| 63 | + } |
57 | 64 | |
58 | 65 | // Figure out the group |
59 | 66 | $groupKey = self::titleToGroup( $title ); |
60 | 67 | $group = MessageGroups::getGroup( $groupKey ); |
61 | | - if ( !$group instanceof WikiPageMessageGroup ) return; |
| 68 | + if ( !$group instanceof WikiPageMessageGroup ) { |
| 69 | + return; |
| 70 | + } |
62 | 71 | |
63 | 72 | // Finally we know the title and can construct a Translatable page |
64 | 73 | $page = TranslatablePage::newFromTitle( $group->title ); |
— | — | @@ -75,7 +84,9 @@ |
76 | 85 | } |
77 | 86 | |
78 | 87 | protected static function addSectionTag( Title $title, $revision, $pageRevision ) { |
79 | | - if ( $pageRevision === null ) throw new MWException( 'Page revision is null' ); |
| 88 | + if ( $pageRevision === null ) { |
| 89 | + throw new MWException( 'Page revision is null' ); |
| 90 | + } |
80 | 91 | |
81 | 92 | $dbw = wfGetDB( DB_MASTER ); |
82 | 93 | |
— | — | @@ -129,6 +140,7 @@ |
130 | 141 | public static function addSidebar( $out, $tpl ) { |
131 | 142 | // TODO: fixme |
132 | 143 | return true; |
| 144 | + |
133 | 145 | global $wgLang; |
134 | 146 | |
135 | 147 | // Sort by translation percentage |
— | — | @@ -137,7 +149,7 @@ |
138 | 150 | foreach ( $status as $code => $percent ) { |
139 | 151 | $name = TranslateUtils::getLanguageName( $code, false, $wgLang->getCode() ); |
140 | 152 | $percent = $wgLang->formatNum( round( 100 * $percent ) ); |
141 | | - $label = "$name ($percent%)"; |
| 153 | + $label = "$name ($percent%)"; // FIXME: i18n |
142 | 154 | |
143 | 155 | $_title = TranslateTagUtils::codefyTitle( $title, $code ); |
144 | 156 | |
— | — | @@ -156,8 +168,6 @@ |
157 | 169 | return true; |
158 | 170 | } |
159 | 171 | |
160 | | - |
161 | | - |
162 | 172 | public static function languages( $data, $params, $parser ) { |
163 | 173 | $title = $parser->getTitle(); |
164 | 174 | |
— | — | @@ -166,10 +176,15 @@ |
167 | 177 | if ( $page->getMarkedTag() === false ) { |
168 | 178 | $page = TranslatablePage::isTranslationPage( $title ); |
169 | 179 | } |
170 | | - if ( $page === false || $page->getMarkedTag() === false ) return ''; |
171 | 180 | |
| 181 | + if ( $page === false || $page->getMarkedTag() === false ) { |
| 182 | + return ''; |
| 183 | + } |
| 184 | + |
172 | 185 | $status = $page->getTranslationPercentages(); |
173 | | - if ( !$status ) return ''; |
| 186 | + if ( !$status ) { |
| 187 | + return ''; |
| 188 | + } |
174 | 189 | |
175 | 190 | // Fix title |
176 | 191 | $title = $page->getTitle(); |
— | — | @@ -202,8 +217,8 @@ |
203 | 218 | |
204 | 219 | $percent = Xml::element( 'img', array( |
205 | 220 | 'src' => TranslateUtils::assetPath( "images/prog-$image.png" ), |
206 | | - 'alt' => "$percent%", |
207 | | - 'title' => "$percent%", |
| 221 | + 'alt' => "$percent%", // FIXME: i18n |
| 222 | + 'title' => "$percent%", // FIXME: i18n |
208 | 223 | 'width' => '9', |
209 | 224 | 'height' => '9', |
210 | 225 | ) ); |
— | — | @@ -217,6 +232,7 @@ |
218 | 233 | if ( $code === $wgLang->getCode() ) { |
219 | 234 | $label = Html::rawElement( 'b', null, $label ); |
220 | 235 | } |
| 236 | + |
221 | 237 | if ( $parser->getTitle()->getText() === $_title->getText() ) { |
222 | 238 | $languages[] = "$label"; |
223 | 239 | } else { |
— | — | @@ -242,13 +258,17 @@ |
243 | 259 | |
244 | 260 | // To display nice error for editpage |
245 | 261 | public static function tpSyntaxCheckForEditPage( $editpage, $text, $section, &$error, $summary ) { |
246 | | - if ( strpos( $text, '<translate>' ) === false ) return true; |
| 262 | + if ( strpos( $text, '<translate>' ) === false ) { |
| 263 | + return true; |
| 264 | + } |
| 265 | + |
247 | 266 | $page = TranslatablePage::newFromText( $editpage->mTitle, $text ); |
248 | 267 | try { |
249 | 268 | $page->getParse(); |
250 | 269 | } catch ( TPException $e ) { |
251 | 270 | $error .= Html::rawElement( 'div', array( 'class' => 'error' ), $e->getMessage() ); |
252 | 271 | } |
| 272 | + |
253 | 273 | return true; |
254 | 274 | } |
255 | 275 | |
— | — | @@ -259,7 +279,9 @@ |
260 | 280 | public static function tpSyntaxCheck( $article, $user, $text, $summary, |
261 | 281 | $minor, $_, $_, $flags, $status ) { |
262 | 282 | // Quick escape on normal pages |
263 | | - if ( strpos( $text, '<translate>' ) === false ) return true; |
| 283 | + if ( strpos( $text, '<translate>' ) === false ) { |
| 284 | + return true; |
| 285 | + } |
264 | 286 | |
265 | 287 | $page = TranslatablePage::newFromText( $article->getTitle(), $text ); |
266 | 288 | try { |
— | — | @@ -275,10 +297,14 @@ |
276 | 298 | public static function addTranstag( $article, $user, $text, $summary, |
277 | 299 | $minor, $_, $_, $flags, $revision ) { |
278 | 300 | // We are not interested in null revisions |
279 | | - if ( $revision === null ) return true; |
| 301 | + if ( $revision === null ) { |
| 302 | + return true; |
| 303 | + } |
280 | 304 | |
281 | 305 | // Quick escape on normal pages |
282 | | - if ( strpos( $text, '</translate>' ) === false ) return true; |
| 306 | + if ( strpos( $text, '</translate>' ) === false ) { |
| 307 | + return true; |
| 308 | + } |
283 | 309 | |
284 | 310 | // Add the ready tag |
285 | 311 | $page = TranslatablePage::newFromTitle( $article->getTitle() ); |
— | — | @@ -295,7 +321,7 @@ |
296 | 322 | if ( $title->getNamespace() == NS_TRANSLATIONS && $action === 'edit' ) { |
297 | 323 | $group = self::titleToGroup( $title ); |
298 | 324 | if ( $group === null ) { |
299 | | - // No group means that the page is currently not |
| 325 | + // No group means that the page is currently not |
300 | 326 | // registered to any page translation message groups |
301 | 327 | $result = array( 'tpt-unknown-page' ); |
302 | 328 | return false; |
— | — | @@ -304,11 +330,12 @@ |
305 | 331 | return true; |
306 | 332 | } |
307 | 333 | |
308 | | - |
309 | 334 | // Case 2: Target pages |
310 | 335 | $page = TranslatablePage::isTranslationPage( $title ); |
311 | 336 | if ( $page !== false ) { |
312 | | - if ( self::$allowTargetEdit ) return true; |
| 337 | + if ( self::$allowTargetEdit ) { |
| 338 | + return true; |
| 339 | + } |
313 | 340 | |
314 | 341 | if ( $page->getMarkedTag() ) { |
315 | 342 | list( , $code ) = TranslateUtils::figureMessage( $title->getText() ); |
— | — | @@ -326,6 +353,7 @@ |
327 | 354 | |
328 | 355 | public static function schemaUpdates() { |
329 | 356 | global $wgExtNewTables; |
| 357 | + |
330 | 358 | $dir = dirname( __FILE__ ) . '/..'; |
331 | 359 | $wgExtNewTables[] = array( 'translate_sections', "$dir/translate.sql" ); |
332 | 360 | $wgExtNewTables[] = array( 'revtag_type', "$dir/revtags.sql" ); |
— | — | @@ -336,9 +364,11 @@ |
337 | 365 | // TODO: fix the name |
338 | 366 | public static function test( &$article, &$outputDone, &$pcache ) { |
339 | 367 | global $wgOut; |
| 368 | + |
340 | 369 | if ( !$article->getOldID() ) { |
341 | 370 | self::header( $article->getTitle() ); |
342 | 371 | } |
| 372 | + |
343 | 373 | return true; |
344 | 374 | } |
345 | 375 | |
— | — | @@ -356,9 +386,7 @@ |
357 | 387 | } |
358 | 388 | } |
359 | 389 | |
360 | | - protected static function sourcePageHeader( TranslatablePage $page, |
361 | | - $marked, $ready ) { |
362 | | - |
| 390 | + protected static function sourcePageHeader( TranslatablePage $page, $marked, $ready ) { |
363 | 391 | global $wgUser, $wgLang; |
364 | 392 | |
365 | 393 | $title = $page->getTitle(); |
— | — | @@ -375,6 +403,7 @@ |
376 | 404 | 'language' => $wgLang->getCode(), |
377 | 405 | 'task' => 'view' |
378 | 406 | ); |
| 407 | + |
379 | 408 | $translate = SpecialPage::getTitleFor( 'Translate' ); |
380 | 409 | $linkDesc = wfMsgHtml( 'translate-tag-translate-link-desc' ); |
381 | 410 | $actions[] = $sk->link( $translate, $linkDesc, array(), $par ); |
— | — | @@ -399,16 +428,18 @@ |
400 | 429 | } |
401 | 430 | } |
402 | 431 | |
403 | | - if ( !count( $actions ) ) return; |
| 432 | + if ( !count( $actions ) ) { |
| 433 | + return; |
| 434 | + } |
| 435 | + |
404 | 436 | $legend = Html::rawElement( |
405 | 437 | 'div', |
406 | 438 | array( 'style' => 'font-size: x-small; text-align: center;' ), |
407 | 439 | $wgLang->semicolonList( $actions ) |
408 | 440 | ) . Html::element( 'hr' ); |
409 | | - |
| 441 | + |
410 | 442 | global $wgOut; |
411 | 443 | $wgOut->addHTML( $legend ); |
412 | | - |
413 | 444 | } |
414 | 445 | |
415 | 446 | protected static function translationPageHeader( Title $title ) { |
— | — | @@ -416,7 +447,9 @@ |
417 | 448 | |
418 | 449 | // Check if applicable |
419 | 450 | $page = TranslatablePage::isTranslationPage( $title ); |
420 | | - if ( $page === false ) return; |
| 451 | + if ( $page === false ) { |
| 452 | + return; |
| 453 | + } |
421 | 454 | |
422 | 455 | list( , $code ) = TranslateUtils::figureMessage( $title->getText() ); |
423 | 456 | |
— | — | @@ -429,7 +462,7 @@ |
430 | 463 | |
431 | 464 | // Output |
432 | 465 | $wrap = '<div style="font-size: x-small; text-align: center">$1</div>'; |
433 | | - |
| 466 | + |
434 | 467 | $wgOut->wrapWikiMsg( $wrap, array( 'tpt-translation-intro', $url, $titleText, $per ) ); |
435 | 468 | |
436 | 469 | if ( ( (int) $per ) < 100 ) { |
— | — | @@ -437,7 +470,6 @@ |
438 | 471 | $wgOut->wrapWikiMsg( $wrap, array( 'tpt-translation-intro-fuzzy' ) ); |
439 | 472 | } |
440 | 473 | $wgOut->addHTML( '<hr />' ); |
441 | | - |
442 | 474 | } |
443 | 475 | |
444 | 476 | public static function parserTestTables( &$tables ) { |
— | — | @@ -455,10 +487,14 @@ |
456 | 488 | if ( $page->getMarkedTag() === false ) { |
457 | 489 | $page = TranslatablePage::isTranslationPage( $title ); |
458 | 490 | } |
459 | | - if ( $page === false || $page->getMarkedTag() === false ) return true; |
460 | 491 | |
| 492 | + if ( $page === false || $page->getMarkedTag() === false ) { |
| 493 | + return true; |
| 494 | + } |
| 495 | + |
461 | 496 | $export = array( $page->getTitle()->getPrefixedText() ); // Source page |
462 | 497 | $titles = $page->getTranslationPages(); |
| 498 | + |
463 | 499 | foreach ( $titles as $title ) { |
464 | 500 | $export[] = $title->getPrefixedText(); |
465 | 501 | } |
— | — | @@ -469,7 +505,7 @@ |
470 | 506 | $linkText = wfMsgHtml( 'tpt-download-page' ); |
471 | 507 | |
472 | 508 | print "<li id=\"t-export-translationpages\"><a href=\"$href\" rel=\"nofollow\">$linkText</a></li>"; |
| 509 | + |
473 | 510 | return true; |
474 | 511 | } |
475 | | - |
476 | 512 | } |
Index: trunk/extensions/Translate/tag/TPSection.php |
— | — | @@ -26,9 +26,11 @@ |
27 | 27 | $count = 0; |
28 | 28 | |
29 | 29 | $text = preg_replace( $re, $rep, $this->text, 1, $count ); |
| 30 | + |
30 | 31 | if ( $count === 0 ) { |
31 | 32 | $text = $header . "\n" . $this->text; |
32 | 33 | } |
| 34 | + |
33 | 35 | return $text; |
34 | 36 | } |
35 | 37 | |
— | — | @@ -41,9 +43,11 @@ |
42 | 44 | $matches = array(); |
43 | 45 | preg_match_all( $re, $this->text, $matches, PREG_SET_ORDER ); |
44 | 46 | $vars = array(); |
| 47 | + |
45 | 48 | foreach ( $matches as $m ) { |
46 | 49 | $vars['$' . $m[1]] = $m[2]; |
47 | 50 | } |
| 51 | + |
48 | 52 | return $vars; |
49 | 53 | } |
50 | | -} |
\ No newline at end of file |
| 54 | +} |