Making WordPress.org


Ignore:
Timestamp:
09/02/2015 10:38:03 PM (9 years ago)
Author:
dd32
Message:

Translate: Stats overview: Update the styles.
Props sam.
See #1202

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/public_html/gp-templates/stats-overview.php

    r1852 r1859  
    88gp_tmpl_header();
    99
    10 function get_rgb_for_percent( $percent ) {
    11     // This function does 100% = Green, < 100% = Red~Yellow
    12     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 }
    2010
    2111?>
    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">
    3913    <table class="table">
    4014        <thead>
    4115            <tr>
    42                 <th><?php _e( 'Language' ); ?></th>
     16                <th class="title"><?php _e( 'Locale' ); ?></th>
    4317                <?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>
    4522                <?php endforeach; ?>
    4623            </tr>
    4724        </thead>
    4825        <tbody>
    49             <?php foreach ( $translation_locale_complete as $locale_slug => $total_complete ) :
     26            <?php
     27            foreach ( $translation_locale_complete as $locale_slug => $total_complete ) :
    5028                $gp_locale = GP_Locales::by_slug( $locale_slug );
     29                $set_slug = 'default';
    5130                // 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                }
    5239            ?>
    5340                <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
    5650                        if ( isset( $translation_locale_statuses[ $locale_slug ][ $project->path ] ) ) {
    5751                            $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>';
    5955
    6056                        } else {
    61                             $percent = '<span class="none">&mdash;</span>';
     57                            echo '<td class="none">&mdash;</td>';
    6258                        }
     59                       
     60                       
     61                    }
    6362                    ?>
    64                         <td><?php echo $percent; ?></td>
    65                     <?php endforeach; ?>
    6663                </tr>
    6764            <?php endforeach; ?>
Note: See TracChangeset for help on using the changeset viewer.