mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
CSV importer: boolean and ap variants/typos
- add AP aliases for: - Design & politique du multiple → DPM, - Pratiques artistiques & complexité scientifique → PACS, - Narraion Speculative typo → NS - Fix: OUI/NON CSV artefacts in contact_interne — clean DB, guard in findOrCreateAuthor and CSV import - Cleaned 141 authors.email = 'NON' rows → NULL in dev DB - findOrCreateAuthor: treat OUI/NON as null (CSV boolean artefact in email column) - CSV import: sanitize contact column — OUI/NON → empty string before passing to findOrCreateAuthor
This commit is contained in:
@@ -173,11 +173,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
|
||||
=> 'LIENS',
|
||||
'récits et expérimentation' => 'NS',
|
||||
'recits et experimentation' => 'NS',
|
||||
'atelier pratiques situées' => 'APS',
|
||||
'design et politique du multiple' => 'DPM',
|
||||
'narraion spéculative' => 'NS',
|
||||
'narration spéculative' => 'NS',
|
||||
'atelier pratiques situées' => 'APS',
|
||||
'design & politique du multiple' => 'DPM',
|
||||
'design et politique du multiple' => 'DPM',
|
||||
'pacs' => 'PACS',
|
||||
'pratique de l\'art' => 'PACS',
|
||||
'pratiques artistiques & complexité scientifique' => 'PACS',
|
||||
];
|
||||
|
||||
// Resolve an AP string (code or full name) → ap_program id.
|
||||
@@ -230,6 +233,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
|
||||
$subtitle = $cell($row, 'sous-titre', 2);
|
||||
$authorsRaw = $cell($row, 'auteur', 3);
|
||||
$contact = $cell($row, 'contact', 4);
|
||||
// Normalise CSV artefacts: OUI/NON → empty (not a valid email)
|
||||
if ($contact !== '' && in_array(strtoupper(trim($contact)), ['NON', 'OUI'], true)) {
|
||||
$contact = '';
|
||||
}
|
||||
$supervisorsRaw = $cell($row, 'promoteur', 5);
|
||||
$formatsRaw = $cell($row, 'format', 6);
|
||||
$yearRaw = $cell($row, 'année', 7);
|
||||
@@ -342,13 +349,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
|
||||
}
|
||||
}
|
||||
if (!empty($languageRaw)) {
|
||||
$s = $importPdo->prepare("SELECT id FROM languages WHERE name = ?");
|
||||
$s->execute([ucfirst(strtolower($languageRaw))]);
|
||||
$langName = strtolower(trim($languageRaw));
|
||||
// Lookup case-insensitively; insert if missing (stored lowercase).
|
||||
$s = $importPdo->prepare("SELECT id FROM languages WHERE LOWER(name) = LOWER(?)");
|
||||
$s->execute([$langName]);
|
||||
$r = $s->fetch();
|
||||
if ($r) {
|
||||
$s2 = $importPdo->prepare("INSERT INTO thesis_languages (thesis_id, language_id) VALUES (?,?)");
|
||||
$s2->execute([$thesisId, $r['id']]);
|
||||
$langId = $r ? (int)$r['id'] : null;
|
||||
if ($langId === null) {
|
||||
$importPdo->prepare("INSERT INTO languages (name) VALUES (?)")->execute([$langName]);
|
||||
$langId = (int)$importPdo->lastInsertId();
|
||||
}
|
||||
$s2 = $importPdo->prepare("INSERT INTO thesis_languages (thesis_id, language_id) VALUES (?,?)");
|
||||
$s2->execute([$thesisId, $langId]);
|
||||
}
|
||||
if (!empty($formatsRaw)) {
|
||||
foreach (array_map('trim', explode(',', $formatsRaw)) as $fmt) {
|
||||
|
||||
Reference in New Issue
Block a user