| | 1 | <?php |
| | 2 | $edit_link = gp_link_project_edit_get( $project, __( '(edit)' ) ); |
| | 3 | |
| | 4 | gp_title( sprintf( __( 'Translators < %s < GlotPress' ), esc_html( $project->name ) ) ); |
| | 5 | gp_breadcrumb_project( $project ); |
| | 6 | |
| | 7 | wp_enqueue_script( 'common' ); |
| | 8 | wp_enqueue_script( 'tablesorter' ); |
| | 9 | |
| | 10 | $translators_recent = $translators_total = $translators_minimum10 = $translators_minimum100 = 0; |
| | 11 | foreach ( $project_translators as $locale_slug => $translators ) { |
| | 12 | foreach ( $translators as $translator_id => $translations ) { |
| | 13 | $translators_total += 1; |
| | 14 | |
| | 15 | if ( $translations->recent > 0 ) { |
| | 16 | $translators_recent += 1; |
| | 17 | } |
| | 18 | if ( $translations->count >= 10 ) { |
| | 19 | $translators_minimum10 += 1; |
| | 20 | } |
| | 21 | if ( $translations->count >= 100 ) { |
| | 22 | $translators_minimum100 += 1; |
| | 23 | } |
| | 24 | } |
| | 25 | } |
| | 26 | |
| | 27 | gp_tmpl_header(); |
| | 28 | ?> |
| | 29 | |
| | 30 | <div class="project-header"> |
| | 31 | <p class="project-description"><?php echo apply_filters( 'project_description', $project->description, $project ); ?></p> |
| | 32 | <div class="project-description"> |
| | 33 | <a href="" id="translator-stats-toggle"><?php _e( 'Show translator stats »' ); ?></a> |
| | 34 | |
| | 35 | <ul id="translator-stats"> |
| | 36 | <li><?php printf( _n( '%d people contributed translations to this project.', '%d people contributed translations to this project', $translators_total ), $translators_total ); ?></li> |
| | 37 | |
| | 38 | <?php if ( $translators_recent > 0 ): ?> |
| | 39 | <li class="filter" data-filter="recent" data-filter-name="<?php echo esc_attr( __( 'only people who translated in the last 12 months' ) ); ?>"><span><?php printf( _n( '%d person contributed translations in the last 12 months.', '%d people contributed translations in the last 12 months.', $translators_recent ), $translators_recent ); ?></span></li> |
| | 40 | <?php endif; ?> |
| | 41 | |
| | 42 | <?php if ( $translators_minimum10 > 0 ): ?> |
| | 43 | <li class="filter" data-filter="minimum10" data-filter-name="<?php echo esc_attr( __( 'only people who contributed at least 10 translations' ) ); ?>"><span><?php printf( _n( '%d person contributed at least 10 translations.', '%d people contributed at least 10 translations.', $translators_minimum10 ), $translators_minimum10 ); ?></span></li> |
| | 44 | <?php endif; ?> |
| | 45 | |
| | 46 | <?php if ( $translators_minimum100 > 0 ): ?> |
| | 47 | <li class="filter" data-filter="minimum100" data-filter-name="<?php echo esc_attr( __( 'only people who contributed at least 100 translations' ) ); ?>"><span><?php printf( _n( '%d person contributed at least 100 translations.', '%d people contributed at least 100 translations.', $translators_minimum100 ), $translators_minimum100 ); ?></span></li> |
| | 48 | <?php endif; ?> |
| | 49 | |
| | 50 | </ul> |
| | 51 | </div> |
| | 52 | |
| | 53 | |
| | 54 | <div class="project-box"> |
| | 55 | <div class="project-box-header"> |
| | 56 | <div class="project-icon"> |
| | 57 | <?php echo $project->icon; ?> |
| | 58 | </div> |
| | 59 | |
| | 60 | <ul class="project-meta"> |
| | 61 | <li class="project-name"><?php echo $project->name; ?> <?php echo $edit_link; ?></li> |
| | 62 | </ul> |
| | 63 | </div> |
| | 64 | </div> |
| | 65 | </div> |
| | 66 | |
| | 67 | <div class="stats-table"> |
| | 68 | <table id="translators-table" class="table"> |
| | 69 | <thead> |
| | 70 | <tr> |
| | 71 | <th class="locale"><?php echo _( 'Locale' ); ?> <span class="filter-name"></span></th> |
| | 72 | <th class="username"><?php echo _( 'Username' ); ?></th> |
| | 73 | <th class="translations"><?php echo _( 'Translations' ); ?></th> |
| | 74 | <th class="recent-translations"><?php echo _( 'Last 12 months' ); ?></th> |
| | 75 | </tr> |
| | 76 | </thead> |
| | 77 | <tbody> |
| | 78 | <?php |
| | 79 | foreach ( $project_translators as $locale_slug => $translators ) : |
| | 80 | $gp_locale = GP_Locales::by_slug( $locale_slug ); |
| | 81 | |
| | 82 | $set_slug = 'default'; |
| | 83 | |
| | 84 | // Variants (de/formal for example) don't have GP_Locales in this context |
| | 85 | if ( ! $gp_locale && ( list( $base_locale_slug, $set_slug ) = explode( '/', $locale_slug ) ) ) : |
| | 86 | $gp_locale = clone GP_Locales::by_slug( $base_locale_slug ); |
| | 87 | |
| | 88 | // Just append it for now.. |
| | 89 | $gp_locale->wp_locale .= '/' . $set_slug; |
| | 90 | $gp_locale->english_name .= ' (' . ucfirst( $set_slug ) . ')'; |
| | 91 | endif; |
| | 92 | |
| | 93 | if ( ! $gp_locale || ! $gp_locale->wp_locale ) : |
| | 94 | continue; |
| | 95 | endif; |
| | 96 | |
| | 97 | foreach ( $translators as $translator_id => $translations ): |
| | 98 | $user = GP::$user->get( $translator_id ); |
| | 99 | ?> |
| | 100 | <tr> |
| | 101 | <th title="<?php echo esc_attr( $gp_locale->wp_locale ); ?>"> |
| | 102 | <a href="<?php echo gp_url( gp_url_join( 'locale', $gp_locale->slug, $set_slug, $project->path ) ); ?>"> |
| | 103 | <?php echo esc_html( $gp_locale->english_name ); ?> |
| | 104 | </a> |
| | 105 | </th> |
| | 106 | <td><?php echo $user->user_login; ?></td> |
| | 107 | <td><?php echo $translations->count; ?></td> |
| | 108 | <td><?php echo $translations->recent; ?></td> |
| | 109 | </tr> |
| | 110 | <?php endforeach; ?> |
| | 111 | <?php endforeach; ?> |
| | 112 | </tbody> |
| | 113 | </table> |
| | 114 | </div> |
| | 115 | |
| | 116 | <script type="text/javascript"> |
| | 117 | jQuery( function( $ ) { |
| | 118 | $( '#translators-table' ).tablesorter( { |
| | 119 | textExtraction: function( node ) { |
| | 120 | var cellValue = $( node ).text(), |
| | 121 | sortValue = $( node ).data( 'sortValue' ); |
| | 122 | |
| | 123 | return ( undefined !== sortValue ) ? sortValue : cellValue; |
| | 124 | } |
| | 125 | }); |
| | 126 | |
| | 127 | $( '#translator-stats-toggle' ).on( 'click', function() { |
| | 128 | $( '#translator-stats' ).toggle(); |
| | 129 | return false; |
| | 130 | }); |
| | 131 | |
| | 132 | $( '#translator-stats li.filter' ).on( 'click', function() { |
| | 133 | var $this = $( this ), filter = $this.data( 'filter' ); |
| | 134 | |
| | 135 | |
| | 136 | if ( |
| | 137 | $this.hasClass( 'active' ) |
| | 138 | || $( '#translator-stats li.filter.active' ).length |
| | 139 | ) { |
| | 140 | $( '#translators-table thead th.locale span.filter-name' ).text( '' ); |
| | 141 | $( '#translators-table tbody tr').each( function() { |
| | 142 | this.style.display = 'table-row'; |
| | 143 | }); |
| | 144 | } |
| | 145 | |
| | 146 | if ( $this.hasClass( 'active' ) ) { |
| | 147 | $this.removeClass( 'active' ); |
| | 148 | return; |
| | 149 | } |
| | 150 | $( '#translator-stats li.filter.active' ).removeClass( 'active' ); |
| | 151 | |
| | 152 | $this.addClass( 'active' ); |
| | 153 | $( '#translators-table thead th.locale span.filter-name' ).text( '(' + $this.data( 'filter-name' ) + ')' ); |
| | 154 | |
| | 155 | if ( filter === 'recent' ) { |
| | 156 | $( '#translators-table tbody tr').each( function() { |
| | 157 | this.style.display = parseInt( $( this ).find( 'td' ).eq( 2 ).text(), 10 ) > 0 ? |
| | 158 | 'table-row' : 'none'; |
| | 159 | }); |
| | 160 | } else if ( filter === 'minimum10' ) { |
| | 161 | $( '#translators-table tbody tr').each( function() { |
| | 162 | this.style.display = parseInt( $( this ).find( 'td' ).eq( 1 ).text(), 10 ) >= 10 ? |
| | 163 | 'table-row' : 'none'; |
| | 164 | }); |
| | 165 | } else if ( filter === 'minimum100' ) { |
| | 166 | $( '#translators-table tbody tr').each( function() { |
| | 167 | this.style.display = parseInt( $( this ).find( 'td' ).eq( 1 ).text(), 10 ) >= 100 ? |
| | 168 | 'table-row' : 'none'; |
| | 169 | }); |
| | 170 | } |
| | 171 | return false; |
| | 172 | }) |
| | 173 | }); |
| | 174 | </script> |
| | 175 | |
| | 176 | <?php gp_tmpl_footer(); |