Projet

Général

Profil

Paste
Télécharger (22,5 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / colorbox / colorbox.module @ b433176d

1
<?php
2

    
3
/**
4
 * @file
5
 * A light-weight, customizable lightbox plugin for jQuery 1.3.
6
 */
7

    
8
/**
9
 * The minimum required version of the Colorbox plugin.
10
 */
11
define('COLORBOX_MIN_PLUGIN_VERSION', '1.6.1');
12

    
13
/**
14
 * Implements hook_theme().
15
 */
16
function colorbox_theme() {
17
  return array(
18
    'colorbox_imagefield' => array(
19
      'variables' => array(
20
        'image' => array(),
21
        'path' => NULL,
22
        'title' => NULL,
23
        'gid' => NULL,
24
      ),
25
      'file' => 'colorbox.theme.inc',
26
    ),
27
    'colorbox_insert_image' => array(
28
      'variables' => array(
29
        'item' => NULL,
30
        'widget' => NULL,
31
      ),
32
      'template' => 'colorbox-insert-image',
33
      'pattern' => 'colorbox_insert_image__[a-z0-9_]+',
34
      'file' => 'colorbox.theme.inc',
35
    ),
36
    'colorbox_image_formatter' => array(
37
      'variables' => array(
38
        'item' => NULL,
39
        'entity_type' => NULL,
40
        'entity' => NULL,
41
        // Left for legacy support.
42
        'node' => NULL,
43
        'field' => array(),
44
        'display_settings' => array(),
45
        'delta' => NULL,
46
      ),
47
      'file' => 'colorbox.theme.inc',
48
    ),
49
  );
50
}
51

    
52
/**
53
 * Implements hook_init().
54
 */
55
function colorbox_init() {
56
  // Do not load colorbox during the Drupal installation process, e.g. if part
57
  // of installation profiles. Only add the JavaScript and CSS on specified
58
  // paths.
59
  if (!drupal_installation_attempted() && _colorbox_active()) {
60
    _colorbox_doheader();
61
  }
62
}
63

    
64
/**
65
 * Implements hook_views_api().
66
 */
67
function colorbox_views_api() {
68
  return array(
69
    'api' => 2,
70
    'path' => drupal_get_path('module', 'colorbox') . '/views',
71
  );
72
}
73

    
74
/**
75
 * Implements hook_libraries_info().
76
 */
77
function colorbox_libraries_info() {
78
  $libraries['colorbox'] = array(
79
    'name' => 'Colorbox plugin',
80
    'vendor url' => 'http://www.jacklmoore.com/colorbox',
81
    'download url' => 'https://github.com/jackmoore/colorbox/archive/1.x.zip',
82
    'version arguments' => array(
83
      'file' => 'jquery.colorbox-min.js',
84
      'pattern' => '@(?i:Colorbox)\sv?([0-9\.a-z]+)@',
85
      'lines' => 5,
86
    ),
87
    'files' => array(
88
      'js' => array(
89
        'jquery.colorbox-min.js',
90
      ),
91
    ),
92
    'variants' => array(
93
      'minified' => array(
94
        'files' => array(
95
          'js' => array(
96
            'jquery.colorbox-min.js',
97
          ),
98
        ),
99
      ),
100
      'source' => array(
101
        'files' => array(
102
          'js' => array(
103
            'jquery.colorbox.js',
104
          ),
105
        ),
106
      ),
107
    ),
108
  );
109

    
110
  return $libraries;
111
}
112

    
113
/**
114
 * Implements hook_menu().
115
 */
116
function colorbox_menu() {
117
  $items = array();
118

    
119
  $items['admin/config/media/colorbox'] = array(
120
    'title' => 'Colorbox',
121
    'description' => 'Adjust Colorbox settings.',
122
    'file' => 'colorbox.admin.inc',
123
    'page callback' => 'drupal_get_form',
124
    'page arguments' => array('colorbox_admin_settings'),
125
    'access arguments' => array('administer site configuration'),
126
  );
127

    
128
  return $items;
129
}
130

    
131
/**
132
 * Check if Colorbox should be active for the current URL.
133
 *
134
 * @return bool
135
 *   TRUE if Colorbox should be active for the current page.
136
 */
137
function _colorbox_active() {
138
  // Make it possible deactivate Colorbox with
139
  // parameter ?colorbox=no in the url.
140
  if (isset($_GET['colorbox']) && $_GET['colorbox'] == 'no') {
141
    return FALSE;
142
  }
143

    
144
  // Code from the block_list function in block.module.
145
  $path = drupal_get_path_alias($_GET['q']);
146
  $colorbox_pages = variable_get('colorbox_pages', "admin*\nimagebrowser*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*\nsystem/ajax\nsystem/ajax/*");
147
  // Compare with the internal and path alias (if any).
148
  $page_match = drupal_match_path($path, $colorbox_pages);
149
  if ($path != $_GET['q']) {
150
    $page_match = $page_match || drupal_match_path($_GET['q'], $colorbox_pages);
151
  }
152
  $page_match = variable_get('colorbox_visibility', 0) == 0 ? !$page_match : $page_match;
153

    
154
  // Allow other modules to change the state of colorbox for the current URL.
155
  drupal_alter('colorbox_active', $page_match);
156

    
157
  return $page_match;
158
}
159

    
160
/**
161
 * Loads the various js and css files.
162
 */
163
function _colorbox_doheader() {
164
  static $already_added = FALSE;
165
  if ($already_added) {
166
    // Don't add the JavaScript and CSS multiple times.
167
    return;
168
  }
169

    
170
  // Insert options and translated strings as JavaScript settings.
171
  if (variable_get('colorbox_custom_settings_activate', 0)) {
172
    $js_settings = array(
173
      'transition' => variable_get('colorbox_transition_type', 'elastic'),
174
      'speed' => variable_get('colorbox_transition_speed', 350),
175
      'opacity' => variable_get('colorbox_opacity', '0.85'),
176
      'slideshow' => variable_get('colorbox_slideshow', 0) ? TRUE : FALSE,
177
      'slideshowAuto' => variable_get('colorbox_slideshowauto', 1) ? TRUE : FALSE,
178
      'slideshowSpeed' => variable_get('colorbox_slideshowspeed', 2500),
179
      'slideshowStart' => variable_get('colorbox_text_start', 'start slideshow'),
180
      'slideshowStop' => variable_get('colorbox_text_stop', 'stop slideshow'),
181
      'current' => strip_tags(variable_get('colorbox_text_current', '{current} of {total}')),
182
      'previous' => strip_tags(variable_get('colorbox_text_previous', '« Prev')),
183
      'next' => strip_tags(variable_get('colorbox_text_next', 'Next »')),
184
      'close' => strip_tags(variable_get('colorbox_text_close', 'Close')),
185
      'overlayClose' => variable_get('colorbox_overlayclose', 1) ? TRUE : FALSE,
186
      'returnFocus' => variable_get('colorbox_returnfocus', 1) ? TRUE : FALSE,
187
      'maxWidth' => variable_get('colorbox_maxwidth', '98%'),
188
      'maxHeight' => variable_get('colorbox_maxheight', '98%'),
189
      'initialWidth' => variable_get('colorbox_initialwidth', '300'),
190
      'initialHeight' => variable_get('colorbox_initialheight', '250'),
191
      'fixed' => variable_get('colorbox_fixed', 1) ? TRUE : FALSE,
192
      'scrolling' => variable_get('colorbox_scrolling', 1) ? TRUE : FALSE,
193
      'mobiledetect' => variable_get('colorbox_mobile_detect', 1) ? TRUE : FALSE,
194
      'mobiledevicewidth' => variable_get('colorbox_mobile_device_width', '480px'),
195
    );
196
  }
197
  else {
198
    $js_settings = array(
199
      'opacity' => '0.85',
200
      'current' => t('{current} of {total}'),
201
      'previous' => t('« Prev'),
202
      'next' => t('Next »'),
203
      'close' => t('Close'),
204
      'maxWidth' => '98%',
205
      'maxHeight' => '98%',
206
      'fixed' => TRUE,
207
      'mobiledetect' => variable_get('colorbox_mobile_detect', 1) ? TRUE : FALSE,
208
      'mobiledevicewidth' => variable_get('colorbox_mobile_device_width', '480px'),
209
    );
210
  }
211

    
212
  $js_settings['specificPagesDefaultValue'] = "admin*\nimagebrowser*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*\nsystem/ajax\nsystem/ajax/*";
213

    
214
  $path = drupal_get_path('module', 'colorbox');
215
  $style = variable_get('colorbox_style', 'default');
216

    
217
  // Give other modules the possibility to override Colorbox settings and style.
218
  $data = &$js_settings;
219
  drupal_alter('colorbox_settings', $data, $style);
220

    
221
  drupal_add_js(array('colorbox' => $js_settings), array('type' => 'setting', 'scope' => JS_DEFAULT));
222

    
223
  // Add and initialise the Colorbox plugin.
224
  $variant = variable_get('colorbox_compression_type', 'minified');
225
  if (module_exists('libraries')) {
226
    libraries_load('colorbox', $variant);
227
  }
228
  drupal_add_js($path . '/js/colorbox.js');
229

    
230
  // Add JS and CSS based on selected style.
231
  switch ($style) {
232
    case 'none':
233
      break;
234

    
235
    case 'default':
236
    case 'plain':
237
    case 'stockholmsyndrome':
238
      drupal_add_css($path . '/styles/' . $style . '/colorbox_style.css');
239
      drupal_add_js($path . '/styles/' . $style . '/colorbox_style.js');
240
      break;
241

    
242
    default:
243
      drupal_add_css($style . '/colorbox.css');
244
  }
245

    
246
  if (variable_get('colorbox_load', 0)) {
247
    drupal_add_js($path . '/js/colorbox_load.js');
248
  }
249

    
250
  if (variable_get('colorbox_inline', 0)) {
251
    drupal_add_js($path . '/js/colorbox_inline.js');
252
  }
253

    
254
  $already_added = TRUE;
255
}
256

    
257
/**
258
 * Implements hook_field_formatter_info().
259
 */
260
function colorbox_field_formatter_info() {
261
  return array(
262
    'colorbox' => array(
263
      'label' => t('Colorbox'),
264
      'field types' => array('image'),
265
      'settings' => array(
266
        'colorbox_node_style' => '',
267
        'colorbox_node_style_first' => '',
268
        'colorbox_image_style' => '',
269
        'colorbox_gallery' => 'post',
270
        'colorbox_gallery_custom' => '',
271
        'colorbox_caption' => 'auto',
272
        'colorbox_caption_custom' => '',
273
        'colorbox_multivalue_index' => NULL,
274
      ),
275
    ),
276
  );
277
}
278

    
279
/**
280
 * Implements hook_field_formatter_settings_form().
281
 */
282
function colorbox_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
283
  $display = $instance['display'][$view_mode];
284
  $settings = $display['settings'];
285

    
286
  $image_styles = image_style_options(FALSE);
287
  $image_styles_hide = $image_styles;
288
  $image_styles_hide['hide'] = t('Hide (do not display image)');
289
  $element['colorbox_node_style'] = array(
290
    '#title' => t('Content image style'),
291
    '#type' => 'select',
292
    '#default_value' => $settings['colorbox_node_style'],
293
    '#empty_option' => t('None (original image)'),
294
    '#options' => $image_styles_hide,
295
    '#description' => t('Image style to use in the content.'),
296
  );
297
  $element['colorbox_node_style_first'] = array(
298
    '#title' => t('Content image style for first image'),
299
    '#type' => 'select',
300
    '#default_value' => $settings['colorbox_node_style_first'],
301
    '#empty_option' => t('No special style.'),
302
    '#options' => $image_styles,
303
    '#description' => t('Image style to use in the content for the first image.'),
304
  );
305
  $element['colorbox_image_style'] = array(
306
    '#title' => t('Colorbox image style'),
307
    '#type' => 'select',
308
    '#default_value' => $settings['colorbox_image_style'],
309
    '#empty_option' => t('None (original image)'),
310
    '#options' => $image_styles,
311
    '#description' => t('Image style to use in the Colorbox.'),
312
  );
313

    
314
  $gallery = array(
315
    'post' => t('Per post gallery'),
316
    'page' => t('Per page gallery'),
317
    'field_post' => t('Per field in post gallery'),
318
    'field_page' => t('Per field in page gallery'),
319
    'custom' => t('Custom'),
320
    'none' => t('No gallery'),
321
  );
322
  $element['colorbox_gallery'] = array(
323
    '#title' => t('Gallery (image grouping)'),
324
    '#type' => 'select',
325
    '#default_value' => $settings['colorbox_gallery'],
326
    '#options' => $gallery,
327
    '#description' => t('How Colorbox should group the image galleries.'),
328
  );
329
  $element['colorbox_gallery_custom'] = array(
330
    '#title' => t('Custom gallery'),
331
    '#type' => 'textfield',
332
    '#maxlength' => 32,
333
    '#default_value' => $settings['colorbox_gallery_custom'],
334
    '#description' => t('All images on a page with the same gallery value (rel attribute) will be grouped together. It must only contain lowercase letters, numbers, hyphen and underscores.'),
335
    '#element_validate' => array('colorbox_gallery_custom_validate'),
336
    '#required' => FALSE,
337
    '#states' => array(
338
      'visible' => array(
339
        ':input[name$="[settings_edit_form][settings][colorbox_gallery]"]' => array('value' => 'custom'),
340
      ),
341
    ),
342
  );
343

    
344
  $caption = array(
345
    'auto' => t('Automatic'),
346
    'title' => t('Title text'),
347
    'alt' => t('Alt text'),
348
    'node_title' => t('Content title'),
349
    'custom' => t('Custom (with tokens)'),
350
    'none' => t('None'),
351
  );
352
  $element['colorbox_caption'] = array(
353
    '#title' => t('Caption'),
354
    '#type' => 'select',
355
    '#default_value' => $settings['colorbox_caption'],
356
    '#options' => $caption,
357
    '#description' => t('Automatic will use the first non-empty value of the title, the alt text and the content title.'),
358
  );
359
  $element['colorbox_caption_custom'] = array(
360
    '#title' => t('Custom caption'),
361
    '#type' => 'textfield',
362
    '#default_value' => $settings['colorbox_caption_custom'],
363
    '#states' => array(
364
      'visible' => array(
365
        ':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
366
      ),
367
    ),
368
  );
369
  // Allow users to hide or set a custom recursion limit.
370
  // The module token_tweaks sets a global recursion limit that can not be
371
  // bypassed.
372
  if (module_exists('token') && $recursion_limit = min(variable_get('token_tree_recursion_limit', 3), variable_get('colorbox_token_recursion_limit', 3))) {
373
    // File entities do not have $field, only $instance.
374
    if (!empty($field)) {
375
      $token_types = array_merge(array_keys($field['bundles']), array('file'));
376
    }
377
    else {
378
      $token_types = array($instance['entity_type'], 'file');
379
    }
380
    $element['colorbox_token'] = array(
381
      '#type' => 'fieldset',
382
      '#title' => t('Replacement patterns'),
383
      '#theme' => 'token_tree',
384
      '#token_types' => $token_types,
385
      '#recursion_limit' => $recursion_limit,
386
      '#dialog' => TRUE,
387
      '#states' => array(
388
        'visible' => array(
389
          ':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
390
        ),
391
      ),
392
    );
393
  }
394
  else {
395
    $element['colorbox_token'] = array(
396
      '#type' => 'fieldset',
397
      '#title' => t('Replacement patterns'),
398
      '#description' => '<strong class="error">' . t('For token support the <a href="@token_url">token module</a> must be installed.', array('@token_url' => 'http://drupal.org/project/token')) . '</strong>',
399
      '#states' => array(
400
        'visible' => array(
401
          ':input[name$="[settings_edit_form][settings][colorbox_caption]"]' => array('value' => 'custom'),
402
        ),
403
      ),
404
    );
405
  }
406

    
407
  return $element;
408
}
409

    
410
/**
411
 * Validate function for colorbox_gallery_custom.
412
 */
413
function colorbox_gallery_custom_validate($element, &$form_state) {
414
  if (!empty($element['#value']) && !preg_match('!^[a-z0-9_-]+$!', $element['#value'])) {
415
    form_error($element, t('%name must only contain lowercase letters, numbers, hyphen and underscores.', array('%name' => $element['#title'])));
416
  }
417
}
418

    
419
/**
420
 * Implements hook_field_formatter_settings_summary().
421
 */
422
function colorbox_field_formatter_settings_summary($field, $instance, $view_mode) {
423
  $display = $instance['display'][$view_mode];
424
  $settings = $display['settings'];
425

    
426
  $summary = array();
427

    
428
  $image_styles = image_style_options(FALSE);
429
  // Unset possible 'No defined styles' option.
430
  unset($image_styles['']);
431
  // Styles could be lost because of enabled/disabled modules that defines
432
  // their styles in code.
433
  if (isset($image_styles[$settings['colorbox_node_style']])) {
434
    $summary[] = t('Content image style: @style', array('@style' => $image_styles[$settings['colorbox_node_style']]));
435
  }
436
  elseif ($settings['colorbox_node_style'] == 'hide') {
437
    $summary[] = t('Content image style: Hide');
438
  }
439
  else {
440
    $summary[] = t('Content image style: Original image');
441
  }
442

    
443
  if (isset($image_styles[$settings['colorbox_node_style_first']])) {
444
    $summary[] = t('Content image style of first image: @style', array('@style' => $image_styles[$settings['colorbox_node_style_first']]));
445
  }
446

    
447
  if (isset($image_styles[$settings['colorbox_image_style']])) {
448
    $summary[] = t('Colorbox image style: @style', array('@style' => $image_styles[$settings['colorbox_image_style']]));
449
  }
450
  else {
451
    $summary[] = t('Colorbox image style: Original image');
452
  }
453

    
454
  $gallery = array(
455
    'post' => t('Per post gallery'),
456
    'page' => t('Per page gallery'),
457
    'field_post' => t('Per field in post gallery'),
458
    'field_page' => t('Per field in page gallery'),
459
    'custom' => t('Custom'),
460
    'none' => t('No gallery'),
461
  );
462
  if (isset($settings['colorbox_gallery'])) {
463
    $summary[] = t('Colorbox gallery type: @type', array('@type' => $gallery[$settings['colorbox_gallery']])) . ($settings['colorbox_gallery'] == 'custom' ? ' (' . $settings['colorbox_gallery_custom'] . ')' : '');
464
  }
465

    
466
  $caption = array(
467
    'auto' => t('Automatic'),
468
    'title' => t('Title text'),
469
    'alt' => t('Alt text'),
470
    'node_title' => t('Content title'),
471
    'custom' => t('Custom (with tokens)'),
472
    'none' => t('None'),
473
  );
474
  if (isset($settings['colorbox_caption'])) {
475
    $summary[] = t('Colorbox caption: @type', array('@type' => $caption[$settings['colorbox_caption']]));
476
  }
477

    
478
  return implode('<br />', $summary);
479
}
480

    
481
/**
482
 * Implements hook_field_formatter_view().
483
 */
