media_archive.styles.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. /**
  3. * @file media_archive/includes/media_archive.styles.inc
  4. * Styles definitions for Media: Archive.
  5. */
  6. /**
  7. * Implementation of Styles module hook_styles_default_containers().
  8. */
  9. function media_archive_styles_default_containers() {
  10. // We append Archive to the file containers.
  11. return array(
  12. 'file' => array(
  13. 'containers' => array(
  14. 'media_archive' => array(
  15. 'class' => 'MediaArchiveStyles',
  16. 'name' => 'media_archive',
  17. 'label' => t('Archive'),
  18. 'preview' => 'media_archive_preview_style',
  19. ),
  20. ),
  21. ),
  22. );
  23. }
  24. /**
  25. * Implementation of Styles module hook_styles_default_presets().
  26. */
  27. function media_archive_styles_default_presets() {
  28. return array(
  29. 'file' => array(
  30. 'containers' => array(
  31. 'media_archive' => array(
  32. 'default preset' => 'linked_thumbnail',
  33. 'styles' => array(
  34. 'original' => array(
  35. 'default preset' => 'video',
  36. ),
  37. 'thumbnail' => array(
  38. 'default preset' => 'linked_thumbnail',
  39. ),
  40. 'square_thumbnail' => array(
  41. 'default preset' => 'linked_square_thumbnail',
  42. ),
  43. 'medium' => array(
  44. 'default preset' => 'linked_medium',
  45. ),
  46. 'large' => array(
  47. 'default preset' => 'large_video',
  48. ),
  49. ),
  50. 'presets' => array(
  51. 'unlinked_thumbnail' => array(
  52. array(
  53. 'name' => 'thumbnail',
  54. 'settings' => array(),
  55. ),
  56. ),
  57. 'linked_thumbnail' => array(
  58. array(
  59. 'name' => 'link_to_media',
  60. 'settings' => array(),
  61. ),
  62. array(
  63. 'name' => 'thumbnail',
  64. 'settings' => array(),
  65. ),
  66. ),
  67. 'linked_square_thumbnail' => array(
  68. array(
  69. 'name' => 'link_to_media',
  70. 'settings' => array(),
  71. ),
  72. array(
  73. 'name' => 'image_style',
  74. 'settings' => array(
  75. 'image_style' => 'square_thumbnail',
  76. ),
  77. ),
  78. array(
  79. 'name' => 'thumbnail',
  80. 'settings' => array(),
  81. ),
  82. ),
  83. 'linked_medium' => array(
  84. array(
  85. 'name' => 'link_to_media',
  86. 'settings' => array(),
  87. ),
  88. array(
  89. 'name' => 'image_style',
  90. 'settings' => array(
  91. 'image_style' => 'medium',
  92. ),
  93. ),
  94. array(
  95. 'name' => 'thumbnail',
  96. 'settings' => array(),
  97. ),
  98. ),
  99. 'video' => array(
  100. array(
  101. 'name' => 'video',
  102. 'settings' => array(),
  103. ),
  104. ),
  105. 'large_video' => array(
  106. array(
  107. 'name' => 'resize',
  108. 'settings' => array(
  109. 'width' => 480,
  110. 'height' => 360,
  111. ),
  112. ),
  113. array(
  114. 'name' => 'video',
  115. 'settings' => array(),
  116. ),
  117. ),
  118. ),
  119. ),
  120. ),
  121. ),
  122. );
  123. }
  124. class MediaArchiveStyles extends FileStyles {
  125. public $autoplay;
  126. public $fullscreen;
  127. function get_autoplay() {
  128. return $this->get('autoplay');
  129. }
  130. function set_autoplay($value) {
  131. return $this->set('autoplay', $value);
  132. }
  133. function get_fullscreen() {
  134. return $this->get('fullscreen');
  135. }
  136. function set_fullscreen($value) {
  137. return $this->set('fullscreen', $value);
  138. }
  139. function get_image_uri() {
  140. if ($image_uri = $this->get('image_uri')) {
  141. return $image_uri;
  142. }
  143. $object = $this->get_object();
  144. if ($object->uri) {
  145. $wrapper = file_stream_wrapper_get_instance_by_uri($object->uri);
  146. return $wrapper->getLocalThumbnailPath();
  147. }
  148. }
  149. function video($effect) {
  150. $variables = array(
  151. 'uri' => $this->get_uri(),
  152. 'width' => $this->get_width(),
  153. 'height' => $this->get_height(),
  154. 'autoplay' => $this->get_autoplay(),
  155. 'fullscreen' => $this->get_fullscreen(),
  156. );
  157. $this->set_output(theme('media_archive_video', $variables));
  158. }
  159. }