Просмотр файла phpmytourney/grid.php

Размер файла: 6.61Kb
<html>
<?php
/***********************************************************
* This file was created by Jйrфme Poulin under the phpmytourney
* project.  
* You can modify and redistribute this file as long as this
* copyright notice stays in the file.
*
* If you want to do major upgrades on my script, please contact
* me and we could work together.
* 
* Jйrфme Poulin
* Student University of Sherbrooke
* [email protected] <== dont use for support !!!
* http:/phpmytourney.sourceforge.net/ <== use sourceforce forum for support
* 
*  phpMyTourney <C> 2001-2002
************************************************************/
 
	include('config.inc');
	echo($grid_body_string);
?>
<head>
<SCRIPT LANGUAGE = "JavaScript"
        TYPE="text/javascript">
function rien(){}
</SCRIPT>
</head>
<LINK REL="stylesheet" TYPE="text/css" HREF="/styles.css">
<?php
if(!isset($tourney_id)) echo("ERROR : page not properly called");
else{
	
	include($functions_file);
	$status = get_status($tourney_id);	
	if($status < 7) print_error("Grid isn't yet generated");
	else{
//*********************************************************
//	Parameters passed to scripts (prolly the number or players)
//*********************************************************
$nb_players = get_nb_tourney($tourney_id);
$round = get_nb_round($nb_players);
$round++;	//there is 1 more column then the number of rounds...
//*********************************************************
//	Sets the Starting line for each round.
//*********************************************************
$r1=1;
for($i=2;$i<=$round;$i++){
	$curround = "r" . $i;
	$previousround = "r" . ($i-1);
	$$curround = $$previousround *2;
}
//*********************************************************
//	Sets the add number for each round.
//*********************************************************
$add1=2;
for($i=2;$i<=$round;$i++){
	$curadd = "add" . $i;
	$previousround = "add" . ($i-1);
	$$curadd = $$previousround *2;
}
//*********************************************************
//	This Parts inits all the flags to False (0)
//*********************************************************
for($i=1;$i<=$round;$i++){
	$flagvar = "flag" . $i;
	$$flagvar = 0;
}
//*********************************************************
//	This parts inits the cpt to 0 for each round
//*********************************************************
for($i=1;$i<=$round;$i++){
	$cptvar = "cpt" . $i;
	$$cptvar = 1;
}
//*********************************************************
//	This parts inits array containing players information
//*********************************************************
for($i=1;$i<=$round;$i++){
	$arrayvar = "player" . $i;
	$$arrayvar = get_players_array($i);
}

//*********************************************************
//	This parts prints the Standing GRid!
//*********************************************************
echo("<table>");
for($row=1;$row<($nb_players*2);$row++){
	$oth_flag = 0;
	echo("<tr>");
	//Find which colums a name has to be printed...
	for($col=1;$col<=$round;$col++){	
		$curround = "r" . $col;
		$curadd = "add" . $col;
		if ($row == $$curround){
			$flagvar = "flag" . $col;
			if ($$flagvar) $oth_flag = 1;
			if ($col != $round) $$flagvar = neg($$flagvar);	
			$name_col = $col;
			$$curround += $$curadd;
			$arrayvar = "player" . $col;
			$cptvar = "cpt" . $col;
			$name = ${$arrayvar}[$$cptvar];
			${$cptvar}++;
		}
	}
	for($col=1;$col<=$round;$col++){
		$flagvar = "flag" . $col;
		if($col == $name_col) 
			if($col != $round) print_td_name($name,1);
			else print_td_name($name,0);
		else print_td_vide($$flagvar);
	}

	echo("</tr>");
}	
	echo("</table>");
	do_not_remove_please();

	}
}
//*********************************************************
//	These Function Print the columns...
//*********************************************************
function print_td_name($name,$flag){
	echo("<td bgcolor=\"#977E53\" width=\"100\">-". $name . "</td>");
	if ($flag) print_td_bar_color();
	else print_td_bar_vide();
}
function print_td_vide($flag){
	echo("<td width=\"100\"> </td>");
	if ($flag) print_td_bar_color();
	else print_td_bar_vide();
}
function print_td_bar_color(){
	echo("<td width=\"8\" bgcolor=\"#C4A879\"> </td>");
}
function print_td_bar_vide(){
	echo("<td width=\"8\"> </td>");
}
//*********************************************************
//	This function return the opposition of current flag var
//*********************************************************
function neg($flag){
	if ($flag) return 0;
	else return 1;
}
function get_players_array($round){
	global $tourney_id;
	$tou_type = get_tourney_type($tourney_id);
	$get_name_fct = "get_" . $tou_type . "_name";
	$sql = "SELECT id,r". $round ." FROM " . $GLOBALS['dbtable_header'] . "data_" . $tourney_id . "
		WHERE r" . $round . " > 0
		ORDER BY r" . $round;
	$array = get_mysql_rows($sql,"no");
	$nb_array = count($array);
	for($i=0;$i<$nb_array;$i++){
		if($array[$i][0] >= 0)
			if ($array[$i][0] == 0) $name = "-={ BYE }=-";
			else{
				if($tou_type == "team"){
					$name = $get_name_fct(get_players_team($array[$i][0]));
					$members_list = get_team_list_java($array[$i][0]);
				}
				else {			
					$name = $get_name_fct($array[$i][0]); 
					$members_list = "No team Member ~ SINGLES tourney";
				}
				$name = "<A HREF =\"javascript:rien()\"
							ONCLICK = \"alert('$members_list')\"
							onMouseOver = \"window.status = '';return true\">" . $name . "</a>";
				$comment = get_comment_tourney($array[$i][0],$round);
				if ($comment){
					$comment = "<A HREF =\"javascript:rien()\"
							ONCLICK = \"alert('$comment')\"
							onMouseOver = \"window.status = '';return true\"><img src=\"http://fw.altajeux.com/images/league/comment.gif\" border=\"0\"></a>";
				$name .= " " . $comment;
				}
			}
	$array_1dim[$array[$i][1]] = $name;
	}
	return $array_1dim;
	
}
function get_comment_tourney($id,$round){
	global $tourney_id;
	$sql = "SELECT commment from  " . $GLOBALS['dbtable_header'] . "data_" . $tourney_id . "
		WHERE 	id='$id' 
		and 	curround ='$round'";
	return get_mysql_value($sql);
}
function get_team_list_java($id){
	global $tourney_id;
if($id <= 0) return "not a valid team";
else{	
	$sql = "SELECT pid from  " . $GLOBALS['dbtable_header'] . "team_members_" . $tourney_id . " where id = '$id' order by nb";
	$allies = get_mysql_rows($sql);
	$members_list = "- " . get_player_name($id);
	$nb = get_nb_per_team($tourney_id);
	for($i=1;$i<$nb;$i++)
		if($allies[$i][0] > 0)
			$members_list .= "\\n- " . get_player_name($allies[$i][0]);
	return $members_list;
}
}
?>
</body>
</html>