484
function colorbox_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
485
  $element = array();
486
  $index = $display['settings']['colorbox_multivalue_index'];
487

    
488
  foreach ($items as $delta => $item) {
489
    if ($index === NULL || $index === $delta) {
490
      $element[$delta] = array(
491
        '#theme' => 'colorbox_image_formatter',
492
        '#item' => $item,
493
        '#entity_type' => $entity_type,
494
        '#entity' => $entity,
495
        // Left for legacy support.
496
        '#node' => $entity,
497
        '#field' => $field,
498
        '#display_settings' => $display['settings'],
499
        '#delta' => $delta,
500
      );
501
    }
502
  }
503

    
504
  return $element;
505
}
506

    
507
/**
508
 * Implements hook_insert_styles().
509
 *
510
 * @codingStandardsIgnoreStart
511
 * @return array
512
 *   Returns a array with styles.
513
 */
514
function colorbox_insert_styles() {
515
  $insert_styles = array();
516
  foreach (image_styles() as $key => $style) {
517
    $label = isset($style['label']) ? $style['label'] : $style['name'];
518
    $insert_styles['colorbox__' . $key] = array('label' => t('Colorbox @style', array('@style' => $label)));
519
  }
520

    
521
  return $insert_styles;
522
}
523

    
524
/**
525
 * Implements hook_help().
526
 */
