function file_view in File Entity (fieldable files) 7.2
Same name and namespace in other branches
- 7.3 file_entity.file_api.inc \file_view()
- 7 file_entity.file_api.inc \file_view()
Generate an array for rendering the given file.
Parameters
object $file: A file object.
string $view_mode: View mode.
string $langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Return value
array An array as expected by drupal_render().
7 calls to file_view()
- file_entity_field_formatter_view in ./
file_entity.field.inc - Implements hook_field_formatter_view().
- file_entity_search_execute in ./
file_entity.module - Implements hook_search_execute().
- file_entity_view_page in ./
file_entity.pages.inc - Menu callback; view a single file entity.
- file_view_multiple in ./
file_entity.file_api.inc - Construct a drupal_render() style array from an array of loaded files.
- views_plugin_row_file_rss::render in views/
views_plugin_row_file_rss.inc - Render a row object. This usually passes through to a theme template of some form, but not always.
4 string references to 'file_view'
- file_entity_file_view_page in plugins/
tasks/ file_view.inc - Entry point for our overridden file view.
- file_entity_hook_info in ./
file_entity.module - Implements hook_hook_info().
- PanelizerEntityFile::hook_default_page_manager_handlers in plugins/
entity/ PanelizerEntityFile.class.php - Implements a delegated hook_page_manager_handlers().
- PanelizerEntityFile::settings_form in plugins/
entity/ PanelizerEntityFile.class.php
File
- ./
file_entity.file_api.inc, line 120 - API extensions of Drupal core's file.inc.
Code
function file_view($file, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Populate $file->content with a render() array.
file_build_content($file, $view_mode, $langcode);
$build = $file->content;
// We don't need duplicate rendering info in $file->content.
unset($file->content);
$build += array(
'#theme' => 'file_entity',
'#file' => $file,
'#view_mode' => $view_mode,
'#language' => $langcode,
);
// Add contextual links for this file, except when the file is already being
// displayed on its own page. Modules may alter this behavior (for example,
// to restrict contextual links to certain view modes) by implementing
// hook_file_view_alter().
if (!empty($file->fid) && !($view_mode == 'full' && file_entity_is_page($file))) {
$build['#contextual_links']['file'] = array(
'file',
array(
$file->fid,
),
);
}
// Allow modules to modify the structured file.
$type = 'file';
drupal_alter(array(
'file_view',
'entity_view',
), $build, $type);
return $build;
}