Autosave: 20260409-023612
This commit is contained in:
parent
a528142c4f
commit
2944f9f509
146
scmining.php
146
scmining.php
@ -31,6 +31,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
// Add mineral to list
|
// Add mineral to list
|
||||||
if ($action === 'add_mineral') {
|
if ($action === 'add_mineral') {
|
||||||
$obj_id = (int)$_POST['obj_id'];
|
$obj_id = (int)$_POST['obj_id'];
|
||||||
|
$return_search = trim($_POST['return_search'] ?? '');
|
||||||
|
$return_page = max(1, (int)($_POST['return_page'] ?? 1));
|
||||||
|
|
||||||
if ($obj_id > 0) {
|
if ($obj_id > 0) {
|
||||||
try {
|
try {
|
||||||
$stmt = $db->prepare("INSERT INTO tbl_scmining (cl_scmining_obj_id, cl_scmining_scan_value, cl_scmining_max_occurrence) VALUES (:obj_id, 0, 1)");
|
$stmt = $db->prepare("INSERT INTO tbl_scmining (cl_scmining_obj_id, cl_scmining_scan_value, cl_scmining_max_occurrence) VALUES (:obj_id, 0, 1)");
|
||||||
@ -40,11 +43,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
if ($e->getCode() == 23000) {
|
if ($e->getCode() == 23000) {
|
||||||
auth_flash_set('error', 'Ce minéral est déjà dans la liste.');
|
auth_flash_set('error', 'Ce minéral est déjà dans la liste.');
|
||||||
} else {
|
} else {
|
||||||
auth_flash_set('error', 'Erreur lors de l\'ajout : ' . $e->getMessage());
|
auth_flash_set('error', "Erreur lors de l'ajout : " . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header('Location: scmining.php');
|
header('Location: ' . scmining_search_url($return_search, $return_page));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,33 +88,72 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search for adding items
|
// Search for adding items
|
||||||
function sc_rarity_label(?string $rarity): string
|
function sc_normalize_rarity(?string $rarity): string
|
||||||
{
|
{
|
||||||
return match ($rarity) {
|
return strtoupper(trim((string) $rarity));
|
||||||
'L' => 'Legendary',
|
|
||||||
'E' => 'Epic',
|
|
||||||
'R' => 'Rare',
|
|
||||||
'U' => 'Uncommon',
|
|
||||||
'C' => 'Common',
|
|
||||||
default => 'Non définie',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sc_rarity_class(?string $rarity): string
|
function sc_rarity_class(?string $rarity): string
|
||||||
{
|
{
|
||||||
|
$rarity = sc_normalize_rarity($rarity);
|
||||||
|
|
||||||
return in_array($rarity, ['L', 'E', 'R', 'U', 'C'], true) ? 'rarity-' . $rarity : 'rarity-none';
|
return in_array($rarity, ['L', 'E', 'R', 'U', 'C'], true) ? 'rarity-' . $rarity : 'rarity-none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sc_rarity_style(?string $rarity): string
|
||||||
|
{
|
||||||
|
return match (sc_normalize_rarity($rarity)) {
|
||||||
|
'L' => 'color:#ff8000 !important;text-shadow:0 0 10px rgba(255,128,0,0.3);',
|
||||||
|
'E' => 'color:#a335ee !important;text-shadow:0 0 10px rgba(163,53,238,0.3);',
|
||||||
|
'R' => 'color:#0070dd !important;text-shadow:0 0 10px rgba(0,112,221,0.3);',
|
||||||
|
'U' => 'color:#1eff00 !important;text-shadow:0 0 10px rgba(30,255,0,0.3);',
|
||||||
|
'C' => 'color:#ffffff !important;',
|
||||||
|
default => 'color:#8f96a3 !important;',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function scmining_search_url(string $search = '', int $page = 1): string
|
||||||
|
{
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
if ($search !== '') {
|
||||||
|
$params['search'] = $search;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($page > 1) {
|
||||||
|
$params['search_page'] = $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'scmining.php' . ($params ? '?' . http_build_query($params) : '');
|
||||||
|
}
|
||||||
|
|
||||||
$search = isset($_GET['search']) ? trim($_GET['search']) : '';
|
$search = isset($_GET['search']) ? trim($_GET['search']) : '';
|
||||||
|
$search_page = max(1, (int)($_GET['search_page'] ?? 1));
|
||||||
|
$search_per_page = 10;
|
||||||
$search_results = [];
|
$search_results = [];
|
||||||
|
$search_total_results = 0;
|
||||||
|
$search_total_pages = 0;
|
||||||
|
|
||||||
if ($search !== '') {
|
if ($search !== '') {
|
||||||
$stmt_search = $db->prepare("SELECT * FROM tbl_scobjs WHERE cl_scobjs_name LIKE :search AND cl_scobjs_id NOT IN (SELECT cl_scmining_obj_id FROM tbl_scmining) ORDER BY cl_scobjs_name ASC LIMIT 10");
|
$search_where = "FROM tbl_scobjs WHERE cl_scobjs_name LIKE :search AND cl_scobjs_id NOT IN (SELECT cl_scmining_obj_id FROM tbl_scmining)";
|
||||||
$stmt_search->execute(['search' => "%$search%"]);
|
|
||||||
|
$stmt_search_count = $db->prepare("SELECT COUNT(*) " . $search_where);
|
||||||
|
$stmt_search_count->execute(['search' => "%$search%"]);
|
||||||
|
$search_total_results = (int)$stmt_search_count->fetchColumn();
|
||||||
|
$search_total_pages = max(1, (int)ceil($search_total_results / $search_per_page));
|
||||||
|
$search_page = min($search_page, $search_total_pages);
|
||||||
|
$search_offset = ($search_page - 1) * $search_per_page;
|
||||||
|
|
||||||
|
$stmt_search = $db->prepare("SELECT * " . $search_where . " ORDER BY cl_scobjs_name ASC, cl_scobjs_id ASC LIMIT :limit OFFSET :offset");
|
||||||
|
$stmt_search->bindValue(':search', "%$search%", PDO::PARAM_STR);
|
||||||
|
$stmt_search->bindValue(':limit', $search_per_page, PDO::PARAM_INT);
|
||||||
|
$stmt_search->bindValue(':offset', $search_offset, PDO::PARAM_INT);
|
||||||
|
$stmt_search->execute();
|
||||||
$search_results = $stmt_search->fetchAll();
|
$search_results = $stmt_search->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch current mining list
|
// Fetch current mining list
|
||||||
$sql_list = "SELECT m.*, o.cl_scobjs_name, o.cl_scobjs_uuid, o.cl_scobjs_type, o.cl_scobjs_subtype
|
$sql_list = "SELECT m.*, o.cl_scobjs_name, o.cl_scobjs_uuid, o.cl_scobjs_type, o.cl_scobjs_subtype, o.cl_scobjs_rarity
|
||||||
FROM tbl_scmining m
|
FROM tbl_scmining m
|
||||||
JOIN tbl_scobjs o ON m.cl_scmining_obj_id = o.cl_scobjs_id
|
JOIN tbl_scobjs o ON m.cl_scmining_obj_id = o.cl_scobjs_id
|
||||||
ORDER BY o.cl_scobjs_name ASC";
|
ORDER BY o.cl_scobjs_name ASC";
|
||||||
@ -228,6 +270,12 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
box-shadow: 0 0 15px var(--primary-glow);
|
box-shadow: 0 0 15px var(--primary-glow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-modern.active {
|
||||||
|
background: var(--primary);
|
||||||
|
color: var(--bg-dark);
|
||||||
|
box-shadow: 0 0 15px var(--primary-glow);
|
||||||
|
}
|
||||||
|
|
||||||
.btn-modern.danger { border-color: var(--danger); color: var(--danger); }
|
.btn-modern.danger { border-color: var(--danger); color: var(--danger); }
|
||||||
.btn-modern.danger:hover { background: var(--danger); color: #fff; }
|
.btn-modern.danger:hover { background: var(--danger); color: #fff; }
|
||||||
|
|
||||||
@ -314,22 +362,25 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
.search-result-info { flex: 1; }
|
.search-result-info { flex: 1; }
|
||||||
.search-result-name { display: block; color: var(--primary); font-weight: bold; }
|
.search-result-name { display: block; color: var(--primary); font-weight: bold; }
|
||||||
.search-result-meta { display: block; font-size: 0.75rem; color: #888; }
|
.search-result-meta { display: block; font-size: 0.75rem; color: #888; }
|
||||||
.search-result-rarity {
|
.search-results-summary {
|
||||||
display: inline-flex;
|
margin-bottom: 1rem;
|
||||||
align-items: center;
|
font-size: 0.8rem;
|
||||||
gap: 0.35rem;
|
color: #9a9a9a;
|
||||||
margin-top: 0.4rem;
|
|
||||||
font-size: 0.72rem;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.08em;
|
|
||||||
}
|
}
|
||||||
.search-result-rarity::before {
|
.pagination-controls {
|
||||||
content: '';
|
display: flex;
|
||||||
width: 8px;
|
flex-wrap: wrap;
|
||||||
height: 8px;
|
align-items: center;
|
||||||
border-radius: 50%;
|
gap: 8px;
|
||||||
background: currentColor;
|
margin-top: 1rem;
|
||||||
box-shadow: 0 0 8px currentColor;
|
}
|
||||||
|
.pagination-controls .btn-modern {
|
||||||
|
min-width: 42px;
|
||||||
|
}
|
||||||
|
.pagination-status {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #9a9a9a;
|
||||||
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rarity-L { color: var(--rarity-L) !important; text-shadow: 0 0 10px rgba(255, 128, 0, 0.3); }
|
.rarity-L { color: var(--rarity-L) !important; text-shadow: 0 0 10px rgba(255, 128, 0, 0.3); }
|
||||||
@ -409,27 +460,54 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
<?php if (empty($search_results)): ?>
|
<?php if (empty($search_results)): ?>
|
||||||
<p style="text-align: center; color: #666;">Aucun objet non listé trouvé.</p>
|
<p style="text-align: center; color: #666;">Aucun objet non listé trouvé.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
<?php $search_first_result = (($search_page - 1) * $search_per_page) + 1; ?>
|
||||||
|
<?php $search_last_result = min($search_total_results, $search_first_result + count($search_results) - 1); ?>
|
||||||
|
<div class="search-results-summary">
|
||||||
|
Résultats <?php echo $search_first_result; ?> à <?php echo $search_last_result; ?> sur <?php echo $search_total_results; ?> — page <?php echo $search_page; ?>/<?php echo $search_total_pages; ?>
|
||||||
|
</div>
|
||||||
<?php foreach ($search_results as $res):
|
<?php foreach ($search_results as $res):
|
||||||
if (is_array($res) && isset($res['cl_scobjs_uuid']) && isset($res['cl_scobjs_name']) && isset($res['cl_scobjs_type']) && isset($res['cl_scobjs_subtype']) && isset($res['cl_scobjs_id'])) {
|
if (is_array($res) && isset($res['cl_scobjs_uuid']) && isset($res['cl_scobjs_name']) && isset($res['cl_scobjs_type']) && isset($res['cl_scobjs_subtype']) && isset($res['cl_scobjs_id'])) {
|
||||||
$rarity_code = $res['cl_scobjs_rarity'] ?? '';
|
$rarity_code = $res['cl_scobjs_rarity'] ?? '';
|
||||||
$rarity_class = sc_rarity_class($rarity_code);
|
$rarity_class = sc_rarity_class($rarity_code);
|
||||||
$rarity_label = sc_rarity_label($rarity_code);
|
|
||||||
?>
|
?>
|
||||||
<div class="search-result-item">
|
<div class="search-result-item">
|
||||||
<img src="https://cstone.space/uifimages/<?php echo $res['cl_scobjs_uuid']; ?>.png" class="item-preview" alt="">
|
<img src="https://cstone.space/uifimages/<?php echo $res['cl_scobjs_uuid']; ?>.png" class="item-preview" alt="">
|
||||||
<div class="search-result-info">
|
<div class="search-result-info">
|
||||||
<span class="search-result-name <?php echo htmlspecialchars($rarity_class); ?>"><?php echo htmlspecialchars($res['cl_scobjs_name']); ?></span>
|
<span class="search-result-name <?php echo htmlspecialchars($rarity_class); ?>" style="<?php echo htmlspecialchars(sc_rarity_style($rarity_code)); ?>"><?php echo htmlspecialchars($res['cl_scobjs_name']); ?></span>
|
||||||
<span class="search-result-meta"><?php echo htmlspecialchars($res['cl_scobjs_type']); ?> / <?php echo htmlspecialchars($res['cl_scobjs_subtype']); ?></span>
|
<span class="search-result-meta"><?php echo htmlspecialchars($res['cl_scobjs_type']); ?> / <?php echo htmlspecialchars($res['cl_scobjs_subtype']); ?></span>
|
||||||
<span class="search-result-rarity <?php echo htmlspecialchars($rarity_class); ?>">Rareté : <?php echo htmlspecialchars($rarity_label); ?></span>
|
|
||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token); ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrf_token); ?>">
|
||||||
<input type="hidden" name="action" value="add_mineral">
|
<input type="hidden" name="action" value="add_mineral">
|
||||||
<input type="hidden" name="obj_id" value="<?php echo $res['cl_scobjs_id']; ?>">
|
<input type="hidden" name="obj_id" value="<?php echo $res['cl_scobjs_id']; ?>">
|
||||||
|
<input type="hidden" name="return_search" value="<?php echo htmlspecialchars($search); ?>">
|
||||||
|
<input type="hidden" name="return_page" value="<?php echo $search_page; ?>">
|
||||||
<button type="submit" class="btn-modern btn-mini">+</button>
|
<button type="submit" class="btn-modern btn-mini">+</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<?php } endforeach; ?>
|
<?php } endforeach; ?>
|
||||||
|
|
||||||
|
<?php if ($search_total_pages > 1): ?>
|
||||||
|
<?php
|
||||||
|
$page_window_start = max(1, $search_page - 2);
|
||||||
|
$page_window_end = min($search_total_pages, $search_page + 2);
|
||||||
|
?>
|
||||||
|
<div class="pagination-controls">
|
||||||
|
<?php if ($search_page > 1): ?>
|
||||||
|
<a href="<?php echo htmlspecialchars(scmining_search_url($search, $search_page - 1)); ?>" class="btn-modern btn-mini">«</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php for ($page_number = $page_window_start; $page_number <= $page_window_end; $page_number++): ?>
|
||||||
|
<a href="<?php echo htmlspecialchars(scmining_search_url($search, $page_number)); ?>" class="btn-modern btn-mini<?php echo $page_number === $search_page ? ' active' : ''; ?>"><?php echo $page_number; ?></a>
|
||||||
|
<?php endfor; ?>
|
||||||
|
|
||||||
|
<?php if ($search_page < $search_total_pages): ?>
|
||||||
|
<a href="<?php echo htmlspecialchars(scmining_search_url($search, $search_page + 1)); ?>" class="btn-modern btn-mini">»</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<span class="pagination-status">Navigation des homonymes activée</span>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@ -458,13 +536,15 @@ $current_session_user = $_SESSION['user'] ?? '';
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php foreach ($mining_list as $item):
|
<?php foreach ($mining_list as $item):
|
||||||
if (is_array($item) && isset($item['cl_scobjs_uuid']) && isset($item['cl_scobjs_name']) && isset($item['cl_scobjs_type']) && isset($item['cl_scobjs_subtype']) && isset($item['cl_scmining_id']) && isset($item['cl_scmining_scan_value']) && isset($item['cl_scmining_max_occurrence'])) {
|
if (is_array($item) && isset($item['cl_scobjs_uuid']) && isset($item['cl_scobjs_name']) && isset($item['cl_scobjs_type']) && isset($item['cl_scobjs_subtype']) && isset($item['cl_scmining_id']) && isset($item['cl_scmining_scan_value']) && isset($item['cl_scmining_max_occurrence'])) {
|
||||||
|
$rarity_code = $item['cl_scobjs_rarity'] ?? '';
|
||||||
|
$rarity_class = sc_rarity_class($rarity_code);
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<img src="https://cstone.space/uifimages/<?php echo $item['cl_scobjs_uuid']; ?>.png" class="item-preview" alt="">
|
<img src="https://cstone.space/uifimages/<?php echo $item['cl_scobjs_uuid']; ?>.png" class="item-preview" alt="">
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<strong style="color: var(--primary);"><?php echo htmlspecialchars($item['cl_scobjs_name']); ?></strong><br>
|
<strong class="<?php echo htmlspecialchars($rarity_class); ?>" style="<?php echo htmlspecialchars(sc_rarity_style($rarity_code)); ?>"><?php echo htmlspecialchars($item['cl_scobjs_name']); ?></strong><br>
|
||||||
<span style="font-size: 0.75rem; color: #888;"><?php echo htmlspecialchars($item['cl_scobjs_type']); ?> / <?php echo htmlspecialchars($item['cl_scobjs_subtype']); ?></span>
|
<span style="font-size: 0.75rem; color: #888;"><?php echo htmlspecialchars($item['cl_scobjs_type']); ?> / <?php echo htmlspecialchars($item['cl_scobjs_subtype']); ?></span>
|
||||||
</td>
|
</td>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user