function file_build_content in File Entity (fieldable files) 7
Same name and namespace in other branches
- 7.3 file_entity.file_api.inc \file_build_content()
- 7.2 file_entity.file_api.inc \file_build_content()
Builds a structured array representing the file's content.
Parameters
$file: A file object.
$view_mode: View mode, e.g. 'default', 'full', etc.
$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
1 call to file_build_content()
- file_view in ./
file_entity.file_api.inc - Generate an array for rendering the given file.
File
- ./
file_entity.file_api.inc, line 186 - API extensions of Drupal core's file.inc.
Code
function file_build_content($file, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Remove previously built content, if exists.
$file->content = array();
// Build the actual file display.
// @todo Figure out how to clean this crap up.
$file->content['file'] = file_view_file($file, $view_mode, $langcode);
if (isset($file->content['file'])) {
if ($file->content['file']['#theme'] != 'file_link') {
unset($file->content['file']['#file']);
}
unset($file->content['file']['#view_mode']);
unset($file->content['file']['#language']);
}
else {
unset($file->content['file']);
}
// Build fields content.
// In case of a multiple view, file_view_multiple() already ran the
// 'prepare_view' step. An internal flag prevents the operation from running
// twice.
field_attach_prepare_view('file', array(
$file->fid => $file,
), $view_mode, $langcode);
entity_prepare_view('file', array(
$file->fid => $file,
), $langcode);
$file->content += field_attach_view('file', $file, $view_mode, $langcode);
$links = array();
$file->content['links'] = array(
'#theme' => 'links__file',
'#pre_render' => array(
'drupal_pre_render_links',
),
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
);
$file->content['links']['file'] = array(
'#theme' => 'links__file__file',
'#links' => $links,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
);
// Allow modules to make their own additions to the file.
module_invoke_all('file_view', $file, $view_mode, $langcode);
module_invoke_all('entity_view', $file, 'file', $view_mode, $langcode);
}