/** * Get bundle preview for a relationship bundle * @param BundlableLabelableBaseModelWithAttributes $t_rel_instance * @param array $pa_initial_values * @param string $ps_template * @param string $ps_delimiter * @return string */ function caGetBundlePreviewForRelationshipBundle($t_rel_instance, $pa_initial_values, $ps_template, $ps_delimiter = '; ') { if (!is_array($pa_initial_values) || sizeof($pa_initial_values) == 0) { return '""'; } // it's very unlikely that the preview will fit more then 10 items if (sizeof($pa_initial_values) > 10) { $pa_initial_values = array_slice($pa_initial_values, 0, 10); } if (!$t_rel_instance instanceof BundlableLabelableBaseModelWithAttributes) { return '""'; } $va_ids = $va_previews = array(); foreach ($pa_initial_values as $va_item) { $va_ids[] = $va_item['id']; } $o_res = $t_rel_instance->makeSearchResult($t_rel_instance->tableName(), $va_ids); while ($o_res->nextHit()) { $va_previews[] = $o_res->getWithTemplate($ps_template); } return caEscapeForBundlePreview(join($ps_delimiter, $va_previews)); }