Ticket #1388: 1388.diff
File 1388.diff, 4.7 KB (added by , 10 years ago) |
---|
-
gp-plugins/wporg-project-stats.php
144 144 } 145 145 } 146 146 147 function get_project_contributors( $project_id, $locale = false, $locale_slug = false ) { 148 global $gpdb; 149 $where_locale = ''; 150 151 if ( $locale !== false ) { 152 $where_locale .= $gpdb->prepare( ' AND ts.`locale` = %s', $locale ); 153 } 154 155 if ( $locale_slug !== false ) { 156 $where_locale .= $gpdb->prepare( ' AND ts.`slug` = %s', $slug ); 157 } 158 159 $sql = $gpdb->prepare( ' 160 SELECT ts.`locale`, ts.`slug` AS `locale_slug`, t.`user_id`, COUNT(*) AS `translation_count` 161 FROM `' . $gpdb->translations .'` t, `'. $gpdb->translation_sets . '` ts 162 WHERE t.`translation_set_id` = ts.`id` AND t.`user_id` IS NOT NULL AND ts.`project_id` = %d 163 ' . $where_locale . ' 164 GROUP BY ts.`locale`, ts.`slug`, t.`user_id` 165 ', $project_id); 166 167 $result = array(); 168 foreach ( $gpdb->get_results( $sql ) as $row ) { 169 $locale_key = $row->locale; 170 if ( 'default' != $row->locale_slug ) { 171 $locale_key = $row->locale . '/' . $row->locale_slug; 172 } 173 174 if ( !isset( $result[ $locale_key ] ) ) { 175 $result[ $locale_key ] = array(); 176 } 177 $result[ $locale_key ][] = $row; 178 } 179 180 return $result; 181 } 182 147 183 } 148 184 GP::$plugins->wporg_project_stats = new GP_WPorg_Project_Stats; 149 185 -
gp-templates/projects-wp-plugins.php
19 19 ?> 20 20 21 21 <div class="project-header"> 22 <p class="project-description"><?php echo apply_filters( 'project_description', $project->description, $project ); ?></p> 22 <p class="project-description"> 23 <?php echo apply_filters( 'project_description', $project->description, $project ); ?><br/> 24 <a href="" id="project-contributors-link">Display Contributors</a> 25 </p> 23 26 24 27 <div class="project-box"> 25 28 <div class="project-box-header"> … … 32 35 </ul> 33 36 </div> 34 37 </div> 38 39 <p id="project-contributors"> 40 <?php 41 foreach ( GP::$plugins->wporg_project_stats->get_project_contributors( $project->id ) as $locale => $contributors ) : 42 $gp_locale = GP_Locales::by_slug( $locale ); 43 44 $set_slug = 'default'; 45 46 // Variants (de/formal for example) don't have GP_Locales in this context 47 if ( ! $gp_locale && ( list( $base_locale_slug, $set_slug ) = explode( '/', $locale_slug ) ) ) : 48 $gp_locale = clone GP_Locales::by_slug( $base_locale_slug ); 49 50 // Just append it for now.. 51 $gp_locale->wp_locale .= '/' . $set_slug; 52 $gp_locale->english_name .= ' (' . ucfirst( $set_slug ) . ')'; 53 endif; 54 55 if ( ! $gp_locale || ! $gp_locale->wp_locale ) : 56 continue; 57 endif; 58 ?> 59 <span title="<?php echo esc_attr( $gp_locale->wp_locale );?>"> 60 <a href="<?php echo gp_url( gp_url_join( 'locale', $gp_locale->slug, $set_slug, $project->path ) ); ?>"><?php 61 echo esc_html( $gp_locale->english_name ); 62 ?></a>: 63 </span> 64 <?php $t = ''; foreach ( $contributors as $contributor ) { 65 $user = GP::$user->get( $contributor->user_id ); 66 echo $t; 67 $t = ', '; 68 ?><span title="<?php printf( _n( '%d translation', '%d translations', $contributor->translation_count ), $contributor->translation_count ); ?>"><?php echo $user->user_login; ?></span><?php 69 } ?><br/> 70 <?php endforeach; ?> 71 </p> 72 73 35 74 </div> 36 75 37 76 <div class="stats-table"> … … 113 152 114 153 <script type="text/javascript"> 115 154 jQuery( function( $ ) { 155 $( '#project-contributors-link' ).on( 'click', function() { 156 $( '#project-contributors' ).toggle(); 157 return false; 158 }); 116 159 $( '#stats-table' ).tablesorter( { 117 160 textExtraction: function( node ) { 118 161 var cellValue = $( node ).text(), -
gp-templates/style.css
540 540 line-height: 1.3; 541 541 } 542 542 543 .projects .project-description { 543 .projects .project-description, 544 .projects #project-contributors { 544 545 font-size: 13px; 545 546 } 546 547 … … 632 633 margin-bottom: 30px; 633 634 } 634 635 635 .project-header .project-description { 636 .project-header .project-description, 637 .project-header #project-contributors { 636 638 float: left; 637 639 width: 100%; 638 640 max-width: 520px; … … 639 641 margin-top: 20px; 640 642 } 641 643 644 .project-header #project-contributors { 645 display: none; 646 } 647 642 648 .project-header .project-box { 643 649 position: relative; 644 650 float: right; … … 870 876 width: 100%; 871 877 } 872 878 873 .project-header .project-description { 879 .project-header .project-description, 880 .project-header #project-contributors { 874 881 float: none; 875 882 } 876 883