mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
524b9e7edd
On a fresh install several strings were still hardcoded in English (reported on the live server, RO locale): - statistiken.php: the page <title>, the <h1> and the tab bar (Player / Alliances / Villages / Heroes / General) were literal English. - Templates/Ranking/ranksearch.tpl: the "back | forward" pagination links. - Templates/troops.tpl: the "Hero" troop-row label. Wire them to language constants. Reuse existing ones (STATISTICS, PLAYER, PLAYERS, VILLAGES, BACK, FORWARD, U0) and add three new constants (ALLIANCES, HEROES, GENERAL) to en/fr/ro. WW is kept as-is (universal acronym). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
138 lines
3.7 KiB
Smarty
138 lines
3.7 KiB
Smarty
<?php
|
|
#################################################################################
|
|
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
|
## --------------------------------------------------------------------------- ##
|
|
## Filename troops.tpl ##
|
|
## Developed by: Dzoki ##
|
|
## Refactored by: Shadow Incremental Refactor ##
|
|
## License: TravianZ Project ##
|
|
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
|
## ##
|
|
## Incremental Refactor Notes: ##
|
|
## - Preserved original functionality ##
|
|
## - Reduced repeated method calls for unit names ##
|
|
## - Added small safety guards for legacy PHP ##
|
|
## - Improved readability ##
|
|
## ##
|
|
#################################################################################
|
|
?>
|
|
|
|
<table id="troops" cellpadding="1" cellspacing="1">
|
|
|
|
<thead>
|
|
<tr>
|
|
<th colspan="3">
|
|
<?php echo TROOPS; ?>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<?php
|
|
/**
|
|
* ---------------------------------------------------------
|
|
* Load all village troops
|
|
* ---------------------------------------------------------
|
|
*/
|
|
$troops = $technology->getAllUnits($village->wid, true, 1);
|
|
|
|
/**
|
|
* Cache unit list to avoid repeated calls
|
|
*/
|
|
$unitNameCache = array();
|
|
|
|
$troopsPresent = false;
|
|
|
|
/**
|
|
* ---------------------------------------------------------
|
|
* Loop all possible units (Travian standard max 50)
|
|
* ---------------------------------------------------------
|
|
*/
|
|
for ($i = 1; $i <= 50; $i++) {
|
|
|
|
$unitKey = 'u' . $i;
|
|
|
|
if (!empty($troops[$unitKey])) {
|
|
|
|
/**
|
|
* Cache unit name (avoid repeated calls)
|
|
*/
|
|
if (!isset($unitNameCache[$i])) {
|
|
$unitNameCache[$i] = $technology->getUnitName($i);
|
|
}
|
|
|
|
$unitName = $unitNameCache[$i];
|
|
|
|
echo '
|
|
<tr>
|
|
<td class="ico">
|
|
<a href="build.php?id=39">
|
|
<img
|
|
class="unit u' . $i . '"
|
|
src="img/x.gif"
|
|
alt="' . $unitName . '"
|
|
title="' . $unitName . '"
|
|
/>
|
|
</a>
|
|
</td>
|
|
|
|
<td class="num">
|
|
' . $troops[$unitKey] . '
|
|
</td>
|
|
|
|
<td class="un">
|
|
' . $unitName . '
|
|
</td>
|
|
</tr>';
|
|
|
|
$troopsPresent = true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* ---------------------------------------------------------
|
|
* Hero handling
|
|
* ---------------------------------------------------------
|
|
*/
|
|
if (!empty($troops['hero'])) {
|
|
|
|
echo '
|
|
<tr>
|
|
<td class="ico">
|
|
<a href="build.php?id=39">
|
|
<img
|
|
class="unit uhero"
|
|
src="img/x.gif"
|
|
alt="'.U0.'"
|
|
title="'.U0.'"
|
|
/>
|
|
</a>
|
|
</td>
|
|
|
|
<td class="num">
|
|
' . (int)$troops['hero'] . '
|
|
</td>
|
|
|
|
<td class="un">
|
|
' . U0 . '
|
|
</td>
|
|
</tr>';
|
|
|
|
$troopsPresent = true;
|
|
}
|
|
|
|
/**
|
|
* ---------------------------------------------------------
|
|
* Empty state
|
|
* ---------------------------------------------------------
|
|
*/
|
|
if (!$troopsPresent) {
|
|
echo '<tr><td>none</td></tr>';
|
|
}
|
|
?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
</div> |