par
jimmy69 » 17 août 2006, 10:50
Salut,
voila la fonction qui me permet d'afficher la table ($p correspond a l'affichage de la place dans le classement):
function display_division_table($did, $name, $sid, $lid, $disp=1) {
global $bgcolor1, $bgcolor2;
$prefs = getLeaguePrefs($lid);
if ($rowcolor != "")
$color="bgcolor=\"$prefs[rowcolor]\"";
else
$color="";
$standings = new Standings($lid);
$max = $standings->size();
$str = "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$bgcolor1\">";
$str .= "<tr><td colspan=\"" . ($max + 3) . "\"><font class=\"option\">$name</font>";
if (isAdminLeague($lid, ADD_TEAM) and $disp) {
$str .= " [ <a href=\"modules.php?name=League&file=admin&op=add_team&did=$did&lid=$lid&sid=$sid\">" . _ADDTEAM . "</a> | <a href=\"modules.php?name=League&file=admin&op=recreate_standings_ok&sid=$sid&lid=$lid\">" . _RECREATESTANDING . "</a> | <a href=\"modules.php?name=League&file=admin&op=recalc_standings&sid=$sid&lid=$lid\">" . _RECALCSTANDING . "</a>] ";
$plugin = new Plugins($lid);
echo $plugin->getLinks(PLUGIN_STANDINGS_DIVISION);
}
$str .= "</td></tr>";
$str .= "<tr><td bgcolor=\"$bgcolor2\"</td><td bgcolor=\"$bgcolor2\" align=\"left\" width=\"36%\"><b>" . _TEAMNAME . "</b></td>";
$standings = new Standings($lid);
$maxcol = $standings->size();
while (($lheader = $standings->headings())) {
$str .= "<td bgcolor=\"$bgcolor2\" align=\"center\"><b>$lheader</b></td>";
}
if ($disp)
$str .= "<td bgcolor=\"$bgcolor2\"> </td>";
$str .= "</tr>";
$p=1;
$standings->select($did, $sid);
while ($standings->fetchRow()) {
$tid = $standings->tid();
if ($bgcolor=="")
$bgcolor="$color";
else
$bgcolor="";
$str .= "<tr $bgcolor>"
. "<td align=\"right\" width=\"3%\">$p.</td>"
. "<td align=\"left\" nowrap width=\"36%\">";
$str .= getTeamNamewithURL($tid, "modules.php?name=League&file=index&op=team&tid=$tid&sid=$sid&lid=$lid&did=$did ") . "<i> (" . getManagerNamesaison($tid, $sid) .") </i></td>";
for ($i=0; $i < $standings->size(); $i++) {
$pos = $standings->position($i);
$value = $standings->fetchRowValue();
if ($pos != "")
$value=$pos;
$str .= "<td nowrap align=\"center\" nowrap>$value</td>";
}
if (isAdminLeague($lid, REMOVE_TEAM) and $disp) {
$str .= "<td><a href=\"modules.php?name=League&file=admin&op=del_team&tid=$tid&lid=$lid&did=$did&sid=$sid\" title=\"" . _REMOVE . "\"><img src=\"modules/League/images/remove.gif\" border=\"0\" width=\"11\" height=\"11\"></a></td>";
}
$str .= "</tr>";
$p++;
}
$str .= "</table>";
return $str;
}
et voila la fonction qui fait appel a cette fonction
function display_standings($lid, $sid=0) {
global $db, $prefix;
include("header.php");
$sid = zeroIfBlank($sid);
validateNumForError($lid);
validateNumForError($sid);
$prefs = getLeaguePrefs($lid);
if ($sid == 0)
$where = $prefix . "_league.curr_sid = " . $prefix . "_league_season.id";
else
$where = $prefix . "_league_season.id = $sid";
$result = $db->sql_query("select " . $prefix . "_league.name, " . $prefix . "_league_season.id," . $prefix . "_league_season.name, tournament from " . $prefix . "_league," . $prefix . "_league_season where " . $prefix . "_league.id = " . $prefix . "_league_season.lid and " . $prefix . "_league.id = $lid and $where");
list($name, $sid, $season, $tournament) = $db->sql_fetchrow($result);
if ($sid == "") {
OpenTable();
echo "<center><b>" . _SEASONNOTSET . "</b></center>";
CloseTable();
}
else if ($tournament) {
title(_TOURNAMENT . " - " . stripslashes($name) . " - " . stripslashes($season));
display_tournament($sid, $lid, "show_round", 0, 0);
}
else {
title(_STANDINGS . " - " . stripslashes($name) . " - " . stripslashes($season));
OpenTable2();
echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">" ;
$season_selector = display_season_selector($lid, $sid);
if ($season_selector != "") {
echo "<tr><td align=\"right\">";
$plugin = new Plugins($lid);
echo $plugin->getLinks(PLUGIN_STANDINGS) . " ";
echo $season_selector;
echo "</td>";
echo "</tr>";
echo "<tr><td><img src=\"modules/League/images/spacer.gif\" border=\"0\" height=\"6\"></td></tr>";
}
$result = $db->sql_query("select " . $prefix . "_league_division.id, name from " . $prefix . "_league_division, " . $prefix . "_league_division_seasons where " . $prefix . "_league_division.id = did and tour = 0 and sid = $sid and lid = $lid order by position");
while (list($did, $name) = $db->sql_fetchrow($result)) {
echo "<tr><td>";
OpenTable();
echo display_division_table($did, stripslashes($name), $sid, $lid);
CloseTable();
echo "</td></tr>";
}
echo "</table>";
CloseTable2();
}
LeagueFooter($prefs[rightblock], $lid);
}
display_standings($lid, $sid);
Etant debutant j'ai du mal a tout decrypter dans ce code, mais s'il vous faut d'autre fonction, partie de code, demandez
Merci
jimmy
[b]Salut,
voila la fonction qui me permet d'afficher la table ($p correspond a l'affichage de la place dans le classement): [/b]
[php]
function display_division_table($did, $name, $sid, $lid, $disp=1) {
global $bgcolor1, $bgcolor2;
$prefs = getLeaguePrefs($lid);
if ($rowcolor != "")
$color="bgcolor=\"$prefs[rowcolor]\"";
else
$color="";
$standings = new Standings($lid);
$max = $standings->size();
$str = "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\" bgcolor=\"$bgcolor1\">";
$str .= "<tr><td colspan=\"" . ($max + 3) . "\"><font class=\"option\">$name</font>";
if (isAdminLeague($lid, ADD_TEAM) and $disp) {
$str .= " [ <a href=\"modules.php?name=League&file=admin&op=add_team&did=$did&lid=$lid&sid=$sid\">" . _ADDTEAM . "</a> | <a href=\"modules.php?name=League&file=admin&op=recreate_standings_ok&sid=$sid&lid=$lid\">" . _RECREATESTANDING . "</a> | <a href=\"modules.php?name=League&file=admin&op=recalc_standings&sid=$sid&lid=$lid\">" . _RECALCSTANDING . "</a>] ";
$plugin = new Plugins($lid);
echo $plugin->getLinks(PLUGIN_STANDINGS_DIVISION);
}
$str .= "</td></tr>";
$str .= "<tr><td bgcolor=\"$bgcolor2\"</td><td bgcolor=\"$bgcolor2\" align=\"left\" width=\"36%\"><b>" . _TEAMNAME . "</b></td>";
$standings = new Standings($lid);
$maxcol = $standings->size();
while (($lheader = $standings->headings())) {
$str .= "<td bgcolor=\"$bgcolor2\" align=\"center\"><b>$lheader</b></td>";
}
if ($disp)
$str .= "<td bgcolor=\"$bgcolor2\"> </td>";
$str .= "</tr>";
$p=1;
$standings->select($did, $sid);
while ($standings->fetchRow()) {
$tid = $standings->tid();
if ($bgcolor=="")
$bgcolor="$color";
else
$bgcolor="";
$str .= "<tr $bgcolor>"
. "<td align=\"right\" width=\"3%\">$p.</td>"
. "<td align=\"left\" nowrap width=\"36%\">";
$str .= getTeamNamewithURL($tid, "modules.php?name=League&file=index&op=team&tid=$tid&sid=$sid&lid=$lid&did=$did ") . "<i> (" . getManagerNamesaison($tid, $sid) .") </i></td>";
for ($i=0; $i < $standings->size(); $i++) {
$pos = $standings->position($i);
$value = $standings->fetchRowValue();
if ($pos != "")
$value=$pos;
$str .= "<td nowrap align=\"center\" nowrap>$value</td>";
}
if (isAdminLeague($lid, REMOVE_TEAM) and $disp) {
$str .= "<td><a href=\"modules.php?name=League&file=admin&op=del_team&tid=$tid&lid=$lid&did=$did&sid=$sid\" title=\"" . _REMOVE . "\"><img src=\"modules/League/images/remove.gif\" border=\"0\" width=\"11\" height=\"11\"></a></td>";
}
$str .= "</tr>";
$p++;
}
$str .= "</table>";
return $str;
}
[/php]
[b]et voila la fonction qui fait appel a cette fonction [/b]
[php]
function display_standings($lid, $sid=0) {
global $db, $prefix;
include("header.php");
$sid = zeroIfBlank($sid);
validateNumForError($lid);
validateNumForError($sid);
$prefs = getLeaguePrefs($lid);
if ($sid == 0)
$where = $prefix . "_league.curr_sid = " . $prefix . "_league_season.id";
else
$where = $prefix . "_league_season.id = $sid";
$result = $db->sql_query("select " . $prefix . "_league.name, " . $prefix . "_league_season.id," . $prefix . "_league_season.name, tournament from " . $prefix . "_league," . $prefix . "_league_season where " . $prefix . "_league.id = " . $prefix . "_league_season.lid and " . $prefix . "_league.id = $lid and $where");
list($name, $sid, $season, $tournament) = $db->sql_fetchrow($result);
if ($sid == "") {
OpenTable();
echo "<center><b>" . _SEASONNOTSET . "</b></center>";
CloseTable();
}
else if ($tournament) {
title(_TOURNAMENT . " - " . stripslashes($name) . " - " . stripslashes($season));
display_tournament($sid, $lid, "show_round", 0, 0);
}
else {
title(_STANDINGS . " - " . stripslashes($name) . " - " . stripslashes($season));
OpenTable2();
echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">" ;
$season_selector = display_season_selector($lid, $sid);
if ($season_selector != "") {
echo "<tr><td align=\"right\">";
$plugin = new Plugins($lid);
echo $plugin->getLinks(PLUGIN_STANDINGS) . " ";
echo $season_selector;
echo "</td>";
echo "</tr>";
echo "<tr><td><img src=\"modules/League/images/spacer.gif\" border=\"0\" height=\"6\"></td></tr>";
}
$result = $db->sql_query("select " . $prefix . "_league_division.id, name from " . $prefix . "_league_division, " . $prefix . "_league_division_seasons where " . $prefix . "_league_division.id = did and tour = 0 and sid = $sid and lid = $lid order by position");
while (list($did, $name) = $db->sql_fetchrow($result)) {
echo "<tr><td>";
OpenTable();
echo display_division_table($did, stripslashes($name), $sid, $lid);
CloseTable();
echo "</td></tr>";
}
echo "</table>";
CloseTable2();
}
LeagueFooter($prefs[rightblock], $lid);
}
display_standings($lid, $sid);
[/php]
[b]Etant debutant j'ai du mal a tout decrypter dans ce code, mais s'il vous faut d'autre fonction, partie de code, demandez :)[/b]
Merci
jimmy