mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-26 13:17:15 +00:00
Fix autocomplete
Fix autocomplete
This commit is contained in:
@@ -46,8 +46,8 @@ if ($x!== '' && $y!== '' && is_numeric($x) && is_numeric($y)) {
|
||||
$getwref = (int)$database->getVilWref((int)$x, (int)$y);
|
||||
$checkexist = $database->checkVilExist($getwref);
|
||||
} elseif ($dname!== '') {
|
||||
// Preferam satele jucatorului: numele NU sunt unice (vezi getVillageByName).
|
||||
$getwref = (int) $database->getVillageByName($dname, true, (int) ($session->uid ?? 0));
|
||||
// Accepta si formatul dat de autocomplete pentru nume ambigue: "Nume (x|y)".
|
||||
$getwref = (int) $database->resolveVillageInput($dname, (int) ($session->uid ?? 0));
|
||||
$checkexist = $database->checkVilExist($getwref);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,34 @@ if ($acV1 || $acV2 || $acV3) {
|
||||
$acV3
|
||||
);
|
||||
|
||||
echo '<datalist id="dnameSuggest">';
|
||||
foreach ($acNames as $acName) {
|
||||
echo '<option value="' . htmlspecialchars($acName, ENT_QUOTES) . '">';
|
||||
/**
|
||||
* Numele de sate NU sunt unice - cele 13 sate de Minune ale Natarilor se
|
||||
* cheama toate "WW village". Daca sugestia trimite doar numele, cautarea
|
||||
* poate nimeri alt sat, iar resursele pleaca aiurea.
|
||||
*
|
||||
* Asa ca adaugam coordonatele DOAR la numele care apar de mai multe ori.
|
||||
* Numele unice raman curate, deci pentru majoritatea jucatorilor nu se
|
||||
* schimba nimic.
|
||||
*/
|
||||
$acCount = array();
|
||||
|
||||
foreach ($acNames as $acRow) {
|
||||
$acKey = $acRow['name'];
|
||||
$acCount[$acKey] = isset($acCount[$acKey]) ? $acCount[$acKey] + 1 : 1;
|
||||
}
|
||||
|
||||
echo '<datalist id="dnameSuggest">';
|
||||
|
||||
foreach ($acNames as $acRow) {
|
||||
$acValue = $acRow['name'];
|
||||
|
||||
if ($acCount[$acRow['name']] > 1) {
|
||||
$acValue .= ' (' . (int) $acRow['x'] . '|' . (int) $acRow['y'] . ')';
|
||||
}
|
||||
|
||||
echo '<option value="' . htmlspecialchars($acValue, ENT_QUOTES) . '">';
|
||||
}
|
||||
|
||||
echo '</datalist>';
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user