Autosave: 20260419-012627

This commit is contained in:
Flatlogic Bot 2026-04-19 01:26:27 +00:00
parent 4c879b508b
commit ffbb7a96d6
5 changed files with 120 additions and 32 deletions

View File

@ -53,6 +53,7 @@ CREATE TABLE `tbl_scobjs` (
`cl_scobjs_uuid` varchar(100) NOT NULL,
`cl_scobjs_rarity` varchar(10) DEFAULT '',
`cl_scobjs_about` text DEFAULT NULL,
`cl_scobjs_description` text DEFAULT NULL,
PRIMARY KEY (`cl_scobjs_id`),
UNIQUE KEY `cl_scobjs_uuid` (`cl_scobjs_uuid`)
) ENGINE=InnoDB AUTO_INCREMENT=18305 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

View File

@ -125,6 +125,7 @@ CREATE TABLE `tbl_scobjs` (
`cl_scobjs_uuid` varchar(100) NOT NULL,
`cl_scobjs_rarity` varchar(10) DEFAULT '',
`cl_scobjs_about` text DEFAULT NULL,
`cl_scobjs_description` text DEFAULT NULL,
PRIMARY KEY (`cl_scobjs_id`),
UNIQUE KEY `cl_scobjs_uuid` (`cl_scobjs_uuid`)
) ENGINE=InnoDB AUTO_INCREMENT=18305 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

45
db/scitems.php Normal file
View File

