Mercurial > hg > drupalISMI
changeset 12:797c6051e489
add openmindattribute_addCodexIDs(). rename *_addIDs() to _addBioIDs().
author | casties |
---|---|
date | Tue, 07 Jul 2015 17:45:11 +0200 |
parents | 61dd2a96c4e2 |
children | 5e2bf3cde543 |
files | openmindattribute/openmindattribute.module |
diffstat | 1 files changed, 40 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/openmindattribute/openmindattribute.module Mon Jul 06 18:53:41 2015 +0200 +++ b/openmindattribute/openmindattribute.module Tue Jul 07 17:45:11 2015 +0200 @@ -64,17 +64,7 @@ // Support hook_entity_property_info() from contrib "Entity API". #'property_type' => 'field_item_openmindattribute', #'property_callbacks' => array('openmindattribute_field_property_info_callback') - ), - 'openmindattribute_field' => array( - 'label' => t('Attribute'), - 'description' => t('The attribute'), - 'default_widget' => 'openmindattribute_field', - 'default_formatter' => 'openmindattribute_default', - // Support hook_entity_property_info() from contrib "Entity API". - 'property_type' => 'field_item_openmindattribute', - 'property_callbacks' => array('openmindattribute_field_property_info_callback') - ), - + ), ); } @@ -985,14 +975,7 @@ function theme_openmindattribute_formatter_field_identifier($vars) { - $type = $vars['type']; - - return theme_render_template(drupal_get_path('module', 'openmindattribute') . "/templates/openmindattribute_identifier.tpl.php", $vars); - - - - } @@ -1355,8 +1338,7 @@ $entity->$field_name = $field; } - -function openmindattribute_addIDs(){ +function openmindattribute_addBioIDs(){ #adds the author id from openmind to the biographies and umgekehrt $query = new EntityFieldQuery(); @@ -1462,6 +1444,44 @@ } + +function openmindattribute_addCodexIDs() { + #adds the codex identifier as an int + $query = new EntityFieldQuery(); + + $query->entityCondition('entity_type', 'node') + ->entityCondition('bundle', 'openmind_entity') + ->propertyCondition('status', 1) + ->fieldCondition('field_oc', 'tid', '4', '='); #4 is CODEX + + $result = $query->execute(); + + if (isset($result['node'])) { + $nids = array_keys($result['node']); + $codices = entity_load('node', $nids); + } else { + return; + } + + foreach ($codices as $codex){ + + $attrs = $codex->field_attribute['und']; + $mappedattrs = _openmindattribute_field_remap($attrs); + + if (isset($mappedattrs['identifier'])) { + $id = $mappedattrs['identifier']['ov']; + // set identifier + $id_field = [ + 'und' => [['value' => (int)$id]] + ]; + $codex->field_num_identifier = $id_field; + node_save($codex); + } + } + print "Updated numId for " . count($codices) . " codices.\n"; +} + + function openmindattribute_addIDbibliographieID(){ #adds the add bibliographie $query = new EntityFieldQuery();