mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 01:09:21 +02:00
Move lastkills/killstatistics to twig template
This commit is contained in:
parent
1859867039
commit
276f3a5516
@ -11,26 +11,26 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Last Kills';
|
||||
|
||||
$deaths_list = array();
|
||||
$players_deaths_count = 0;
|
||||
$players_rows = '';
|
||||
|
||||
$tmp = null;
|
||||
if($cache->enabled() && $cache->fetch('lastkills', $tmp)) {
|
||||
$tmp = unserialize($tmp);
|
||||
$players_rows = $tmp['rows'];
|
||||
$players_deaths_count = $tmp['count'];
|
||||
$deaths_list = $tmp['deaths_list'];
|
||||
}
|
||||
else {
|
||||
if($db->hasTable('player_killers')) // tfs 0.3
|
||||
{
|
||||
$players_deaths = $db->query('SELECT `player_deaths`.`id`, `player_deaths`.`date`, `player_deaths`.`level`, `players`.`name`' . ($db->hasColumn('players', 'world_id') ? ', `players`.`world_id`' : '') . ' FROM `player_deaths` LEFT JOIN `players` ON `player_deaths`.`player_id` = `players`.`id` ORDER BY `date` DESC LIMIT 0, ' . $config['last_kills_limit']);
|
||||
|
||||
if(!empty($players_deaths)) {
|
||||
foreach($players_deaths as $death) {
|
||||
$players_rows .= '<TR BGCOLOR="' . getStyle($players_deaths_count++) . '"><TD WIDTH="30"><div style="text-align:center">' . $players_deaths_count . '.</div></TD><TD WIDTH="125"><small>' . date("j.m.Y, G:i:s", $death['date']) . '</small></TD><TD>' . getPlayerLink($death['name']) . ' ';
|
||||
$killers = $db->query("SELECT environment_killers.name AS monster_name, players.name AS player_name, players.deleted AS player_exists
|
||||
FROM killers LEFT JOIN environment_killers ON killers.id = environment_killers.kill_id
|
||||
LEFT JOIN player_killers ON killers.id = player_killers.kill_id LEFT JOIN players ON players.id = player_killers.player_id
|
||||
WHERE killers.death_id = '" . $death['id'] . "' ORDER BY killers.final_hit DESC, killers.id ASC")->fetchAll();
|
||||
$players_deaths_count++;
|
||||
$killers_string = getPlayerLink($death['name']) . ' ';
|
||||
$killer_name = '';
|
||||
|
||||
$killers = $db->query("SELECT environment_killers.name AS monster_name, players.name AS player_name, players.deleted AS player_exists FROM killers LEFT JOIN environment_killers ON killers.id = environment_killers.kill_id LEFT JOIN player_killers ON killers.id = player_killers.kill_id LEFT JOIN players ON players.id = player_killers.player_id WHERE killers.death_id = '" . $death['id'] . "' ORDER BY killers.final_hit DESC, killers.id ASC")->fetchAll();
|
||||
|
||||
$i = 0;
|
||||
$count = count($killers);
|
||||
@ -39,72 +39,78 @@ else {
|
||||
if($killer['player_name'] != "") {
|
||||
if($i == 1) {
|
||||
if($count <= 4)
|
||||
$players_rows .= 'killed';
|
||||
$killers_string .= 'killed';
|
||||
else if($count > 4 and $count < 10)
|
||||
$players_rows .= 'slain';
|
||||
$killers_string .= 'slain';
|
||||
else if($count > 9 and $count < 15)
|
||||
$players_rows .= 'crushed';
|
||||
$killers_string .= 'crushed';
|
||||
else if($count > 14 and $count < 20)
|
||||
$players_rows .= 'eliminated';
|
||||
$killers_string .= 'eliminated';
|
||||
else if($count > 19)
|
||||
$players_rows .= 'annihilated';
|
||||
|
||||
$players_rows .= 'at level <b>' . $death['level'] . '</b> by ';
|
||||
$killers_string .= 'annihilated';
|
||||
$killers_string .= ' at level <b>' . $death['level'] . '</b> ';
|
||||
} else if($i == $count)
|
||||
$players_rows .= ' and';
|
||||
$killers_string .= ' and';
|
||||
else
|
||||
$players_rows .= ',';
|
||||
$killers_string .= ',';
|
||||
|
||||
$players_rows .= ' by ';
|
||||
$killers_string .= ' by ';
|
||||
if($killer['monster_name'] != '')
|
||||
$players_rows .= $killer['monster_name'] . ' summoned by ';
|
||||
$killers_string .= $killer['monster_name'] . ' summoned by ';
|
||||
|
||||
if($killer['player_exists'] == 0)
|
||||
$players_rows .= getPlayerLink($killer['player_name']);
|
||||
$killers_string .= getPlayerLink($killer['player_name']);
|
||||
} else {
|
||||
if($i == 1)
|
||||
$players_rows .= 'died at level <b>' . $death['level'] . '</b>';
|
||||
$killers_string .= 'died at level <b>' . $death['level'] . '</b>';
|
||||
else if($i == $count)
|
||||
$players_rows .= ' and';
|
||||
$killers_string .= ' and';
|
||||
else
|
||||
$players_rows .= ',';
|
||||
$killers_string .= ',';
|
||||
|
||||
$players_rows .= ' by ' . $killer['monster_name'];
|
||||
$killers_string .= ' by ' . $killer['monster_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$players_rows .= '.</TD>';
|
||||
if($config['multiworld'])
|
||||
$player_rows .= '<TD>' . $config['worlds'][(int)$death['world_id']] . '</TD>';
|
||||
$killers_string .= '.';
|
||||
|
||||
$players_rows .= '</TR>';
|
||||
$deaths_list[] = array(
|
||||
'id' => $players_deaths_count,
|
||||
'date' => $death['date'],
|
||||
'killers_string' => $killers_string,
|
||||
'world_id' => $config['worlds'][(int)$death['world_id']]
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//$players_deaths = $db->query("SELECT `p`.`name` AS `victim`, `player_deaths`.`killed_by` as `killed_by`, `player_deaths`.`time` as `time`, `player_deaths`.`is_player` as `is_player`, `player_deaths`.`level` as `level` FROM `player_deaths`, `players` as `d` INNER JOIN `players` as `p` ON player_deaths.player_id = p.id WHERE player_deaths.`is_player`='1' ORDER BY `time` DESC LIMIT " . $config['last_kills_limit'] . ";");
|
||||
|
||||
$players_deaths = $db->query("SELECT `p`.`name` AS `victim`, `d`.`killed_by` as `killed_by`, `d`.`time` as `time`, `d`.`level`, `d`.`is_player` FROM `player_deaths` as `d` INNER JOIN `players` as `p` ON d.player_id = p.id ORDER BY `time` DESC LIMIT 20;");
|
||||
|
||||
if(!empty($players_deaths)) {
|
||||
foreach($players_deaths as $death) {
|
||||
$players_rows .= '<TR BGCOLOR="' . getStyle($players_deaths_count++) . '"><TD WIDTH="30"><div style="text-align:center">' . $players_deaths_count . '.</div></TD><TD WIDTH="125"><small>' . date("j.m.Y, G:i:s", $death['time']) . '</small></TD><TD>' . getPlayerLink($death['victim']) . ' died at level ' . $death['level'] . ' by ';
|
||||
$killers_string .= getPlayerLink($death['victim']) . ' died at level ' . $death['level'] . ' by ';
|
||||
if($death['is_player'] == '1')
|
||||
$players_rows .= getPlayerLink($death['killed_by']);
|
||||
$killers_string .= getPlayerLink($death['killed_by']);
|
||||
else
|
||||
$players_rows .= $death['killed_by'];
|
||||
$killers_string .= $death['killed_by'];
|
||||
|
||||
$players_rows .= '.</TR>';
|
||||
$killers_string .= '.';
|
||||
|
||||
$deaths_list[] = array(
|
||||
'id' => $players_deaths_count,
|
||||
'date' => $death['date'],
|
||||
'killers_string' => $killers_string,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($cache->enabled()) {
|
||||
$cache->set('lastkills', serialize(array('rows' => $players_rows, 'count' => $players_deaths_count)), 60);
|
||||
$cache->set('lastkills', serialize(array('deaths_list' => $deaths_list)), 60);
|
||||
}
|
||||
}
|
||||
|
||||
if($players_deaths_count === 0)
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['vdarkborder'].'"><TD class="white"><B>Last Deaths</B></TD></TR><TR BGCOLOR='.$config['darkborder'].'><TD><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1><TR><TD>No one died on '.$config['lua']['serverName'].'.</TD></TR></TABLE></TD></TR></TABLE><BR>';
|
||||
else
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR="'.$config['vdarkborder'].'"><TD class="white"><B>Last Deaths</B></TD></TR></TABLE><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>'.$players_rows.'</TABLE>';
|
||||
?>
|
||||
$twig->display('lastkills.html.twig', array(
|
||||
'lastkills' => $deaths_list
|
||||
));
|
||||
?>
|
49
system/templates/lastkills.html.twig
Normal file
49
system/templates/lastkills.html.twig
Normal file
@ -0,0 +1,49 @@
|
||||
<div class="TableContainer" >
|
||||
<table class="Table1" cellpadding="0" cellspacing="0" >
|
||||
<div class="CaptionContainer" >
|
||||
<div class="CaptionInnerContainer" >
|
||||
<span class="CaptionEdgeLeftTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);" /></span>
|
||||
<span class="CaptionEdgeRightTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);" /></span>
|
||||
<span class="CaptionBorderTop" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);" ></span>
|
||||
<span class="CaptionVerticalLeft" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);" /></span>
|
||||
<div class="Text" >Last Kills</div>
|
||||
<span class="CaptionVerticalRight" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);" /></span>
|
||||
<span class="CaptionBorderBottom" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);" ></span>
|
||||
<span class="CaptionEdgeLeftBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);" /></span>
|
||||
<span class="CaptionEdgeRightBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);" /></span>
|
||||
</div>
|
||||
</div>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="InnerTableContainer" >
|
||||
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
||||
{% if lastkills|length <= 0 %}
|
||||
<td>
|
||||
No one died on {{ config.lua.serverName }}
|
||||
</td>
|
||||
{% else %}
|
||||
{% for lastkill in lastkills %}
|
||||
<tr>
|
||||
<td class="centralizeContent" width="30">
|
||||
{{ lastkill.id }}
|
||||
</td>
|
||||
<td width="125">
|
||||
<small>{{ lastkill.date|date("j.m.Y, G:i:s") }}</small>
|
||||
</td>
|
||||
<td>
|
||||
{{ lastkill.killers_string|raw }}
|
||||
</td>
|
||||
{% if config.multiworld %}
|
||||
<td>
|
||||
{{ lastkill.world_id }}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user