Skip to content
Snippets Groups Projects

Hl/20441 marc21 dynix dedup

Merged Ghislain Loas requested to merge hl/20441-marc21-dynix-dedup into stable
Compare and
+ 90
12
Preferences
Compare changes
Files
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//////////////////////////////////////////////////////////////////////////////////////
// CLASSE MARC21 (Surcharge la classe notice_unimarc)
@@ -30,7 +30,7 @@ class notice_marc21 extends notice_unimarc
private $map;
// ----------------------------------------------------------------
// Constructeur
// Constructeur
// ----------------------------------------------------------------
function __construct()
{
@@ -104,11 +104,75 @@ class notice_marc21 extends notice_unimarc
$this->setNotice($this->marc21ToUnimarc());
return true;
}
public function setNotice($string, $type_accents = 0) {
parent::setNotice($string, 4);
}
protected function append200IToFirst200E($new_subfields, $i) {
$e_subfield_found = false;
foreach ($new_subfields as $index => $subfield) {
if ($subfield[0] == 'e') {
$e_subfield_found = true;
$subfield[1] .= ' ' . $i;
$new_subfields[$index] = $subfield;
break;
}
}
if (!$e_subfield_found) {
$new_subfields[] = ['e', $i];
}
return $new_subfields;
}
protected function getCodeIFromSubfields($subfields) {
foreach ($subfields as $subfield) {
if ($subfield['code'] == 'i')
return $subfield['valeur'];
}
return '';
}
protected function prepareSubfieldsFor200E($subfields) {
$new_subfields = [];
foreach ($subfields as $index => $subfield) {
if ($subfield['code'] == 'i')
continue;
$new_subfields[] = [$subfield['code'], $subfield['valeur']];
}
return $new_subfields;
}
protected function getNewSubfields($field_block) {
$subfields = $this->decoupe_bloc_champ($field_block);
$i = $this->getCodeIFromSubfields($subfields);
$new_subfields = $this->prepareSubfieldsFor200E($subfields);
return $i
? $this->append200IToFirst200E($new_subfields, $i)
: $new_subfields;
}
// Special case: append 200$i to 200$e so it appears in clef_alpha
// and can be used for deduping
protected function unimarc200iTo200e() {
if(!$field_blocks = $this->notice_unimarc->get_subfield('200'))
return ;
$this->notice_unimarc->delete_field('200');
foreach($field_blocks as $field_block)
$this->notice_unimarc->add_field('200', '01', $this->getNewSubfields($field_block));
}
// ----------------------------------------------------------------
// Transco marc21 to unimarc
// ----------------------------------------------------------------
@@ -125,7 +189,7 @@ class notice_marc21 extends notice_unimarc
// identifiants
$bloc=$this->get_subfield('001');
$this->notice_unimarc->add_field("001","",$bloc[0]);
// date de nouveaute
$bloc=$this->get_subfield('008');
$this->notice_unimarc->add_field("005","",$bloc[0]);
@@ -143,7 +207,8 @@ class notice_marc21 extends notice_unimarc
// titres
$this->traiteZone("245","200");
$this->traiteZone("246","510");
$this->unimarc200iTo200e();
$this->traiteZone("246","510");
$this->traiteZone("130","500"); // titre uniforme
$this->traiteZone("505","464"); // titres de depouillement
$this->traiteZone("856","464"); // morceaux docs sonores
@@ -152,7 +217,7 @@ class notice_marc21 extends notice_unimarc
$this->traiteZone("765","510"); // titre original
$this->traiteZone("780","432"); // titre précédent pour périodiques
$this->traiteZone("785","440"); // titre successeur
// auteurs
$this->traiteZone("100","700");
$this->traiteZone("110","710");