1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
// $Id: lightbox2.formatter.inc,v 1.1.2.30 2010/09/22 10:47:15 snpower Exp $
|
3 |
|
|
|
4 |
|
|
/**
|
5 |
|
|
* @file
|
6 |
|
|
* Lightbox2 formatter hooks and callbacks.
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
/**
|
11 |
|
|
* Theme function for displaying the lightbox2 trigger image in an imagefield.
|
12 |
|
|
*
|
13 |
|
|
* @param $path
|
14 |
|
|
* The path to the image to be displayed.
|
15 |
|
|
* @param $alt
|
16 |
|
|
* The image alternative text.
|
17 |
|
|
* @param $title
|
18 |
|
|
* The image title.
|
19 |
|
|
* @param $attributes
|
20 |
|
|
* An array of image attributes, e.g. class name.
|
21 |
|
|
* @return
|
22 |
|
|
* HTML output for displaying the image.
|
23 |
|
|
*/
|
24 |
|
|
function theme_lightbox2_image($variables) {
|
25 |
|
|
$path = $variables['path'];
|
26 |
|
|
$item = $variables['item'];
|
27 |
|
|
$image_style = $variables['image_style'];
|
28 |
|
|
$node_id = $variables['node_id'];
|
29 |
|
|
$field_name = $variables['field_name'];
|
30 |
|
|
|
31 |
|
|
if (!$variables["lightbox_style"]) {
|
32 |
|
|
$path['path'] = file_create_url($item['uri']);
|
33 |
|
|
}
|
34 |
|
|
else {
|
35 |
|
|
$path['path'] = image_style_url($variables["lightbox_style"], $item['uri']);
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
// Lightbox type
|
39 |
|
|
$rel = $variables['lightbox_type'];
|
40 |
|
|
|
41 |
|
|
// Grouping
|
42 |
|
|
$rel .= '[';
|
43 |
|
|
$group = variable_get('lightbox2_image_group_node_id', 1);
|
44 |
|
|
|
45 |
|
|
switch ($group) {
|
46 |
|
|
// No groups
|
47 |
|
|
case '0':
|
48 |
|
|
break;
|
49 |
|
|
// Group by field name
|
50 |
|
|
case '1':
|
51 |
|
|
$rel .= $field_name;
|
52 |
|
|
break;
|
53 |
|
|
// Group by node id
|
54 |
|
|
case '2':
|
55 |
|
|
$rel .= $node_id;
|
56 |
|
|
break;
|
57 |
|
|
// Group by field name and node id
|
58 |
|
|
case '3':
|
59 |
|
|
$rel .= $field_name . '_' . $node_id;
|
60 |
|
|
break;
|
61 |
|
|
// All nodes and fields in same group
|
62 |
|
|
case '4':
|
63 |
|
|
$rel .= 'group';
|
64 |
|
|
break;
|
65 |
|
|
}
|
66 |
|
|
$rel .= ']';
|
67 |
|
|
|
68 |
|
|
// Title Start
|
69 |
|
|
$rel .= '[' . $item['title'];
|
70 |
|
|
|
71 |
|
|
// Download Link
|
72 |
|
|
if (user_access('download original image')) {
|
73 |
|
|
$rel .= '<p><a href="' . file_create_url($item['uri']) . '">' . variable_get('lightbox2_download_link_text', 'Download Original') . '</a></p>';
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
// Title End
|
77 |
|
|
$rel .= ']';
|
78 |
|
|
|
79 |
|
|
$path['options']['attributes']['rel'] = $rel;
|
80 |
|
|
$path['options']['attributes']['title'] = $item['title'];
|
81 |
|
|
|
82 |
|
|
return theme('image_formatter', array( 'item' => $item, 'path' => $path, 'image_style' => $image_style ) );
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
/**
|
86 |
|
|
* Handler for Lightbox2 display of imagecache + imagefield CCK fields.
|
87 |
|
|
*
|
88 |
|
|
* The compact view shows only the first image in a multiple imagefield but
|
89 |
|
|
* shows all images in the lightbox.
|
90 |
|
|
*
|
91 |
|
|
* @param $element
|
92 |
|
|
* The CCK field element.
|
93 |
|
|
* @return
|
94 |
|
|
* HTML output for displaying the image and link.
|
95 |
|
|
*/
|
96 |
|
|
/*function theme_lightbox2_formatter_imagefield($variables) {
|
97 |
|
|
$element = $variables['element'];
|
98 |
|
|
if (!module_exists("image")) {
|
99 |
|
|
return;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
$field_name = $element['#field_name'];
|
103 |
|
|
$item = $element['#item'];
|
104 |
|
|
$formatter = $element['#formatter'];
|
105 |
|
|
$node = node_load($element['#item']['nid']);
|
106 |
|
|
|
107 |
|
|
if (strpos($formatter, '__lightbox2__') !== FALSE || strpos($formatter, '__lightshow2__') !== FALSE || strpos($formatter, '__lightframe2__') !== FALSE
|
108 |
|
|
|| strpos($formatter, '__lightbox2_compact__') !== FALSE || strpos($formatter, '__lightshow2_compact__') !== FALSE || strpos($formatter, '__lightframe2_compact__') !== FALSE) {
|
109 |
|
|
list($tmp, $lightbox_type, $view_preset, $lightbox_preset) = explode('__', $formatter, 4);
|
110 |
|
|
return lightbox2_imagefield_image_imagecache($field_name, $item, $formatter, $node, $view_preset, $lightbox_preset);
|
111 |
|
|
}
|
112 |
|
|
}*/
|
113 |
|
|
|
114 |
|
|
/**
|
115 |
|
|
* Function to set up the data needed for
|
116 |
|
|
* theme_imagefield_image_imagecache_lightbox2().
|
117 |
|
|
*
|
118 |
|
|
* @param $field_name
|
119 |
|
|
* The field name the action is being performed on.
|
120 |
|
|
* @param $item
|
121 |
|
|
* An array, keyed by column, of the data stored for this item in this field.
|
122 |
|
|
* @param $formatter
|
123 |
|
|
* The formatter to use for the field.
|
124 |
|
|
* @param $node
|
125 |
|
|
* The node object.
|
126 |
|
|
* @param $view_preset
|
127 |
|
|
* The imagecache preset to be displayed on the node or in the view.
|
128 |
|
|
* @param $lightbox_preset
|
129 |
|
|
* The imagecache preset to be displayed in the lightbox.
|
130 |
|
|
* @return
|
131 |
|
|
* The themed imagefield + imagecache image and link.
|
132 |
|
|
*/
|
133 |
|
|
/*function lightbox2_imagefield_image_imagecache($variables) {
|
134 |
|
|
$field_name = $variables['field_name'];
|
135 |
|
|
$item = $variables['item'];
|
136 |
|
|
$formatter = $variables['formatter'];
|
137 |
|
|
$node = $variables['node'];
|
138 |
|
|
$view_preset = $variables['view_preset'];
|
139 |
|
|
$lightbox_preset = $variables['lightbox_preset'];
|
140 |
|
|
// Load file data if missing
|
141 |
|
|
if (!isset($item['filepath']) && !empty($item['fid'])) {
|
142 |
|
|
$file = field_file_load($item['fid']);
|
143 |
|
|
$item = array_merge($item, (array)$file);
|
144 |
|
|
}
|
145 |
|
|
elseif (!isset($item['filepath'])) {
|
146 |
|
|
// No file in field, return.
|
147 |
|
|
return '';
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
$args['lightbox_preset'] = $lightbox_preset;
|
151 |
|
|
|
152 |
|
|
// Check view_preset for existence.
|
153 |
|
|
$rules = array();
|
154 |
|
|
if (function_exists('imagecache_presets')) {
|
155 |
|
|
$presets = imagecache_presets();
|
156 |
|
|
foreach ($presets as $preset_id => $preset_info) {
|
157 |
|
|
$rules[$preset_id] = $preset_info['presetname'];
|
158 |
|
|
}
|
159 |
|
|
}
|
160 |
|
|
else {
|
161 |
|
|
$rules = _imagecache_get_presets();
|
162 |
|
|
}
|
163 |
|
|
if ($view_preset == 'link' || $view_preset == 'original' || in_array($view_preset, (array) $rules)) {
|
164 |
|
|
$rel = 'lightbox';
|
165 |
|
|
if (strpos($formatter, '__lightshow2__') !== FALSE) {
|
166 |
|
|
$rel = 'lightshow';
|
167 |
|
|
}
|
168 |
|
|
elseif (strpos($formatter, '__lightshow2_compact__') !== FALSE) {
|
169 |
|
|
$rel = 'lightshow';
|
170 |
|
|
$args['compact'] = TRUE;
|
171 |
|
|
}
|
172 |
|
|
elseif (strpos($formatter, '__lightframe2__') !== FALSE) {
|
173 |
|
|
$rel = 'lightframe';
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
// Check if this is a compact display.
|
177 |
|
|
list($tmp, $lightbox_type, $tmp) = explode('__', $formatter, 3);
|
178 |
|
|
if ($lightbox_type == 'lightbox2_compact') {
|
179 |
|
|
$args['compact'] = TRUE;
|
180 |
|
|
}
|
181 |
|
|
return theme('imagefield_image_imagecache_lightbox2', array( 'view_preset' => $view_preset, 'field_name' => $field_name, 'item' => $item, 'node' => $node, 'rel' => $rel, 'args' => $args ) );
|
182 |
|
|
}
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
/**
|
186 |
|
|
* Generate the HTML output for imagefield + imagecache images so they can be
|
187 |
|
|
* opened in a lightbox by clicking on the image on the node page or in a view.
|
188 |
|
|
*
|
189 |
|
|
* This actually also handles filefields + imagecache images too.
|
190 |
|
|
*
|
191 |
|
|
* @param $view_preset
|
192 |
|
|
* The imagecache preset to be displayed on the node or in the view.
|
193 |
|
|
* @param $field_name
|
194 |
|
|
* The field name the action is being performed on.
|
195 |
|
|
* @param $item
|
196 |
|
|
* An array, keyed by column, of the data stored for this item in this field.
|
197 |
|
|
* @param $node
|
198 |
|
|
* The node object.
|
199 |
|
|
* @param $rel
|
200 |
|
|
* The type of lightbox to open: lightbox, lightshow or lightframe.
|
201 |
|
|
* @param $args
|
202 |
|
|
* Args may override internal processes: caption, rel_grouping.
|
203 |
|
|
* @return
|
204 |
|
|
* The themed imagefield + imagecache image and link.
|
205 |
|
|
*/
|
206 |
|
|
/*function theme_imagefield_image_imagecache_lightbox2($variables) {
|
207 |
|
|
$view_preset = $variables['view_preset'];
|
208 |
|
|
$field_name = $variables['field_name'];
|
209 |
|
|
$item = $variables['item'];
|
210 |
|
|
$node = $variables['node'];
|
211 |
|
|
$rel = $variables['rel'];
|
212 |
|
|
$args = $variables['args'];
|
213 |
|
|
if (!isset($args['lightbox_preset'])) {
|
214 |
|
|
$args['lightbox_preset'] = 'original';
|
215 |
|
|
}
|
216 |
|
|
// Can't show current node page in a lightframe on the node page.
|
217 |
|
|
// Switch instead to show it in a lightbox.
|
218 |
|
|
$on_image_node = (arg(0) == 'node') && (arg(1) == $node->nid);
|
219 |
|
|
if ($rel == 'lightframe' && $on_image_node) {
|
220 |
|
|
$rel = 'lightbox';
|
221 |
|
|
}
|
222 |
|
|
$orig_rel = $rel;
|
223 |
|
|
|
224 |
|
|
// Unserialize into original - if sourced by views.
|
225 |
|
|
$item_data = $item['data'];
|
226 |
|
|
if (is_string($item['data'])) {
|
227 |
|
|
$item_data = unserialize($item['data']);
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
// Set up the title.
|
231 |
|
|
$image_title = $item_data['description'];
|
232 |
|
|
$image_title = (!empty($image_title) ? $image_title : $item_data['title']);
|
233 |
|
|
$image_title = (!empty($image_title) ? $image_title : $item_data['alt']);
|
234 |
|
|
if (empty($image_title) || variable_get('lightbox2_imagefield_use_node_title', FALSE)) {
|
235 |
|
|
$node = node_load($node->nid);
|
236 |
|
|
$image_title = $node->title;
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
$image_tag_title = '';
|
240 |
|
|
if (!empty($item_data['title'])) {
|
241 |
|
|
$image_tag_title = $item_data['title'];
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
// Enforce image alt.
|
246 |
|
|
$image_tag_alt = '';
|
247 |
|
|
if (!empty($item_data['alt'])) {
|
248 |
|
|
$image_tag_alt = $item_data['alt'];
|
249 |
|
|
}
|
250 |
|
|
elseif (!empty($image_title)) {
|
251 |
|
|
$image_tag_alt = $image_title;
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
// Set up the caption.
|
255 |
|
|
$node_links = array();
|
256 |
|
|
if (!empty($item['nid'])) {
|
257 |
|
|
$attributes = array();
|
258 |
|
|
$attributes['id'] = 'lightbox2-node-link-text';
|
259 |
|
|
$target = variable_get('lightbox2_node_link_target', FALSE);
|
260 |
|
|
if (!empty($target)) {
|
261 |
|
|
$attributes['target'] = $target;
|
262 |
|
|
}
|
263 |
|
|
$node_link_text = variable_get('lightbox2_node_link_text', 'View Image Details');
|
264 |
|
|
if (!$on_image_node && !empty($node_link_text)) {
|
265 |
|
|
$node_links[] = l($node_link_text, 'node/'. $item['nid'], array('attributes' => $attributes));
|
266 |
|
|
}
|
267 |
|
|
$download_link_text = check_plain(variable_get('lightbox2_download_link_text', 'Download Original'));
|
268 |
|
|
if (!empty($download_link_text) && user_access('download original image')) {
|
269 |
|
|
$node_links[] = l($download_link_text, file_create_url($item['filepath']), array('attributes' => array('target' => '_blank', 'id' => 'lightbox2-download-link-text')));
|
270 |
|
|
}
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
$caption = $image_title;
|
274 |
|
|
if (count($node_links)) {
|
275 |
|
|
$caption .= '<br /><br />'. implode(" - ", $node_links);
|
276 |
|
|
}
|
277 |
|
|
if (isset($args['caption'])) {
|
278 |
|
|
$caption = $args['caption']; // Override caption.
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
if ($orig_rel == 'lightframe') {
|
282 |
|
|
$frame_width = variable_get('lightbox2_default_frame_width', 600);
|
283 |
|
|
$frame_height = variable_get('lightbox2_default_frame_height', 400);
|
284 |
|
|
$frame_size = 'width:'. $frame_width .'px; height:'. $frame_height .'px;';
|
285 |
|
|
$rel = preg_replace('/\]$/', "|$frame_size]", $rel);
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
// Set up the rel attribute.
|
289 |
|
|
$full_rel = '';
|
290 |
|
|
$imagefield_grouping = variable_get('lightbox2_imagefield_group_node_id', 1);
|
291 |
|
|
if (isset($args['rel_grouping'])) {
|
292 |
|
|
$full_rel = $rel .'['. $args['rel_grouping'] .']['. $caption .']';
|
293 |
|
|
}
|
294 |
|
|
elseif ($imagefield_grouping == 1) {
|
295 |
|
|
$full_rel = $rel .'['. $field_name .']['. $caption .']';
|
296 |
|
|
}
|
297 |
|
|
elseif ($imagefield_grouping == 2 && !empty($item['nid'])) {
|
298 |
|
|
$full_rel = $rel .'['. $item['nid'] .']['. $caption .']';
|
299 |
|
|
}
|
300 |
|
|
elseif ($imagefield_grouping == 3 && !empty($item['nid'])) {
|
301 |
|
|
$full_rel = $rel .'['. $field_name .'_'. $item['nid'] .']['. $caption .']';
|
302 |
|
|
}
|
303 |
|
|
elseif ($imagefield_grouping == 4 ) {
|
304 |
|
|
$full_rel = $rel .'[allnodes]['. $caption .']';
|
305 |
|
|
}
|
306 |
|
|
else {
|
307 |
|
|
$full_rel = $rel .'[]['. $caption .']';
|
308 |
|
|
}
|
309 |
|
|
$class = '';
|
310 |
|
|
if ($view_preset != 'original') {
|
311 |
|
|
$class = 'imagecache imagecache-' . $field_name . ' imagecache-' . $view_preset . ' imagecache-' . $field_name . '-' . $view_preset;
|
312 |
|
|
}
|
313 |
|
|
$link_attributes = array(
|
314 |
|
|
'rel' => $full_rel,
|
315 |
|
|
'class' => 'imagefield imagefield-lightbox2 imagefield-lightbox2-' . $view_preset . ' imagefield-' . $field_name . ' ' . $class,
|
316 |
|
|
);
|
317 |
|
|
|
318 |
|
|
$attributes = array();
|
319 |
|
|
if (isset($args['compact']) && $item['#delta']) {
|
320 |
|
|
$image = '';
|
321 |
|
|
}
|
322 |
|
|
elseif ($view_preset == 'original') {
|
323 |
|
|
$image = theme('lightbox2_image', array( 'path' => $item['filepath'], 'alt' => $image_tag_alt, 'title' => $image_tag_title, 'attributes' => $attributes ) );
|
324 |
|
|
}
|
325 |
|
|
elseif ($view_preset == 'link') {
|
326 |
|
|
// Not actually an image, just a text link.
|
327 |
|
|
$image = variable_get('lightbox2_view_image_text', 'View image');
|
328 |
|
|
}
|
329 |
|
|
else {
|
330 |
|
|
$image = theme('imagecache', array( 'style_name' => $view_preset, 'path' => $item['filepath'], 'alt' => $image_tag_alt, 'title' => $image_tag_title, 'attributes' => $attributes ) );
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
if ($args['lightbox_preset'] == 'node') {
|
334 |
|
|
$output = l($image, 'node/'. $node->nid .'/lightbox2', array('attributes' => $link_attributes, 'html' => TRUE));
|
335 |
|
|
}
|
336 |
|
|
elseif ($args['lightbox_preset'] == 'original') {
|
337 |
|
|
$output = l($image, file_create_url($item['filepath']), array('attributes' => $link_attributes, 'html' => TRUE));
|
338 |
|
|
}
|
339 |
|
|
else {
|
340 |
|
|
$output = l($image, imagecache_create_url($args['lightbox_preset'], $item['filepath']), array('attributes' => $link_attributes, 'html' => TRUE));
|
341 |
|
|
}
|
342 |
|
|
return $output;
|
343 |
|
|
}*/
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
/**
|
347 |
|
|
* Theme function for the lightbox iframe filefield formatter.
|
348 |
|
|
*
|
349 |
|
|
* @param $element
|
350 |
|
|
* The CCK field element.
|
351 |
|
|
* @return
|
352 |
|
|
* The themed link to the file, with lightframe support.
|
353 |
|
|
*/
|
354 |
|
|
/*function theme_lightbox2_formatter_filefield_lightframe($variables) {
|
355 |
|
|
$element = $variables['element'];
|
356 |
|
|
$file = $element['#item'];
|
357 |
|
|
$field = content_fields($element['#field_name']);
|
358 |
|
|
if (!filefield_view_access($field['field_name']) || empty($file['list'])) {
|
359 |
|
|
return '';
|
360 |
|
|
}
|
361 |
|
|
if (empty($file['fid']) || !is_file($file['filepath'])) {
|
362 |
|
|
return '';
|
363 |
|
|
}
|
364 |
|
|
$file = (object)$file;
|
365 |
|
|
if (!lightbox2_check_filefield_extension($file, $field)) {
|
366 |
|
|
return '';
|
367 |
|
|
}
|
368 |
|
|
drupal_add_css(drupal_get_path('module', 'filefield') .'/filefield.css');
|
369 |
|
|
return '<div class="filefield-item">'. theme('lightbox2_file_formatter_lightbox2_iframe', array( 'file' => $file, 'field' => $field, 'file_formatter_settings' => NULL ) ) .'</div>';
|
370 |
|
|
}*/
|
371 |
|
|
|
372 |
|
|
/**
|
373 |
|
|
* Theme function for the lightbox iframe filefield formatter.
|
374 |
|
|
*
|
375 |
|
|
* @param $file
|
376 |
|
|
* Filefield file object.
|
377 |
|
|
* @param $field
|
378 |
|
|
* The CCK field the action is being performed on.
|
379 |
|
|
* @param $file_formatter_settings
|
380 |
|
|
* File formatter settings; ignored.
|
381 |
|
|
* @return
|
382 |
|
|
* Themed link to filefield.
|
383 |
|
|
*/
|
384 |
|
|
/*function theme_lightbox2_file_formatter_lightbox2_iframe($variables) {
|
385 |
|
|
$file = $variables['file'];
|
386 |
|
|
$field = $varbiables['field'];
|
387 |
|
|
$file_formatter_settings = $variables['file_formatter_settings'];
|
388 |
|
|
$path = $file->filepath;
|
389 |
|
|
$url = file_create_url($path);
|
390 |
|
|
$icon = theme('file_icon', array( 'file' => $file ) );
|
391 |
|
|
$file_data = $file->data;
|
392 |
|
|
if (is_string($file_data)) {
|
393 |
|
|
$file_data = unserialize($file->data);
|
394 |
|
|
}
|
395 |
|
|
$description = $file_data['description'];
|
396 |
|
|
if (empty($description)) {
|
397 |
|
|
$description = $file->filename;
|
398 |
|
|
}
|
399 |
|
|
$attributes = array();
|
400 |
|
|
$attributes['id'] = 'lightbox2-node-link-text';
|
401 |
|
|
$target = variable_get('lightbox2_node_link_target', FALSE);
|
402 |
|
|
if (!empty($target)) {
|
403 |
|
|
$attributes['target'] = $target;
|
404 |
|
|
}
|
405 |
|
|
$node_link = '';
|
406 |
|
|
$node_link_text = check_plain(variable_get('lightbox2_node_link_text', 'View Image Details'));
|
407 |
|
|
if (!empty($node_link_text)) {
|
408 |
|
|
$node_link .= '<br /><br />'. l($node_link_text, $url, array('attributes' => $attributes));
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
// Only files with supported extensions make it this far, so no need to check here.
|
412 |
|
|
$link_attributes = array('rel' => 'lightframe[]['. $description . $node_link .']');
|
413 |
|
|
|
414 |
|
|
return '<div class="filefield-formatter-lightbox2-iframe">'. $icon . l($description, $url, array('attributes' => $link_attributes)) .'</div>';
|
415 |
|
|
}*/
|
416 |
|
|
|
417 |
|
|
/**
|
418 |
|
|
* Generate the HTML output to open embedded cck images in a lightbox.
|
419 |
|
|
*
|
420 |
|
|
* @param $element
|
421 |
|
|
* The CCK field element.
|
422 |
|
|
* @return
|
423 |
|
|
* The themed link to the embedded image.
|
424 |
|
|
*/
|
425 |
|
|
/*function theme_lightbox2_formatter_emimage($variables) {
|
426 |
|
|
$element = $variables['element'];
|
427 |
|
|
$field = content_fields($element['#field_name'], $element['#type_name']);
|
428 |
|
|
$item = $element['#item'];
|
429 |
|
|
$formatter = $element['#formatter'];
|
430 |
|
|
$node = node_load($element['#node']->nid);
|
431 |
|
|
|
432 |
|
|
list($tmp, $lightbox_type) = explode('_', $formatter, 2);
|
433 |
|
|
$field['lightbox_type'] = $lightbox_type;
|
434 |
|
|
$formatter = "emimage";
|
435 |
|
|
|
436 |
|
|
return module_invoke('emfield', 'emfield_field_formatter', $field, $item, $formatter, $node, 'lightbox2');
|
437 |
|
|
}*/
|
438 |
|
|
|
439 |
|
|
/**
|
440 |
|
|
* Generate the HTML output to open embedded cck images in a lightbox.
|
441 |
|
|
*
|
442 |
|
|
* @param $field
|
443 |
|
|
* The CCK field the action is being performed on.
|
444 |
|
|
* @param $item
|
445 |
|
|
* An array, keyed by column, of the data stored for this item in this field.
|
446 |
|
|
* @param $formatter
|
447 |
|
|
* The formatter to use for the field.
|
448 |
|
|
* @param $node
|
449 |
|
|
* The node object.
|
450 |
|
|
* @param $args
|
451 |
|
|
* Args may override internal processes: caption, rel_grouping.
|
452 |
|
|
* @return
|
453 |
|
|
* Themed embedded media field image and link.
|
454 |
|
|
*/
|
455 |
|
|
/*function theme_lightbox2_emimage($variables) {
|
456 |
|
|
$field = $variables['field'];
|
457 |
|
|
$item = $variables['item'];
|
458 |
|
|
$formatter = $variables['formatter'];
|
459 |
|
|
$node = $variables['node'];
|
460 |
|
|
$args = $variables['args'];
|
461 |
|
|
|
462 |
|
|
$lightbox_type = $field['lightbox_type'];
|
463 |
|
|
|
464 |
|
|
if ($item['value'] && $item['provider']) {
|
465 |
|
|
$rel = 'lightbox';
|
466 |
|
|
if ($lightbox_type == 'lightshow2') {
|
467 |
|
|
$rel = 'lightshow';
|
468 |
|
|
}
|
469 |
|
|
elseif ($lightbox_type == 'lightframe2') {
|
470 |
|
|
$rel = 'lightframe';
|
471 |
|
|
}
|
472 |
|
|
if ($rel == 'lightframe' && arg(0) == 'node' && arg(1) == $node->nid) {
|
473 |
|
|
$rel = 'lightbox';
|
474 |
|
|
}
|
475 |
|
|
$orig_rel = $rel;
|
476 |
|
|
|
477 |
|
|
$code = $item['value'];
|
478 |
|
|
$width = $field['widget']['thumbnail_width'] == '' ? variable_get('emimage_default_full_width', EMIMAGE_DEFAULT_FULL_WIDTH) : $field['widget']['thumbnail_width'];
|
479 |
|
|
$height = $field['widget']['thumbnail_height'] == '' ? variable_get('emimage_default_full_height', EMIMAGE_DEFAULT_FULL_HEIGHT) : $field['widget']['thumbnail_height'];
|
480 |
|
|
$link = $field['widget']['thumbnail_link'] ? $field['widget']['thumbnail_link'] : variable_get('emimage_default_thumbnail_link', EMIMAGE_DEFAULT_THUMBNAIL_LINK);
|
481 |
|
|
if ($link == EMIMAGE_LINK_CONTENT) {
|
482 |
|
|
$link = 'node/'. $node->nid;
|
483 |
|
|
}
|
484 |
|
|
elseif ($link == EMIMAGE_LINK_PROVIDER) {
|
485 |
|
|
$link = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'embedded_link', $code, $item['data']);
|
486 |
|
|
}
|
487 |
|
|
else {
|
488 |
|
|
$link = NULL;
|
489 |
|
|
}
|
490 |
|
|
$attributes = array();
|
491 |
|
|
$attributes['id'] = 'lightbox2-node-link-text';
|
492 |
|
|
if ($width) {
|
493 |
|
|
$attributes['width'] = $width;
|
494 |
|
|
}
|
495 |
|
|
if ($height) {
|
496 |
|
|
$attributes['height'] = $height;
|
497 |
|
|
}
|
498 |
|
|
$target = variable_get('lightbox2_node_link_target', FALSE);
|
499 |
|
|
if (!empty($target)) {
|
500 |
|
|
$attributes['target'] = $target;
|
501 |
|
|
}
|
502 |
|
|
|
503 |
|
|
// Set up the title.
|
504 |
|
|
$title = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_title', $code, $item['data']);
|
505 |
|
|
|
506 |
|
|
// Set up the caption.
|
507 |
|
|
$node_link = '';
|
508 |
|
|
$node_link_text = variable_get('lightbox2_node_link_text', 'View Image Details');
|
509 |
|
|
if (!empty($node_link_text) && !empty($link)) {
|
510 |
|
|
$node_link = '<br /><br />'. l($node_link_text, $link, array('attributes' => $attributes));
|
511 |
|
|
}
|
512 |
|
|
// @TODO original download link possible with emfield?
|
513 |
|
|
|
514 |
|
|
$caption = $title . $node_link;
|
515 |
|
|
if (isset($args['caption'])) {
|
516 |
|
|
$caption = $args['caption']; // Override caption.
|
517 |
|
|
}
|
518 |
|
|
|
519 |
|
|
// Set up url and image.
|
520 |
|
|
$url = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_url', $code, $width, $height, "emimage", $field, $item, $node);
|
521 |
|
|
$image = theme('image', array( 'path' => $url, 'alt' => $title, 'title' => $title, 'attributes' => $attributes, 'getsize' => FALSE ) );
|
522 |
|
|
|
523 |
|
|
// Set up full rel attribute.
|
524 |
|
|
$image_grouping = variable_get('lightbox2_emimage_group_node_id', 1);
|
525 |
|
|
if ($image_grouping == 1) {
|
526 |
|
|
$full_rel = $rel .'['. $field['field_name'] .']['. $caption .']';
|
527 |
|
|
}
|
528 |
|
|
elseif ($image_grouping == 2 && !empty($node->nid)) {
|
529 |
|
|
$full_rel = $rel .'['. $node->nid .']['. $caption .']';
|
530 |
|
|
}
|
531 |
|
|
elseif ($image_grouping == 3 && !empty($node->nid)) {
|
532 |
|
|
$full_rel = $rel .'['. $field['field_name'] .'_'. $node->nid .']['. $caption .']';
|
533 |
|
|
}
|
534 |
|
|
elseif (isset($args['rel_grouping'])) {
|
535 |
|
|
$full_rel = $rel .'['. $args['rel_grouping'] .']['. $caption .']';
|
536 |
|
|
}
|
537 |
|
|
else {
|
538 |
|
|
$rel = $full_rel .'[]['. $caption .']';
|
539 |
|
|
}
|
540 |
|
|
|
541 |
|
|
if ($orig_rel != 'lightframe') {
|
542 |
|
|
$link_attributes = array('rel' => $full_rel);
|
543 |
|
|
$full_width = $field['widget']['full_width'] == '' ? variable_get('emimage_default_full_width', EMIMAGE_DEFAULT_FULL_WIDTH) : $field['widget']['full_width'];
|
544 |
|
|
$full_height = $field['widget']['full_height'] == '' ? variable_get('emimage_default_full_height', EMIMAGE_DEFAULT_FULL_HEIGHT) : $field['widget']['full_height'];
|
545 |
|
|
$full_image_url = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_url', $code, $full_width, $full_height, "emimage", $field, $item, $node);
|
546 |
|
|
$output = l($image, $full_image_url, array('attributes' => $link_attributes, 'html' => TRUE));
|
547 |
|
|
}
|
548 |
|
|
else {
|
549 |
|
|
$frame_width = variable_get('lightbox2_default_frame_width', 600);
|
550 |
|
|
$frame_height = variable_get('lightbox2_default_frame_height', 400);
|
551 |
|
|
$frame_size = 'width:'. $frame_width .'px; height:'. $frame_height .'px;';
|
552 |
|
|
$full_rel = preg_replace('/\]\[/', "|$frame_size][", $full_rel);
|
553 |
|
|
$link_attributes = array('rel' => $full_rel);
|
554 |
|
|
$output = l($image, $link .'/lightbox2', array('attributes' => $link_attributes, 'html' => TRUE));
|
555 |
|
|
}
|
556 |
|
|
}
|
557 |
|
|
|
558 |
|
|
return $output;
|
559 |
|
|
}*/
|
560 |
|
|
|
561 |
|
|
/**
|
562 |
|
|
* Generate the HTML output to open embedded cck videos in a lightbox.
|
563 |
|
|
*
|
564 |
|
|
* @param $element
|
565 |
|
|
* The CCK field element.
|
566 |
|
|
* @return
|
567 |
|
|
* HTML output for displaying the video and link.
|
568 |
|
|
*/
|
569 |
|
|
/*function theme_lightbox2_formatter_emvideo_lightvideo($variables) {
|
570 |
|
|
$element = $variables['element'];
|
571 |
|
|
if (!variable_get('lightbox2_enable_video', FALSE)) {
|
572 |
|
|
return;
|
573 |
|
|
}
|
574 |
|
|
$field = content_fields($element['#field_name'], $element['#type_name']);
|
575 |
|
|
$item = $element['#item'];
|
576 |
|
|
$formatter = "emvideo";
|
577 |
|
|
$node = node_load($element['#node']->nid);
|
578 |
|
|
|
579 |
|
|
return module_invoke('emfield', 'emfield_field_formatter', $field, $item, $formatter, $node, 'lightbox2');
|
580 |
|
|
}*/
|
581 |
|
|
|
582 |
|
|
/**
|
583 |
|
|
* Generate the HTML output to open embedded cck videos in a lightbox.
|
584 |
|
|
*
|
585 |
|
|
* @param $field
|
586 |
|
|
* The CCK field the action is being performed on.
|
587 |
|
|
* @param $item
|
588 |
|
|
* An array, keyed by column, of the data stored for this item in this field.
|
589 |
|
|
* @param $formatter
|
590 |
|
|
* The formatter to use for the field.
|
591 |
|
|
* @param $node
|
592 |
|
|
* The node object.
|
593 |
|
|
* @param $options
|
594 |
|
|
* Options array.
|
595 |
|
|
* @return
|
596 |
|
|
* Themed link to the embedded media field video.
|
597 |
|
|
*/
|
598 |
|
|
/*function theme_lightbox2_emvideo($variables) {
|
599 |
|
|
$field = $variables['field'];
|
600 |
|
|
$item = $variables['item'];
|
601 |
|
|
$formatter = $variables['formatter'];
|
602 |
|
|
$node = $variables['node'];
|
603 |
|
|
$thumbnail = isset($options['thumbnail']) ? $options['thumbnail'] : theme('emvideo_video_thumbnail', $field, $item, 'video_thumbnail', $node, TRUE, $options);
|
604 |
|
|
// if options title set use that, otherwise use video title if set in node,
|
605 |
|
|
// otherwise try node title, then widget thumbnail setting and fallback to
|
606 |
|
|
// default string.
|
607 |
|
|
$title = isset($options['title']) ? $options['title'] : (isset($item['data']['emthumb']['emthumb_title']) ? $item['data']['emthumb']['emthumb_title'] : (isset($node->title) ? $node->title : (isset($field['widget']['thumbnail_link_title']) ? $field['widget']['thumbnail_link_title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video')))));
|
608 |
|
|
|
609 |
|
|
$destination = 'video-cck/lightbox2/'. $node->nid .'/'. $field['widget']['video_width'] .'/'. $field['widget']['video_height'] .'/'. $field['field_name'] .'/'. $item['provider'] .'/'. $item['value'];
|
610 |
|
|
$width = $field['widget']['video_width'] + 20;
|
611 |
|
|
$height = $field['widget']['video_height'] + 20;
|
612 |
|
|
if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)) {
|
613 |
|
|
$width = $field['widget']['video_width'] + 40;
|
614 |
|
|
$height = $field['widget']['video_height'] + 40;
|
615 |
|
|
}
|
616 |
|
|
$rel_full = 'lightframe['. $field['type_name'] . '|width:'. $width .'px; height:'. $height .'px; overflow:visible;]';
|
617 |
|
|
|
618 |
|
|
$attributes = array(
|
619 |
|
|
'attributes' => array(
|
620 |
|
|
'title' => $title,
|
621 |
|
|
'class' => $field['type_name'],
|
622 |
|
|
'rel' => $rel_full,
|
623 |
|
|
),
|
624 |
|
|
'query' => NULL,
|
625 |
|
|
'fragment' => NULL,
|
626 |
|
|
'absolute' => FALSE,
|
627 |
|
|
'html' => TRUE,
|
628 |
|
|
);
|
629 |
|
|
|
630 |
|
|
$output = l($thumbnail, $destination, $attributes);
|
631 |
|
|
return $output;
|
632 |
|
|
}*/ |