Ticket #1388: 1388.2.diff
File 1388.2.diff, 6.2 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` 163 AND t.`user_id` IS NOT NULL AND t.`user_id` != 0 164 AND ts.`project_id` = %d 165 ' . $where_locale . ' 166 GROUP BY ts.`locale`, ts.`slug`, t.`user_id` 167 ', $project_id); 168 169 $result = array(); 170 foreach ( $gpdb->get_results( $sql ) as $row ) { 171 $locale_key = $row->locale; 172 if ( 'default' != $row->locale_slug ) { 173 $locale_key = $row->locale . '/' . $row->locale_slug; 174 } 175 176 if ( !isset( $result[ $locale_key ] ) ) { 177 $result[ $locale_key ] = array(); 178 } 179 $result[ $locale_key ][] = $row; 180 } 181 182 return $result; 183 } 184 147 185 } 148 186 GP::$plugins->wporg_project_stats = new GP_WPorg_Project_Stats; 149 187 -
gp-plugins/wporg-routes/routes/wp-plugins.php
80 80 } 81 81 } ); 82 82 83 $project->icon = wporg_get_plugin_icon( $project->slug, 64 ); 83 if ( function_exists( 'wporg_get_plugin_icon' ) ) { 84 $project->icon = wporg_get_plugin_icon( $project->slug, 64 ); 85 } else { 86 $project->icon = ''; 87 } 84 88 85 89 $this->tmpl( 'projects-wp-plugins', get_defined_vars() ); 86 90 } 91 92 function get_project_contributors( $project_slug ) { 93 $project_path = 'wp-plugins/' . $project_slug; 94 $project = GP::$project->by_path( $project_path ); 95 if ( ! $project ) { 96 return $this->die_with_404(); 97 } 98 $project_contributors = GP::$plugins->wporg_project_stats->get_project_contributors( $project->id ); 99 100 $this->tmpl( 'contributors-project', get_defined_vars() ); 101 } 87 102 } -
gp-plugins/wporg-routes/wporg-routes.php
43 43 GP::$router->prepend( "/locale/$locale/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_projects' ) ); 44 44 GP::$router->prepend( "/locale/$locale/$path/$path/$path", array( 'GP_WPorg_Route_Locale', 'get_locale_project' ) ); 45 45 46 $project = '([^/]*)/?'; 47 GP::$router->prepend( "/projects/wp-plugins/$project", array( 'GP_WPorg_Route_WP_Plugins', 'get_plugin_projects' ) ); 46 $project = '([^/]*)'; 47 GP::$router->prepend( "/projects/wp-plugins/$project/?", array( 'GP_WPorg_Route_WP_Plugins', 'get_plugin_projects' ) ); 48 GP::$router->prepend( "/projects/wp-plugins/$project/contributors/?", array( 'GP_WPorg_Route_WP_Plugins', 'get_project_contributors' ) ); 48 49 } 49 50 } 50 51 -
gp-templates/contributors-project.php
1 <?php 2 $edit_link = gp_link_project_edit_get( $project, __( '(edit)' ) ); 3 4 gp_title( sprintf( __( 'Contributors < %s < GlotPress' ), esc_html( $project->name ) ) ); 5 gp_breadcrumb_project( $project ); 6 7 wp_enqueue_script( 'common' ); 8 wp_enqueue_script( 'tablesorter' ); 9 10 gp_tmpl_header(); 11 ?> 12 13 <div class="project-header"> 14 <p class="project-description"><?php echo apply_filters( 'project_description', $project->description, $project ); ?></p> 15 16 <div class="project-box"> 17 <div class="project-box-header"> 18 <div class="project-icon"> 19 <?php echo $project->icon; ?> 20 </div> 21 22 <ul class="project-meta"> 23 <li class="project-name"><?php echo $project->name; ?> <?php echo $edit_link; ?></li> 24 </ul> 25 </div> 26 </div> 27 </div> 28 29 <div class="contributors-table"> 30 <table id="contributors-table" class="table"> 31 <thead> 32 <tr> 33 <th class="locale"><?php echo _( 'Locale' ); ?></th> 34 <th class="username"><?php echo _( 'Username' ); ?></th> 35 <th class="translations"><?php echo _( 'Translations' ); ?></th> 36 </tr> 37 </thead> 38 <tbody> 39 <?php 40 foreach ( $project_contributors as $locale => $contributors ) : 41 $gp_locale = GP_Locales::by_slug( $locale ); 42 43 $set_slug = 'default'; 44 45 // Variants (de/formal for example) don't have GP_Locales in this context 46 if ( ! $gp_locale && ( list( $base_locale_slug, $set_slug ) = explode( '/', $locale_slug ) ) ) : 47 $gp_locale = clone GP_Locales::by_slug( $base_locale_slug ); 48 49 // Just append it for now.. 50 $gp_locale->wp_locale .= '/' . $set_slug; 51 $gp_locale->english_name .= ' (' . ucfirst( $set_slug ) . ')'; 52 endif; 53 54 if ( ! $gp_locale || ! $gp_locale->wp_locale ) : 55 continue; 56 endif; 57 58 foreach ( $contributors as $contributor ): 59 $user = GP::$user->get( $contributor->user_id ); 60 ?> 61 <tr> 62 <th title="<?php echo esc_attr( $gp_locale->wp_locale ); ?>"> 63 <a href="<?php echo gp_url( gp_url_join( 'locale', $gp_locale->slug, $set_slug, $project->path ) ); ?>"> 64 <?php echo esc_html( $gp_locale->english_name ); ?> 65 </a> 66 </th> 67 <td><?php echo $user->user_login; ?></td> 68 <td><?php echo $contributor->translation_count; ?></td> 69 </tr> 70 <?php endforeach; ?> 71 <?php endforeach; ?> 72 </tbody> 73 </table> 74 </div> 75 76 <script type="text/javascript"> 77 jQuery( function( $ ) { 78 $( '#contributors-table' ).tablesorter( { 79 textExtraction: function( node ) { 80 var cellValue = $( node ).text(), 81 sortValue = $( node ).data( 'sortValue' ); 82 83 return ( undefined !== sortValue ) ? sortValue : cellValue; 84 } 85 }); 86 }); 87 </script> 88 89 <?php gp_tmpl_footer();