- Timestamp:
- 09/02/2015 10:38:03 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/translate.wordpress.org/public_html/gp-templates/stats-overview.php
r1852 r1859 8 8 gp_tmpl_header(); 9 9 10 function get_rgb_for_percent( $percent ) {11 // This function does 100% = Green, < 100% = Red~Yellow12 if ( $percent == 100 ) {13 return 'rgb(0,153,0)';14 }15 $min = 0;16 $max = 153;17 $num = floor( $min + ( ($max - $min) * ( $percent/100 ) ) );18 return "rgb(153,$num,0)";19 }20 10 21 11 ?> 22 <div class="table"> 23 <style> 24 <?php /* Temporary styling */ ?> 25 table.table { 26 text-align: center; 27 } 28 table.table thead th { 29 text-align: center; 30 font-weight: bold; 31 } 32 table.table .none { 33 color: #ccc; 34 } 35 table.table tbody th { 36 text-align: left; 37 } 38 </style> 12 <div class="stats-table"> 39 13 <table class="table"> 40 14 <thead> 41 15 <tr> 42 <th ><?php _e( 'Language' ); ?></th>16 <th class="title"><?php _e( 'Locale' ); ?></th> 43 17 <?php foreach ( $projects as $slug => $project ) : ?> 44 <th><?php echo esc_html( str_replace( 'WordPress.org ', '', $project->name ) ); ?></th> 18 <th><?php 19 $namereplace = array( 'WordPress.org ', 'WordPress for ', 'WordPress ', 'ectory' ); 20 echo esc_html( str_replace( $namereplace, '', $project->name ) ); 21 ?></th> 45 22 <?php endforeach; ?> 46 23 </tr> 47 24 </thead> 48 25 <tbody> 49 <?php foreach ( $translation_locale_complete as $locale_slug => $total_complete ) : 26 <?php 27 foreach ( $translation_locale_complete as $locale_slug => $total_complete ) : 50 28 $gp_locale = GP_Locales::by_slug( $locale_slug ); 29 $set_slug = 'default'; 51 30 // Variants (de/formal for example) don't have GP_Locales in this context 31 if ( ! $gp_locale && ( list( $base_locale_slug, $set_slug ) = explode( '/', $locale_slug ) ) ) { 32 $gp_locale = clone GP_Locales::by_slug( $base_locale_slug ); 33 // Just append it for now.. 34 $gp_locale->wp_locale .= '/' . $set_slug; 35 } 36 if ( ! $gp_locale || ! $gp_locale->wp_locale ) { 37 continue; 38 } 52 39 ?> 53 40 <tr> 54 <th title="<?php echo esc_attr( $gp_locale->english_name ?: $locale_slug ); ?>"><?php echo esc_html( $gp_locale->wp_locale ?: $locale_slug ); ?></th> 55 <?php foreach ( $projects as $slug => $project ) : 41 <th title="<?php echo esc_attr( $gp_locale->english_name ); ?>"> 42 <a href="<?php echo gp_url_join( 'locale', $gp_locale->slug, $set_slug ); ?>"> 43 <?php echo esc_html( $gp_locale->wp_locale ); ?> 44 </a> 45 </th> 46 <?php 47 foreach ( $projects as $slug => $project ) { 48 $projecturl = gp_url_join( 'locale', $gp_locale->slug, $set_slug, $project->path ); 49 56 50 if ( isset( $translation_locale_statuses[ $locale_slug ][ $project->path ] ) ) { 57 51 $percent = $translation_locale_statuses[ $locale_slug ][ $project->path ]; 58 $percent = '<span style="color:' . get_rgb_for_percent( $percent ) . '">' . $percent . '%</span>'; 52 53 $percent_class = 'percent' . (int) ( $percent / 10 ) * 10; 54 echo '<td class="' . $percent_class .'"><a href="' . $projecturl . '">' . $percent . '%</a></td>'; 59 55 60 56 } else { 61 $percent = '<span class="none">—</span>';57 echo '<td class="none">—</td>'; 62 58 } 59 60 61 } 63 62 ?> 64 <td><?php echo $percent; ?></td>65 <?php endforeach; ?>66 63 </tr> 67 64 <?php endforeach; ?>
Note: See TracChangeset
for help on using the changeset viewer.