function _asset_widget_form in Asset 6
Same name in this branch
- 6 modules/asset_content.inc \_asset_widget_form()
- 6 inc/modules/asset_content.inc \_asset_widget_form()
Same name and namespace in other branches
- 5 modules/asset_content.inc \_asset_widget_form()
4 calls to _asset_widget_form()
- asset_widget in modules/
asset_content.inc - Define the behavior of a widget.
- asset_widget in inc/
modules/ asset_content.inc - Implementation of hook_widget().
- asset_widget_js in modules/
asset_content.inc - asset_widget_js in inc/
modules/ asset_content.inc
File
- inc/
modules/ asset_content.inc, line 366
Code
function _asset_widget_form(&$form_item, $field, $node_field, $delta = 0) {
/*
$rtl = module_invoke('i18n', 'language_rtl') ? "right" : "left";
$field_name = $field['field_name'];
$item_count = $delta + 1;
$form_item = array(
'#tree' => TRUE,
);
// Set the title
$form_item['value'] = array(
'#type' => 'textfield',
'#title' => t($field['widget']['label']) . " " . $item_count,
'#attributes' => array('disabled' => 'disabled'),
'#default_value' => $node_field['value'],
);
// Set the aid (hidden)
$form_item['aid'] = array(
'#type' => 'hidden',
'#default_value' => $node_field['aid'],
);
if (!empty($node_field['aid'])) {
$aid = $node_field['aid'];
// Set the preview
$is_image = array('jpg', 'jpeg', 'png', 'gif', 'tif', 'tiff', 'bmp');
$a = asset_load(array('aid' => $aid));
// Preview the image
if (in_array($a->extension, $is_image)) {
if(variable_get('asset_imagecache', 0)) {
$presets = _imagecache_get_presets();
$preset = $presets[variable_get('asset_imagecache', 0)];
$preview = theme('imagecache', $preset, str_replace("//","/", $a->filepath));
} else {
$asset = array(
'aid' => $aid,
'format' => 'image',
'formatter' => 'asset',
'width' => '120',
'height' => '80',
);
$preview = asset_render_macro($asset);
}
$form_item['preview'] = array(
'#prefix' => '<div id="preview_' . $field_name . '_' . $delta . '" style="float:' . $rtl . '">',
'#suffix' => '</div>',
'#value' => $preview,
);
} else {
// Try to auto-detect the format
if (asset_preview($aid)) {
$form_item['preview'] = array(
'#prefix' => '<div id="preview_' . $field_name . '_' . $delta . '" style="float:' . $rtl . '">',
'#suffix' => '</div>',
'#value' => asset_preview($aid),
);
} else {
// Display a placeholder for assets that don't have a preview: .mov, .doc, ...
$form_item['preview'] = array(
'#type' => 'markup',
'#value' => '<div id="preview_' . $field_name . '_' . $delta . '" style="float:' . $rtl . '"></div>',
);
}
}
} else {
$form_item['preview'] = array(
'#value' => '<div id="preview_' . $field_name . '_' . $delta . '" style="float:'.$rtl.'"></div>',
);
}
// Set the caption
$l_text = '<img src="' . base_path() . drupal_get_path('module', 'asset') . '/misc/lullacons/doc-option-add.png' . '" alt="' . t("Insert asset") . '" title="' . t("Insert asset") . '"/>';
$l = l($l_text, 'asset/wizard/textfield', array(
'html' => true,
'query' => 'textfield=' . $field_name . '[' . $delta . '][value]&aidfield=' . $field_name . '[' . $delta . '][aid]&delta=' . $delta,
'attributes' => array(
'class'=>'asset-textfield-link',
'id'=>'asset-link-' . $field_name . '-' . $delta . '-value',
'onclick'=>"window.open(this.href, 'asset_textfield_link', 'width=614,height=400,scrollbars=yes,status=yes,resizable=yes,toolbar=no,menubar=no'); return false",
)));
$form_item['caption'] = array(
'#type' => 'textfield',
'#maxlength' => '256',
'#default_value' => $node_field['caption'],
'#description' => 'Enter the caption for this asset',
'#prefix' => '<div style="margin-'.$rtl.':130px"><table style="width:400px;margin-top:-15px;border-collapse:inherit"><tr><td style="padding:0px;margin:0px;text-align:center;padding-top:16px;width:10px" valign="top">' . $l . '</td><td>',
'#suffix' => '</td></tr></table></div>',
);
// Set the copyright
$l_text = '<img src="' . base_path() . drupal_get_path('module', 'asset') . '/misc/lullacons/doc-option-remove.png' . '" alt="' . t("Delete asset") . '" title="' . t("Delete asset") . '"/>';
$l = l($l_text, '', array(
'html' => true,
'attributes' => array(
'onclick' => "
$('#edit-" . str_replace("_","-",$field_name) . "-" . $delta . "-value').val('');
$('#edit-" . str_replace("_","-",$field_name) . "-" . $delta . "-aid').val('');
$('#edit-" . str_replace("_","-",$field_name) . "-" . $delta . "-caption').val('');
$('#edit-" . str_replace("_","-",$field_name) . "-" . $delta . "-copyright').val('');
$('#preview_" . $field_name . "_" . $delta . "').html('');
return false;",
)));
$form_item['copyright'] = array(
'#type' => 'textfield',
'#maxlength' => '256',
'#default_value' => $node_field['copyright'],
'#description' => 'Enter the copyright for this asset',
'#prefix' => '<div style="margin-'.$rtl.':130px"><table style="width:400px;margin-top:-30px;border-collapse:inherit"><tr><td style="padding:0px;margin:0px;text-align:center;padding-top:16px;width:10px" valign="top">' . $l . '</td><td>',
'#suffix' => '</td></tr></table></div>',
);
if($delta==0 && isset($field['widget']['description']) && !empty($field['widget']['description'])) {
$form_item['description'] = array(
'#value' => '<div class="description">' . $field['widget']['description'] . '</div>',
);
}
$form_item['#prefix'] = '<div class="clear-block">';
$form_item['#suffix'] = '</div>';
*/
}