Changeset 13529 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/templates/event.php
- Timestamp:
- 04/15/2024 01:37:55 PM (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
r13298 r13529 6 6 namespace Wporg\TranslationEvents; 7 7 8 use WP_Post; 9 10 /** @var WP_Post $event */ 8 use WP_User; 9 use Wporg\TranslationEvents\Attendee\Attendee; 10 use Wporg\TranslationEvents\Attendee\Attendee_Repository; 11 use Wporg\TranslationEvents\Event\Event; 12 use Wporg\TranslationEvents\Event\Event_End_Date; 13 use Wporg\TranslationEvents\Event\Event_Start_Date; 14 15 /** @var Attendee_Repository $attendee_repo */ 16 /** @var Attendee $attendee */ 17 /** @var Event $event */ 11 18 /** @var int $event_id */ 12 19 /** @var string $event_title */ 13 20 /** @var string $event_description */ 14 /** @var string $event_start */ 15 /** @var string $event_end */ 16 /** @var bool $user_is_attending */ 21 /** @var Event_Start_Date $event_start */ 22 /** @var Event_End_Date $event_end */ 17 23 /** @var Event_Stats $event_stats */ 24 /** @var array $projects */ 25 /** @var WP_User $user */ 18 26 19 27 /* translators: %s: Event title. */ … … 21 29 gp_breadcrumb_translation_events( array( esc_html( $event_title ) ) ); 22 30 gp_tmpl_header(); 31 $event_page_title = $event_title; 23 32 gp_tmpl_load( 'events-header', get_defined_vars(), __DIR__ ); 24 33 ?> 25 34 26 35 <div class="event-page-wrapper"> 27 <div class="event-details-head">28 <h1>29 <?php echo esc_html( $event_title ); ?>30 <?php if ( 'draft' === $event->post_status ) : ?>31 <span class="event-label-draft"><?php echo esc_html( $event->post_status ); ?></span>32 <?php endif; ?>33 </h1>34 <p>35 Host: <a href="<?php echo esc_attr( get_author_posts_url( $event->post_author ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $event->post_author ) ); ?></a>36 <?php if ( current_user_can( 'edit_post', $event_id ) ) : ?>37 <a class="event-page-edit-link button" href="<?php echo esc_url( gp_url( 'events/edit/' . $event_id ) ); ?>"><span class="dashicons dashicons-edit"></span>Edit event</a>38 <?php endif ?>39 </p>40 </div>41 36 <div class="event-details-left"> 42 37 <div class="event-page-content"> … … 45 40 ?> 46 41 </div> 42 <?php if ( ! empty( $contributors ) ) : ?> 43 <div class="event-contributors"> 44 <h2><?php esc_html_e( 'Contributors', 'gp-translation-events' ); ?></h2> 45 <ul> 46 <?php foreach ( $contributors as $contributor ) : ?> 47 <li class="event-contributor" title="<?php echo esc_html( implode( ', ', $contributor->locales ) ); ?>"> 48 <a href="<?php echo esc_url( get_author_posts_url( $contributor->ID ) ); ?>"><?php echo get_avatar( $contributor->ID, 48 ); ?></a> 49 <a href="<?php echo esc_url( get_author_posts_url( $contributor->ID ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $contributor->ID ) ); ?></a> 50 <?php if ( $stats_calculator->is_first_time_contributor( $event_start, $contributor->ID ) ) : ?> 51 <span class="first-time-contributor-tada"></span> 52 <?php endif; ?> 53 <?php 54 if ( ! $event->end()->is_in_the_past() ) : 55 if ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'manage_options' ) ) : 56 if ( $user->ID !== $contributor->ID ) : 57 $_attendee = $attendee_repo->get_attendee( $event_id, $contributor->ID ); 58 if ( $_attendee instanceof Attendee ) : 59 echo '<form class="add-remove-user-as-host" method="post" action="' . esc_url( gp_url( "/events/host/$event_id/$contributor->ID" ) ) . '">'; 60 if ( $_attendee->is_host() ) : 61 if ( 1 === count( $attendee_repo->get_hosts( $event_id ) ) ) : 62 echo '<input type="submit" class="button is-primary remove-as-host" disabled value="Remove as host"/>'; 63 else : 64 echo '<input type="submit" class="button is-primary remove-as-host" value="Remove as host"/>'; 65 endif; 66 else : 67 echo '<input type="submit" class="button is-secondary convert-to-host" value="Make co-host"/>'; 68 endif; 69 echo '</form>'; 70 endif; 71 elseif ( ( $attendee instanceof Attendee && $attendee->is_host() ) ) : 72 echo '<span class="event-you">' . esc_html__( 'You (host)', 'gp-translation-events' ) . '</span>'; 73 else : 74 echo '<span class="event-you">' . esc_html__( 'You (event creator)', 'gp-translation-events' ) . '</span>'; 75 endif; 76 endif; 77 endif; 78 ?> 79 </li> 80 <?php endforeach; ?> 81 </ul> 82 </div> 83 <?php endif; ?> 84 <?php if ( ! empty( $attendees ) && ( ! $event->end()->is_in_the_past() || ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'manage_options' ) ) ) ) : ?> 85 <div class="event-attendees"> 86 <h2><?php esc_html_e( 'Attendees', 'gp-translation-events' ); ?></h2> 87 <ul> 88 <?php foreach ( $attendees as $_user ) : ?> 89 <li class="event-attendee"> 90 <a href="<?php echo esc_url( get_author_posts_url( $_user->ID ) ); ?>"><?php echo get_avatar( $_user->ID, 48 ); ?></a> 91 <a href="<?php echo esc_url( get_author_posts_url( $_user->ID ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $_user->ID ) ); ?></a> 92 <?php if ( $stats_calculator->is_first_time_contributor( $event_start, $_user->ID ) ) : ?> 93 <span class="first-time-contributor-tada"></span> 94 <?php endif; ?> 95 <?php 96 if ( ! $event->end()->is_in_the_past() ) : 97 if ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'manage_options' ) ) : 98 if ( $user->ID !== $_user->ID ) : 99 $_attendee = $attendee_repo->get_attendee( $event_id, $_user->ID ); 100 if ( $_attendee instanceof Attendee ) : 101 echo '<form class="add-remove-user-as-host" method="post" action="' . esc_url( gp_url( "/events/host/$event_id/$_user->ID" ) ) . '">'; 102 if ( $_attendee->is_host() ) : 103 if ( 1 === count( $attendee_repo->get_hosts( $event_id ) ) ) : 104 echo '<input type="submit" class="button is-primary remove-as-host" disabled value="Remove as host"/>'; 105 else : 106 echo '<input type="submit" class="button is-primary remove-as-host" value="Remove as host"/>'; 107 endif; 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 elseif ( ( $attendee instanceof Attendee && $attendee->is_host() ) ) : 114 echo '<span class="event-you">' . esc_html__( 'You (host)', 'gp-translation-events' ) . '</span>'; 115 else : 116 echo '<span class="event-you">' . esc_html__( 'You (event creator)', 'gp-translation-events' ) . '</span>'; 117 endif; 118 endif; 119 endif; 120 ?> 121 </li> 122 <?php endforeach; ?> 123 </ul> 124 </div> 125 <?php endif; ?> 47 126 <?php if ( ! empty( $event_stats->rows() ) ) : ?> 48 <div class="event-details-stats"> 49 <h2><?php esc_html_e( 'Stats', 'gp-translation-events' ); ?></h2> 50 <table> 51 <thead> 52 <tr> 53 <th scope="col">Locale</th> 54 <th scope="col">Translations created</th> 55 <th scope="col">Translations reviewed</th> 56 <th scope="col">Contributors</th> 57 </tr> 58 </thead> 59 <tbody> 60 <?php /** @var $row Stats_Row */ ?> 61 <?php foreach ( $event_stats->rows() as $_locale => $row ) : ?> 62 <tr> 63 <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> 64 <td><?php echo esc_html( $row->created ); ?></td> 65 <td><?php echo esc_html( $row->reviewed ); ?></td> 66 <td><?php echo esc_html( $row->users ); ?></td> 67 </tr> 68 <?php endforeach ?> 69 <tr class="event-details-stats-totals"> 70 <td>Total</td> 71 <td><?php echo esc_html( $event_stats->totals()->created ); ?></td> 72 <td><?php echo esc_html( $event_stats->totals()->reviewed ); ?></td> 73 <td><?php echo esc_html( $event_stats->totals()->users ); ?></td> 74 </tr> 75 </tbody> 76 </table> 77 </div> 78 <div class="event-contributors"> 79 <h2><?php esc_html_e( 'Contributors', 'gp-translation-events' ); ?></h2> 80 <ul> 81 <?php foreach ( $contributors as $contributor ) : ?> 82 <li class="event-contributor" title="<?php echo esc_html( implode( ', ', $contributor->locales ) ); ?>" 83 <a href="<?php echo esc_url( get_author_posts_url( $contributor->ID ) ); ?>"><?php echo get_avatar( $contributor->ID, 48 ); ?></a> 84 <a href="<?php echo esc_url( get_author_posts_url( $contributor->ID ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $contributor->ID ) ); ?></a> 85 </li> 86 <?php endforeach; ?> 87 </ul> 88 </div> 89 <details class="event-stats-summary"> 90 <summary>View stats summary in text </summary> 91 <p class="event-stats-text"> 92 <?php 93 echo wp_kses( 94 sprintf( 95 // translators: %1$s: Event title, %2$d: Number of contributors, %3$d: Number of languages, %4$s: List of languages, %5$d: Number of strings translated, %6$d: Number of strings reviewed. 96 __( 'At the <strong>%1$s</strong> event, %2$d people contributed in %3$d languages (%4$s), translated %5$d strings and reviewed %6$d strings.', 'gp-translation-events' ), 97 esc_html( $event_title ), 98 esc_html( $event_stats->totals()->users ), 99 count( $event_stats->rows() ), 100 esc_html( 101 implode( 102 ', ', 103 array_map( 104 function ( $row ) { 105 return $row->language->english_name; 106 }, 107 $event_stats->rows() 127 <div class="event-details-stats"> 128 <h2><?php esc_html_e( 'Stats', 'gp-translation-events' ); ?></h2> 129 <table> 130 <thead> 131 <tr> 132 <th scope="col">Locale</th> 133 <th scope="col">Translations created</th> 134 <th scope="col">Translations reviewed</th> 135 <th scope="col">Contributors</th> 136 </tr> 137 </thead> 138 <tbody> 139 <?php /** @var $row Stats_Row */ ?> 140 <?php foreach ( $event_stats->rows() as $_locale => $row ) : ?> 141 <tr> 142 <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> 143 <td><?php echo esc_html( $row->created ); ?></td> 144 <td><?php echo esc_html( $row->reviewed ); ?></td> 145 <td><?php echo esc_html( $row->users ); ?></td> 146 </tr> 147 <?php endforeach ?> 148 <tr class="event-details-stats-totals"> 149 <td>Total</td> 150 <td><?php echo esc_html( $event_stats->totals()->created ); ?></td> 151 <td><?php echo esc_html( $event_stats->totals()->reviewed ); ?></td> 152 <td><?php echo esc_html( $event_stats->totals()->users ); ?></td> 153 </tr> 154 </tbody> 155 </table> 156 </div> 157 <div class="event-projects"> 158 <h2><?php esc_html_e( 'Projects', 'gp-translation-events' ); ?></h2> 159 <ul> 160 <?php foreach ( $projects as $project_name => $row ) : ?> 161 <li class="event-project" title="<?php echo esc_html( str_replace( ',', ', ', $row->locales ) ); ?>"> 162 <a href="<?php echo esc_url( gp_url_project( $row->project ) ); ?>"><?php echo esc_html( $project_name ); ?></a> <small> to 163 <?php 164 foreach ( explode( ',', $row->locales ) as $_locale ) { 165 $_locale = \GP_Locales::by_slug( $_locale ); 166 ?> 167 <a href="<?php echo esc_url( gp_url_project_locale( $row->project, $_locale, 'default' ) ); ?>"><?php echo esc_html( $_locale->english_name ); ?></a> 168 <?php 169 } 170 // translators: %d: Number of contributors. 171 echo esc_html( sprintf( _n( 'by %d contributor', 'by %d contributors', $row->users, 'gp-translation-events' ), $row->users ) ); 172 ?> 173 </small> 174 </li> 175 <?php endforeach; ?> 176 </ul> 177 </div> 178 <details class="event-stats-summary"> 179 <summary>View stats summary in text </summary> 180 <p class="event-stats-text"> 181 <?php 182 echo wp_kses( 183 sprintf( 184 // translators: %1$s: Event title, %2$d: Number of contributors, %3$d: Number of languages, %4$s: List of languages, %5$d: Number of strings translated, %6$d: Number of strings reviewed. 185 __( 'At the <strong>%1$s</strong> event, %2$d people contributed in %3$d languages (%4$s), translated %5$d strings and reviewed %6$d strings.', 'gp-translation-events' ), 186 esc_html( $event_title ), 187 esc_html( $event_stats->totals()->users ), 188 count( $event_stats->rows() ), 189 esc_html( 190 implode( 191 ', ', 192 array_map( 193 function ( $row ) { 194 return $row->language->english_name; 195 }, 196 $event_stats->rows() 197 ) 198 ) 199 ), 200 esc_html( $event_stats->totals()->created ), 201 esc_html( $event_stats->totals()->reviewed ) 202 ), 203 array( 204 'strong' => array(), 205 ) 206 ); 207 ?> 208 <?php 209 echo wp_kses( 210 sprintf( 211 // translators: %s the contributors. 212 esc_html__( 'Contributors were %s.', 'gp-translation-events' ), 213 implode( 214 ', ', 215 array_map( 216 function ( $contributor ) use ( $stats_calculator, $event_start ) { 217 $append_tada = $stats_calculator->is_first_time_contributor( $event_start, $contributor->ID ) ? '<span class="first-time-contributor-tada"></span>' : ''; 218 return '@' . $contributor->user_login . $append_tada; 219 }, 220 $contributors 221 ) 108 222 ) 223 ), 224 array( 225 'span' => array( 226 'class' => array(), 227 ), 109 228 ) 110 ), 111 esc_html( $event_stats->totals()->created ), 112 esc_html( $event_stats->totals()->reviewed ) 113 ), 114 array( 115 'strong' => array(), 116 ) 117 ); 118 ?> 119 <?php 120 echo esc_html( 121 sprintf( 122 // translators: %s the contributors. 123 __( 'Contributors were %s.', 'gp-translation-events' ), 124 esc_html( 125 implode( 126 ', ', 127 array_map( 128 function ( $contributor ) { 129 return '@' . $contributor->user_login; 130 }, 131 $contributors 132 ) 133 ) 134 ) 135 ) 136 ); 137 ?> 229 ); 230 ?> 138 231 </p> 139 232 </details> 140 141 <?php endif; ?> 233 <?php endif; ?> 142 234 </div> 143 235 <div class="event-details-right"> 144 236 <div class="event-details-date"> 145 237 <p> 146 <span class="event-details-date-label">Starts:</span> <time class="event-utc-time" datetime="<?php echo esc_attr( $event_start ); ?>"></time> 147 <span class="event-details-date-label">Ends:</span><time class="event-utc-time" datetime="<?php echo esc_attr( $event_end ); ?>"></time> 238 <span class="event-details-date-label"> 239 <?php echo esc_html( $event_start->is_in_the_past() ? __( 'Started', 'gp-translation-events' ) : __( 'Starts', 'gp-translation-events' ) ); ?>: 240 <?php $event_start->print_relative_time_html(); ?> 241 </span> 242 <?php $event_start->print_time_html(); ?> 243 <span class="event-details-date-label"> 244 <?php echo esc_html( $event_end->is_in_the_past() ? __( 'Ended', 'gp-translation-events' ) : __( 'Ends', 'gp-translation-events' ) ); ?>: 245 <?php $event_end->print_relative_time_html(); ?> 246 247 </span> 248 <?php $event_end->print_time_html(); ?> 148 249 </p> 149 250 </div> 150 251 <?php if ( is_user_logged_in() ) : ?> 151 252 <div class="event-details-join"> 152 <?php 153 $current_time = gmdate( 'Y-m-d H:i:s' ); 154 if ( strtotime( $current_time ) > strtotime( $event_end ) ) : 155 ?> 156 <?php if ( $user_is_attending ) : ?> 157 <span class="event-details-join-expired"><?php esc_html_e( 'You attended', 'gp-translation-events' ); ?></span> 158 <?php endif ?> 253 <?php if ( $event_end->is_in_the_past() ) : ?> 254 <?php if ( $attendee instanceof Attendee ) : ?> 255 <button disabled="disabled" class="button is-primary attend-btn"><?php esc_html_e( 'You attended', 'gp-translation-events' ); ?></button> 256 <?php endif; ?> 159 257 <?php else : ?> 160 258 <form class="event-details-attend" method="post" action="<?php echo esc_url( gp_url( "/events/attend/$event_id" ) ); ?>"> 161 <?php if ( ! $user_is_attending ) : ?> 259 <?php if ( $attendee instanceof Attendee ) : ?> 260 <?php if ( $attendee->is_host() && ( 1 === count( $attendee_repo->get_hosts( $event_id ) ) ) ) : ?> 261 <input type="submit" class="button is-secondary attending-btn" disabled value="You're attending" /> 262 <?php else : ?> 263 <input type="submit" class="button is-secondary attending-btn" value="You're attending" /> 264 <?php endif; ?> 265 <?php else : ?> 162 266 <input type="submit" class="button is-primary attend-btn" value="Attend Event"/> 163 <?php else : ?> 164 <input type="submit" class="button is-secondary attending-btn" value="You're attending"/> 165 <?php endif ?> 267 <?php endif; ?> 166 268 </form> 167 <?php endif ?>269 <?php endif; ?> 168 270 </div> 169 271 <?php else : ?> 170 272 <div class="event-details-join"> 171 273 <p> 172 <?php global $wp; ?> 173 <a href="<?php echo esc_url( wp_login_url( home_url( $wp->request ) ) ); ?>" class="button is-primary attend-btn"><?php esc_html_e( 'Login to attend', 'gp-translation-events' ); ?></a> 274 <?php if ( ! $event_end->is_in_the_past() ) : ?> 275 <a href="<?php echo esc_url( wp_login_url() ); ?>" class="button is-primary attend-btn"><?php esc_html_e( 'Login to attend', 'gp-translation-events' ); ?></a> 276 <?php else : ?> 277 <button disabled="disabled" class="button is-primary attend-btn"><?php esc_html_e( 'Event is over', 'gp-translation-events' ); ?></button> 278 <?php endif; ?> 174 279 </p> 175 280 </div>
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)