Force event team result order

This commit is contained in:
Brian Miyaji
2014-07-21 15:02:58 +10:00
parent 06221321b5
commit 8d8ef87c96
2 changed files with 20 additions and 12 deletions

View File

@@ -36,7 +36,7 @@ class SP_Event extends SP_Custom_Post{
$usecolumns = get_post_meta( $this->ID, 'sp_result_columns', true ); $usecolumns = get_post_meta( $this->ID, 'sp_result_columns', true );
// Get results for all teams // Get results for all teams
$data = sp_array_combine( $teams, $results ); $data = sp_array_combine( $teams, $results, true );
if ( $admin ): if ( $admin ):
return array( $columns, $usecolumns, $data ); return array( $columns, $usecolumns, $data );

View File

@@ -260,12 +260,20 @@ if ( !function_exists( 'sp_array_value' ) ) {
} }
if ( !function_exists( 'sp_array_combine' ) ) { if ( !function_exists( 'sp_array_combine' ) ) {
function sp_array_combine( $keys = array(), $values = array() ) { function sp_array_combine( $keys = array(), $values = array(), $key_order = false ) {
if ( ! is_array( $keys ) ) return array(); if ( ! is_array( $keys ) ) return array();
if ( ! is_array( $values ) ) $values = array(); if ( ! is_array( $values ) ) $values = array();
$output = array(); $output = array();
if ( $key_order ):
foreach( $keys as $key ):
if ( array_key_exists( $key, $values ) )
$output[ $key ] = $values[ $key ];
else
$output[ $key ] = array();
endforeach;
else:
foreach ( $values as $key => $value ): foreach ( $values as $key => $value ):
if ( in_array( $key, $keys ) ): if ( in_array( $key, $keys ) ):
$output[ $key ] = $value; $output[ $key ] = $value;
@@ -276,7 +284,7 @@ if ( !function_exists( 'sp_array_combine' ) ) {
if ( $key !== false && ! array_key_exists( $key, $output ) ) if ( $key !== false && ! array_key_exists( $key, $output ) )
$output[ $key ] = array(); $output[ $key ] = array();
endforeach; endforeach;
endif;
return $output; return $output;
} }
} }