function assets_build_placeholder in Asset 7
Generates a placeholder for wysiwyg.
3 calls to assets_build_placeholder()
- assets_override_form_submit in includes/
asset.admin.inc - Custom submit handler.
- assets_wysiwyg_form_submit in includes/
asset.admin.inc - Custom submit handler.
- _asset_get_tag in includes/
asset.admin.inc - Page callback, return html of asset by wysiwyg view mode.
File
- ./
asset.module, line 791 - Asset module.
Code
function assets_build_placeholder($asset, array $options = array(), $original_asset = NULL) {
$type = $asset->type;
$tag_array = array(
'[[asset:' . $type . ':' . $asset->aid . ' ',
);
$fields = field_info_instances('asset', $type);
$types = _assets_get_overridable_field_types();
foreach ($fields as $field) {
if (!$field['required']) {
$field_name = $field['field_name'];
$info = field_info_field($field_name);
$field_type = $info['type'];
if (isset($types[$field_type])) {
$values = field_get_items('asset', $asset, $field_name);
$original_values = NULL;
if (!empty($original_asset)) {
$original_values = field_get_items('asset', $original_asset, $field_name);
}
if (is_array($values)) {
if ($values != $original_values) {
$field_values = array();
$columns = $types[$field_type];
foreach ($values as $delta => $data) {
// If there is only one col, store it directly in the key, without sub-sections.
// We need to follow this way for bachward compatibility.
if (count($columns) > 1) {
foreach ($columns as $column) {
$field_values[$delta][$column] = $data[$column];
}
}
else {
$column = reset($columns);
$field_values[$delta] = $data[$column];
}
}
$options[$field_name] = $field_values;
}
}
}
}
}
$tag_array[] = drupal_json_encode($options);
$tag_array[] = ']]';
return implode('', $tag_array);
}