Commit db966898 authored by generalredneck's avatar generalredneck

Merge branch '7.x-2.x' of git.drupal.org:project/views_natural_sort into 7.x-2.x

parents 375158a9 6ffe05fa
......@@ -64,6 +64,7 @@ function views_natural_sort_store_multiple(array $index_entries) {
}
function views_natural_sort_store($index_entry) {
//This should take a formatted object and store it into the views_natural_sort table.
$string = views_natural_sort_encode($index_entry);
return db_merge('views_natural_sort')
->key(array(
'eid' => $index_entry['eid'],
......@@ -76,7 +77,7 @@ function views_natural_sort_store($index_entry) {
'entity_type' => $index_entry['entity_type'],
'field' => $index_entry['field'],
'delta' => $index_entry['delta'],
'content' => views_natural_sort_encode($index_entry),
'content' => substr($string, 0, 255),
))
->execute();
}
......@@ -130,6 +131,9 @@ function views_natural_sort_encode($index_entry) {
$string = $transformation_method($string);
}
// The size limit on the content field for views_natual_sort is sometimes not
// enough. Lets truncate all data down to that size. I personally feel the
// inaccuracy is an acceptable loss.
return $string;
}
......
......@@ -110,14 +110,17 @@ function _views_natural_sort_text_field_to_vns($entity_type, $entity, $field) {
//TODO: add support for Field Language
$entries = array();
foreach(field_get_items($entity_type, $entity, $field_name) as $delta => $row) {
$entries[] = array(
'eid' => $entity->$entity_id_property,
'entity_type' => $entity_type,
'field' => $field_name,
'delta' => $delta,
'content' => $row['value']
);
$field_items = field_get_items($entity_type, $entity, $field_name);
if (!empty($field_items)) {
foreach($field_items as $delta => $row) {
$entries[] = array(
'eid' => $entity->$entity_id_property,
'entity_type' => $entity_type,
'field' => $field_name,
'delta' => $delta,
'content' => $row['value']
);
}
}
return $entries;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment