Index: trunk/extensions/Translate/specials/SpecialManageGroups.php |
— | — | @@ -44,6 +44,7 @@ |
45 | 45 | } |
46 | 46 | |
47 | 47 | if ( $group ) { |
| 48 | + |
48 | 49 | if ( |
49 | 50 | $wgRequest->getBool( 'rebuildall', false ) && |
50 | 51 | $wgRequest->wasPosted() && |
— | — | @@ -64,70 +65,96 @@ |
65 | 66 | $code = 'en'; |
66 | 67 | } |
67 | 68 | |
68 | | - $this->importForm( $group, $code ); |
69 | | - } else { |
70 | | - global $wgLang, $wgOut; |
| 69 | + if ( $wgRequest->getVal( 'from' ) !== 'main' ) { |
| 70 | + $this->importForm( $group, $code ); |
| 71 | + return; |
| 72 | + } |
71 | 73 | |
72 | | - $groups = MessageGroups::singleton()->getGroups(); |
| 74 | + } |
| 75 | + // Main list |
| 76 | + global $wgLang, $wgOut; |
73 | 77 | |
74 | | - $wgOut->wrapWikiMsg( '<h2>$1</h2>', 'translate-manage-listgroups' ); |
75 | | - $separator = wfMsg( 'word-separator' ); |
| 78 | + $groups = MessageGroups::singleton()->getGroups(); |
76 | 79 | |
77 | | - $languages = array_keys( Language::getLanguageNames( false ) ); |
| 80 | + $wgOut->wrapWikiMsg( '<h2>$1</h2>', 'translate-manage-listgroups' ); |
| 81 | + $separator = wfMsg( 'word-separator' ); |
78 | 82 | |
79 | | - foreach ( $groups as $group ) { |
80 | | - if ( !$group instanceof FileBasedMessageGroup ) { |
81 | | - continue; |
82 | | - } |
| 83 | + $languages = array_keys( Language::getLanguageNames( false ) ); |
83 | 84 | |
84 | | - wfDebug( __METHOD__ . ": {$group->getId()}\n" ); |
| 85 | + foreach ( $groups as $group ) { |
| 86 | + if ( !$group instanceof FileBasedMessageGroup ) { |
| 87 | + continue; |
| 88 | + } |
85 | 89 | |
86 | | - $link = $this->skin->link( $this->getTitle(), $group->getLabel(), array(), array( 'group' => $group->getId() ) ); |
87 | | - $out = $link . $separator; |
| 90 | + wfDebug( __METHOD__ . ": {$group->getId()}\n" ); |
88 | 91 | |
89 | | - $cache = new MessageGroupCache( $group ); |
90 | | - if ( $cache->exists() ) { |
91 | | - $timestamp = wfTimestamp( TS_MW, $cache->getTimestamp() ); |
92 | | - $out .= wfMsg( 'translate-manage-cacheat', |
93 | | - $wgLang->date( $timestamp ), |
94 | | - $wgLang->time( $timestamp ) |
95 | | - ); |
| 92 | + $link = $this->skin->link( $this->getTitle(), $group->getLabel(), array(), array( 'group' => $group->getId() ) ); |
| 93 | + $out = $link . $separator; |
96 | 94 | |
97 | | - $modified = array(); |
| 95 | + $cache = new MessageGroupCache( $group ); |
| 96 | + if ( $cache->exists() ) { |
| 97 | + $timestamp = wfTimestamp( TS_MW, $cache->getTimestamp() ); |
| 98 | + $out .= wfMsg( 'translate-manage-cacheat', |
| 99 | + $wgLang->date( $timestamp ), |
| 100 | + $wgLang->time( $timestamp ) |
| 101 | + ); |
98 | 102 | |
99 | | - foreach ( $languages as $code ) { |
100 | | - $cache = new MessageGroupCache( $group, $code ); |
101 | | - if ( !$cache->isValid() ) $modified[] = $code; |
102 | | - } |
| 103 | + $modified = array(); |
103 | 104 | |
104 | | - if ( count( $modified ) ) { |
105 | | - $out = '[' . implode( ",", $modified ) . '] ' . $out; |
106 | | - } else { |
107 | | - $out = Html::rawElement( 'span', array( 'style' => 'color:grey' ), $out ); |
| 105 | + foreach ( $languages as $code ) { |
| 106 | + $cache = new MessageGroupCache( $group, $code ); |
| 107 | + if ( !$cache->isValid() ) $modified[] = $code; |
| 108 | + } |
| 109 | + |
| 110 | + if ( count( $modified ) ) { |
| 111 | + $out = '[' . implode( ",", $modified ) . '] ' . $out; |
| 112 | + if ( !in_array( 'en', $modified ) && $this->user->isAllowed( 'translate-manage' ) ) { |
| 113 | + $out .= $this->rebuildButton( $group, $modified, 'main' ); |
108 | 114 | } |
109 | 115 | } else { |
110 | | - $out .= wfMsg( 'translate-manage-newgroup' ); |
| 116 | + $out = Html::rawElement( 'span', array( 'style' => 'color:grey' ), $out ); |
111 | 117 | } |
112 | | - |
113 | | - $wgOut->addHtml( $out ); |
114 | | - $wgOut->addHtml( '<hr>' ); |
| 118 | + } else { |
| 119 | + $out .= wfMsg( 'translate-manage-newgroup' ); |
115 | 120 | } |
116 | 121 | |
117 | | - $wgOut->wrapWikiMsg( '<h2>$1</h2>', 'translate-manage-listgroups-old' ); |
118 | | - $wgOut->addHTML( '<ul>' ); |
| 122 | + $wgOut->addHtml( $out ); |
| 123 | + $wgOut->addHtml( '<hr>' ); |
| 124 | + } |
119 | 125 | |
120 | | - foreach ( $groups as $group ) { |
121 | | - if ( $group instanceof FileBasedMessageGroup ) { |
122 | | - continue; |
123 | | - } |
| 126 | + $wgOut->wrapWikiMsg( '<h2>$1</h2>', 'translate-manage-listgroups-old' ); |
| 127 | + $wgOut->addHTML( '<ul>' ); |
124 | 128 | |
125 | | - $wgOut->addHtml( Xml::element( 'li', null, $group->getLabel() ) ); |
| 129 | + foreach ( $groups as $group ) { |
| 130 | + if ( $group instanceof FileBasedMessageGroup ) { |
| 131 | + continue; |
126 | 132 | } |
127 | 133 | |
128 | | - $wgOut->addHTML( '</ul>' ); |
| 134 | + $wgOut->addHtml( Xml::element( 'li', null, $group->getLabel() ) ); |
129 | 135 | } |
| 136 | + |
| 137 | + $wgOut->addHTML( '</ul>' ); |
130 | 138 | } |
131 | 139 | |
| 140 | + protected function rebuildButton( $group, $codes, $from ) { |
| 141 | + $formParams = array( |
| 142 | + 'method' => 'post', |
| 143 | + 'action' => $this->getTitle()->getLocalURL(), |
| 144 | + ); |
| 145 | + |
| 146 | + $html = |
| 147 | + Xml::openElement( 'form', $formParams ) . |
| 148 | + Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . |
| 149 | + Html::hidden( 'token', $this->user->editToken() ) . |
| 150 | + Html::hidden( 'group', $group->getId() ) . |
| 151 | + Html::hidden( 'codes', implode( ',', $codes ) ) . |
| 152 | + Html::hidden( 'rebuildall', 1 ) . |
| 153 | + Html::hidden( 'from', $from ) . |
| 154 | + Xml::submitButton( wfMsg( 'translate-manage-import-rebuild-all' ) ) . |
| 155 | + Xml::closeElement( 'form' ); |
| 156 | + return $html; |
| 157 | + } |
| 158 | + |
132 | 159 | /** |
133 | 160 | * @todo Very long code block; split up. |
134 | 161 | */ |
— | — | @@ -402,18 +429,7 @@ |
403 | 430 | ); |
404 | 431 | |
405 | 432 | if ( $this->user->isAllowed( 'translate-manage' ) ) { |
406 | | - |
407 | | - $this->out->addHTML( |
408 | | - Xml::openElement( 'form', $formParams ) . |
409 | | - Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . |
410 | | - Html::hidden( 'token', $this->user->editToken() ) . |
411 | | - Html::hidden( 'group', $group->getId() ) . |
412 | | - Html::hidden( 'codes', implode( ',', $codes ) ) . |
413 | | - Html::hidden( 'rebuildall', 1 ) . |
414 | | - Xml::submitButton( wfMsg( 'translate-manage-import-rebuild-all' ) ) . |
415 | | - Xml::closeElement( 'form' ) |
416 | | - ); |
417 | | - |
| 433 | + $this->out->addHTML( $this->rebuildButton( $group, $codes, 'import' ) ); |
418 | 434 | } |
419 | 435 | |
420 | 436 | $this->out->addHTML( |