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