Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | |
14 | 14 | $wgExtensionCredits['specialpage'][] = array( |
15 | 15 | 'name' => 'Translate', |
16 | | - 'version' => '4.1', |
| 16 | + 'version' => '4.2', |
17 | 17 | 'author' => 'Niklas Laxström', |
18 | 18 | 'description' => 'Special page for translating Mediawiki and beyond' |
19 | 19 | ); |
— | — | @@ -25,11 +25,14 @@ |
26 | 26 | $wgAutoloadClasses['languages'] = $IP . '/maintenance/language/languages.inc'; |
27 | 27 | $wgAutoloadClasses['SpecialTranslate'] = $dir . 'TranslatePage.php'; |
28 | 28 | $wgAutoloadClasses['SpecialMagic'] = $dir . 'SpecialMagic.php'; |
| 29 | +$wgAutoloadClasses['SpecialTranslationChanges'] = $dir . 'SpecialTranslationChanges.php'; |
29 | 30 | |
| 31 | + |
30 | 32 | $wgExtensionMessagesFiles['Translate'] = $dir . 'Translate.i18n.php'; |
31 | 33 | |
32 | 34 | $wgSpecialPages['Translate'] = 'SpecialTranslate'; |
33 | 35 | $wgSpecialPages['Magic'] = 'SpecialMagic'; |
| 36 | +$wgSpecialPages['TranslationChanges'] = 'SpecialTranslationChanges'; |
34 | 37 | |
35 | 38 | $wgHooks['EditPage::showEditForm:initial'][] = 'TranslateEditAddons::addTools'; |
36 | 39 | |
— | — | @@ -78,6 +81,7 @@ |
79 | 82 | 'ext-editcount' => 'EditcountMessageGroup', |
80 | 83 | 'ext-expandtemplates' => 'ExpandTemplatesMessageGroup', |
81 | 84 | 'ext-fancycaptcha' => 'FancyCaptchaMessageGroup', |
| 85 | +'ext-fckeditor' => 'FCKeditorExtensionGroup', |
82 | 86 | 'ext-filepath' => 'FilePathMessageGroup', |
83 | 87 | 'ext-flaggedrevs' => 'FlaggedRevsMessageGroup', |
84 | 88 | 'ext-gadgets' => 'GadgetsExtensionGroup', |
Index: trunk/extensions/Translate/SpecialMagic.php |
— | — | @@ -529,12 +529,17 @@ |
530 | 530 | */ |
531 | 531 | public function export() { |
532 | 532 | $array = $this->getArray(); |
| 533 | + foreach ($array[self::LANG_MASTER] as $index => $ns) { |
| 534 | + if ($index !== 0 && !isset($array[self::LANG_CURRENT][$index][0])) { |
| 535 | + return "Missing translation for ns $index, cannot export"; |
| 536 | + } |
| 537 | + } |
533 | 538 | |
534 | 539 | $text = <<<EOL |
535 | 540 | \$namespaceNames = array( |
536 | 541 | NS_MEDIA => '{$array[self::LANG_CURRENT][-2][0]}', |
537 | 542 | NS_SPECIAL => '{$array[self::LANG_CURRENT][-1][0]}', |
538 | | - NS_MAIN => '{$array[self::LANG_CURRENT][0][0]}', |
| 543 | + NS_MAIN => '', |
539 | 544 | NS_TALK => '{$array[self::LANG_CURRENT][1][0]}', |
540 | 545 | NS_USER => '{$array[self::LANG_CURRENT][2][0]}', |
541 | 546 | NS_USER_TALK => '{$array[self::LANG_CURRENT][3][0]}', |
Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -47,6 +47,8 @@ |
48 | 48 | |
49 | 49 | if ( $translation === null ) { return false; } |
50 | 50 | |
| 51 | + if ( strpos($translation, '!!FUZZY!!') !== false ) { return false; } |
| 52 | + |
51 | 53 | if ( $m['optional'] ) { |
52 | 54 | if ( $translation !== $fallback ) { |
53 | 55 | $comment = "#optional"; |
— | — | @@ -490,7 +492,6 @@ |
491 | 493 | |
492 | 494 | protected $exportStart = '$messages = array('; |
493 | 495 | protected $exportEnd = ');'; |
494 | | - |
495 | 496 | } |
496 | 497 | |
497 | 498 | class CentralAuthMessageGroup extends ExtensionMessageGroup { |
— | — | @@ -708,6 +709,18 @@ |
709 | 710 | protected $exportEnd = '),'; |
710 | 711 | } |
711 | 712 | |
| 713 | +class FCKeditorExtensionGroup extends MultipleFileMessageGroup { |
| 714 | + protected $label = 'FCKeditor'; |
| 715 | + protected $id = 'ext-fckeditor'; |
| 716 | + |
| 717 | + protected $arrName = 'allMessages'; |
| 718 | + protected $messageFile = 'FCKeditor/FCKeditor.i18n.en.php'; |
| 719 | + protected $filePattern = 'FCKeditor/FCKeditor.i18n.$CODE.php'; |
| 720 | + |
| 721 | + protected $exportStart = '$allMessages = array('; |
| 722 | + protected $exportEnd = ');'; |
| 723 | +} |
| 724 | + |
712 | 725 | class FlaggedRevsMessageGroup extends ExtensionMessageGroup { |
713 | 726 | protected $label = 'Flagged Revs'; |
714 | 727 | protected $id = 'ext-flaggedrevs'; |
— | — | @@ -835,6 +848,11 @@ |
836 | 849 | |
837 | 850 | protected $arrName = 'messages'; |
838 | 851 | protected $messageFile = 'Makesysop/SpecialMakesysop.i18n.php'; |
| 852 | + |
| 853 | + protected $exportStart = '\'$CODE\' => array('; |
| 854 | + protected $exportPrefix= ''; |
| 855 | + protected $exportLineP = ''; |
| 856 | + protected $exportEnd = '),'; |
839 | 857 | } |
840 | 858 | |
841 | 859 | class MakeValidateMessageGroup extends ExtensionMessageGroup { |
Index: trunk/extensions/Translate/fuzzy.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | $this->titles = $titles; |
28 | 28 | $this->dryrun = $dryrun; |
29 | 29 | |
30 | | - global $wgTranslateFuzzyBotName, $wgTranslateFuzzyBotId, $wgUser; |
| 30 | + global $wgTranslateFuzzyBotName, $wgUser; |
31 | 31 | |
32 | 32 | if ( !isset( $wgTranslateFuzzyBotName ) ) { |
33 | 33 | echo "\$wgTranslateFuzzyBotName is not set\n"; |
Index: trunk/extensions/Translate/SpecialTranslationChanges.php |
— | — | @@ -0,0 +1,162 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class SpecialTranslationChanges extends SpecialPage { |
| 5 | + |
| 6 | + function __construct() { |
| 7 | + SpecialPage::SpecialPage( 'TranslationChanges' ); |
| 8 | + } |
| 9 | + |
| 10 | + /** Access point for this special page */ |
| 11 | + public function execute() { |
| 12 | + global $wgOut, $wgScriptPath, $wgJsMimeType, $wgStyleVersion; |
| 13 | + wfLoadExtensionMessages( 'Translate' ); |
| 14 | + |
| 15 | + $wgOut->addScript( |
| 16 | + Xml::openElement( 'script', array( 'type' => $wgJsMimeType, 'src' => |
| 17 | + "$wgScriptPath/extensions/CleanChanges/cleanchanges.js?$wgStyleVersion" ) |
| 18 | + ) . '</script>' |
| 19 | + ); |
| 20 | + |
| 21 | + |
| 22 | + #$this->setup(); |
| 23 | + $this->setHeaders(); |
| 24 | + |
| 25 | + $rows = $this->runQuery(); |
| 26 | + $wgOut->addHTMl( $this->output( $rows ) ); |
| 27 | + } |
| 28 | + |
| 29 | + protected function runQuery() { |
| 30 | + $dbr = wfGetDB( DB_SLAVE ); |
| 31 | + $recentchanges = $dbr->tableName( 'recentchanges' ); |
| 32 | + |
| 33 | + $from = ''; |
| 34 | + $days = 1; |
| 35 | + $cutoff_unixtime = time() - ( $days * 86400 ); |
| 36 | + $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400); |
| 37 | + $cutoff = $dbr->timestamp( $cutoff_unixtime ); |
| 38 | + if(preg_match('/^[0-9]{14}$/', $from) and $from > wfTimestamp(TS_MW,$cutoff)) { |
| 39 | + $cutoff = $dbr->timestamp($from); |
| 40 | + } |
| 41 | + |
| 42 | + |
| 43 | + $sql = "SELECT *, substring_index(rc_title, '/', -1) as lang FROM $recentchanges " . |
| 44 | + "WHERE rc_timestamp >= '{$cutoff}' " . |
| 45 | + "AND rc_namespace = 8 " . |
| 46 | + "ORDER BY lang ASC, rc_timestamp DESC"; |
| 47 | + |
| 48 | + $res = $dbr->query( $sql, __METHOD__ ); |
| 49 | + |
| 50 | + // Fetch results, prepare a batch link existence check query |
| 51 | + $rows = array(); |
| 52 | + $batch = new LinkBatch; |
| 53 | + while( $row = $dbr->fetchObject( $res ) ){ |
| 54 | + $rows[] = $row; |
| 55 | + // User page link |
| 56 | + $title = Title::makeTitleSafe( NS_USER, $row->rc_user_text ); |
| 57 | + $batch->addObj( $title ); |
| 58 | + |
| 59 | + // User talk |
| 60 | + $title = Title::makeTitleSafe( NS_USER_TALK, $row->rc_user_text ); |
| 61 | + $batch->addObj( $title ); |
| 62 | + } |
| 63 | + $dbr->freeResult( $res ); |
| 64 | + $batch->execute(); |
| 65 | + return $rows; |
| 66 | + } |
| 67 | + |
| 68 | + protected function output( Array $rows ) { |
| 69 | + global $wgLang; |
| 70 | + $index = 0; |
| 71 | + $lastLanguage = ''; |
| 72 | + $output = ''; |
| 73 | + $rowTitle = ''; |
| 74 | + $rowId = ''; |
| 75 | + $rowLang = ''; |
| 76 | + $rowTl = ''; |
| 77 | + $rowCache = array(); |
| 78 | + foreach ( $rows as $row ) { |
| 79 | + |
| 80 | + if ( $row->lang !== $lastLanguage ) { |
| 81 | + $lastLanguage = $row->lang; |
| 82 | + if ( count($rowCache) ) { |
| 83 | + $output .= self::makeBlock( $rowLang, $rowTl, $rowCache, $rowId ); |
| 84 | + $rowCache = array(); |
| 85 | + } |
| 86 | + |
| 87 | + $rci = 'RCI' . $row->lang . $index; |
| 88 | + $rcl = 'RCL' . $row->lang . $index; |
| 89 | + $rcm = 'RCM' . $row->lang . $index; |
| 90 | + $toggleLink = "javascript:toggleVisibilityE('$rci', '$rcm', '$rcl', 'block')"; |
| 91 | + $rowTl = |
| 92 | + Xml::tags( 'span', array( 'id' => $rcm ), |
| 93 | + Xml::tags('a', array( 'href' => $toggleLink ), $this->sideArrow() ) ) . |
| 94 | + Xml::tags( 'span', array( 'id' => $rcl, 'style' => 'display: none;' ), |
| 95 | + Xml::tags('a', array( 'href' => $toggleLink ), $this->downArrow() ) ); |
| 96 | + |
| 97 | + $rowLang = $row->lang; |
| 98 | + $rowId = $rci; |
| 99 | + } |
| 100 | + |
| 101 | + # New row |
| 102 | + $date = $wgLang->timeAndDate( $row->rc_timestamp, /* adj */ true, /* format */ true ); |
| 103 | + $rowCache[] = Xml::element( 'li', null, "$date $row->rc_title by $row->rc_user_text" ); |
| 104 | + |
| 105 | + $index++; |
| 106 | + } |
| 107 | + |
| 108 | + if ( count($rowCache) ) { |
| 109 | + $output .= self::makeBlock( $rowLang, $rowTl, $rowCache, $rowId ); |
| 110 | + $rowCache = array(); |
| 111 | + } |
| 112 | + |
| 113 | + return $output; |
| 114 | + } |
| 115 | + |
| 116 | + private static function makeBlock( $tl, $lang, $rowCache, $rowId ) { |
| 117 | + $changes = count($rowCache); |
| 118 | + $output = Xml::tags( 'h2', null, "$tl $lang ($changes changes)" ); |
| 119 | + $output .= Xml::tags( 'ul', |
| 120 | + array( 'id' => $rowId, 'style' => 'display: none' ), |
| 121 | + implode( "\n", $rowCache ) |
| 122 | + ); |
| 123 | + return $output; |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Generate HTML for an arrow or placeholder graphic |
| 128 | + * @param string $dir one of '', 'd', 'l', 'r' |
| 129 | + * @param string $alt text |
| 130 | + * @return string HTML <img> tag |
| 131 | + * @access private |
| 132 | + */ |
| 133 | + function arrow( $dir, $alt='' ) { |
| 134 | + global $wgStylePath; |
| 135 | + $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' ); |
| 136 | + $encAlt = htmlspecialchars( $alt ); |
| 137 | + return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" />"; |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * Generate HTML for a right- or left-facing arrow, |
| 142 | + * depending on language direction. |
| 143 | + * @return string HTML <img> tag |
| 144 | + * @access private |
| 145 | + */ |
| 146 | + function sideArrow() { |
| 147 | + global $wgContLang; |
| 148 | + $dir = $wgContLang->isRTL() ? 'l' : 'r'; |
| 149 | + return $this->arrow( $dir, '+' ); |
| 150 | + } |
| 151 | + |
| 152 | + /** |
| 153 | + * Generate HTML for a down-facing arrow |
| 154 | + * depending on language direction. |
| 155 | + * @return string HTML <img> tag |
| 156 | + * @access private |
| 157 | + */ |
| 158 | + function downArrow() { |
| 159 | + return $this->arrow( 'd', '-' ); |
| 160 | + } |
| 161 | + |
| 162 | + |
| 163 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Translate/SpecialTranslationChanges.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 164 | + native |