Changeset 6691 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php
- Timestamp:
- 02/18/2018 05:24:48 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php
r6005 r6691 358 358 359 359 /** 360 * Retrieves contributors of a project. 360 * Retrieves translation editors of a project. 361 * 362 * Also includes cross-locale editors and editors of parent projects. 361 363 * 362 364 * @param GP_Project $project A GlotPress project. 363 365 * @param string $locale_slug Slug of the locale. 364 * @param string $set_slug Slug of the translation set. 365 * @return array Contributors. 366 */ 367 private function get_locale_contributors( $project, $locale_slug, $set_slug ) { 366 * @return array List of user IDs. 367 */ 368 private function get_translation_editors( $project, $locale_slug ) { 368 369 global $wpdb; 369 370 370 $locale_contributors = array(371 'editors' => array(),372 'contributors' => array(),373 );374 375 371 // Get the translation editors of the project. 376 $editors = $wpdb->get_col( $wpdb->prepare( "372 $editors = (array) $wpdb->get_col( $wpdb->prepare( " 377 373 SELECT 378 374 `user_id` … … 380 376 WHERE 381 377 `project_id` = %d 382 AND `locale` = %s378 AND `locale` IN (%s, 'all-locales') 383 379 ", $project->id, $locale_slug ) ); 380 381 if ( $project->parent_project_id ) { 382 $parent_project_id = $project->parent_project_id; 383 $parent_project = GP::$project->get( $parent_project_id ); 384 while ( $parent_project_id ) { 385 $editors = $editors + (array) $wpdb->get_col( $wpdb->prepare( " 386 SELECT 387 `user_id` 388 FROM {$wpdb->wporg_translation_editors} 389 WHERE 390 `project_id` = %d 391 AND `locale` IN (%s, 'all-locales') 392 ", $parent_project->id, $locale_slug ) ); 393 394 $parent_project = GP::$project->get( $parent_project_id ); 395 $parent_project_id = $parent_project->parent_project_id; 396 } 397 } 398 399 return $editors; 400 } 401 402 /** 403 * Retrieves contributors of a project. 404 * 405 * @param GP_Project $project A GlotPress project. 406 * @param string $locale_slug Slug of the locale. 407 * @param string $set_slug Slug of the translation set. 408 * @return array Contributors. 409 */ 410 private function get_locale_contributors( $project, $locale_slug, $set_slug ) { 411 global $wpdb; 412 413 $locale_contributors = array( 414 'editors' => array(), 415 'contributors' => array(), 416 ); 417 418 // Get the translation editors of the project. 419 $editors = $this->get_translation_editors( $project, $locale_slug ); 384 420 385 421 // Get the names of the translation editors. … … 468 504 unset( $contributors, $editors ); 469 505 470 uasort( $locale_contributors['contributors'], array( $this, '_sort_contributors_by_total_count_callback' ) ); 506 uasort( $locale_contributors['contributors'], function( $a, $b ) { 507 return $a->total_count < $b->total_count; 508 } ); 509 510 uasort( $locale_contributors['editors'], function( $a, $b ) { 511 return strcasecmp( $a->display_name, $b->display_name ); 512 } ); 471 513 472 514 return $locale_contributors; … … 891 933 } 892 934 893 private function _sort_contributors_by_total_count_callback( $a, $b ) {894 return $a->total_count < $b->total_count;895 }896 897 935 private function _sort_reverse_name_callback( $a, $b ) { 898 936 // The Waiting project should always be first. … … 903 941 } 904 942 905 private function _sort_name_callback( $a, $b ) {906 return strcasecmp( $a->name, $b->name );907 }908 909 943 private function _encode( $raw ) { 910 944 $raw = mb_convert_encoding( $raw, 'UTF-8', 'ASCII, JIS, UTF-8, Windows-1252, ISO-8859-1' );
Note: See TracChangeset
for help on using the changeset viewer.