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:
@@ -74,9 +74,18 @@ Basculer le flag à `true` dans `class-admin-page.php` pour réactiver.
|
|||||||
| `HDR` | HDR | `14` |
|
| `HDR` | HDR | `14` |
|
||||||
| `SON` | Son | `19` |
|
| `SON` | Son | `19` |
|
||||||
| `VIDEO` | Vidéo | `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`.
|
`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
|
## Champs HAL → champs WP
|
||||||
|
|
||||||
À l'import, chaque publication remplit :
|
À l'import, chaque publication remplit :
|
||||||
|
|||||||
@@ -37,7 +37,20 @@ class Thalim_HAL_API {
|
|||||||
*/
|
*/
|
||||||
public function fetch_by_hal_ids(array $hal_ids, int $batch = 100) {
|
public function fetch_by_hal_ids(array $hal_ids, int $batch = 100) {
|
||||||
$docs = [];
|
$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) {
|
foreach ($chunks as $chunk) {
|
||||||
$filter = 'halId_s:(' . implode(' OR ', $chunk) . ')';
|
$filter = 'halId_s:(' . implode(' OR ', $chunk) . ')';
|
||||||
$params = [
|
$params = [
|
||||||
@@ -51,8 +64,11 @@ class Thalim_HAL_API {
|
|||||||
$data = $this->request($url);
|
$data = $this->request($url);
|
||||||
if (is_wp_error($data)) return $data;
|
if (is_wp_error($data)) return $data;
|
||||||
foreach ($data['response']['docs'] ?? [] as $doc) {
|
foreach ($data['response']['docs'] ?? [] as $doc) {
|
||||||
if (!empty($doc['halId_s'])) {
|
$canonical = $doc['halId_s'] ?? '';
|
||||||
$docs[$doc['halId_s']] = $doc;
|
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
|
// Be polite with HAL if we have multiple chunks
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ class Thalim_HAL_Importer_Logic {
|
|||||||
'HDR' => 14, // HDR -> Soutenances
|
'HDR' => 14, // HDR -> Soutenances
|
||||||
'SON' => 19, // Son -> Captations audio/vidéo
|
'SON' => 19, // Son -> Captations audio/vidéo
|
||||||
'VIDEO' => 19, // Vidéo -> 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
|
// 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');
|
update_post_meta($post_id, 'fonction_auteur', 'Auteur du chapitre // Chapter author');
|
||||||
} elseif ($doc_type === 'ISSUE') {
|
} elseif ($doc_type === 'ISSUE') {
|
||||||
update_post_meta($post_id, 'fonction_auteur', 'Direction de numéro // Editor-in-Chief');
|
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) ---
|
// --- Keywords -> étiquettes (Pods triple-storage, picks from post_tag) ---
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ define('THALIM_HAL_PLUGIN_URL', plugin_dir_url(__FILE__));
|
|||||||
// HAL API configuration
|
// HAL API configuration
|
||||||
define('THALIM_HAL_API_BASE', 'https://api.archives-ouvertes.fr/search/');
|
define('THALIM_HAL_API_BASE', 'https://api.archives-ouvertes.fr/search/');
|
||||||
define('THALIM_HAL_STRUCT_ID', 254015); // THALIM lab structure ID
|
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
|
* Main plugin class - minimal bootstrap
|
||||||
|
|||||||
Reference in New Issue
Block a user