Option to split time and results in event list

This commit is contained in:
Brian Miyaji
2014-12-09 18:07:05 +11:00
parent 4cd103d81c
commit ecb3d02eb3
5 changed files with 225 additions and 75 deletions

View File

@@ -43,7 +43,8 @@ if ( $order != 'default' )
$calendar->order = $order;
$data = $calendar->data();
$usecolumns = $calendar->columns;
$title_format = $calendar->title_format;
$title_format = get_option( 'sportspress_event_list_title_format', 'title' );
$time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
if ( isset( $columns ) ):
if ( is_array( $columns ) )
@@ -51,6 +52,10 @@ if ( isset( $columns ) ):
else
$usecolumns = explode( ',', $columns );
endif;
if ( $id ) {
echo '<h4 class="sp-table-caption">' . get_the_title( $id ) . '</h4>';
}
?>
<div class="sp-template sp-template-event-list">
<div class="sp-table-wrapper<?php if ( $scrollable ) { ?> sp-scrollable-table-wrapper<?php } ?>">
@@ -60,25 +65,47 @@ endif;
<?php
echo '<th class="data-date">' . __( 'Date', 'sportspress' ) . '</th>';
if ( $usecolumns == null || in_array( 'event', $usecolumns ) ):
if ( $title_format == 'homeaway' ):
echo '<th class="data-home">' . __( 'Home', 'sportspress' ) . '</th>';
elseif ( $title_format == 'teams' ):
echo '<th class="data-teams">' . __( 'Teams', 'sportspress' ) . '</th>';
else:
echo '<th class="data-event">' . __( 'Event', 'sportspress' ) . '</th>';
endif;
endif;
switch ( $title_format ) {
case 'homeaway':
if ( sp_column_active( $usecolumns, 'event' ) ) {
echo '<th class="data-home">' . __( 'Home', 'sportspress' ) . '</th>';
if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
if ( $usecolumns == null || in_array( 'event', $usecolumns ) && $title_format == 'homeaway' )
echo '<th class="data-time">&nbsp;</th>';
else
echo '<th class="data-time">' . __( 'Time/Results', 'sportspress' ) . '</th>';
endif;
if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
echo '<th class="data-time">&nbsp;</th>';
} elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
echo '<th class="data-results">&nbsp;</th>';
}
if ( $usecolumns == null || in_array( 'event', $usecolumns ) && $title_format == 'homeaway' )
echo '<th class="data-away">' . __( 'Away', 'sportspress' ) . '</th>';
echo '<th class="data-away">' . __( 'Away', 'sportspress' ) . '</th>';
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>';
}
}
break;
default:
if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' )
echo '<th class="data-teams">' . __( 'Teams', 'sportspress' ) . '</th>';
else
echo '<th class="data-event">' . __( 'Event', 'sportspress' ) . '</th>';
}
switch ( $time_format ) {
case 'separate':
echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>';
echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>';
break;
case 'time':
echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>';
break;
case 'results':
echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>';
break;
default:
echo '<th class="data-time">' . __( 'Time/Results', 'sportspress' ) . '</th>';
}
}
if ( $usecolumns == null || in_array( 'league', $usecolumns ) )
echo '<th class="data-league">' . __( 'Competition', 'sportspress' ) . '</th>';
@@ -110,7 +137,7 @@ endif;
$main_results = sp_get_main_results( $event );
$teams_output = '';
$teams_array = '';
$teams_array = array();
if ( $teams ):
foreach ( $teams as $team ):
@@ -143,33 +170,95 @@ endif;
echo '<td class="data-date"><a href="' . get_permalink( $event->ID ) . '"><date>' . get_post_time( 'Y-m-d H:i:s', false, $event ) . '</date>' . get_post_time( get_option( 'date_format' ), false, $event, true ) . '</a></td>';
if ( $usecolumns == null || in_array( 'event', $usecolumns ) ):
if ( $title_format == 'homeaway' ):
$team = array_shift( $teams_array );
echo '<td class="data-home">' . $team . '</td>';
else:
if ( $title_format == 'teams' ):
echo '<td class="data-event">' . $teams_output . '</td>';
else:
echo '<td class="data-event"><a href="' . get_permalink( $event->ID ) . '">' . $event->post_title . '</a></td>';
endif;
endif;
endif;
switch ( $title_format ) {
case 'homeaway':
if ( sp_column_active( $usecolumns, 'event' ) ) {
$team = array_shift( $teams_array );
echo '<td class="data-home">' . $team . '</td>';
if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
echo '<td class="data-time"><a href="' . get_permalink( $event->ID ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
endif;
echo '</a></td>';
endif;
if ( 'combined' == $time_format && sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time"><a href="' . get_permalink( $event->ID ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
endif;
echo '</a></td>';
} elseif ( in_array( $time_format, array( 'separate', 'results' ) ) && sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results"><a href="' . get_permalink( $event->ID ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '-';
endif;
echo '</a></td>';
}
if ( $usecolumns == null || in_array( 'event', $usecolumns ) && $title_format == 'homeaway' ):
$team = array_shift( $teams_array );
echo '<td class="data-away">' . $team . '</td>';
endif;
$team = array_shift( $teams_array );
echo '<td class="data-away">' . $team . '</td>';
if ( in_array( $time_format, array( 'separate', 'time' ) ) && sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time"><a href="' . get_permalink( $event->ID ) . '">';
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
echo '</a></td>';
}
}
break;
default:
if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' )
echo '<td class="data-event">' . $teams_output . '</td>';
else
echo '<td class="data-event"><a href="' . get_permalink( $event->ID ) . '">' . $event->post_title . '</a></td>';
}
switch ( $time_format ) {
case 'separate':
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time"><a href="' . get_permalink( $event->ID ) . '">';
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
echo '</a></td>';
}
if ( sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results"><a href="' . get_permalink( $event->ID ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '-';
endif;
echo '</a></td>';
}
break;
case 'time':
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time"><a href="' . get_permalink( $event->ID ) . '">';
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
echo '</a></td>';
}
break;
case 'results':
if ( sp_column_active( $usecolumns, 'results' ) ) {
echo '<td class="data-results"><a href="' . get_permalink( $event->ID ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '-';
endif;
echo '</a></td>';
}
break;
default:
if ( sp_column_active( $usecolumns, 'time' ) ) {
echo '<td class="data-time"><a href="' . get_permalink( $event->ID ) . '">';
if ( ! empty( $main_results ) ):
echo implode( ' - ', $main_results );
else:
echo '<date>&nbsp;' . get_post_time( 'H:i:s', false, $event ) . '</date>' . sp_get_time( $event );
endif;
echo '</a></td>';
}
}
}
if ( $usecolumns == null || in_array( 'league', $usecolumns ) ):
echo '<td class="data-league">';
@@ -231,8 +320,8 @@ endif;
</tbody>
</table>
</div>
</div>
<?php
if ( $id && $show_all_events_link )
echo '<a class="sp-calendar-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
?>
<?php
if ( $id && $show_all_events_link )
echo '<a class="sp-calendar-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
?>
</div>