Example #1
0
 /**
  * export matches
  *
  * @param none
  * @return string
  */
 function exportMatches()
 {
     global $leaguemanager;
     $matches = parent::getMatches("league_id=" . $this->league_id);
     if ($matches) {
         $league = $this->league;
         $teams = parent::getTeams("league_id=" . $this->league_id, "`id` ASC", 'ARRAY');
         // Build header
         $contents = __('Date', 'leaguemanager') . "\t" . __('Season', 'leaguemanager') . "\t" . __('Match Day', 'leaguemanager') . "\t" . __('Home', 'leaguemanager') . "\t" . __('Guest', 'leaguemanager') . "\t" . __('Location', 'leaguemanager') . "\t" . __('Begin', 'leaguemanager') . "\t" . __('Group', 'leaguemanager') . "\t" . __('Score', 'leaguemanager');
         $contents = apply_filters('leaguemanager_export_matches_header_' . $league->sport, $contents);
         foreach ($matches as $match) {
             $contents .= "\n" . mysql2date('Y-m-d', $match->date) . "\t" . $match->season . "\t" . $match->match_day . "\t" . $teams[$match->home_team]['title'] . "\t" . $teams[$match->away_team]['title'] . "\t" . $match->location . "\t" . mysql2date("H:i", $match->date) . "\t" . $match->group . "\t";
             $contents .= !empty($match->home_points) ? sprintf("%d-%d", $match->home_points, $match->away_points) : '';
             $contents = apply_filters('leaguemanager_export_matches_data_' . $league->sport, $contents, $match);
         }
         return $contents;
     }
     return false;
 }
Example #2
0
 /**
  * save match statistics
  *
  * The first parameter is simply the match ID. The second is a multidimensional array holding all statistics.
  *
  * @param int $match_id
  * @param array $stats
  * @return string
  */
 function save($match_id, $stats)
 {
     global $wpdb, $leaguemanager;
     $match = $leaguemanager->getMatch($match_id);
     $custom = $match->custom;
     foreach ((array) $stats as $stat => $data) {
         $custom[$stat] = array_values($data);
     }
     $custom['hasStats'] = true;
     $wpdb->query($wpdb->prepare("UPDATE {$wpdb->leaguemanager_matches} SET `custom` = '%s' WHERE `id` = '%s'", maybe_serialize($custom), $match_id));
     parent::setMessage(__('Saved Statstics', 'leaguemanager'));
     parent::printMessage();
 }
Example #3
0
 /**
  * Load template for user display. First the current theme directory is checked for a template
  * before defaulting to the plugin
  *
  * @param string $template Name of the template file (without extension)
  * @param array $vars Array of variables name=>value available to display code (optional)
  * @return the content
  */
 function loadTemplate($template, $vars = array())
 {
     global $leaguemanager, $lmStats, $championship;
     extract($vars);
     ob_start();
     if (file_exists(get_template_directory() . "/leaguemanager/{$template}.php")) {
         include get_template_directory() . "/leaguemanager/{$template}.php";
     } elseif (file_exists(LEAGUEMANAGER_PATH . "/templates/" . $template . ".php")) {
         include LEAGUEMANAGER_PATH . "/templates/" . $template . ".php";
     } else {
         parent::setMessage(sprintf(__('Could not load template %s.php', 'leaguemanager'), $template), true);
         parent::printMessage();
     }
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }