function lingotek_get_paragraph_snippet in Lingotek Translation 7.7
1 call to lingotek_get_paragraph_snippet()
File
- ./
lingotek.bulk_grid.inc, line 2405
Code
function lingotek_get_paragraph_snippet($entity_type, $entity_id) {
$fields = field_info_fields();
$paragraph = lingotek_entity_load_single($entity_type, $entity_id);
$snippet = 'N/A';
foreach ($paragraph as $key => $value) {
if (strpos($key, 'field_') !== FALSE) {
if (!isset($value[language_default()->language][0]['value'])) {
continue;
}
$field_value = $value[language_default()->language][0]['value'];
$field_type = $fields[$key]['type'];
if (!is_numeric($field_value) && $field_type === 'text') {
if (strlen($field_value) > 20) {
$field_value = substr($field_value, 0, 20);
}
$snippet = $field_value;
break;
}
}
}
return $snippet;
}