527
function colorbox_help($path, $arg) {
528

    
529
  switch ($path) {
530
    case 'admin/help#colorbox':
531
      $output = '<h3>' . t('About') . '</h3>';
532
      $output .= '<p>' . t('<a target="_blank" href="@colorbox_project_link">Colorbox</a> is a light-weight customizable lightbox plugin for jQuery. This module allows for integration of Colorbox into Drupal.', array('@colorbox_project_link' => 'https://www.drupal.org/project/colorbox')) . '</p>';
533
      $output .= '<p>' . t('Images, iframed or inline content etc. can be displayed in a overlay above the current page.') . '</p>';
534

    
535
      $output .= '<h3>' . t('Usage') . '</h3>';
536
      $output .= '<p>' . t('Go to "Configuration" » "Media" » "Colorbox" to find all the configuration options.') . '</p>';
537

    
538
      $output .= '<h3>' . t('Features') . '</h3>';
539
      $output .= '<b>' . t('The Colorbox:') . '</b>';
540
      $output .= '<ul>';
541
      $output .= '<li>' . t('Excellent integration with Image field and Image styles') . '</li>';
542
      $output .= '<li>' . t('Choose between a default style and 5 example styles that are included.') . '</li>';
543
      $output .= '<li>' . t('Style the Colorbox with a custom colorbox.css file in your theme.') . '</li>';
544
      $output .= '<li>' . t('Drush command to download and install the Colorbox plugin in sites/all/libraries') . '</li>';
545
      $output .= '</ul>';
546

    
547
      $output .= '<b>' . t('The Colorbox plugin:') . '</b>';
548
      $output .= '<ul>';
549
      $output .= '<li>' . t('Supports photos, grouping, slideshow, ajax, inline, and iframed content.') . '</li>';
550
      $output .= '<li>' . t('Appearance is controlled through CSS so it can be restyled.') . '</li>';
551
      $output .= '<li>' . t('Preloads upcoming images in a photo group.') . '</li>';
552
      $output .= '<li>' . t('Completely unobtrusive, options are set in the JS and require no') . '</li>';
553
      $output .= '<li>' . t('changes to existing HTML.') . '</li>';
554
      $output .= '<li>' . t('Compatible with: jQuery 1.3.2+ in Firefox, Safari, Chrome, Opera,') . '</li>';
555
      $output .= '<li>' . t('Internet Explorer 7+.') . '</li>';
556
      $output .= '<li>' . t('Released under the MIT License.') . '</p>';
557
      $output .= '</ul>';
558

    
559
      $output .= '<h3>' . t('Colorbox screencasts') . '</h3>';
560
      $output .= '<b>' . t('Part 1 to 3 is for an older 7.x-1.x version of the Colorbox:') . '</b>';
561
      $output .= '<ul>';
562
      $output .= '<li>' . t('Part 1: <a href="@colorbox_screencasts_part1" target="blank">Installation and image field integration on Vimeo</a>', array('@colorbox_screencasts_part1' => 'https://vimeo.com/19122850')) . '</li>';
563
      $output .= '<li>' . t('Part 2: <a href="@colorbox_screencasts_part2" target="blank">Inline images with the Insert module on Vimeo</a>', array('@colorbox_screencasts_part2' => 'https://vimeo.com/19386122')) . '</li>';
564
      $output .= '<li>' . t('Part 3: <a href="@colorbox_screencasts_part3" target="blank">Building a image gallery and a image slideshow.</a>', array('@colorbox_screencasts_part3' => 'https://vimeo.com/26411524')) . '</li>';
565
      $output .= '</ul>';
566

    
567
      $output .= '<b>' . t('Contributed screencasts:') . '</b>';
568
      $output .= '<ul>';
569
      $output .= '<li>' . t('<a href="@colorbox_contributed_screencasts_part1" target="blank">Drupal 7 Colorbox project</a> by Code Karate', array('@colorbox_contributed_screencasts_part1' => 'http://codekarate.com/daily-dose-of-drupal/drupal-7-colorbox-module')) . '</li>';
570
      $output .= '<li>' . t('<a href="@colorbox_contributed_screencasts_part2" target="blank">Creating and Theming a Node Photo Gallery with Drupal 7 and Colorbox</a> by High Rock Media.', array('@colorbox_contributed_screencasts_part2' => 'http://dannyenglander.com/blog/screencast-creating-and-theming-node-photo-gallery-drupal-7-and-colorbox')) . '</li>';
571
      $output .= '<li>' . t('<a href="@colorbox_contributed_screencasts_part3" target="blank">How to Build a Lightbox Portfolio in Drupal 7</a> by CMS Quickstart', array('@colorbox_contributed_screencasts_part3' => 'http://www.cmsquickstart.com/blog/tutorial-how-build-lightbox-portfolio-drupal-7')) . '</li>';
572
      $output .= '</ul>';
573

    
574
      $output .= '<h3>' . t('Load Content in a Colorbox') . '</h3>';
575
      $output .= '<p>' . t('Check the "Enable Colorbox load" option in Colorbox settings.') . '</p>';
576
      $output .= '<p>' . t('This enables custom links that can open content in a Colorbox.') . '</p>';
577
      $output .= '<p>' . t('Add the class "colorbox-load" to the link and build the url like this "[path]?width=500&height=500&iframe=true" or "[path]?width=500&height=500" if you don\'t want an iframe.') . '</p>';
578
      $output .= '<p>' . t('Other projects may activate this for easy Colorbox integration.') . '</p>';
579

    
580
      $output .= '<h3>' . t('Load Images from custom links in a Colorbox') . '</h3>';
581
      $output .= '<p>' . t('Add the class "colorbox" to the link and point its href attribute to the image you want to display in the Colorbox.') . '</p>';
582

    
583
      return $output;
584
  }
585
}
586

    
587
/**
588
 * Implements hook_insert_content().
589
 */
590
function colorbox_insert_content($item, $style, $widget) {
591
  list($item['module_name'], $item['style_name']) = explode('__', $style['name'], 2);
592
  return theme(array(
593
    'colorbox_insert_image__' . str_replace('-', '_', $item['style_name']),
594
    'colorbox_insert_image',
595
      ), array(
596
    'item' => $item,
597
    'widget' => $widget,
598
  ));
599
}
600

    
601
/**
602
 * Gallery Exists Function.
603
 *
604
 * Machine names normally need to be unique but that does not apply to
605
 * galleries.
606
 *
607
 * @return false
608
 *   Always FALSE
609
 */
610
function colorbox_gallery_exists() {
611
  return FALSE;
612
}