@ -0,0 +1,45 @@
<?php
require_once __DIR__ . '/config.php';
function scitems_column_exists(PDO $db, string $table, string $column): bool
{
$stmt = $db->query("SHOW COLUMNS FROM `{$table}` LIKE " . $db->quote($column));
return (bool) $stmt->fetch();
}
function scitems_bootstrap(): void
{
static $bootstrapped = false;
if ($bootstrapped) {
return;
}
$db = db();
$db->exec(
"CREATE TABLE IF NOT EXISTS tbl_scobjs (
cl_scobjs_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
cl_scobjs_name VARCHAR(255) NOT NULL,
cl_scobjs_type VARCHAR(100) DEFAULT NULL,
cl_scobjs_subtype VARCHAR(100) DEFAULT NULL,
cl_scobjs_uuid VARCHAR(100) NOT NULL,
cl_scobjs_rarity VARCHAR(10) DEFAULT '',
cl_scobjs_about TEXT DEFAULT NULL,
cl_scobjs_description TEXT DEFAULT NULL,
PRIMARY KEY (cl_scobjs_id),
UNIQUE KEY cl_scobjs_uuid (cl_scobjs_uuid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
);
if (!scitems_column_exists($db, 'tbl_scobjs', 'cl_scobjs_description')) {
$db->exec(
'ALTER TABLE tbl_scobjs
ADD COLUMN cl_scobjs_description TEXT DEFAULT NULL AFTER cl_scobjs_about'
);
}
$bootstrapped = true;
}

View File

@ -55,6 +55,20 @@ function index_itemcustom_stat_preview(?string $sign, $value, ?string $unit): st
return trim($prefix . $displayValue . ($displayUnit !== '' ? ' ' . $displayUnit : ''));
}
function index_vanilla_description_html(?string $description): string
{
$description = trim((string) $description);
if ($description === '') {
return '<span class="vanilla-db-muted">Aucune description.</span>';
}
if ($description !== strip_tags($description)) {
return $description;
}
return nl2br(htmlspecialchars($description, ENT_QUOTES, 'UTF-8'));
}
auth_start_session();
auth_bootstrap();
@ -306,6 +320,7 @@ if ($has_vanilla_db_access) {
OR cl_scobjs_subtype LIKE :vanilla_search
OR cl_scobjs_uuid LIKE :vanilla_search
OR cl_scobjs_rarity LIKE :vanilla_search
OR cl_scobjs_description LIKE :vanilla_search
)";
$vanilla_db_bindings[':vanilla_search'] = '%' . $vanilla_db_search . '%';
}
@ -326,7 +341,7 @@ if ($has_vanilla_db_access) {
$vanilla_db_offset = ($vanilla_db_current_page - 1) * $vanilla_db_per_page;
$stmt_vanilla_db = $db->prepare(
"SELECT cl_scobjs_id, cl_scobjs_name, cl_scobjs_type, cl_scobjs_subtype, cl_scobjs_uuid, cl_scobjs_rarity
"SELECT cl_scobjs_id, cl_scobjs_name, cl_scobjs_type, cl_scobjs_subtype, cl_scobjs_uuid, cl_scobjs_rarity, cl_scobjs_description
FROM tbl_scobjs" . $vanilla_db_where_sql . "
ORDER BY cl_scobjs_name ASC, cl_scobjs_type ASC, cl_scobjs_subtype ASC, cl_scobjs_id ASC
LIMIT :vanilla_limit OFFSET :vanilla_offset"
@ -345,6 +360,7 @@ if ($has_vanilla_db_access) {
$subtype = trim((string) ($row['cl_scobjs_subtype'] ?? '')) ?: '—';
$uuid = trim((string) ($row['cl_scobjs_uuid'] ?? '')) ?: '—';
$rarity = index_scan_normalize_rarity($row['cl_scobjs_rarity'] ?? '');
$description = trim((string) ($row['cl_scobjs_description'] ?? ''));
$vanilla_db_rows[] = [
'id' => (int) ($row['cl_scobjs_id'] ?? 0),
@ -356,6 +372,7 @@ if ($has_vanilla_db_access) {
'rarity' => $rarity !== '' ? $rarity : '—',
'rarity_label' => $rarity !== '' ? index_scan_rarity_label($rarity) : 'Non définie',
'rarity_class' => index_scan_rarity_class($rarity),
'description_html' => index_vanilla_description_html($description),
];
}
@ -1345,12 +1362,12 @@ if ($has_vanilla_db_access) {
overflow-y: auto;
padding-right: 4px;
}
.vanilla-db-card {
grid-template-columns: 56px minmax(260px, 380px) minmax(320px, 1fr);
align-items: stretch;
}
.vanilla-db-card {
grid-template-columns: 56px minmax(0, 1fr);
}
.vanilla-db-card-main {
.vanilla-db-card-main {
display: flex;
flex-direction: column;
justify-content: center;
@ -1382,15 +1399,32 @@ if ($has_vanilla_db_access) {
.vanilla-db-card-meta span {
word-break: break-all;
}
.vanilla-db-card-details {
display: flex;
align-items: flex-start;
justify-content: flex-start;
min-width: 0;
}
.vanilla-db-card-details {
display: flex;
align-items: center;
justify-content: flex-end;
min-width: 0;
}
.vanilla-db-card-description {
width: 100%;
margin: 0;
font-size: 0.8em;
line-height: 1.45;
color: rgba(255, 255, 255, 0.8);
word-break: break-word;
overflow-wrap: anywhere;
}
.vanilla-db-muted {
.vanilla-db-card-description p {
margin: 0 0 0.45em;
}
.vanilla-db-card-description p:last-child {
margin-bottom: 0;
}
.vanilla-db-muted {
color: rgba(255, 255, 255, 0.45);
}
@ -1932,6 +1966,9 @@ if ($has_vanilla_db_access) {
<h4 class="item-custom-card-name vanilla-db-item-name <?php echo htmlspecialchars($vanilla_db_row['rarity_class'], ENT_QUOTES, 'UTF-8'); ?>" title="<?php echo htmlspecialchars($vanilla_db_row['rarity_label'], ENT_QUOTES, 'UTF-8'); ?>"><?php echo htmlspecialchars($vanilla_db_row['name'], ENT_QUOTES, 'UTF-8'); ?></h4>
<p class="vanilla-db-card-meta"><?php if ($vanilla_db_row['uuid'] !== '—'): ?><strong>UUID :</strong> <span><?php echo htmlspecialchars($vanilla_db_row['uuid'], ENT_QUOTES, 'UTF-8'); ?></span><?php else: ?><span class="vanilla-db-muted">UUID : —</span><?php endif; ?></p>
</div>
<div class="vanilla-db-card-details">
<div class="vanilla-db-card-description"><?php echo $vanilla_db_row['description_html']; ?></div>
</div>
</article>
<?php endforeach; ?>
</div>

View File

@ -1,12 +1,15 @@
<?php
require_once __DIR__ . '/db/auth.php';
require_once __DIR__ . '/db/scitems.php';
auth_start_session();
auth_bootstrap();
auth_handle_page_access_post('scitems.php', "Base d'Objets");
auth_require_page_access('scitems.php', "Base d'Objets");
scitems_bootstrap();
$flash = auth_flash_get();
$flash_type = $flash['type'] ?? '';
$flash_message = $flash['message'] ?? '';
@ -54,33 +57,34 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$count_updated = 0;
$stmt_check = $db->prepare("SELECT cl_scobjs_id FROM tbl_scobjs WHERE cl_scobjs_uuid = :uuid");
$stmt_insert = $db->prepare("INSERT INTO tbl_scobjs (cl_scobjs_name, cl_scobjs_type, cl_scobjs_subtype, cl_scobjs_uuid, cl_scobjs_rarity, cl_scobjs_about) VALUES (:name, :type, :subtype, :uuid, '', '')");
$stmt_update = $db->prepare("UPDATE tbl_scobjs SET cl_scobjs_name = :name, cl_scobjs_type = :type, cl_scobjs_subtype = :subtype WHERE cl_scobjs_uuid = :uuid");
$stmt_insert = $db->prepare("INSERT INTO tbl_scobjs (cl_scobjs_name, cl_scobjs_type, cl_scobjs_subtype, cl_scobjs_uuid, cl_scobjs_rarity, cl_scobjs_about, cl_scobjs_description) VALUES (:name, :type, :subtype, :uuid, '', '', :description)");
$stmt_update = $db->prepare("UPDATE tbl_scobjs SET cl_scobjs_name = :name, cl_scobjs_type = :type, cl_scobjs_subtype = :subtype, cl_scobjs_description = :description WHERE cl_scobjs_uuid = :uuid");
foreach ($items as $item) {
$uuid = $item['reference'] ?? ($item['stdItem']['UUID'] ?? '');
if (!$uuid) continue;
$uuid = trim((string) ($item['reference'] ?? ($item['stdItem']['UUID'] ?? '')));
if ($uuid === '') continue;
$name = $item['Name'] ?? ($item['stdItem']['Name'] ?? '');
$classification = $item['classification'] ?? ''; $parts = explode('.', $classification); $type = $parts[1] ?? ($item['type'] ?? '');
$subtype = $parts[2] ?? ($item['subType'] ?? '');
$name = trim((string) ($item['Name'] ?? ($item['stdItem']['Name'] ?? '')));
$classification = trim((string) ($item['classification'] ?? ''));
$parts = $classification !== '' ? explode('.', $classification) : [];
$type = trim((string) ($parts[1] ?? ($item['type'] ?? '')));
$subtype = trim((string) ($parts[2] ?? ($item['subType'] ?? '')));
$description = trim((string) ($item['Description'] ?? ($item['stdItem']['Description'] ?? '')));
$payload = [
'name' => $name,
'type' => $type,
'subtype' => $subtype,
'uuid' => $uuid,
'description' => $description !== '' ? $description : null,
];
$stmt_check->execute(['uuid' => $uuid]);
if ($stmt_check->fetch()) {
$stmt_update->execute([
'name' => $name,
'type' => $type,
'subtype' => $subtype,
'uuid' => $uuid
]);
$stmt_update->execute($payload);
$count_updated++;
} else {
$stmt_insert->execute([
'name' => $name,
'type' => $type,
'subtype' => $subtype,
'uuid' => $uuid
]);
$stmt_insert->execute($payload);
$count_new++;
}
}