Fixes on new highscores

Fixed link to next page on first visit default highscores
Fixed position of "No records yet."
Also count pages is starting from 1 now (not from 0 like before)
This commit is contained in:
slawkens 2020-12-21 01:54:00 +01:00
parent 6cec5ba5bf
commit c1027d3663
2 changed files with 43 additions and 40 deletions

View File

@ -15,10 +15,14 @@ $configHighscoresCountryBox = config('highscores_country_box');
if(config('account_country') && $configHighscoresCountryBox) if(config('account_country') && $configHighscoresCountryBox)
require SYSTEM . 'countries.conf.php'; require SYSTEM . 'countries.conf.php';
$list = isset($_GET['list']) ? $_GET['list'] : ''; $list = isset($_GET['list']) ? $_GET['list'] : 'experience';
$_page = isset($_GET['page']) ? $_GET['page'] : 0; $_page = isset($_GET['page']) ? $_GET['page'] : 1;
$vocation = isset($_GET['vocation']) ? $_GET['vocation'] : 'all'; $vocation = isset($_GET['vocation']) ? $_GET['vocation'] : 'all';
if(!is_numeric($_page) || $_page < 1 || $_page > PHP_INT_MAX) {
$_page = 1;
}
$add_sql = ''; $add_sql = '';
$configHighscoresVocationBox = config('highscores_vocation_box'); $configHighscoresVocationBox = config('highscores_vocation_box');
@ -146,7 +150,7 @@ if ($cache->enabled()) {
} }
} }
$offset = $_page * $configHighscoresPerPage; $offset = ($_page - 1) * $configHighscoresPerPage;
if (!isset($highscores) || empty($highscores)) { if (!isset($highscores) || empty($highscores)) {
if ($skill >= POT::SKILL_FIRST && $skill <= POT::SKILL_LAST) { // skills if ($skill >= POT::SKILL_FIRST && $skill <= POT::SKILL_LAST) { // skills
if ($db->hasColumn('players', 'skill_fist')) {// tfs 1.0 if ($db->hasColumn('players', 'skill_fist')) {// tfs 1.0
@ -274,14 +278,9 @@ foreach($highscores as $id => &$player)
} }
} }
if(!$i) {
$extra = ($configHighscoresOutfit ? 1 : 0);
echo '<tr bgcolor="' . config('darkborder') . '"><td colspan="' . ($skill == POT::SKILL__LEVEL ? 5 + $extra : 4 + $extra) . '">No records yet.</td></tr>';
}
//link to previous page if actual page is not first //link to previous page if actual page is not first
$linkPreviousPage = ''; $linkPreviousPage = '';
if($_page > 0) { if($_page > 1) {
$linkPreviousPage = getLink('highscores') . '/' . $list . ($vocation !== 'all' ? '/' . $vocation : '') . '/' . ($_page - 1); $linkPreviousPage = getLink('highscores') . '/' . $list . ($vocation !== 'all' ? '/' . $vocation : '') . '/' . ($_page - 1);
} }
@ -291,7 +290,6 @@ if($show_link_to_next_page) {
$linkNextPage = getLink('highscores') . '/' . $list . ($vocation !== 'all' ? '/' . $vocation : '') . '/' . ($_page + 1); $linkNextPage = getLink('highscores') . '/' . $list . ($vocation !== 'all' ? '/' . $vocation : '') . '/' . ($_page + 1);
} }
$types = array( $types = array(
'experience' => 'Experience', 'experience' => 'Experience',
'magic' => 'Magic', 'magic' => 'Magic',
@ -313,6 +311,7 @@ if(config('highscores_balance'))
/** @var Twig\Environment $twig */ /** @var Twig\Environment $twig */
$twig->display('highscores.html.twig', [ $twig->display('highscores.html.twig', [
'highscores' => $highscores, 'highscores' => $highscores,
'totalRows' => $i - 1,
'list' => $list, 'list' => $list,
'skill' => $skill, 'skill' => $skill,
'skillName' => ($skill == SKILL_FRAGS ? 'Frags' : ($skill == SKILL_BALANCE ? 'Balance' : getSkillName($skill))), 'skillName' => ($skill == SKILL_FRAGS ? 'Frags' : ($skill == SKILL_BALANCE ? 'Balance' : getSkillName($skill))),

View File

@ -25,39 +25,43 @@
{% endif %} {% endif %}
</tr> </tr>
{% set row = 0 %} {% if totalRows < 1 %}
{% for player in highscores %} <tr bgcolor="{{ config('darkborder') }}"><td colspan="100%">No records yet.</td></tr>
<tr bgcolor="{{ getStyle(row) }}"> {% else %}
{% set row = row + 1 %} {% set row = 0 %}
{% for player in highscores %}
<tr bgcolor="{{ getStyle(row) }}">
{% set row = row + 1 %}
{% if config.account_country %} {% if config.account_country %}
<td>{{ player.flag|raw }}</td> <td>{{ player.flag|raw }}</td>
{% endif %}
<td>{{ player.rank }}.</td>
{% if config.highscores_outfit %}
<td>{{ player.outfit|raw }}</td>
{% endif %}
<td>
<a href="{{ player.link }}">
<span style="color: {% if player.online > 0 %}green{% else %}red{% endif %}">{{ player.name }}</span>
</a>
{% if config.highscores_vocation %}
<br/><small>{{ player.vocation }}</small>
{% endif %} {% endif %}
</td>
<td> <td>{{ player.rank }}.</td>
<div style="text-align:center">{{ player.value }}</div>
</td>
{% if skill == constant('POT::SKILL__LEVEL') %} {% if config.highscores_outfit %}
<td><div style="text-align:center">{{ player.experience }}</div></td> <td>{{ player.outfit|raw }}</td>
{% endif %} {% endif %}
</tr>
{% endfor %} <td>
<a href="{{ player.link }}">
<span style="color: {% if player.online > 0 %}green{% else %}red{% endif %}">{{ player.name }}</span>
</a>
{% if config.highscores_vocation %}
<br/><small>{{ player.vocation }}</small>
{% endif %}
</td>
<td>
<div style="text-align:center">{{ player.value }}</div>
</td>
{% if skill == constant('POT::SKILL__LEVEL') %}
<td><div style="text-align:center">{{ player.experience }}</div></td>
{% endif %}
</tr>
{% endfor %}
{% endif %}
</table> </table>
<table border="0" cellpadding="4" cellspacing="1" width="100%"> <table border="0" cellpadding="4" cellspacing="1" width="100%">
{% if linkPreviousPage|length > 0 %} {% if linkPreviousPage|length > 0 %}
@ -102,4 +106,4 @@
</td> </td>
<td style="width: 18px"></td> <td style="width: 18px"></td>
</tr> </tr>
</table> </table>