Mercurial > hg > drupalISMI
changeset 15:61767ff5ce2b
fixed some biographies that were not linked.
author | casties |
---|---|
date | Thu, 09 Jul 2015 19:44:11 +0200 |
parents | f1a2741ccd2d |
children | de0a06eef13b |
files | openmindattribute/openmindattribute.module |
diffstat | 1 files changed, 39 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/openmindattribute/openmindattribute.module Tue Jul 07 18:09:21 2015 +0200 +++ b/openmindattribute/openmindattribute.module Thu Jul 09 19:44:11 2015 +0200 @@ -1338,7 +1338,7 @@ $entity->$field_name = $field; } -function openmindattribute_addBioIDs(){ +function openmindattribute_addBioIDs() { #adds the author id from openmind to the biographies and umgekehrt $query = new EntityFieldQuery(); @@ -1349,12 +1349,9 @@ $result = $query->execute(); - if (isset($result['node'])) { $persons_nids = array_keys($result['node']); $persons = entity_load('node', $persons_nids); - - } #hole mapping bea url -> id @@ -1364,83 +1361,69 @@ foreach ($persons as $person){ $attrs = $person->field_attribute['und']; - $mappedattrs = _openmindattribute_field_remap($attrs); - if (isset($mappedattrs['url'])){ - - $url = $mappedattrs['url']['ov']; - - $exploded = explode("/", $url); - - #urls haben die Form http://islamsci.mcgill.ca/rasi/bea/tusi_bea.htm - #mich interessiert nur das ende ohne htm - - dpm($exploded); - $ident = $exploded[count($exploded)-1]; - dpm($ident); - $ident = strtolower(str_replace(".htm", "", $ident)); - - dpm($ident); - $beamapping[$ident]=$person->field_id['und'][0]['value']; - //$beamappingNodeId[$ident]=$person->nid; - $beamappingNodeId[$ident][]=$person->nid; + if (isset($mappedattrs['url'])) { + + $url = $mappedattrs['url']['ov']; + + $exploded = explode("/", $url); + + #urls haben die Form http://islamsci.mcgill.ca/rasi/bea/tusi_bea.htm + #mich interessiert nur das ende ohne htm + + $ident = $exploded[count($exploded)-1]; + $ident = strtolower(str_replace(".htm", "", $ident)); + + $ismi_id = $person->field_id['und'][0]['value']; + $beamapping[$ident] = $ismi_id; + $beamappingNodeId[$ident][]=$person->nid; } } #hole jetzt alle biographien - + $cnt = 0; $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'biography'); - $result = $query->execute(); - if (isset($result['node'])) { $bios_nids = array_keys($result['node']); $bios = entity_load('node', $bios_nids); - } foreach ($bios as $bio){ $url = strtolower(drupal_get_path_alias("node/" . $bio->nid)); - - dpm($url); - - if (isset ($beamapping[$url])){ - $authorid = $beamapping[$url]; - - $bio->field_id['und'][0]['value']=$authorid; - - - - - node_save($bio); - - dpm($url . " -->" . $authorid); + if (strpos($url, '.htm')) { + $url = str_replace('.htm', '', $url); + } - dpm($bio); - - - foreach ($beamappingNodeId[$url] as $entNid){ - //$entNid = $beamappingNodeId[$url]; - - $ent = entity_load_single("node", $entNid); - - $ent->field_bio_id['und'][0]['value']=$bio->nid; - $ent->field_bio_id_reference['und'][0]['nid']=$bio->nid; - dpm($ent); - dpm($ent->nid); - node_save($ent); - }} + if (isset($beamapping[$url])) { + $authorid = $beamapping[$url]; + + $bio->field_id['und'][0]['value'] = $authorid; + + node_save($bio); + + foreach ($beamappingNodeId[$url] as $entNid ) { + // $entNid = $beamappingNodeId[$url]; + + $ent = entity_load_single("node", $entNid); + + $ent->field_bio_id['und'][0]['value'] = $bio->nid; + $ent->field_bio_id_reference['und'][0]['nid'] = $bio->nid; + node_save($ent); + $cnt += 1; + } + } } - + print "Linked $cnt biographies.\n"; }