本文整理汇总了PHP中sp_array_combine函数的典型用法代码示例。如果您正苦于以下问题:PHP sp_array_combine函数的具体用法?PHP sp_array_combine怎么用?PHP sp_array_combine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sp_array_combine函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performance
public function performance($admin = false)
{
$teams = get_post_meta($this->ID, 'sp_team', false);
$performance = (array) get_post_meta($this->ID, 'sp_players', true);
$labels = sp_get_var_labels('sp_performance');
$columns = get_post_meta($this->ID, 'sp_columns', true);
if (is_array($teams)) {
foreach ($teams as $i => $team_id) {
$players = sp_array_between((array) get_post_meta($this->ID, 'sp_player', false), 0, $i);
$data = sp_array_combine($players, sp_array_value($performance, $team_id, array()));
$totals = array();
foreach ($labels as $key => $label) {
$totals[$key] = 0;
}
foreach ($data as $player_id => $player_performance) {
foreach ($labels as $key => $label) {
if (array_key_exists($key, $totals)) {
$totals[$key] += sp_array_value($player_performance, $key, 0);
}
}
if (!array_key_exists('number', $player_performance)) {
$performance[$team_id][$player_id]['number'] = get_post_meta($player_id, 'sp_number', true);
}
if (!array_key_exists('position', $player_performance) || $player_performance['position'] == null) {
$performance[$team_id][$player_id]['position'] = get_post_meta($player_id, 'sp_position', true);
}
}
foreach ($totals as $key => $value) {
$manual_total = sp_array_value(sp_array_value($performance, 0, array()), $key, null);
if ($manual_total != null) {
$totals[$key] = $manual_total;
}
}
}
}
if ($admin) {
return array($labels, $columns, $performance, $teams);
} else {
// Add position to performance labels
$labels = array_merge(array('position' => __('Position', 'prosports')), $labels);
if (is_array($columns)) {
foreach ($labels as $key => $label) {
if (!in_array($key, $columns)) {
unset($labels[$key]);
}
}
}
// Move individual players to top level of array
if (array_key_exists(0, $performance)) {
foreach ($performance[0] as $player_id => $player_performance) {
$performance[$player_id] = array($player_id => $player_performance);
}
}
$performance[0] = $labels;
return $performance;
}
}
示例2: performance
public function performance($admin = false)
{
$teams = get_post_meta($this->ID, 'sp_team', false);
$performance = (array) get_post_meta($this->ID, 'sp_players', true);
$labels = apply_filters('sportspress_event_performance_labels', sp_get_var_labels('sp_performance'), $this);
$columns = get_post_meta($this->ID, 'sp_columns', true);
if (is_array($teams)) {
foreach ($teams as $i => $team_id) {
$players = sp_array_between((array) get_post_meta($this->ID, 'sp_player', false), 0, $i);
$data = sp_array_combine($players, sp_array_value($performance, $team_id, array()));
$totals = array();
foreach ($labels as $key => $label) {
$totals[$key] = 0;
}
foreach ($data as $player_id => $player_performance) {
foreach ($labels as $key => $label) {
if (array_key_exists($key, $totals)) {
$totals[$key] += sp_array_value($player_performance, $key, 0);
}
}
if (!array_key_exists('number', $player_performance)) {
$performance[$team_id][$player_id]['number'] = get_post_meta($player_id, 'sp_number', true);
}
if (!array_key_exists('position', $player_performance) || $player_performance['position'] == null) {
$performance[$team_id][$player_id]['position'] = sp_get_the_term_id($player_id, 'sp_position', null);
}
}
foreach ($totals as $key => $value) {
$manual_total = sp_array_value(sp_array_value($performance, 0, array()), $key, null);
if ($manual_total != null) {
$totals[$key] = $manual_total;
}
}
}
}
if ($admin) {
return array($labels, $columns, $performance, $teams);
} else {
// Add position to performance labels
if (taxonomy_exists('sp_position')) {
$labels = array_merge(array('position' => __('Position', 'sportspress')), $labels);
}
if ('manual' == get_option('sportspress_event_performance_columns', 'auto') && is_array($columns)) {
foreach ($labels as $key => $label) {
if (!in_array($key, $columns)) {
unset($labels[$key]);
}
}
}
if ('no' == get_option('sportspress_event_show_position', 'yes')) {
unset($labels['position']);
}
$performance[0] = $labels;
return $performance;
}
}
示例3: output
/**
* Output the metabox
*/
public static function output($post)
{
$event = new SP_Event($post);
list($labels, $columns, $stats, $teams) = $event->performance(true);
$i = 0;
foreach ($teams as $key => $team_id) {
if (-1 == $team_id) {
continue;
}
// Get results for players in the team
$players = sp_array_between((array) get_post_meta($post->ID, 'sp_player', false), 0, $key);
$players[] = -1;
$data = sp_array_combine($players, sp_array_value($stats, $team_id, array()));
// Determine if we need checkboxes
if ('manual' == get_option('sportspress_event_performance_columns', 'auto') && $i == 0) {
$has_checkboxes = true;
} else {
$has_checkboxes = false;
}
// Determine if we need extras
if ('yes' == get_option('sportspress_event_show_extras', 'no')) {
$show_extras = true;
} else {
$show_extras = false;
}
// Determine if we are splitting positions
if ('yes' == get_option('sportspress_event_split_players_by_position', 'no')) {
$split_positions = true;
} else {
$split_positions = false;
}
?>
<div>
<?php
if ($team_id) {
?>
<p><strong><?php
echo get_the_title($team_id);
?>
</strong></p>
<?php
} elseif ($i) {
?>
<br>
<?php
}
?>
<?php
self::table($labels, $columns, $data, $team_id, $has_checkboxes, $show_extras, $split_positions);
?>
</div>
<?php
$i++;
}
}
示例4: output
/**
* Output the metabox
*/
public static function output($post)
{
$event = new SP_Event($post);
list($labels, $columns, $stats, $teams) = $event->performance(true);
$i = 0;
foreach ($teams as $key => $team_id) {
if (-1 == $team_id) {
continue;
}
// Get results for players in the team
$players = sp_array_between((array) get_post_meta($post->ID, 'sp_player', false), 0, $key);
$data = sp_array_combine($players, sp_array_value($stats, $team_id, array()));
?>
<div>
<?php
if ($team_id) {
?>
<p><strong><?php
echo get_the_title($team_id);
?>
</strong></p>
<?php
} elseif ($i) {
?>
<br>
<?php
}
?>
<?php
self::table($labels, $columns, $data, $team_id, $i == 0);
?>
</div>
<?php
$i++;
}
}
示例5: data
/**
* Returns formatted data
*
* @access public
* @param bool $admin
* @return array
*/
public function data($admin = false)
{
$league_ids = sp_get_the_term_ids($this->ID, 'sp_league');
$season_ids = sp_get_the_term_ids($this->ID, 'sp_season');
$position_ids = sp_get_the_term_ids($this->ID, 'sp_position');
$team = get_post_meta($this->ID, 'sp_team', true);
$list_stats = (array) get_post_meta($this->ID, 'sp_players', true);
$adjustments = get_post_meta($this->ID, 'sp_adjustments', true);
$orderby = get_post_meta($this->ID, 'sp_orderby', true);
$order = get_post_meta($this->ID, 'sp_order', true);
$select = get_post_meta($this->ID, 'sp_select', true);
// Get labels from performance variables
$performance_labels = (array) sp_get_var_labels('sp_performance');
// Get labels from outcome variables
$outcome_labels = (array) sp_get_var_labels('sp_outcome');
// Get labels from result variables
$result_labels = (array) sp_get_var_labels('sp_result');
// Get players automatically if set to auto
if ('auto' == $select) {
$player_ids = array();
$args = array('post_type' => 'sp_player', 'numberposts' => -1, 'posts_per_page' => -1, 'meta_key' => 'sp_number', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'tax_query' => array('relation' => 'AND'));
if ($league_ids) {
$args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_ids);
}
if ($season_ids) {
$args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $season_ids);
}
if ($position_ids) {
$args['tax_query'][] = array('taxonomy' => 'sp_position', 'field' => 'id', 'terms' => $position_ids);
}
if ($team && apply_filters('sportspress_has_teams', true)) {
$args['meta_query'] = array(array('key' => 'sp_team', 'value' => $team));
}
$players = get_posts($args);
if ($players && is_array($players)) {
foreach ($players as $player) {
$player_ids[] = $player->ID;
}
}
} else {
$player_ids = (array) get_post_meta($this->ID, 'sp_player', false);
}
// Get all leagues populated with stats where available
$tempdata = sp_array_combine($player_ids, $list_stats);
// Create entry for each player in totals
$totals = array();
$placeholders = array();
// Initialize columns
$columns = array();
// Initialize streaks counter
$streaks = array();
// Initialize last counters
$last5s = array();
$last10s = array();
foreach ($player_ids as $player_id) {
if (!$player_id) {
continue;
}
// Initialize player streaks counter
$streaks[$player_id] = array('name' => '', 'count' => 0, 'fire' => 1);
// Initialize player last counters
$last5s[$player_id] = array();
$last10s[$player_id] = array();
// Add outcome types to player last counters
foreach ($outcome_labels as $key => $value) {
$last5s[$player_id][$key] = 0;
$last10s[$player_id][$key] = 0;
}
// Initialize player totals
$totals[$player_id] = array('eventsattended' => 0, 'eventsplayed' => 0, 'eventsstarted' => 0, 'eventssubbed' => 0, 'eventminutes' => 0, 'streak' => 0);
foreach ($performance_labels as $key => $value) {
$totals[$player_id][$key] = 0;
}
foreach ($outcome_labels as $key => $value) {
$totals[$player_id][$key] = 0;
}
foreach ($result_labels as $key => $value) {
$totals[$player_id][$key . 'for'] = $totals[$player_id][$key . 'against'] = 0;
}
// Get metrics
$metrics = (array) get_post_meta($player_id, 'sp_metrics', true);
foreach ($metrics as $key => $value) {
$adjustment = sp_array_value(sp_array_value($adjustments, $player_id, array()), $key, null);
if ($adjustment != null) {
$metrics[$key] += $adjustment;
}
}
// Get static stats
$static = get_post_meta($player_id, 'sp_statistics', true);
// Get league and season arrays for static stats
$static_league_ids = empty($league_ids) ? array(0) : $league_ids;
$static_season_ids = empty($season_ids) ? array(0) : $season_ids;
// Add static stats to placeholders
//.........这里部分代码省略.........
示例6: prosports_array_combine
function prosports_array_combine($keys = array(), $values = array())
{
return sp_array_combine($keys, $values);
}
示例7: data
/**
* Returns formatted data
*
* @access public
* @param bool $admin
* @return array
*/
public function data($admin = false)
{
$league_ids = sp_get_the_term_ids($this->ID, 'sp_league');
$season_ids = sp_get_the_term_ids($this->ID, 'sp_season');
$table_stats = (array) get_post_meta($this->ID, 'sp_teams', true);
$usecolumns = get_post_meta($this->ID, 'sp_columns', true);
$adjustments = get_post_meta($this->ID, 'sp_adjustments', true);
$select = get_post_meta($this->ID, 'sp_select', true);
// Get labels from result variables
$result_labels = (array) sp_get_var_labels('sp_result');
// Get labels from outcome variables
$outcome_labels = (array) sp_get_var_labels('sp_outcome');
// Get teams automatically if set to auto
if ('auto' == $select) {
$team_ids = array();
$args = array('post_type' => 'sp_team', 'numberposts' => -1, 'posts_per_page' => -1, 'order' => 'ASC', 'tax_query' => array('relation' => 'AND'));
if ($league_ids) {
$args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_ids);
}
if ($season_ids) {
$args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $season_ids);
}
$teams = get_posts($args);
if ($teams && is_array($teams)) {
foreach ($teams as $team) {
$team_ids[] = $team->ID;
}
}
} else {
$team_ids = (array) get_post_meta($this->ID, 'sp_team', false);
}
// Get all leagues populated with stats where available
$tempdata = sp_array_combine($team_ids, $table_stats);
// Create entry for each team in totals
$totals = array();
$placeholders = array();
// Initialize incremental counter
$this->pos = 0;
$this->counter = 0;
// Initialize team compare
$this->compare = null;
// Initialize streaks counter
$streaks = array();
// Initialize last counters
$last5s = array();
$last10s = array();
// Initialize record counters
$homerecords = array();
$awayrecords = array();
foreach ($team_ids as $team_id) {
if (!$team_id) {
continue;
}
// Initialize team streaks counter
$streaks[$team_id] = array('name' => '', 'count' => 0, 'fire' => 1);
// Initialize team last counters
$last5s[$team_id] = array();
$last10s[$team_id] = array();
// Initialize team record counters
$homerecords[$team_id] = array();
$awayrecords[$team_id] = array();
// Add outcome types to team last and record counters
foreach ($outcome_labels as $key => $value) {
$last5s[$team_id][$key] = 0;
$last10s[$team_id][$key] = 0;
$homerecords[$team_id][$key] = 0;
$awayrecords[$team_id][$key] = 0;
}
// Initialize team totals
$totals[$team_id] = array('eventsplayed' => 0, 'eventsplayed_home' => 0, 'eventsplayed_away' => 0, 'eventsplayed_venue' => 0, 'eventminutes' => 0, 'eventminutes_home' => 0, 'eventminutes_away' => 0, 'eventminutes_venue' => 0, 'streak' => 0, 'streak_home' => 0, 'streak_away' => 0, 'streak_venue' => 0);
foreach ($result_labels as $key => $value) {
$totals[$team_id][$key . 'for'] = 0;
$totals[$team_id][$key . 'for_home'] = 0;
$totals[$team_id][$key . 'for_away'] = 0;
$totals[$team_id][$key . 'for_venue'] = 0;
$totals[$team_id][$key . 'against'] = 0;
$totals[$team_id][$key . 'against_home'] = 0;
$totals[$team_id][$key . 'against_away'] = 0;
$totals[$team_id][$key . 'against_venue'] = 0;
}
foreach ($outcome_labels as $key => $value) {
$totals[$team_id][$key] = 0;
$totals[$team_id][$key . '_home'] = 0;
$totals[$team_id][$key . '_away'] = 0;
$totals[$team_id][$key . '_venue'] = 0;
}
// Get static stats
$static = get_post_meta($team_id, 'sp_columns', true);
if ('yes' == get_option('sportspress_team_column_editing', 'no') && $league_ids && $season_ids) {
// Add static stats to placeholders
foreach ($league_ids as $league_id) {
foreach ($season_ids as $season_id) {
$placeholders[$team_id] = (array) sp_array_value(sp_array_value($static, $league_id, array()), $season_id, array());
//.........这里部分代码省略.........
示例8: data
/**
* Returns formatted data
*
* @access public
* @param int $league_id
* @param bool $admin
* @return array
*/
public function data($league_id, $admin = false)
{
$seasons = (array) get_the_terms($this->ID, 'sp_season');
$metrics = (array) get_post_meta($this->ID, 'sp_metrics', true);
$stats = (array) get_post_meta($this->ID, 'sp_statistics', true);
$leagues = sp_array_value((array) get_post_meta($this->ID, 'sp_leagues', true), $league_id, array());
$usecolumns = get_post_meta($this->ID, 'sp_columns', true);
// Get labels from performance variables
$performance_labels = (array) sp_get_var_labels('sp_performance');
// Get labels from outcome variables
$outcome_labels = (array) sp_get_var_labels('sp_outcome');
// Get labels from result variables
$result_labels = (array) sp_get_var_labels('sp_result');
// Generate array of all season ids and season names
$div_ids = array();
$season_names = array();
foreach ($seasons as $season) {
if (is_object($season) && property_exists($season, 'term_id') && property_exists($season, 'name')) {
$div_ids[] = $season->term_id;
$season_names[$season->term_id] = $season->name;
}
}
$div_ids[] = 0;
$season_names[0] = __('Total', 'sportspress');
$data = array();
// Get all seasons populated with data where available
$data = sp_array_combine($div_ids, sp_array_value($stats, $league_id, array()));
// Get equations from statistic variables
$equations = sp_get_var_equations('sp_statistic');
// Initialize placeholders array
$placeholders = array();
foreach ($div_ids as $div_id) {
$totals = array('eventsattended' => 0, 'eventsplayed' => 0, 'eventsstarted' => 0, 'eventssubbed' => 0, 'eventminutes' => 0, 'streak' => 0, 'last5' => null, 'last10' => null);
foreach ($performance_labels as $key => $value) {
$totals[$key] = 0;
}
foreach ($outcome_labels as $key => $value) {
$totals[$key] = 0;
}
foreach ($result_labels as $key => $value) {
$totals[$key . 'for'] = $totals[$key . 'against'] = 0;
}
// Initialize streaks counter
$streak = array('name' => '', 'count' => 0, 'fire' => 1);
// Initialize last counters
$last5 = array();
$last10 = array();
// Add outcome types to last counters
foreach ($outcome_labels as $key => $value) {
$last5[$key] = 0;
$last10[$key] = 0;
}
// Get all events involving the team in current season
$args = array('post_type' => 'sp_event', 'numberposts' => -1, 'posts_per_page' => -1, 'order' => 'DESC', 'meta_query' => array('relation' => 'AND', array('key' => 'sp_player', 'value' => $this->ID), array('key' => 'sp_format', 'value' => apply_filters('sportspress_competitive_event_formats', array('league')), 'compare' => 'IN')), 'tax_query' => array('relation' => 'AND'));
if ($league_id) {
$args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_id);
}
if ($div_id) {
$args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $div_id);
}
$args = apply_filters('sportspress_player_data_event_args', $args);
$events = get_posts($args);
// Event loop
foreach ($events as $i => $event) {
$results = (array) get_post_meta($event->ID, 'sp_results', true);
$team_performance = (array) get_post_meta($event->ID, 'sp_players', true);
$minutes = get_post_meta($event->ID, 'sp_minutes', true);
if ($minutes === '') {
$minutes = get_option('sportspress_event_minutes', 90);
}
// Add all team performance
foreach ($team_performance as $team_id => $players) {
if (is_array($players) && array_key_exists($this->ID, $players)) {
$player_performance = sp_array_value($players, $this->ID, array());
foreach ($player_performance as $key => $value) {
if ('outcome' == $key) {
// Increment events attended, played, and started
$totals['eventsattended']++;
$totals['eventsplayed']++;
$totals['eventsstarted']++;
$totals['eventminutes'] += $minutes;
// Convert to array
if (!is_array($value)) {
$value = array($value);
}
foreach ($value as $outcome) {
if ($outcome && $outcome != '-1') {
// Increment outcome count
if (array_key_exists($outcome, $totals)) {
$totals[$outcome]++;
}
// Add to streak counter
//.........这里部分代码省略.........
示例9: columns
/**
* Returns formatted data
*
* @access public
* @param bool $admin
* @return array
*/
public function columns($league_id)
{
$seasons = (array) get_the_terms($this->ID, 'sp_season');
$columns = (array) get_post_meta($this->ID, 'sp_columns', true);
// Get labels from result variables
$result_labels = (array) sp_get_var_labels('sp_result');
// Get labels from outcome variables
$outcome_labels = (array) sp_get_var_labels('sp_outcome');
// Generate array of all season ids and season names
$div_ids = array();
$season_names = array();
foreach ($seasons as $season) {
if (is_object($season) && property_exists($season, 'term_id') && property_exists($season, 'name')) {
$div_ids[] = $season->term_id;
$season_names[$season->term_id] = $season->name;
}
}
$div_ids[] = 0;
$season_names[0] = __('Total', 'sportspress');
$data = array();
// Get all seasons populated with data where available
$data = sp_array_combine($div_ids, sp_array_value($columns, $league_id, array()));
// Get equations from column variables
$equations = sp_get_var_equations('sp_column');
// Initialize placeholders array
$placeholders = array();
foreach ($div_ids as $div_id) {
$totals = array('eventsplayed' => 0, 'eventsplayed_home' => 0, 'eventsplayed_away' => 0, 'eventsplayed_venue' => 0, 'eventminutes' => 0, 'eventminutes_home' => 0, 'eventminutes_away' => 0, 'eventminutes_venue' => 0, 'streak' => 0, 'streak_home' => 0, 'streak_away' => 0, 'streak_venue' => 0, 'last5' => null, 'last10' => null, 'homerecord' => null, 'awayrecord' => null);
foreach ($result_labels as $key => $value) {
$totals[$key . 'for'] = 0;
$totals[$key . 'for_home'] = 0;
$totals[$key . 'for_away'] = 0;
$totals[$key . 'for_venue'] = 0;
$totals[$key . 'against'] = 0;
$totals[$key . 'against_home'] = 0;
$totals[$key . 'against_away'] = 0;
$totals[$key . 'against_venue'] = 0;
}
foreach ($outcome_labels as $key => $value) {
$totals[$key] = 0;
$totals[$key . '_home'] = 0;
$totals[$key . '_away'] = 0;
$totals[$key . '_venue'] = 0;
}
// Initialize streaks counter
$streak = array('name' => '', 'count' => 0, 'fire' => 1);
// Initialize last counters
$last5 = array();
$last10 = array();
// Initialize record counters
$homerecord = array();
$awayrecord = array();
// Add outcome types to last and record counters
foreach ($outcome_labels as $key => $value) {
$last5[$key] = 0;
$last10[$key] = 0;
$homerecord[$key] = 0;
$awayrecord[$key] = 0;
}
// Get all events involving the team in current season
$args = array('post_type' => 'sp_event', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'meta_query' => array('relation' => 'AND', array('key' => 'sp_team', 'value' => $this->ID), array('key' => 'sp_format', 'value' => apply_filters('sportspress_competitive_event_formats', array('league')), 'compare' => 'IN')), 'tax_query' => array('relation' => 'AND'));
if ($league_id) {
$args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_id);
}
if ($div_id) {
$args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $div_id);
}
$args = apply_filters('sportspress_team_data_event_args', $args);
$events = get_posts($args);
$e = 0;
foreach ($events as $event) {
$results = (array) get_post_meta($event->ID, 'sp_results', true);
$minutes = get_post_meta($event->ID, 'sp_minutes', true);
if ($minutes === '') {
$minutes = get_option('sportspress_event_minutes', 90);
}
$i = 0;
foreach ($results as $team_id => $team_result) {
if (is_array($team_result)) {
foreach ($team_result as $key => $value) {
if ($team_id == $this->ID) {
if ($key == 'outcome') {
// Convert to array
if (!is_array($value)) {
$value = array($value);
}
foreach ($value as $outcome) {
// Increment events played and outcome count
if (array_key_exists($outcome, $totals)) {
$totals['eventsplayed']++;
$totals['eventminutes'] += $minutes;
$totals[$outcome]++;
// Add to home or away stats
//.........这里部分代码省略.........
示例10: array_reverse
if ($reverse_teams) {
$teams = array_reverse($teams, true);
}
if ($split_teams) {
// Split tables
foreach ($teams as $index => $team_id) {
if (-1 == $team_id) {
continue;
}
// Get results for players in the team
$players = sp_array_between((array) get_post_meta($id, 'sp_player', false), 0, $index);
$has_players = sizeof($players) > 1;
$players = apply_filters('sportspress_event_performance_split_team_players', $players);
$show_team_players = $show_players && $has_players;
if (0 < $team_id) {
$data = sp_array_combine($players, sp_array_value($performance, $team_id, array()));
} elseif (0 == $team_id) {
$data = array();
foreach ($players as $player_id) {
if (isset($performance[$player_id][$player_id])) {
$data[$player_id] = $performance[$player_id][$player_id];
}
}
} else {
$data = sp_array_value(array_values($performance), $index);
}
if (!$show_team_players && !$show_staff && !$show_total) {
continue;
}
if ($show_team_players || $show_total) {
if ($split_positions) {
示例11: tables
/**
* Admin edit tables
*/
public static function tables($post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $split_positions = false, $split_teams = true, $positions = array(), $status = true)
{
$i = 0;
if ($split_teams) {
foreach ($teams as $key => $team_id) {
if (-1 == $team_id) {
continue;
}
// Get results for players in the team
$players = sp_array_between((array) get_post_meta($post_id, 'sp_player', false), 0, $key);
$players[] = -1;
$data = sp_array_combine($players, sp_array_value($stats, $team_id, array()));
?>
<div>
<?php
if ($team_id) {
?>
<p><strong><?php
echo get_the_title($team_id);
?>
</strong></p>
<?php
} elseif ($i) {
?>
<br>
<?php
}
?>
<?php
self::table($labels, $columns, $data, $team_id, $has_checkboxes, $split_positions, $positions, $status);
?>
</div>
<?php
$i++;
}
} else {
?>
<div class="sp-data-table-container">
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
<?php
self::header($columns, $labels, $positions, $labels, $has_checkboxes, $status, false, false);
?>
<?php
self::footer(sp_array_value($stats, -1), $labels, 0, $positions, $labels, $split_positions, $status, false, false);
?>
<tbody>
<?php
foreach ($teams as $key => $team_id) {
if (-1 == $team_id) {
continue;
}
// Get results for players in the team
$players = sp_array_between((array) get_post_meta($post_id, 'sp_player', false), 0, $key);
$players[] = -1;
$data = sp_array_combine($players, sp_array_value($stats, $team_id, array()));
foreach ($data as $player_id => $player_performance) {
self::row($labels, $player_id, $player_performance, $team_id, $data, !empty($positions), $status, false, false);
}
}
?>
</tbody>
</table>
</div>
<?php
}
}
示例12: tables
/**
* Admin edit tables
*/
public static function tables($post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $positions = array(), $status = true, $formats = array(), $order = array(), $numbers = true, $is_individual = false, $timeline = array())
{
$sections = get_option('sportspress_event_performance_sections', -1);
if ($is_individual) {
?>
<div class="sp-data-table-container">
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
<?php
self::header($columns, $labels, $positions, $has_checkboxes, $status, false, $numbers, -1, $formats);
?>
<?php
self::footer(sp_array_value($stats, -1), $labels, 0, $positions, $status, false, $numbers, -1, $formats);
?>
<tbody>
<?php
foreach ($teams as $key => $team_id) {
if (-1 == $team_id) {
continue;
}
// Get results for players in the team
$players = sp_array_between((array) get_post_meta($post_id, 'sp_player', false), 0, $key);
$players[] = -1;
$data = sp_array_combine($players, sp_array_value($stats, $team_id, array()));
// Get team timeline
if (is_array($timeline)) {
$team_timeline = (array) sp_array_value($timeline, $team_id, array());
} else {
$team_timeline = false;
}
foreach ($data as $player_id => $player_performance) {
// Get player timeline
if (is_array($team_timeline)) {
$player_timeline = (array) sp_array_value($team_timeline, $player_id, array());
} else {
$player_timeline = false;
}
self::row($labels, $player_id, $player_performance, $team_id, $data, !empty($positions), $status, false, $numbers, -1, $formats, $player_timeline);
}
}
?>
</tbody>
</table>
</div>
<?php
} else {
$i = 0;
foreach ($teams as $key => $team_id) {
if (-1 == $team_id) {
continue;
}
if (-1 == $sections) {
// Get results for players in the team
$players = sp_array_between((array) get_post_meta($post_id, 'sp_player', false), 0, $key);
$players[] = -1;
$data = sp_array_combine($players, sp_array_value($stats, $team_id, array()));
// Get team timeline
if (is_array($timeline)) {
$team_timeline = (array) sp_array_value($timeline, $team_id, array());
} else {
$team_timeline = false;
}
?>
<div>
<p><strong><?php
echo get_the_title($team_id);
?>
</strong></p>
<?php
self::table($labels, $columns, $data, $team_id, $has_checkboxes, $positions, $status, -1, $formats, $order, $numbers, $team_timeline);
?>
<?php
do_action('sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id);
?>
</div>
<?php
} else {
?>
<?php
// Get labels by section
$args = array('post_type' => 'sp_performance', 'numberposts' => 100, 'posts_per_page' => 100, 'orderby' => 'menu_order', 'order' => 'ASC');
$performances = get_posts($args);
$labels = array(array(), array());
foreach ($performances as $performance) {
$section = get_post_meta($performance->ID, 'sp_section', true);
if ('' === $section) {
$section = -1;
}
switch ($section) {
case 1:
$labels[1][$performance->post_name] = $performance->post_title;
break;
default:
$labels[0][$performance->post_name] = $performance->post_title;
}
}
$offense = (array) get_post_meta($post_id, 'sp_offense', false);
$defense = (array) get_post_meta($post_id, 'sp_defense', false);
//.........这里部分代码省略.........
示例13: tables
/**
* Admin edit tables
*/
public static function tables($post_id, $stats = array(), $labels = array(), $columns = array(), $teams = array(), $has_checkboxes = false, $split_positions = false, $split_teams = true, $positions = array(), $status = true)
{
$i = 0;
if ($split_teams) {
foreach ($teams as $key => $team_id) {
if (-1 == $team_id) {
continue;
}
// Get results for players in the team
$players = sp_array_between((array) get_post_meta($post_id, 'sp_player', false), 0, $key);
$players[] = -1;
$data = sp_array_combine($players, sp_array_value($stats, $team_id, array()));
$tabs = array();
if ($team_id) {
$tabs['values'] = get_the_title($team_id);
} elseif ($i) {
echo '<br>';
}
$tabs = apply_filters('sportspress_event_performance_tabs_admin', $tabs);
?>
<div>
<?php
if (sizeof($tabs)) {
?>
<?php
if (sizeof($tabs) > 1) {
?>
<ul class="subsubsub sp-performance-table-bar">
<?php
$t = 0;
?>
<?php
foreach ($tabs as $key => $label) {
?>
<li>
<a href="#"<?php
if (0 == $t) {
?>
class="current"<?php
}
?>
>
<?php
echo $label;
?>
</a>
</li>
<?php
if (sizeof($tabs) > $t + 1) {
?>
| <?php
}
?>
<?php
$t++;
?>
<?php
}
?>
</ul>
<?php
} else {
?>
<?php
$label = reset($tabs);
?>
<p><strong><?php
echo $label;
?>
</strong></p>
<?php
}
?>
<?php
}
?>
<?php
self::table($labels, $columns, $data, $team_id, $has_checkboxes, $split_positions, $positions, $status);
?>
<?php
do_action('sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id);
?>
</div>
<?php
$i++;
}
} else {
?>
<div class="sp-data-table-container">
<table class="widefat sp-data-table sp-performance-table sp-sortable-table">
<?php
self::header($columns, $labels, $positions, $has_checkboxes, $status, false, false);
?>
<?php
self::footer(sp_array_value($stats, -1), $labels, 0, $positions, $split_positions, $status, false, false);
?>
<tbody>
//.........这里部分代码省略.........
示例14: performance
public function performance($admin = false)
{
$teams = get_post_meta($this->ID, 'sp_team', false);
$performance = (array) get_post_meta($this->ID, 'sp_players', true);
$args = array('post_type' => 'sp_performance', 'numberposts' => 100, 'posts_per_page' => 100, 'orderby' => 'menu_order', 'order' => 'ASC');
$vars = get_posts($args);
$labels = array();
foreach ($vars as $var) {
$labels[$var->post_name] = $var->post_title;
$format = get_post_meta($var->ID, 'sp_format', true);
if ('' === $format) {
$format = 'number';
}
$formats[$var->post_name] = $format;
}
$order = (array) get_post_meta($this->ID, 'sp_order', true);
$labels = apply_filters('sportspress_event_performance_labels', $labels, $this);
$columns = get_post_meta($this->ID, 'sp_columns', true);
if (is_array($teams)) {
foreach ($teams as $i => $team_id) {
$players = sp_array_between((array) get_post_meta($this->ID, 'sp_player', false), 0, $i);
$data = sp_array_combine($players, sp_array_value($performance, $team_id, array()));
$totals = array();
foreach ($labels as $key => $label) {
$totals[$key] = 0;
}
foreach ($data as $player_id => $player_performance) {
foreach ($labels as $key => $label) {
if (array_key_exists($key, $totals)) {
$totals[$key] += sp_array_value($player_performance, $key, 0);
}
}
if (!array_key_exists('number', $player_performance)) {
$performance[$team_id][$player_id]['number'] = apply_filters('sportspress_event_performance_default_squad_number', get_post_meta($player_id, 'sp_number', true));
}
if (!array_key_exists('position', $player_performance) || $player_performance['position'] == null) {
$performance[$team_id][$player_id]['position'] = sp_get_the_term_id($player_id, 'sp_position', null);
}
}
foreach ($totals as $key => $value) {
$manual_total = sp_array_value(sp_array_value($performance, 0, array()), $key, null);
if ($manual_total != null) {
$totals[$key] = $manual_total;
}
}
}
}
if ($admin) {
return array($labels, $columns, $performance, $teams, $formats, $order);
} else {
// Add position to performance labels
if (taxonomy_exists('sp_position')) {
$labels = array_merge(array('position' => __('Position', 'sportspress')), $labels);
}
if ('manual' == get_option('sportspress_event_performance_columns', 'auto') && is_array($columns)) {
foreach ($labels as $key => $label) {
if (!in_array($key, $columns)) {
unset($labels[$key]);
}
}
}
if ('no' == get_option('sportspress_event_show_position', 'yes')) {
unset($labels['position']);
}
if ('no' == get_option('sportspress_event_show_player_numbers', 'yes')) {
unset($labels['number']);
}
$performance[0] = $labels;
return apply_filters('sportspress_get_event_performance', $performance);
}
}