Changeset 1838
- Timestamp:
- 08/19/2015 02:08:28 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/css/i18n-teams.css
r1163 r1838 116 116 float: left; 117 117 width: 280px; /* todo use flexbox to prog enhance this so that they fill the space. AF is good one to test */ 118 padding-bottom: 15px;118 margin-bottom: 15px; 119 119 list-style-type: none; 120 120 } … … 127 127 } 128 128 .validators a { 129 text-decoration: none; 130 } 131 .validators .user-name { 132 font-size: 16px; 133 } 134 .validators .user-slack { 129 135 display: block; 130 margin: 6px 0 2px; 131 font-size: 16px; 132 text-decoration: none; 136 margin-top: .2em; 133 137 } 134 138 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/views/locale-details.php
r1800 r1838 61 61 <?php else : ?> 62 62 <ul class="validators"> 63 <?php foreach ( $locale_data['validators'] as $validator ) : ?> 63 <?php foreach ( $locale_data['validators'] as $validator ) : 64 ?> 64 65 <li> 65 <a href="https://profiles.wordpress.org/<?php echo esc_attr( $validator[2] ); ?>"> 66 <img src="https://secure.gravatar.com/avatar/<?php echo esc_attr( $validator[1] ); ?>?size=60" class="gravatar" alt="<?php echo esc_attr( $validator[0] ); ?>" /> 67 <?php echo esc_html( $validator[0] ); ?> 68 </a> 66 <a class="user-avatar" href="https://profiles.wordpress.org/<?php echo esc_attr( $validator['nice_name'] ); ?>"><?php 67 echo get_avatar( $validator['email'], 60 ); 68 ?></a> 69 <a class="user-name" href="https://profiles.wordpress.org/<?php echo esc_attr( $validator['nice_name'] ); ?>"><?php 70 echo esc_html( $validator['display_name'] ); 71 ?></a> 72 <?php 73 if ( $validator['slack'] ) { 74 printf( '<span class="user-slack">@%s on <a href="%s">Slack</a></span>', $validator['slack'], 'https://make.wordpress.org/chat/' ); 75 } 76 ?> 69 77 </li> 70 78 <?php endforeach; ?> … … 77 85 <?php if ( empty( $locale_data['translators'] ) ) : ?> 78 86 <p><?php printf( __( '%s does not have any translators yet.', 'wporg' ), $locale->english_name ); ?></p> 79 <?php else : ?> 80 <ul> 81 <?php foreach ( $locale_data['translators'] as $username => $name ) : ?> 82 <li> 83 <a href="https://profiles.wordpress.org/<?php echo esc_attr( $username ); ?>"> 84 <?php echo esc_html( $name ); ?> 85 </a> 86 </li> 87 <?php endforeach; ?> 88 </ul> 87 <?php else :?> 88 <p> 89 <?php 90 $translators = array(); 91 foreach ( $locale_data['translators'] as $translator ) { 92 $translators[] = sprintf( 93 '<a href="https://profiles.wordpress.org/%s">%s</a>', 94 esc_attr( $translator['nice_name'] ), 95 esc_html( $translator['display_name'] ) 96 ); 97 } 98 echo wp_sprintf( '%l.', $translators ); 99 ?> 100 </p> 89 101 <?php endif; ?> 90 102 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php
r1800 r1838 210 210 } 211 211 212 $contributors = self::get_contributors( $locale );212 $contributors = $this->get_contributors( $locale ); 213 213 $locale_data['validators'] = $contributors['validators']; 214 214 $locale_data['translators'] = $contributors['translators']; 215 215 216 216 return $locale_data; 217 } 218 219 /** 220 * Get the translators and validators for the given locale. 221 * 222 * @param GP_Locale $locale 223 * @return array 224 */ 225 public function get_contributors( $locale ) { 226 $cache = wp_cache_get( 'contributors-data:' . $locale->wp_locale, 'wp-i18n-teams' ); 227 if ( false !== $cache ) { 228 return $cache; 229 } 230 231 $contributors = array(); 232 $contributors['validators'] = $this->get_translation_editors( $locale ); 233 $contributors['translators'] = $this->get_translation_contributors( $locale ); 234 235 wp_cache_set( 'contributors-data:' . $locale->wp_locale, $contributors, 'wp-i18n-teams', 2 * HOUR_IN_SECONDS ); 236 237 return $contributors; 217 238 } 218 239 … … 249 270 250 271 /** 251 * Get the translat ors and validators for the given locale.272 * Get the translation editors for the given locale. 252 273 * 253 274 * @param GP_Locale $locale 254 275 * @return array 255 276 */ 256 public static function get_contributors( $locale ) { 257 require_once( API_WPORGPATH . 'core/credits/wp-credits.php' ); 258 259 $credits = WP_Credits::factory( WP_CORE_LATEST_RELEASE, $locale ); 260 $results = $credits->get_results(); 261 262 $contributors = array( 263 'validators' => ! empty( $results['groups']['validators']['data'] ) ? $results['groups']['validators']['data'] : array(), 264 'translators' => ! empty( $results['groups']['translators']['data'] ) ? $results['groups']['translators']['data'] : array(), 265 ); 277 private function get_translation_editors( $locale ) { 278 global $wpdb; 279 280 $editors = array(); 281 282 $subdomain = $wpdb->get_var( $wpdb->prepare( "SELECT subdomain FROM locales WHERE locale = %s", $locale->wp_locale ) ); 283 if ( ! $subdomain ) { 284 return $editors; 285 } 286 287 $blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = '/'", "$subdomain.wordpress.org" ) ); 288 if ( ! $blog_id ) { 289 return $editors; 290 } 291 292 $meta_key = $wpdb->base_prefix . intval( $blog_id ) . '_capabilities'; 293 $users = $wpdb->get_col( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$meta_key' AND meta_value LIKE '%translation_editor%'" ); 294 if ( ! $users ) { 295 return $editors; 296 } 297 298 $user_data = $wpdb->get_results( "SELECT ID, user_nicename, display_name, user_email FROM $wpdb->users WHERE ID IN (" . implode( ',', $users ) . ")" ); 299 foreach ( $user_data as $user ) { 300 if ( $user->display_name && $user->display_name !== $user->user_nicename ) { 301 $editors[ $user->user_nicename ] = array( 302 'display_name' => $user->display_name, 303 'email' => $user->user_email, 304 'nice_name' => $user->user_nicename, 305 'slack' => self::get_slack_username( $user->ID ), 306 ); 307 } else { 308 $editors[ $user->user_nicename ] = array( 309 'display_name' => $user->user_nicename, 310 'email' => $user->user_email, 311 'nice_name' => $user->user_nicename, 312 'slack' => self::get_slack_username( $user->ID ), 313 ); 314 } 315 } 316 317 uasort( $editors, array( $this, '_sort_display_name_callback' ) ); 318 319 return $editors; 320 } 321 322 /** 323 * Get the translation contributors for the given locale. 324 * 325 * @param GP_Locale $locale 326 * @return array 327 */ 328 private function get_translation_contributors( $locale ) { 329 global $wpdb; 330 331 $contributors = array(); 332 333 $users = $wpdb->get_col( $wpdb->prepare( 334 "SELECT DISTINCT user_id FROM translate_user_translations_count WHERE accepted > 0 AND locale = %s", 335 $locale->slug 336 ) ); 337 338 if ( ! $users ) { 339 $contributors; 340 } 341 342 $user_data = $wpdb->get_results( "SELECT user_nicename, display_name, user_email FROM $wpdb->users WHERE ID IN (" . implode( ',', $users ) . ")" ); 343 foreach ( $user_data as $user ) { 344 if ( $user->display_name && $user->display_name !== $user->user_nicename ) { 345 $contributors[ $user->user_nicename ] = array( 346 'display_name' => $user->display_name, 347 'nice_name' => $user->user_nicename, 348 ); 349 } else { 350 $contributors[ $user->user_nicename ] = array( 351 'display_name' => $user->user_nicename, 352 'nice_name' => $user->user_nicename, 353 ); 354 } 355 } 356 357 uasort( $contributors, array( $this, '_sort_display_name_callback' ) ); 266 358 267 359 return $contributors; … … 318 410 } 319 411 } 412 413 /** 414 * Get the Slack username for a .org user. 415 * 416 * @param int $user_id 417 * 418 * @return string 419 */ 420 protected static function get_slack_username( $user_id ) { 421 global $wpdb; 422 423 $data = $wpdb->get_var( $wpdb->prepare( "SELECT profiledata FROM slack_users WHERE user_id = %d", $user_id ) ); 424 if ( $data && ( $data = json_decode( $data, true ) ) ) { 425 return $data['name']; 426 } 427 428 return ''; 429 } 430 431 public function _sort_display_name_callback( $a, $b ) { 432 return strnatcasecmp( $a['display_name'], $b['display_name'] ); 433 } 320 434 } 321 435
Note: See TracChangeset
for help on using the changeset viewer.