function nodeorder_orderable_tids_by_node in Node Order 7
Returns an array of the node's tids that are in orderable vocabularies. Slower than nodeorder_orderable_tids but needed when tids have already been removed from the database.
Adopted form API function taxonomy_build_node_index().
1 call to nodeorder_orderable_tids_by_node()
- nodeorder_node_delete in ./
nodeorder.module - Implements hook_node_delete().
File
- ./
nodeorder.module, line 655 - Nodeorder module.
Code
function nodeorder_orderable_tids_by_node($node) {
$tids = array();
foreach (field_info_instances('node', $node->type) as $instance) {
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
if ($field['module'] == 'taxonomy' && $field['storage']['type'] == 'field_sql_storage') {
// If a field value is not set in the node object when node_save() is
// called, the old value from $node->original is used.
if (isset($node->{$field_name})) {
$items = $node->{$field_name};
}
elseif (isset($node->original->{$field_name})) {
$items = $node->original->{$field_name};
}
else {
continue;
}
foreach (field_available_languages('node', $field) as $langcode) {
if (!empty($items[$langcode])) {
foreach ($items[$langcode] as $item) {
$tids[$item['tid']] = $item['tid'];
}
}
}
}
}
return $tids;
}