/[drupal]/contributions/modules/movino/movino_theme.inc
ViewVC logotype

Contents of /contributions/modules/movino/movino_theme.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Sun May 4 23:53:50 2008 UTC (18 months, 3 weeks ago) by tomsun
Branch: MAIN
CVS Tags: DRUPAL-5--1-1, HEAD
Changes since 1.5: +16 -8 lines
File MIME type: text/x-php
Added new preview default image options, changed default sizes, added logo, bugfix: width and height mixed when player enabled on teaser.
1 <?php // $Id: movino_theme.inc,v 1.5 2007/10/02 03:35:14 tomsun Exp $
2 /*
3 Movino Web Frontend - Theme functions
4 Copyright 2006, 2007 Tom Sundström
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20
21 /**
22 * Theme function for embedded video teasers.
23 *
24 * @param array $video
25 * Array with video information
26 * @param boolean $page
27 * Whether this is a video page or a video teaser
28 * @param array $metadata_enabled
29 * An array with id:s for all metadata fields that should be displayed
30 * @param boolean $metadata_labels
31 * Whether or not to show labels above metadata fields
32 *
33 * @return string of HTML
34 */
35 function theme_movino_content($video, $page = FALSE, $metadata_enabled = NULL, $metadata_labels = NULL) {
36
37 $output = '';
38
39 if ($metadata_enabled === NULL) {
40 $metadata_enabled = movino_metadata_enabled(!$page);
41 }
42 if ($metadata_labels === NULL) {
43 $metadata_labels = movino_metadata_labels_enabled(!$page);
44 }
45
46 $metadata_labels = movino_metadata(!$page);
47 $metadata_labels_enabled = movino_metadata_labels_enabled(!$page);
48 $metadata = '';
49
50 if(!empty($metadata_enabled)) {
51
52 if (variable_get('movino_display_movino_metadata_button', 1) && $metadata_enabled['player']) {
53 $metadata_enabled['movino_button'] = 1;
54 }
55
56 foreach($metadata_enabled as $key => $field) {
57 if ($field == 1) {
58 $field = $key;
59 }
60
61 $field_content = '';
62
63 if (!empty($field)) {
64 switch($field) {
65
66 case 'player':
67 if ($page && variable_get('movino_display_player_override_size_page', 1)) {
68 $video['width'] = variable_get('movino_display_player_width_page', 320);
69 $video['height'] = variable_get('movino_display_player_height_page', 240);
70 }
71 if (!$page && variable_get('movino_display_player_override_size_teaser', 1)) {
72 $video['width'] = variable_get('movino_display_player_width_teaser', 320);
73 $video['height'] = variable_get('movino_display_player_height_teaser', 240);
74 }
75 $field_content = movino_player($video);
76 break;
77
78 case 'icon':
79 if (empty($metadata_enabled['player'])) {
80 $field_content = l(theme('movino_video_icon', $video), $video['page'], array('title' => _movino_video_title($video, FALSE)), NULL, NULL, FALSE, TRUE);
81 }
82 break;
83
84 case 'title':
85 $field_content = l(_movino_video_title($video), $video['page'], array('title' => _movino_video_title($video, FALSE)));
86 break;
87
88 case 'author':
89 $field_content = $video['author'];
90 break;
91
92 case 'created':
93 $field_content = format_date($video['created']);
94 break;
95
96 case 'length':
97 $field_content = theme('movino_content_length', $video);
98 break;
99
100 case 'url':
101 $field_content = '<a href="'.$video['url'].'">'.$video['url'].'</a>';
102 break;
103
104 case 'movino_button':
105 $field_content = '<a href="http://www.movino.org" target="_blank"><img style="margin: 10px 0px; " src="' . base_path() . drupal_get_path('module', 'movino') . '/button.png" alt="Powered by Movino" title="Powered by Movino" /></a>';
106
107 default:
108 if (isset($video[$field])) {
109 $field_content = $video[$field];
110 }
111 }
112 }
113
114 // Add wrapper, but only if the field is non-empty.
115 if (!empty($field_content)) {
116 $metadata .= '<div class="movino-field movino-field-' . $field . '">';
117
118 // Add a label.
119 if (!empty($metadata_labels_enabled[$field])) {
120 $metadata .= '<div class="movino-field-label">' . $metadata_labels[$field] . '</div>';
121 }
122
123 // Add the data.
124 $metadata .= '<div class="movino-field-content">' . $field_content . '</div>';
125 $metadata .= '</div>';
126 }
127 }
128 }
129
130 return '<div class="movino-content movino-content-' . ($page ? 'page' : 'teaser') . '">' . $metadata . '</div>';
131 }
132
133
134 /**
135 * Theme function for embedded for video icons.
136 */
137 function theme_movino_video_icon($video) {
138 if (!empty($video['icon_width']) && !empty($video['icon_height'])) {
139 $width = $video['icon_width'];
140 $height = $video['icon_height'];
141 } else {
142 $width = variable_get('movino_display_preview_width', 176);
143 $height = variable_get('movino_display_preview_height', 144);
144 }
145
146 if (variable_get('movino_display_archive_previews', TRUE) && !empty($video['preview'])) {
147 $icon_url = $video['preview'];
148 } else {
149 $icon_url = base_path() . drupal_get_path('module', 'movino') . '/preview/' . variable_get('movino_display_preview_default_image', 'movino-logo.png');
150 }
151
152 return '<img class="movino-video-icon" src="' . $icon_url . '"' .
153 (empty($width) ? '' : ' width="' . $width . '"') .
154 (empty($height) ? '' : ' height="' . $height . '"') .
155 '/>';
156 }
157
158
159 /**
160 * Theme function for video length values.
161 */
162 function theme_movino_content_length($video) {
163
164 // Do not show length for live content.
165 if ($video['type'] == 'live') {
166 return;
167 }
168 $hours = floor($video['length'] / 3600);
169 $minutes = floor(($video['length'] % 3600) / 60);
170 $seconds = $video['length'] % 60;
171
172 return (!empty($hours) ? $hours . ':' : '')
173 . ($minutes < 10 ? '0' : '') . $minutes . ':'
174 . ($seconds < 10 ? '0' : '') . $seconds;
175 }

  ViewVC Help
Powered by ViewVC 1.1.2