Making WordPress.org

Changeset 2200


Ignore:
Timestamp:
12/17/2015 05:20:22 PM (10 years ago)
Author:
ocean90
Message:

WP i18n teams: Separate global and project specific editors on language team pages.

Fixes #1234.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/css/i18n-teams.css

    r1838 r2200  
    113113    padding: 0;
    114114}
     115
     116ul.validators {
     117    display: -webkit-box;
     118    display: -webkit-flex;
     119    display: -ms-flexbox;
     120    display: flex;
     121    -webkit-flex-flow: row wrap;
     122    -ms-flex-flow: row wrap;
     123    flex-flow: row wrap;
     124}
     125
    115126.validators li {
    116     float: left;
    117     width: 280px;       /* todo use flexbox to prog enhance this so that they fill the space. AF is good one to test */
     127    list-style-type: none;
    118128    margin-bottom: 15px;
    119     list-style-type: none;
     129    width: 33%;
    120130}
    121 .validators .gravatar {
    122     position: relative;
    123     top: -6px;
    124     float: left;
    125     margin: 0 10px 10px 0;
    126     padding: 2px;
     131
     132.validators.project-validators li {
     133    width: 25%;
     134    margin-bottom: 5px;
     135}
     136
     137@media only screen and (max-width: 850px) {
     138    .validators li {
     139        width: 50%;
     140    }
     141
     142    .validators.project-validators li {
     143        width: 33%;
     144    }
     145}
     146
     147@media only screen and (max-width: 470px) {
     148    .validators li {
     149        width: 100%;
     150    }
     151    .validators.project-validators li {
     152        width: 50%;
     153    }
     154}
     155
     156.validators.project-validators img.avatar {
     157    margin-right: 5px !important;
    127158}
    128159.validators a {
     
    131162.validators .user-name {
    132163    font-size: 16px;
     164    position: relative;
     165    top: .2em;
    133166}
     167.validators.project-validators .user-name {
     168    font-size: 13px;
     169}
     170
    134171.validators .user-slack {
    135172    display: block;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/views/locale-details.php

    r1911 r2200  
    5555
    5656
    57 <h2><?php _e( 'Translation Editors', 'wporg' ); ?></h2>
     57<h2><?php _e( 'General Translation Editors', 'wporg' ); ?></h2>
    5858
    5959<?php if ( empty( $locale_data['validators'] ) ) : ?>
     
    6565            <li>
    6666                <a class="user-avatar" href="https://profiles.wordpress.org/<?php echo esc_attr( $validator['nice_name'] ); ?>"><?php
    67                     echo get_avatar( $validator['email'], 60 );
     67                    echo get_avatar( $validator['email'], 50 );
    6868                ?></a>
    6969                <a class="user-name" href="https://profiles.wordpress.org/<?php echo esc_attr( $validator['nice_name'] ); ?>"><?php
     
    7575                }
    7676                ?>
     77            </li>
     78        <?php endforeach; ?>
     79    </ul>
     80<?php endif; ?>
     81
     82
     83<?php if ( ! empty( $locale_data['project_validators'] ) ) : ?>
     84    <h2><?php _e( 'Project Translation Editors', 'wporg' ); ?></h2>
     85
     86    <ul class="validators project-validators">
     87        <?php foreach ( $locale_data['project_validators'] as $validator ) :
     88            ?>
     89            <li>
     90                <a class="user-avatar" href="https://profiles.wordpress.org/<?php echo esc_attr( $validator['nice_name'] ); ?>"><?php
     91                    echo get_avatar( $validator['email'], 25 );
     92                ?></a>
     93                <a class="user-name" href="https://profiles.wordpress.org/<?php echo esc_attr( $validator['nice_name'] ); ?>"><?php
     94                    echo esc_html( $validator['display_name'] );
     95                ?></a>
    7796            </li>
    7897        <?php endforeach; ?>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php

    r1838 r2200  
    2828    public function enqueue_assets() {
    2929        if ( is_singular() && false !== strpos( get_post()->post_content, '[wp-locales' ) ) {
    30             wp_enqueue_style( 'wp-i18n-teams', plugins_url( 'css/i18n-teams.css', __FILE__ ), array(), 2 );
     30            wp_enqueue_style( 'wp-i18n-teams', plugins_url( 'css/i18n-teams.css', __FILE__ ), array(), 3 );
    3131            wp_enqueue_script( 'wp-i18n-teams', plugins_url( 'js/i18n-teams.js', __FILE__ ), array( 'jquery' ), 2 );
    3232        }
     
    212212        $contributors = $this->get_contributors( $locale );
    213213        $locale_data['validators'] = $contributors['validators'];
     214        $locale_data['project_validators'] = $contributors['project_validators'];
    214215        $locale_data['translators'] = $contributors['translators'];
    215216
     
    230231
    231232        $contributors = array();
    232         $contributors['validators'] = $this->get_translation_editors( $locale );
     233        $contributors['validators'] = $this->get_general_translation_editors( $locale );
     234        $contributors['project_validators'] = $this->get_project_translation_editors( $locale );
    233235        $contributors['translators'] = $this->get_translation_contributors( $locale );
    234236
     
    270272
    271273    /**
    272      * Get the translation editors for the given locale.
     274     * Get the general translation editors for the given locale.
    273275     *
    274276     * @param GP_Locale $locale
    275277     * @return array
    276278     */
    277     private function get_translation_editors( $locale ) {
     279    private function get_general_translation_editors( $locale ) {
    278280        global $wpdb;
    279281
    280282        $editors = array();
    281283
    282         $subdomain = $wpdb->get_var( $wpdb->prepare( "SELECT subdomain FROM locales WHERE locale = %s", $locale->wp_locale ) );
    283         if ( ! $subdomain ) {
    284             return $editors;
    285         }
    286 
    287         $blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = '/'", "$subdomain.wordpress.org" ) );
    288         if ( ! $blog_id ) {
    289             return $editors;
    290         }
    291 
    292         $meta_key = $wpdb->base_prefix . intval( $blog_id ) . '_capabilities';
    293         $users = $wpdb->get_col( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$meta_key' AND meta_value LIKE '%translation_editor%'" );
     284        $users = $wpdb->get_col( $wpdb->prepare( "
     285            SELECT `user_id` FROM `translate_translation_editors`
     286            WHERE `project_id` = '0' AND `locale` = %s
     287        ", $locale->slug ) );
     288
    294289        if ( ! $users ) {
    295290            return $editors;
     
    311306                    'nice_name'    => $user->user_nicename,
    312307                    'slack'        => self::get_slack_username( $user->ID ),
     308                );
     309            }
     310        }
     311
     312        uasort( $editors, array( $this, '_sort_display_name_callback' ) );
     313
     314        return $editors;
     315    }
     316
     317    /**
     318     * Get the general translation editors for the given locale.
     319     *
     320     * @param GP_Locale $locale
     321     * @return array
     322     */
     323    private function get_project_translation_editors( $locale ) {
     324        global $wpdb;
     325
     326        $editors = array();
     327
     328        $users = $wpdb->get_col( $wpdb->prepare( "
     329            SELECT `user_id` FROM `translate_translation_editors`
     330            WHERE `project_id` <> '0' AND `locale` = %s
     331        ", $locale->slug ) );
     332
     333        if ( ! $users ) {
     334            return $editors;
     335        }
     336
     337        $user_data = $wpdb->get_results( "SELECT ID, user_nicename, display_name, user_email FROM $wpdb->users WHERE ID IN (" . implode( ',', $users ) . ")" );
     338        foreach ( $user_data as $user ) {
     339            if ( $user->display_name && $user->display_name !== $user->user_nicename ) {
     340                $editors[ $user->user_nicename ] = array(
     341                    'display_name' => $user->display_name,
     342                    'email'        => $user->user_email,
     343                    'nice_name'    => $user->user_nicename,
     344                );
     345            } else {
     346                $editors[ $user->user_nicename ] = array(
     347                    'display_name' => $user->user_nicename,
     348                    'email'        => $user->user_email,
     349                    'nice_name'    => $user->user_nicename,
    313350                );
    314351            }
Note: See TracChangeset for help on using the changeset viewer.