Commit 3dd27e3f authored by quicksketch's avatar quicksketch

#404764: Remove spans from path_plain and url_plain formatters. Move to FileField.

parent 6e2a8176
......@@ -89,6 +89,14 @@ function filefield_theme() {
'arguments' => array('element' => NULL),
'file' => 'filefield_formatter.inc',
),
'filefield_formatter_url_plain' => array(
'arguments' => array('element' => NULL),
'file' => 'filefield_formatter.inc',
),
'filefield_formatter_path_plain' => array(
'arguments' => array('element' => NULL),
'file' => 'filefield_formatter.inc',
),
'filefield_item' => array(
'arguments' => array('file' => NULL, 'field' => NULL),
'file' => 'filefield_formatter.inc',
......@@ -364,6 +372,16 @@ function filefield_field_formatter_info() {
'multiple values' => CONTENT_HANDLE_CORE,
'description' => t('Displays all kinds of files with an icon and a linked file description.'),
),
'path_plain' => array(
'label' => t('Path to file'),
'field types' => array('filefield'),
'description' => t('Displays the file system path to the file.'),
),
'url_plain' => array(
'label' => t('URL to file'),
'field types' => array('filefield'),
'description' => t('Displays a full URL to the file.'),
),
);
}
......
......@@ -20,6 +20,52 @@ function theme_filefield_formatter_default($element) {
return $output;
}
/**
* Theme function for the 'path_plain' formatter.
*/
function theme_filefield_formatter_path_plain($element) {
// Inside a View this function may be called with null data. In that case,
// just return.
if (empty($element['#item'])) {
return '';
}
$field = content_fields($element['#field_name']);
$item = $element['#item'];
// If there is no image on the database, use default.
if (empty($item['fid']) && $field['use_default_file']) {
$item = $field['default_file'];
}
if (empty($item['filepath']) && !empty($item['fid'])) {
$item = array_merge($item, field_file_load($item['fid']));
}
return empty($item['filepath']) ? '' : file_create_path($item['filepath']);
}
/**
* Theme function for the 'url_plain' formatter.
*/
function theme_filefield_formatter_url_plain($element) {
// Inside a View this function may be called with null data. In that case,
// just return.
if (empty($element['#item'])) {
return '';
}
$field = content_fields($element['#field_name']);
$item = $element['#item'];
// If there is no image on the database, use default.
if (empty($item['fid']) && $field['use_default_file']) {
$item = $field['default_file'];
}
if (empty($item['filepath']) && !empty($item['fid'])) {
$item = array_merge($item, field_file_load($item['fid']));
}
return empty($item['filepath']) ? '' : file_create_url($item['filepath']);
}
/**
* Theme function for any file that is managed by filefield.
* It doesn't really format stuff by itself but rather redirects to other
......
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