Index: trunk/extensions/Translate/tag/PageTranslationHooks.php |
— | — | @@ -196,12 +196,22 @@ |
197 | 197 | } |
198 | 198 | // If the prioritylangs set, show those languages alone. |
199 | 199 | $priorityLangs = TranslateMetadata::get( $page->getMessageGroupId(), 'prioritylangs' ); |
| 200 | + $priorityForce = TranslateMetadata::get( $page->getMessageGroupId(), 'priorityforce' ); |
200 | 201 | $filter = null; |
201 | 202 | if( strlen( $priorityLangs ) > 0 ) { |
202 | | - $filter = explode( ',', $priorityLangs ); |
| 203 | + $filter = array_flip( explode( ',', $priorityLangs ) ); |
203 | 204 | } |
204 | 205 | if ( $filter != null) { |
205 | | - $status = array_intersect_key( $status, array_flip( $filter ) ); |
| 206 | + if ( $priorityForce == 'on' ) { |
| 207 | + // Show only the priority languages. |
| 208 | + $status = array_intersect_key( $status, $filter ); |
| 209 | + } |
| 210 | + foreach ( $filter as $langCode => $value) { |
| 211 | + if ( !isset( $status[$langCode] ) ) { |
| 212 | + // We need to show all priority languages even if no translation started |
| 213 | + $status[ $langCode] = 0; |
| 214 | + } |
| 215 | + } |
206 | 216 | } |
207 | 217 | // Fix title |
208 | 218 | $title = $page->getTitle(); |
— | — | @@ -227,7 +237,7 @@ |
228 | 238 | elseif ( $percent < 80 ) { $image = 4; } |
229 | 239 | else { $image = 5; } |
230 | 240 | |
231 | | - $percent = Xml::element( 'img', array( |
| 241 | + $percentImage = Xml::element( 'img', array( |
232 | 242 | 'src' => TranslateUtils::assetPath( "resources/images/prog-$image.png" ), |
233 | 243 | 'alt' => "$percent%", // @todo i18n missing. |
234 | 244 | 'title' => "$percent%", // @todo i18n missing. |
— | — | @@ -241,12 +251,12 @@ |
242 | 252 | |
243 | 253 | if ( $parser->getTitle()->getText() === $_title->getText() ) { |
244 | 254 | $name = Html::rawElement( 'span', array( 'class' => 'mw-pt-languages-selected' ), $name ); |
245 | | - $languages[] = "$name $percent"; |
| 255 | + $languages[] = "$name $percentImage"; |
246 | 256 | } else { |
247 | 257 | if ( $code === $userLangCode ) { |
248 | 258 | $name = Html::rawElement( 'span', array( 'class' => 'mw-pt-languages-ui' ), $name ); |
249 | 259 | } |
250 | | - $languages[] = Linker::linkKnown( $_title, "$name $percent" ); |
| 260 | + $languages[] = Linker::link( $_title, "$name $percentImage" ); |
251 | 261 | } |
252 | 262 | } |
253 | 263 | |
— | — | @@ -336,11 +346,21 @@ |
337 | 347 | */ |
338 | 348 | public static function preventUnknownTranslations( Title $title, User $user, $action, &$result ) { |
339 | 349 | $handle = new MessageHandle( $title ); |
340 | | - if ( $handle->isPageTranslation() && $action === 'edit' && !$handle->isValid() ) { |
341 | | - $result = array( 'tpt-unknown-page' ); |
342 | | - return false; |
| 350 | + if ( $handle->isPageTranslation() && $action === 'edit' ) { |
| 351 | + if( !$handle->isValid() ) { |
| 352 | + $result = array( 'tpt-unknown-page' ); |
| 353 | + return false; |
| 354 | + } |
| 355 | + $priorityLangs = TranslateMetadata::get( $handle->getGroup()->getId() , 'prioritylangs' ); |
| 356 | + $priorityForce = TranslateMetadata::get( $handle->getGroup()->getId() , 'priorityforce' ); |
| 357 | + if ( strlen( $priorityLangs ) > 0 && $priorityForce ) { |
| 358 | + $filter = array_flip( explode ( ',', $priorityLangs ) ); |
| 359 | + if ( count( $filter) > 0 && !isset( $filter[$handle->getCode()] ) ) { |
| 360 | + $result = array( 'tpt-translation-restricted' ); |
| 361 | + return false; |
| 362 | + } |
| 363 | + } |
343 | 364 | } |
344 | | - |
345 | 365 | return true; |
346 | 366 | } |
347 | 367 | |