file_entity.theme.inc

  1. cis7 sites/all/modules/ulmus/file_entity/file_entity.theme.inc
  2. cle7 sites/all/modules/ulmus/file_entity/file_entity.theme.inc
  3. ecd7 sites/all/modules/ulmus/file_entity/file_entity.theme.inc
  4. elmsmedia7 sites/all/modules/ulmus/file_entity/file_entity.theme.inc
  5. harmony7 sites/all/modules/ulmus/file_entity/file_entity.theme.inc
  6. icor7 sites/all/modules/ulmus/file_entity/file_entity.theme.inc
  7. meedjum_blog7 sites/all/modules/ulmus/file_entity/file_entity.theme.inc
  8. mooc7 sites/all/modules/ulmus/file_entity/file_entity.theme.inc

Theme callbacks for the file entity module.

Functions

Namesort descending Description
theme_file_entity_download_link Copy of theme_file_file_link() for linking to the file download URL.
theme_file_entity_file_audio Returns HTML for displaying an HTML5 <audio> tag.
theme_file_entity_file_link Copy of theme_file_file_link() for linking to the view file page.
theme_file_entity_file_video Returns HTML for displaying an HTML5 <video> tag.

File

sites/all/modules/ulmus/file_entity/file_entity.theme.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Theme callbacks for the file entity module.
  5. */
  6. /**
  7. * Copy of theme_file_file_link() for linking to the view file page.
  8. *
  9. * @see theme_file_file_link()
  10. */
  11. function theme_file_entity_file_link($variables) {
  12. $file = $variables['file'];
  13. $icon_directory = $variables['icon_directory'];
  14. $url = 'file/' . $file->fid;
  15. $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory));
  16. // Set options as per anchor format described at
  17. // http://microformats.org/wiki/file-format-examples
  18. $options = array(
  19. 'attributes' => array(
  20. 'type' => $file->filemime . '; length=' . $file->filesize,
  21. ),
  22. );
  23. // Use the description as the link text if available.
  24. if (empty($file->description)) {
  25. $link_text = $file->filename;
  26. }
  27. else {
  28. $link_text = $file->description;
  29. $options['attributes']['title'] = check_plain($file->filename);
  30. }
  31. return '<span class="file">' . $icon . ' ' . l($link_text, $url, $options) . '</span>';
  32. }
  33. /**
  34. * Copy of theme_file_file_link() for linking to the file download URL.
  35. *
  36. * @see theme_file_file_link()
  37. */
  38. function theme_file_entity_download_link($variables) {
  39. $file = $variables['file'];
  40. $icon_directory = $variables['icon_directory'];
  41. $uri = file_entity_download_uri($file);
  42. $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory));
  43. // Set options as per anchor format described at
  44. // http://microformats.org/wiki/file-format-examples
  45. $uri['options']['attributes']['type'] = $file->filemime . '; length=' . $file->filesize;
  46. // Provide the default link text.
  47. if (!isset($variables['text'])) {
  48. $variables['text'] = t('Download [file:name]');
  49. }
  50. // Peform unsanitized token replacement if $uri['options']['html'] is empty
  51. // since then l() will escape the link text.
  52. $variables['text'] = token_replace($variables['text'], array('file' => $file), array('clear' => TRUE, 'sanitize' => empty($uri['options']['html'])));
  53. $output = '<span class="file">' . $icon . ' ' . l($variables['text'], $uri['path'], $uri['options']);
  54. $output .= ' ' . '<span class="file-size">(' . format_size($file->filesize) . ')</span>';
  55. $output .= '</span>';
  56. return $output;
  57. }
  58. /**
  59. * Returns HTML for displaying an HTML5 <audio> tag.
  60. *
  61. * @param array $variables
  62. * An associative array containing:
  63. * - file: Associative array of file data, which must include "uri".
  64. * - controls: Boolean indicating whether or not controls should be displayed.
  65. * - autoplay: Boolean indicating whether or not the audio should start
  66. * playing automatically.
  67. * - loop: Boolean indicating whether or not the audio should loop.
  68. *
  69. * @ingroup themeable
  70. */
  71. function theme_file_entity_file_audio($variables) {
  72. $files = $variables['files'];
  73. $output = '';
  74. $audio_attributes = array();
  75. if ($variables['controls']) {
  76. $audio_attributes['controls'] = 'controls';
  77. }
  78. if ($variables['autoplay']) {
  79. $audio_attributes['autoplay'] = 'autoplay';
  80. }
  81. if ($variables['loop']) {
  82. $audio_attributes['loop'] = 'loop';
  83. }
  84. $output .= '<audio' . drupal_attributes($audio_attributes) . '>';
  85. foreach ($files as $delta => $file) {
  86. $source_attributes = array(
  87. 'src' => file_create_url($file['uri']),
  88. 'type' => $file['filemime'],
  89. );
  90. $output .= '<source' . drupal_attributes($source_attributes) . ' />';
  91. }
  92. $output .= '</audio>';
  93. return $output;
  94. }
  95. /**
  96. * Returns HTML for displaying an HTML5 <video> tag.
  97. *
  98. * @param array $variables
  99. * An associative array containing:
  100. * - file: Associative array of file data, which must include "uri".
  101. * - controls: Boolean indicating whether or not controls should be displayed.
  102. * - autoplay: Boolean indicating whether or not the video should start
  103. * playing automatically.
  104. * - loop: Boolean indicating whether or not the video should loop.
  105. * - muted: Boolean indicating whether or not the sound should be muted.
  106. * - width: Width, in pixels, of the video player.
  107. * - height: Height, in pixels, of the video player.
  108. *
  109. * @ingroup themeable
  110. */
  111. function theme_file_entity_file_video($variables) {
  112. $files = $variables['files'];
  113. $output = '';
  114. $video_attributes = array();
  115. if ($variables['controls']) {
  116. $video_attributes['controls'] = 'controls';
  117. }
  118. if ($variables['autoplay']) {
  119. $video_attributes['autoplay'] = 'autoplay';
  120. }
  121. if ($variables['loop']) {
  122. $video_attributes['loop'] = 'loop';
  123. }
  124. if ($variables['muted']) {
  125. $video_attributes['muted'] = 'muted';
  126. }
  127. if ($variables['width'] && $variables['height']) {
  128. $video_attributes['width'] = $variables['width'];
  129. $video_attributes['height'] = $variables['height'];
  130. }
  131. $output .= '<video' . drupal_attributes($video_attributes) . '>';
  132. foreach ($files as $delta => $file) {
  133. $source_attributes = array(
  134. 'src' => file_create_url($file['uri']),
  135. 'type' => $file['filemime'],
  136. );
  137. $output .= '<source' . drupal_attributes($source_attributes) . ' />';
  138. }
  139. $output .= '</video>';
  140. return $output;
  141. }