Changeset 13683 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event.php
- Timestamp:
- 05/09/2024 08:33:51 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event.php
r13566 r13683 9 9 use WP_User; 10 10 use Wporg\TranslationEvents\Attendee\Attendee; 11 use Wporg\TranslationEvents\Attendee\Attendee_Repository;12 11 use Wporg\TranslationEvents\Event\Event; 13 12 use Wporg\TranslationEvents\Event\Event_End_Date; … … 16 15 use Wporg\TranslationEvents\Stats\Stats_Row; 17 16 18 /** @var Attendee_Repository $attendee_repo */ 19 /** @var Attendee $attendee */ 17 /** @var bool $user_is_attending */ 18 /** @var bool $user_is_contributor */ 19 /** @var Attendee[] $attendees_not_contributing */ 20 /** @var Attendee[] $contributors */ 21 /** @var array $new_contributor_ids */ 20 22 /** @var Event $event */ 21 23 /** @var int $event_id */ … … 53 55 <ul> 54 56 <?php foreach ( $contributors as $contributor ) : ?> 55 <li class="event-contributor" title="<?php echo esc_html( implode( ', ', $contributor-> locales) ); ?>">56 <a href="<?php echo esc_url( get_author_posts_url( $contributor-> ID ) ); ?>" class="avatar"><?php echo get_avatar( $contributor->ID, 48 ); ?></a>57 <a href="<?php echo esc_url( get_author_posts_url( $contributor-> ID ) ); ?>" class="name"><?php echo esc_html( get_the_author_meta( 'display_name', $contributor->ID) ); ?></a>58 <?php if ( $stats_calculator->is_new_translation_contributor( $event_start, $contributor->ID) ) : ?>57 <li class="event-contributor" title="<?php echo esc_html( implode( ', ', $contributor->contributed_locales() ) ); ?>"> 58 <a href="<?php echo esc_url( get_author_posts_url( $contributor->user_id() ) ); ?>" class="avatar"><?php echo get_avatar( $contributor->user_id(), 48 ); ?></a> 59 <a href="<?php echo esc_url( get_author_posts_url( $contributor->user_id() ) ); ?>" class="name"><?php echo esc_html( get_the_author_meta( 'display_name', $contributor->user_id() ) ); ?></a> 60 <?php if ( isset( $new_contributor_ids[ $contributor->user_id() ] ) ) : ?> 59 61 <span class="first-time-contributor-tada" title="<?php esc_html_e( 'New Translation Contributor', 'gp-translation-events' ); ?>"></span> 60 62 <?php endif; ?> 61 <?php62 if ( ! $event->end()->is_in_the_past() ) :63 if ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'manage_options' ) || $user->ID === $event->author_id() ) :64 $_attendee = $attendee_repo->get_attendee( $event_id, $contributor->ID );65 if ( $_attendee instanceof Attendee ) :66 echo '<form class="add-remove-user-as-host" method="post" action="' . esc_url( gp_url( "/events/host/$event_id/$contributor->ID" ) ) . '">';67 if ( $_attendee->is_host() ) :68 echo '<input type="submit" class="button is-primary remove-as-host" value="Remove as host"/>';69 else :70 echo '<input type="submit" class="button is-secondary convert-to-host" value="Make co-host"/>';71 endif;72 echo '</form>';73 else :74 echo '<span class="event-not-attending">' . esc_html__( 'Not attending', 'gp-translation-events' ) . '</span>';75 endif;76 endif;77 endif;78 ?>79 63 </li> 80 64 <?php endforeach; ?> … … 82 66 </div> 83 67 <?php endif; ?> 84 <?php if ( ! empty( $attendees ) && ( ! $event->end()->is_in_the_past() || ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'manage_options' ) || $user->ID === $event->author_id()) ) ) : ?>68 <?php if ( ! empty( $attendees_not_contributing ) && current_user_can( 'edit_translation_event', $event->id() ) ) : ?> 85 69 <div class="event-attendees"> 86 70 <h2> 87 71 <?php 88 72 // translators: %d is the number of attendees. 89 echo esc_html( sprintf( __( 'Attendees (%d)', 'gp-translation-events' ), number_format_i18n( count( $attendees ) ) ) );73 echo esc_html( sprintf( __( 'Attendees (%d)', 'gp-translation-events' ), number_format_i18n( count( $attendees_not_contributing ) ) ) ); 90 74 ?> 91 75 </h2> 92 76 <ul> 93 <?php foreach ( $attendees as $_user) : ?>77 <?php foreach ( $attendees_not_contributing as $_attendee ) : ?> 94 78 <li class="event-attendee"> 95 <a href="<?php echo esc_url( get_author_posts_url( $_ user->ID ) ); ?>" class="avatar"><?php echo get_avatar( $_user->ID, 48 ); ?></a>96 <a href="<?php echo esc_url( get_author_posts_url( $_ user->ID ) ); ?>" class="name"><?php echo esc_html( get_the_author_meta( 'display_name', $_user->ID) ); ?></a>97 <?php if ( $stats_calculator->is_new_translation_contributor( $event_start, $_user->ID) ) : ?>79 <a href="<?php echo esc_url( get_author_posts_url( $_attendee->user_id() ) ); ?>" class="avatar"><?php echo get_avatar( $_attendee->user_id(), 48 ); ?></a> 80 <a href="<?php echo esc_url( get_author_posts_url( $_attendee->user_id() ) ); ?>" class="name"><?php echo esc_html( get_the_author_meta( 'display_name', $_attendee->user_id() ) ); ?></a> 81 <?php if ( isset( $new_contributor_ids[ $_attendee->user_id() ] ) ) : ?> 98 82 <span class="first-time-contributor-tada" title="<?php esc_html_e( 'New Translation Contributor', 'gp-translation-events' ); ?>"></span> 99 83 <?php endif; ?> 100 <?php101 if ( ! $event->end()->is_in_the_past() ) :102 if ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'manage_options' ) || $user->ID === $event->author_id() ) :103 $_attendee = $attendee_repo->get_attendee( $event_id, $_user->ID );104 if ( $_attendee instanceof Attendee ) :105 echo '<form class="add-remove-user-as-host" method="post" action="' . esc_url( gp_url( "/events/host/$event_id/$_user->ID" ) ) . '">';106 if ( $_attendee->is_host() ) :107 echo '<input type="submit" class="button is-primary remove-as-host" value="Remove as host"/>';108 else :109 echo '<input type="submit" class="button is-secondary convert-to-host" value="Make co-host"/>';110 endif;111 echo '</form>';112 endif;113 endif;114 endif;115 ?>116 84 </li> 117 85 <?php endforeach; ?> … … 125 93 <thead> 126 94 <tr> 127 <th scope="col">Locale</th> 128 <th scope="col">Translations created</th> 129 <th scope="col">Translations reviewed</th> 130 <th scope="col">Contributors</th> 95 <th scope="col"><?php esc_html_e( 'Translations', 'gp-translation-events' ); ?></th> 96 <th scope="col"><?php esc_html_e( 'Created', 'gp-translation-events' ); ?></th> 97 <th scope="col"><?php esc_html_e( 'Waiting', 'gp-translation-events' ); ?></th> 98 <th scope="col"><?php esc_html_e( 'Reviewed', 'gp-translation-events' ); ?></th> 99 <th scope="col"><?php esc_html_e( 'Contributors', 'gp-translation-events' ); ?></th> 131 100 </tr> 132 101 </thead> … … 136 105 <tr> 137 106 <td title="<?php echo esc_html( $_locale ); ?> "><a href="<?php echo esc_url( gp_url_join( gp_url( '/languages' ), $row->language->slug ) ); ?>"><?php echo esc_html( $row->language->english_name ); ?></a></td> 138 <td><?php echo esc_html( $row->created ); ?></td> 107 <td><a href="<?php echo esc_url( Urls::event_translations( $event->id(), $row->language->slug ) ); ?>"><?php echo esc_html( $row->created ); ?></a></td> 108 <td><a href="<?php echo esc_url( Urls::event_translations( $event->id(), $row->language->slug, 'waiting' ) ); ?>"><?php echo esc_html( $row->waiting ); ?></a></td> 139 109 <td><?php echo esc_html( $row->reviewed ); ?></td> 140 110 <td><?php echo esc_html( $row->users ); ?></td> … … 144 114 <td>Total</td> 145 115 <td><?php echo esc_html( $event_stats->totals()->created ); ?></td> 116 <td><?php echo esc_html( $event_stats->totals()->waiting ); ?></td> 146 117 <td><?php echo esc_html( $event_stats->totals()->reviewed ); ?></td> 147 118 <td><?php echo esc_html( $event_stats->totals()->users ); ?></td> … … 155 126 <?php foreach ( $projects as $project_name => $row ) : ?> 156 127 <li class="event-project" title="<?php echo esc_html( str_replace( ',', ', ', $row->locales ) ); ?>"> 157 <a href="<?php echo esc_url( gp_url_project( $row->project ) ); ?>"><?php echo esc_html( $project_name ); ?></a> <small> to158 128 <?php 129 $row_locales = array(); 159 130 foreach ( explode( ',', $row->locales ) as $_locale ) { 160 $_locale = GP_Locales::by_slug( $_locale ); 161 ?> 162 <a href="<?php echo esc_url( gp_url_project_locale( $row->project, $_locale->slug, 'default' ) ); ?>"><?php echo esc_html( $_locale->english_name ); ?></a> 163 <?php 131 $_locale = GP_Locales::by_slug( $_locale ); 132 $row_locales[] = '<a href="' . esc_url( gp_url_project_locale( $row->project, $_locale->slug, 'default' ) ) . '">' . esc_html( $_locale->english_name ) . '</a>'; 164 133 } 165 // translators: %d: Number of contributors. 166 echo esc_html( sprintf( _n( 'by %d contributor', 'by %d contributors', $row->users, 'gp-translation-events' ), $row->users ) ); 134 echo wp_kses_post( 135 wp_sprintf( 136 // translators: 1: Project translated. 2: List of languages. 3: Number of contributors. 137 _n( 138 '%1$s <small>to %2$l by %3$d contributor</small>', 139 '%1$s <small>to %2$l by %3$d contributors</small>', 140 $row->users, 141 'gp-translation-events' 142 ), 143 '<a href="' . esc_url( gp_url_project( $row->project ) ) . '">' . esc_html( $project_name ) . '</a>', 144 $row_locales, 145 $row->users 146 ) 147 ); 167 148 ?> 168 </small>169 149 </li> 170 150 <?php endforeach; ?> … … 175 155 <p class="event-stats-text"> 176 156 <?php 177 $new_contributors = array_filter(178 $contributors,179 function ( $contributor ) use ( $stats_calculator, $event_start ) {180 return $stats_calculator->is_new_translation_contributor( $event_start, $contributor->ID );181 }182 );183 184 157 $new_contributors_text = ''; 185 if ( ! empty( $new_contributor s ) ) {158 if ( ! empty( $new_contributor_ids ) ) { 186 159 $new_contributors_text = sprintf( 187 160 // translators: %d is the number of new contributors. 188 _n( '(%d new contributor ๐)', '(%d new contributors ๐)', count( $new_contributor s ), 'gp-translation-events' ),189 count( $new_contributor s )161 _n( '(%d new contributor ๐)', '(%d new contributors ๐)', count( $new_contributor_ids ), 'gp-translation-events' ), 162 count( $new_contributor_ids ) 190 163 ); 191 164 } 192 165 193 166 echo wp_kses( 194 sprintf(195 // translators: %1$s: Event title, %2$d: Number of contributors, %3$s: is a parenthesis with potential text "x new contributors", %4$d: Number of languages, %5$ s: List of languages, %6$d: Number of strings translated, %7$d: Number of strings reviewed.196 __( 'At the <strong>%1$s</strong> event, we had %2$d people %3$s who contributed in %4$d languages (%5$ s), translated %6$d strings and reviewed %7$d strings.', 'gp-translation-events' ),167 wp_sprintf( 168 // translators: %1$s: Event title, %2$d: Number of contributors, %3$s: is a parenthesis with potential text "x new contributors", %4$d: Number of languages, %5$l: List of languages, %6$d: Number of strings translated, %7$d: Number of strings reviewed. 169 __( 'At the <strong>%1$s</strong> event, we had %2$d people %3$s who contributed in %4$d languages (%5$l), translated %6$d strings and reviewed %7$d strings.', 'gp-translation-events' ), 197 170 esc_html( $event_title ), 198 171 esc_html( $event_stats->totals()->users ), 199 172 $new_contributors_text, 200 173 count( $event_stats->rows() ), 201 esc_html( 202 implode( 203 ', ', 204 array_map( 205 function ( $row ) { 206 return $row->language->english_name; 207 }, 208 $event_stats->rows() 209 ) 210 ) 174 array_map( 175 function ( $row ) { 176 return $row->language->english_name; 177 }, 178 $event_stats->rows() 211 179 ), 212 180 esc_html( $event_stats->totals()->created ), … … 220 188 <?php 221 189 echo wp_kses( 222 sprintf( 223 // translators: %s the contributors. 224 esc_html__( 'Contributors were %s.', 'gp-translation-events' ), 225 implode( 226 ', ', 227 array_map( 228 function ( $contributor ) use ( $stats_calculator, $event_start ) { 229 $append_tada = ''; 230 if ( $stats_calculator->is_new_translation_contributor( $event_start, $contributor->ID ) ) { 190 wp_sprintf( 191 // translators: %s List of contributors. 192 _n( 193 'Contributor was %l.', 194 'Contributors were %l.', 195 count( $contributors ), 196 'gp-translation-events' 197 ), 198 array_map( 199 function ( $contributor ) { 200 $append_tada = ''; 201 if ( isset( $new_contributor_ids[ $contributor->user_id() ] ) ) { 231 202 $append_tada = ' <span class="new-contributor" title="' . esc_html__( 'New Translation Contributor', 'gp-translation-events' ) . '">๐</span>'; 232 } 233 return '@' . $contributor->user_login . $append_tada; 234 }, 235 $contributors 236 ) 203 } 204 return '@' . ( new WP_User( $contributor->user_id() ) )->user_login . $append_tada; 205 }, 206 $contributors 237 207 ) 238 208 ), … … 268 238 <div class="event-details-join"> 269 239 <?php if ( $event_end->is_in_the_past() ) : ?> 270 <?php if ( $ attendee instanceof Attendee) : ?>240 <?php if ( $user_is_attending ) : ?> 271 241 <button disabled="disabled" class="button is-primary attend-btn"><?php esc_html_e( 'You attended', 'gp-translation-events' ); ?></button> 272 242 <?php endif; ?> 243 <?php elseif ( $user_is_contributor ) : ?> 244 <?php // Contributors can't un-attend so don't show anything. ?> 273 245 <?php else : ?> 274 <form class="event-details-attend" method="post" action="<?php echo esc_url( gp_url( "/events/attend/$event_id") ); ?>">275 <?php if ( $ attendee instanceof Attendee) : ?>276 <input type="submit" class="button is-secondary attending-btn" value=" You're attending" />246 <form class="event-details-attend" method="post" action="<?php echo esc_url( Urls::event_toggle_attendee( $event_id ) ); ?>"> 247 <?php if ( $user_is_attending ) : ?> 248 <input type="submit" class="button is-secondary attending-btn" value="<?php esc_attr_e( "You're attending", 'gp-translation-events' ); ?>" /> 277 249 <?php else : ?> 278 <input type="submit" class="button is-primary attend-btn" value=" Attend Event"/>250 <input type="submit" class="button is-primary attend-btn" value="<?php esc_attr_e( 'Attend Event', 'gp-translation-events' ); ?>"/> 279 251 <?php endif; ?> 280 252 </form>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)