Rapatriement modifs PROD : types de docs étendus (NOTICE, BLOG, TRAD, REPORT, UNDEFINED, POSTER, OTHER) + mapping catégories + fonction_auteur TRAD + strip suffixe version

This commit is contained in:
2026-06-02 19:12:13 +02:00
parent f93fe77a12
commit 20e2158612
4 changed files with 38 additions and 4 deletions

View File

@@ -74,9 +74,18 @@ Basculer le flag à `true` dans `class-admin-page.php` pour réactiver.
| `HDR` | HDR | `14` |
| `SON` | Son | `19` |
| `VIDEO` | Vidéo | `19` |
| `NOTICE` | Notice / recension | `16` |
| `BLOG` | Blog / tribune | `19` |
| `TRAD` | Traduction | `15` |
| `REPORT` | Rapport | `4` |
| `UNDEFINED` | Non défini | `4` |
| `POSTER` | Poster | `4` |
| `OTHER` | Autre | `4` |
`COMM`, `THESE`, `HDR`, `SON`, `VIDEO` sont traités comme événements et utilisent le champ Pods `date_de_debut`. Les autres utilisent `datetime`.
`TRAD` reçoit en plus `fonction_auteur = « Traduction // Translation »` (au même titre que `COUV` et `ISSUE`).
## Champs HAL → champs WP
À l'import, chaque publication remplit :

View File

@@ -37,7 +37,20 @@ class Thalim_HAL_API {
*/
public function fetch_by_hal_ids(array $hal_ids, int $batch = 100) {
$docs = [];
$chunks = array_chunk(array_values(array_unique($hal_ids)), $batch);
// HAL Solr's halId_s is the canonical ID without a version suffix
// (e.g. "hal-03583975", not "hal-03583975v2"). Some legacy SPIP entries
// carry a version suffix, so strip it before querying and keep a map
// to re-key the result under the original caller-supplied ID.
$originals = array_values(array_unique($hal_ids));
$stripped_map = []; // stripped_id => [original_id, ...]
foreach ($originals as $orig) {
$stripped = preg_replace('/v\d+$/', '', $orig);
$stripped_map[$stripped][] = $orig;
}
$query_ids = array_keys($stripped_map);
$chunks = array_chunk($query_ids, $batch);
foreach ($chunks as $chunk) {
$filter = 'halId_s:(' . implode(' OR ', $chunk) . ')';
$params = [
@@ -51,8 +64,11 @@ class Thalim_HAL_API {
$data = $this->request($url);
if (is_wp_error($data)) return $data;
foreach ($data['response']['docs'] ?? [] as $doc) {
if (!empty($doc['halId_s'])) {
$docs[$doc['halId_s']] = $doc;
$canonical = $doc['halId_s'] ?? '';
if ($canonical === '') continue;
// Key the doc under every original ID that stripped to this canonical form
foreach ($stripped_map[$canonical] ?? [$canonical] as $orig) {
$docs[$orig] = $doc;
}
}
// Be polite with HAL if we have multiple chunks

View File

@@ -21,6 +21,13 @@ class Thalim_HAL_Importer_Logic {
'HDR' => 14, // HDR -> Soutenances
'SON' => 19, // Son -> Captations audio/vidéo
'VIDEO' => 19, // Vidéo -> Captations audio/vidéo
'NOTICE' => 16, // Notice/recension -> Articles
'BLOG' => 19, // Blog/tribune -> Médias
'TRAD' => 15, // Traduction -> Ouvrages (fonction auteur "Traduction")
'REPORT' => 4, // Rapport -> Publications et productions
'UNDEFINED' => 4, // Non défini -> Publications et productions
'POSTER' => 4, // Poster -> Publications et productions
'OTHER' => 4, // Autre -> Publications et productions
];
// Doc types that use date_de_debut instead of datetime
@@ -209,6 +216,8 @@ class Thalim_HAL_Importer_Logic {
update_post_meta($post_id, 'fonction_auteur', 'Auteur du chapitre // Chapter author');
} elseif ($doc_type === 'ISSUE') {
update_post_meta($post_id, 'fonction_auteur', 'Direction de numéro // Editor-in-Chief');
} elseif ($doc_type === 'TRAD') {
update_post_meta($post_id, 'fonction_auteur', 'Traduction // Translation');
}
// --- Keywords -> étiquettes (Pods triple-storage, picks from post_tag) ---

View File

@@ -23,7 +23,7 @@ define('THALIM_HAL_PLUGIN_URL', plugin_dir_url(__FILE__));
// HAL API configuration
define('THALIM_HAL_API_BASE', 'https://api.archives-ouvertes.fr/search/');
define('THALIM_HAL_STRUCT_ID', 254015); // THALIM lab structure ID
define('THALIM_HAL_DOC_TYPES', ['ART', 'COUV', 'OUV', 'COMM', 'ISSUE', 'PROCEEDINGS', 'THESE', 'HDR', 'SON', 'VIDEO']);
define('THALIM_HAL_DOC_TYPES', ['ART', 'COUV', 'OUV', 'COMM', 'ISSUE', 'PROCEEDINGS', 'THESE', 'HDR', 'SON', 'VIDEO', 'NOTICE', 'BLOG', 'TRAD', 'REPORT', 'UNDEFINED', 'POSTER', 'OTHER']);
/**
* Main plugin class - minimal bootstrap