Newer
Older
Stella Power
committed
* Enables the use of lightbox2 which places images above your current page,
* not within. This frees you from the constraints of the layout, particularly
*
* Module by: Mark Ashmead
* Mailto: bugzie@gmail.com
* Co-maintainer: Stella Power (http://drupal.org/user/66894)
Mark A
committed
*
* Image Node Support: Steve McKenzie
*
function lightbox2_help($section) {
switch ($section) {
case 'admin/modules#description':
Stella Power
committed
return t('Enables Lightbox2 for Drupal');
case 'admin/help#lightbox2':
return t('<h3>Overview</h3>
Stella Power
committed
<p align="justify">Lightbox2 JS is a simple, unobtrusive script used to overlay images on the current page. It\'s a snap to setup and works on all modern browsers. The module comes with a Lightbox2 Lite option which does not use the jQuery libraries; it is therefore less likely to conflict with anything else.</p>
<p align="justify">Places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths. Keeps users on the same page. Clicking to view an image and then having to click the back button to return to your site is bad for continuity (and no fun!).</p>
<h3>Features</h3>
The version 2 module has several benefits over the plain Lightbox module. Note, not all of these features are available when the "Lightbox2 Lite" option is enabled.
<ul>
<li>Image Sets: group related images and navigate through them with ease - ideal for your image galleries.</li>
<li>Slideshow Capability: automatically transition between grouped images, includes play/pause and previous and next buttons.</li>
<li>HTML Content Support: ability to show websites or other HTML content in a lightbox.</li>
<li>Video Content Support: ability to show videos in a lightbox.</li>
<li>Visual Effects: fancy pre-loader and transition when you click on the image.</li>
<li>Keyboard Shortcuts: useful <a href="http://drupal.org/node/249827">keyboard shortcuts</a> for switching between images, toggling play / pause, etc.</li>
<li>Zoom Capability: larger images are reduced in size so they fit snugly inside the browser window. A zoom button can then be clicked on to see it in its original size.</li>
Stella Power
committed
<li>Automatic Image Detection: configurable automatic re-formatting of
image thumbnails, so there is no need to add \'rel="lightbox"\' to each
image link on your site. <a
href="http://drupal.org/project/image">Image</a>, <a
href="http://drupal.org/project/inline">Inline</a>, <a
Stella Power
committed
href="http://drupal.org/project/flickr">Flickr</a>, <a
href="http://drupal.org/project/img_assist">Image Assist</a> and <a
href="http://drupal.org/project/imagefield">CCK Imagefield</a> modules are all
supported. It\'s also possible to configure a custom list of image classes
which should trigger the lightbox functionality.</li>
<li><a href="http://drupal.org/project/imagecache">Imagecache</a> Support: adds a Lightbox2 field formatter for <a href="http://drupal.org/project/imagefield">CCK imagefields</a> for your custom <a href="http://drupal.org/project/views">views</a>.</li>
<li>Image Page Link: a link to the image node can be provided within the lightbox itself.</li>
<li>Page Exclusion Capability: exclude certain pages on your site from having the lightbox2 functionality.</li>
<li>Gallery 2 Support: support for Gallery 2 images via the <a href="http://drupal.org/project/gallery">Gallery</a> module (beta).</li>
</ul>
<p align="justify"><h3>Usage</h3></p>
<h5 style="text-decoration: underline;">Adding a Basic Lightbox</h5>
<p>Add rel="lightbox" attribute to any link tag to activate the lightbox. For example: </p>
<p><a href="image-1.jpg" rel="lightbox" title="my caption">image #1</a></p>
<p>Optional: Use the title attribute if you want to show a caption.</p>
<h5 style="text-decoration: underline;">Grouping Images</h5>
<p>If you have a set of related images that you would like to group, follow
Stella Power
committed
step one but additionally include a group name between square brackets in the
rel attribute. For example:</p><p><a href="images/image-1.jpg"
rel="lightbox[roadtrip]">image #1</a><br />
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image
#2</a><br />
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image
#3</a><br /></p>
<p>No limits to the number of image sets per page or how many images are allowed
in each set.</p>
<p>If you have a set of images that you would like to group together in a lightbox, but only wish for one of these images to be visible on your page, you can assign the "lightbox_hide_image" class to hide the additional images. For example:</p>
<p><a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a><br />
<a href="images/image-2.jpg" rel="lightbox[roadtrip]" class="lightbox_hide_image">image #2</a><br />
<a href="images/image-3.jpg" rel="lightbox[roadtrip]" class="lightbox_hide_image">image #3</a></p>
<h5 style="text-decoration: underline;">Slideshow</h5>
<p>This is very similar to the grouping functionality described above. The only difference is that "rel" attribute should be set to "lightshow" instead of "lightbox". Using the same example as above, we could launch the images in a slideshow by doing:</p>
<p><a href="images/image-1.jpg" rel="lightshow[roadtrip]">image #1</a><br />
<a href="images/image-2.jpg" rel="lightshow[roadtrip]">image #2</a><br />
<a href="images/image-3.jpg" rel="lightshow[roadtrip]">image #3</a></p>
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<h5 style="text-decoration: underline;">Video Content</h5>
<p>
It\'s possible to show video content in the lightbox. In this case the "rel" attribute should be set to <code>lightvideo</code>. It\'s not possible to group videos but it is possible to control the size of the lightbox by setting the \'width\' and \'height\' properties. The properties can be configured like <code>lightvideo[width:300px; height: 200px;]</code>. The properties should all be of the format "property: value;" - note the closing semi-colon. If no properties are set, then the default width and height of 400px will be used. See below for more detailed examples.</p>
<p>Basic example:<br />
<code>
<a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo">Google video example - default size</a><br />
</code></p>
<p>Controlling lightbox size example:<br />
<code>
<a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo[width:400px; height:300px;]">Google video example - custom size</a><br />
</code></p>
<p>Supported Video Formats<br />
asx, wmv, mov and swf videos should all be supported. A number of video providers are also supported, for example YouTube and Google Video. For full details on how to integrate these with lightbox, please see the online documentation.</p>
<h5 style="text-decoration: underline;">HTML Content</h5>
<p>It\'s possible to show webpage content in the lightbox, using iframes. In this case the "rel" attribute should be set to <code>lightframe</code>. Again it\'s possible to group the items, (e.g. <code>lightframe[search]</code>) but in addition to that, it\'s possible to control some of the iframe properties. It\'s possible to set the \'width\', \'height\' and \'scrolling\' properties of the iframe. The properties are separated from the group name by a <code>|</code>, for example <code>lightframe[search|width:100px;]</code>. If no grouping is being used, then the <code>|</code> is still used and the format would be <code>lightframe[|width:100px;]</code>. The properties should all be of the format "property: value;" - note the closing semi-colon. If no iframe properties are set, then the default width and height of 400px will be used. See below for more detailed examples.</p>
<p>Basic example:<br />
<code>
<a href="http://www.google.com" rel="lightframe">Search google</a>
</code></p>
<p>Grouped example:<br />
<code>
<a href="http://www.google.com" rel="lightframe[search]">Search google</a><br />
<a href="http://www.yahoo.com" rel="lightframe[search]">Search yahoo</a>
</code></p>
<p>Controlling iframe property example:<br />
<code>
<a href="http://www.google.com" rel="lightframe[|width:400px; height:300px; scrolling: auto;]">Search google</a>
</code></p>
<p>Controlling iframe property when grouped example:<br />
<code>
<a href="http://www.google.com" rel="lightframe[search|width:400px; height:300px; scrolling: auto;]">Search google</a><br />
<a href="http://www.yahoo.com" rel="lightframe[search|width:400px; height:300px;]">Search yahoo</a>
</code></p>
<h3>Keyboard Shortcuts</h3>
<table border=0>
<tr><td>Close Lightbox</td><td>x</td></tr>
<tr><td></td><td>o</td></tr>
<tr><td></td><td>c</td></tr>
<tr><td></td><td>ESC</td></tr>
<tr><td>Previous Image</td><td>p</td></tr>
<tr><td></td><td>Left Arrow</td></tr>
<tr><td>Next Image</td><td>n</td></tr>
<tr><td></td><td>Right Arrow</td></tr>
<tr><td>Toggle Zoom</td><td>z (not available in slideshow)</td></tr>
<tr><td>Toggle Play / Pause</td><td>Spacebar (slideshow only)</td></tr>
</table>
<p>Not all of the keyboard shortcuts work in the Opera browser, for example "z" for toggling the zoom and "spacebar" for toggling play / pause in slideshows. This can be overcome by updating your shortcut settings in the Opera preferences editor.</p>
');
function lightbox2_perm() {
return array('administer lightbox2');
}
/**
function lightbox2_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('path' => 'admin/settings/lightbox2',
'title' => t('Lightbox2'),
'callback' => 'lightbox2_settings_page',
'access' => user_access('administer lightbox2'),
'description' => t('Allows the user to configure the lightbox2 settings'),
);
$items[] = array('path' => 'admin/settings/lightbox2/general',
'title' => t('General'),
'callback arguments' => array('lightbox2_general_settings_form'),
'access' => user_access('administer lightbox2'),
'description' => t('Allows the user to configure the lightbox2 settings'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
$items[] = array('path' => 'admin/settings/lightbox2/slideshow',
'title' => t('Slideshow'),
'callback' => 'drupal_get_form',
'callback arguments' => array('lightbox2_slideshow_settings_form'),
'access' => user_access('administer lightbox2'),
'description' => t('Allows the user to configure the lightbox2 slideshow functionality.'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
Stella Power
committed
$items[] = array('path' => 'admin/settings/lightbox2/html_content',
'title' => t('HTML Content'),
'callback' => 'drupal_get_form',
'callback arguments' => array('lightbox2_iframe_settings_form'),
'access' => user_access('administer lightbox2'),
'description' => t('Allows the user to configure the lightbox2 HTML content functionality.'),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
$items[] = array('path' => 'admin/settings/lightbox2/automatic',
'title' => t('Automatic image handling'),
'callback' => 'drupal_get_form',
'callback arguments' => array('lightbox2_auto_image_handling_settings_form'),
'access' => user_access('administer lightbox2'),
'description' => t('Allows the user to configure the lightbox2 automatic image handling settings'),
'type' => MENU_LOCAL_TASK,
Stella Power
committed
'weight' => 3,
if (module_exists('emfield') && module_exists('video_cck')) {
$items[] = array(
'path' => 'video-cck/lightbox2',
'callback' => 'lightbox2_video_cck',
'access' => user_access('access content'),
'type' => MENU_CALLBACK,
);
}
else {
if (lightbox2_exclude_these_paths() != 1) {
Stella Power
committed
lightbox2_add_files();
}
return $items;
}
* The default lightbox2 settings page.
*/
function lightbox2_settings_page($op = NULL) {
$output .= drupal_get_form('lightbox2_general_settings_form');
return $output;
}
/**
* General configuration form for controlling the lightbox behaviour.
*/
function lightbox2_general_settings_form() {
Stella Power
committed
// Add the javascript which disables / enables form elements.
Stella Power
committed
drupal_add_js(drupal_get_path('module', 'lightbox2') .'/js/lightbox2.js', 'module');
// Enable translation of default strings for potx.
$default_strings = array(t('View Image Details'), t('Image !current of !total'), t('Page !current of !total'));
// Define Lightbox2 Lite fieldset.
/* ------------------------------- */
Stella Power
committed
$use_lite = variable_get('lightbox2_lite', FALSE);
Stella Power
committed
$form['lightbox2_lite_options'] = array(
Stella Power
committed
'#title' => t('Lightbox2 Lite'),
Stella Power
committed
'#collapsed' => !$use_lite,
// Add checkbox for Lightbox2 Lite.
Stella Power
committed
$form['lightbox2_lite_options']['lightbox2_lite'] = array(
Stella Power
committed
'#title' => t('Use Lightbox2 Lite'),
'#description' => t('Checking this box will enable Lightbox2 Lite and will disable all of the automatic image URL re-formatting features. It also disables all grouping features.'),
Stella Power
committed
'#default_value' => $use_lite,
// Add checkbox for alternative layout.
$form['lightbox2_use_alt_layout'] = array(
'#type' => 'checkbox',
'#title' => t('Use Alternative Layout'),
'#description' => t('Enabling this option alters the layout of the lightbox elements. In the alternative layout the navigational links appear under the image with the caption text, instead of being overlayed on the image itself. This doesn\'t apply when using Lightbox Lite.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_use_alt_layout', FALSE),
);
// Add checkbox for force navigation display.
$form['lightbox2_force_show_nav'] = array(
'#type' => 'checkbox',
'#title' => t('Force visibility of navigation links'),
'#description' => t('When viewing grouped images using the default layout, the navigational links to the next and previous images are only displayed when you hover over the image. Checking this box forces these links to be displayed all the time.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_force_show_nav', FALSE),
);
// Add text box for image count for grouping.
$form['lightbox2_image_count_str'] = array(
'#type' => 'textfield',
'#title' => t('Image Count Text'),
'#description' => t('This text is used to display the image count underneath the image in the lightbox when image grouping is enabled. Use !current as a placeholder for the number of the current image and !total for the total number of images in the group. For example, "Image !current of !total".'),
'#default_value' => variable_get('lightbox2_image_count_str', 'Image !current of !total'),
);
// Add text box for page count for grouping.
$form['lightbox2_page_count_str'] = array(
'#type' => 'textfield',
'#title' => t('Page Count Text'),
'#description' => t('This text is used to display the page count underneath HTML content displayed in the lightbox when using groups. Use !current as a placeholder for the number of the current page and !total for the total number of pages in the group. For example, "Page !current of !total".'),
'#default_value' => variable_get('lightbox2_page_count_str', 'Page !current of !total'),
);
// Add checkbox for zoom image.
'#type' => 'checkbox',
'#title' => t('Disable Zoom Feature'),
'#description' => t('By default, when the image being displayed in the lightbox is larger than the browser window, it is resized to fit within the window and a zoom button is provided for users who wish to view the image in its original size. Checking this box will disable this feature and all images will be displayed without any resizing.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_disable_zoom', FALSE),
Stella Power
committed
// Add textarea for urls without lightbox.
$form['lightbox2_disable_these_urls'] = array(
'#type' => 'textarea',
'#title' => t('Disable LightBox for these urls'),
'#description' => t('List the urls where the lightbox should be disabled, e.g. "node/add/page". Use <front> to match the front page. Put each url on a separate line. You can use the % character as a wildcard.'),
'#default_value' => variable_get('lightbox2_disable_these_urls', ''),
);
if ((module_exists('emfield') && module_exists('image_ncck')) || (module_exists('imagefield') && module_exists('imagecache'))) {
$form['lightbox2_cck_options'] = array(
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
0 => t('No Grouping'),
1 => t('Group by Field Name'),
2 => t('Group by Node Id'),
3 => t('Group by Field Name and Node Id'),
);
// Add checkbox for emfield image_ncck grouping.
if (module_exists('emfield') && module_exists('image_ncck')) {
$form['lightbox2_cck_options']['lightbox2_image_ncck_group_node_id'] = array(
'#type' => 'select',
'#title' => t('Select Emfield Image Grouping in Views'),
'#description' => t('By default, emfield images in views are grouped by the field name they appear in the view in. You can override that grouping here.'),
'#options' => $cck_options,
'#default_value' => variable_get('lightbox2_image_ncck_group_node_id', 1),
);
}
if (module_exists('imagefield') && module_exists('imagecache')) {
$form['lightbox2_cck_options']['lightbox2_imagefield_group_node_id'] = array(
'#type' => 'select',
'#title' => t('Select Imagefield Grouping in Views'),
'#description' => t('By default, imagefields in views are grouped by the field name they appear in the view in. You can override that grouping here.'),
'#options' => $cck_options,
'#default_value' => variable_get('lightbox2_imagefield_group_node_id', 1),
);
}
// Define advanced settings fieldset.
$form['lightbox2_advanced_options'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Add checkbox for overlay opacity.
Stella Power
committed
for ($i = 0; $i < 10; $i++) {
$opacity_options["0.$i"] = "0.$i";
}
$opacity_options["1.0"] = "1.0";
$form['lightbox2_advanced_options']['lightbox2_overlay_opacity'] = array(
Stella Power
committed
'#type' => 'select',
'#title' => t('Overlay Opacity'),
'#options' => $opacity_options,
'#description' => t('The overlay opacity setting determines how visible the background page is behind the lightbox. The opacity value can range from 0.0 to 1.0 where 0.0 is 100% transparent and 1.0 is 100% opaque.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_overlay_opacity', '0.6'),
);
// Allow users to decide where javascript should be loaded - header or footer.
// Header is recommended so user can click on images before page has finished
// loading, but footer is needed for sites in IE which use SWFObject.
$form['lightbox2_advanced_options']['lightbox2_js_location'] = array(
'#type' => 'select',
'#title' => t('Location of Javscript'),
'#options' => array('header' => t('Header'), 'footer' => t('Footer')),
'#description' => t('By default, the lightbox javascript files are loaded in the HTML header. However, for sites using SWFObject to load their Flash content, the footer setting is recommended to prevent "Operation Aborted" errors in IE. If using the footer setting, please note that not all themes correctly implement the footer region and may require a small change.'),
'#default_value' => variable_get('lightbox2_js_location', 'header'),
);
Stella Power
committed
* Configuration form for controlling the slideshow behaviour.
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
*/
function lightbox2_slideshow_settings_form() {
// Add the javascript which disables / enables form elements.
drupal_add_js(drupal_get_path('module', 'lightbox2') .'/js/lightbox2.js', 'module');
// Set up a hidden variable.
$form['lightbox2_lite'] = array(
'#type' => 'hidden',
'#value' => variable_get('lightbox2_lite', FALSE),
);
// Add text box for slideshow interval.
$form['lightbox2_slideshow_interval'] = array(
'#type' => 'textfield',
'#title' => t('Interval Seconds'),
'#description' => t('The slideshow interval is the length of time in seconds an image is visible before the slideshow shows the next image.'),
'#default_value' => variable_get('lightbox2_slideshow_interval', 5),
'#size' => 20,
);
// Add checkbox for slideshow automatic exit.
$form['lightbox2_slideshow_automatic_exit'] = array(
'#type' => 'checkbox',
'#title' => t('Automatically Exit Slideshow'),
'#description' => t('When enabled the lightbox will automatically close after displaying the last image.'),
'#default_value' => variable_get('lightbox2_slideshow_automatic_exit', TRUE),
);
// Add checkbox for showing hte play / pause button.
$form['lightbox2_slideshow_show_play_pause'] = array(
'#type' => 'checkbox',
'#title' => t('Show Play / Pause Button'),
'#description' => t('When enabled, a play / pause button will be shown in the slideshow allowing the user more control over their viewing experience.'),
'#default_value' => variable_get('lightbox2_slideshow_show_play_pause', TRUE),
);
// Add checkbox for "pausing on next click".
$form['lightbox2_slideshow_pause_on_next_click'] = array(
'#type' => 'checkbox',
'#title' => t('Pause Slideshow on "Next Image" Click'),
'#description' => t('When enabled the slideshow is automatically paused, and the following image shown, when the "Next" button is clicked.'),
'#default_value' => variable_get('lightbox2_slideshow_pause_on_next_click', FALSE),
);
// Add checkbox for "pausing on prev click".
$form['lightbox2_slideshow_pause_on_prev_click'] = array(
'#type' => 'checkbox',
'#title' => t('Pause Slideshow on "Previous Image" Click'),
'#description' => t('When enabled the slideshow is automatically paused, and the previous image shown, when the "Previous" button is clicked.'),
'#default_value' => variable_get('lightbox2_slideshow_pause_on_previous_click', TRUE),
);
return system_settings_form($form);
}
/**
* Validation function for the slideshow configuration form.
*
* Ensure that the slideshow interval submitted is numeric.
*/
function lightbox2_slideshow_settings_form_validate($form_id, $form_values) {
if (!is_numeric($form_values['lightbox2_slideshow_interval'])) {
form_set_error('lightbox2_slideshow_interval', t('The "interval seconds" value must be numeric.'));
}
}
Stella Power
committed
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
/**
* Configuration form for controlling the iframe behaviour.
*/
function lightbox2_iframe_settings_form() {
// Add the javascript which disables / enables form elements.
drupal_add_js(drupal_get_path('module', 'lightbox2') .'/js/lightbox2.js', 'module');
// Set up a hidden variable.
$form['lightbox2_lite'] = array(
'#type' => 'hidden',
'#value' => variable_get('lightbox2_lite', FALSE),
);
// Add text box for iframe width.
$form['lightbox2_default_frame_width'] = array(
'#type' => 'textfield',
'#title' => t('Default Width'),
'#description' => t('The default width of the iframe in pixels.'),
'#default_value' => variable_get('lightbox2_default_frame_width', 600),
'#size' => 20,
);
// Add text box for iframe height.
$form['lightbox2_default_frame_height'] = array(
'#type' => 'textfield',
'#title' => t('Default Height'),
'#description' => t('The default height of the iframe in pixels.'),
'#default_value' => variable_get('lightbox2_default_frame_height', 400),
'#size' => 20,
);
// Add option for iframe border.
$form['lightbox2_frame_border'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Border'),
'#description' => t('Enable iframe border. You can modify the border style in your theme\'s css file using the iframe\'s id "lightboxFrame".'),
'#default_value' => variable_get('lightbox2_frame_border', 1),
);
Stella Power
committed
return system_settings_form($form);
}
/**
* Validation function for the iframe configuration form.
*
* Ensure that the iframe width and height submitted are numeric.
*/
function lightbox2_iframe_settings_form_validate($form_id, $form_values) {
if (!is_numeric($form_values['lightbox2_default_frame_width'])) {
form_set_error('lightbox2_slideshow_interval', t('The "default width" value must be numeric.'));
}
if (!is_numeric($form_values['lightbox2_default_frame_height'])) {
form_set_error('lightbox2_slideshow_interval', t('The "default height" value must be numeric.'));
}
}
* Configuration form the automatic image handling functionality.
function lightbox2_auto_image_handling_settings_form() {
// Add the javascript which disables / enables form elements.
drupal_add_js(drupal_get_path('module', 'lightbox2') .'/js/lightbox2.js', 'module');
$form['lightbox2_lite'] = array(
'#type' => 'hidden',
Stella Power
committed
'#value' => variable_get('lightbox2_lite', FALSE),
$automatic_options = array(
0 => t('Disabled'),
1 => t('Lightbox'),
2 => t('Lightbox grouped'),
3 => t('Slideshow'),
Stella Power
committed
4 => t('HTML Content'),
5 => t('HTML Content grouped'),
);
$form['image_node_options'] = array(
'#value' => t('These options allow automatic URL re-formatting of images. This removes the need for you to add \'rel="lightbox"\' to each image link throughout your site. You can select which image sizes will trigger the lightbox and configure a list of image CSS classes which should also have their URLs automatically re-formatted. This feature is not available when using Lightbox2 Lite.'),
Stella Power
committed
// Define image nodes settings fieldset.
$form['lightbox2_image_node_options'] = array(
'#type' => 'fieldset',
'#title' => t('Image node settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// Add checkbox for image nodes.
$form['lightbox2_image_node_options']['lightbox2_image_node'] = array(
'#type' => 'select',
'#title' => t('Automatic handler for Image Nodes'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for image nodes will be automatically handled.'),
'#default_value' => variable_get('lightbox2_image_node', 2),
// Add drop-down for list of available image sizes.
Stella Power
committed
if (module_exists('image')) {
$sizes = _image_get_sizes();
foreach ($sizes as $size_key => $size) {
if ($size_key == 'original' || $size_key == '_original') {
$size_key = '';
}
$size_options[$size_key] = $size['label'];
}
$form['lightbox2_image_node_options']['lightbox2_display_image_size'] = array(
Stella Power
committed
'#type' => 'select',
'#title' => t('Lightbox image display size'),
Stella Power
committed
'#options' => $size_options,
'#default_value' => variable_get('lightbox2_display_image_size', ''),
Stella Power
committed
'#description' => t('Select which image size will be loaded in the lightbox. This only applies to images uploaded with the Image module.'),
);
$form['lightbox2_image_node_options']['lightbox2_trigger_image_size'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Image trigger size'),
'#options' => $size_options,
Stella Power
committed
'#default_value' => variable_get('lightbox2_trigger_image_size', array('thumbnail')),
'#description' => t('Select which image size, when clicked on, will automatically trigger the lightbox. This only applies to images uploaded with the Image module.'),
);
Stella Power
committed
}
// Add checkbox for disabling lightbox for gallery lists.
$form['lightbox2_image_node_options']['lightbox2_disable_nested_galleries'] = array(
'#type' => 'checkbox',
'#title' => t('Disable Lightbox for Gallery Lists'),
'#description' => t('Checking this box will disable the lightbox for images in gallery lists. This means it is possible to open a gallery by clicking on the teaser image, but the lightbox will still appear when viewing images within the gallery. This only applies to image galleries created with the "image gallery" module.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_disable_nested_galleries', TRUE),
// Add checkbox for flickr image support.
'#type' => 'select',
'#title' => t('Automatic handler for Flickr images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for Flickr images will be automatically handled.'),
'#default_value' => variable_get('lightbox2_flickr', 2),
Stella Power
committed
// Add checkbox for gallery2 block image support.
$form['lightbox2_gallery2_blocks'] = array(
'#type' => 'select',
'#title' => t('Automatic handler for Gallery2 block images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for images, contained within Gallery2 image blocks, will be automatically handled.'),
'#default_value' => variable_get('lightbox2_gallery2_blocks', 2),
// Add checkbox for inline image support.
$form['lightbox2_inline'] = array(
'#type' => 'select',
'#title' => t('Automatic handler for Inline images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for Inline images will be automatically handled.'),
'#default_value' => variable_get('lightbox2_inline', 2),
// Add checkbox for image assist custom size images.
Stella Power
committed
$form['lightbox2_image_assist_custom'] = array(
'#type' => 'select',
'#title' => t('Automatic handler for Image Assist custom size images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for custom size images, displayed by the Image Assist module, will be automatically handled.'),
'#default_value' => variable_get('lightbox2_image_assist_custom', 2),
Stella Power
committed
);
// Add text box for custom trigger classes.
$form['lightbox2_custom_trigger_classes'] = array(
'#type' => 'textarea',
'#title' => t('Custom image trigger classes'),
'#description' => t('List the image classes which should trigger the lightbox when clicked on. Put each class on a separate line.'),
'#default_value' => variable_get('lightbox2_custom_trigger_classes', ''),
);
// Add text box for link text to node.
$form['lightbox2_node_link_text'] = array(
Stella Power
committed
'#type' => 'textfield',
'#title' => t('Text for Image Page Link'),
'#description' => t('This is the text that will appear as the link to the image page underneath the image in the lightbox.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_node_link_text', 'View Image Details'),
);
Stella Power
committed
// Add checkbox for node link target.
$form['lightbox2_node_link_target'] = array(
'#type' => 'checkbox',
'#title' => t('Open Image Page in New Window'),
'#description' => t('This controls whether the link to the image page underneath the image is opened in a new window or the current window.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_node_link_target', FALSE),
Stella Power
committed
'#return_value' => '_blank',
);
// Add checkbox for disabling lightbox for acidfree gallery lists.
if (module_exists("acidfree")) {
$form['lightbox2_disable_nested_acidfree_galleries'] = array(
'#type' => 'checkbox',
'#title' => t('Disable Lightbox for Acidfree Gallery Lists'),
'#description' => t('Checking this box will disable the lightbox for images in gallery lists. This means it is possible to open a gallery by clicking on the teaser image, but the lightbox will still appear when viewing images within the gallery. This only applies to image galleries created with the "acidfree" module.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_disable_nested_acidfree_galleries', TRUE),
);
}
Stella Power
committed
return system_settings_form($form);
}
/**
*/
Stella Power
committed
function lightbox2_filter_tips($delta, $format, $long = FALSE) {
Stella Power
committed
if ($delta == 0) {
if (!$long) {
return t('Image links with \'rel="lightbox"\' in the <a> tag will appear in a Lightbox when clicked on.');
Stella Power
committed
}
else {
$output = '<p>'. t('To add a lightbox to your images, add rel="lightbox" attribute to any link tag to activate the lightbox. For example:') .'</p>';
$output .= '<p>'. t('<code><a href="image-1.jpg" rel="lightbox" title="my caption">image #1</a></code>') .'</p>';
$output .= '<p>'. t('The title attribute in the link tag is optional. The addition of this attribute enables the display of a caption with the image displayed in the lightbox.') .'</p>';
$output .= '<p>'. t('If you have a set of related images that you would like to group, then you will need to include a group name between square brackets in the rel attribute. For example:') .'</p>';
$output .= '<p>'. t('<code><a href="image-1.jpg" rel="lightbox[roadtrip]">image #1</a><br /> <a href="image-2.jpg" rel="lightbox[roadtrip]">image #2</a><br /> <a href="image-3.jpg" rel="lightbox[roadtrip]">image #3</a><br /> </code>') .'</p>';
$output .= '<p>'. t('There are no limits to the number of image sets per page or how many images are allowed in each set.') .'</p>';
$output .= '<p>'. t('If you wish to turn the caption into a link, format your caption in the following way:') .'</p>';
$output .= '<p>'. t('<code><a href="image-1.jpg" rel="lightbox" title=\'<a href="http://www.yourlink.com">View Image Details</a>\'>image #1</a></code>') .'</p>';
return $output;
}
}
else if ($delta == 1) {
Stella Power
committed
return t('Image links from G2 are formatted for use with Lightbox2');
Stella Power
committed
}
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
else if ($delta == 2) {
if (!$long) {
return t('Image links with \'rel="lightshow"\' in the <a> tag will appear in a Lightbox slideshow when clicked on.');
}
else {
$output = '<p>'. t('To add a lightbox slideshow to your images, add rel="lightshow[slideshowname]" attribute to any link tag to activate the slideshow. For example:') .'</p>';
$output .= '<p>'. t('<code><a href="image-1.jpg" rel="lightshow[show1]">image #1</a><br /> <a href="image-2.jpg" rel="lightshow[show1]">image #2</a><br /> <a href="image-3.jpg" rel="lightshow[show1]">image #3</a><br /> </code>') .'</p>';
$output .= '<p>'. t('The title attribute in the link tag is optional. The addition of this attribute enables the display of a caption with the image displayed in the lightbox.') .'</p>';
$output .= '<p>'. t('There are no limits to the number of slideshow image sets per page or how many images are allowed in each slideshow.') .'</p>';
$output .= '<p>'. t('If you wish to turn the caption into a link, format your caption in the following way:') .'</p>';
$output .= '<p>'. t('<code><a href="image-1.jpg" rel="lightshow[show1]" title=\'<a href="http://www.yourlink.com">View Image Details</a>\'>image #1</a></code>') .'</p>';
return $output;
}
}
else if ($delta == 3) {
if (!$long) {
return t('Links to HTML content with \'rel="lightframe"\' in the <a> tag will appear in a Lightbox when clicked on.');
}
else {
$output = '<p>'. t('It\'s possible to show webpage content in the lightbox, using iframes. In this case the "rel" attribute should be set to "lightframe". Again it\'s possible to group the images, (e.g. <code>lightframe[search]</code>) but in addition to that, it\'s possible to control some of the iframe properties. It\'s possible to set the "width", "height" and "scrolling" properties of the iframe. The properties are separated from the group name by a <code>|</code>, for example <code>lightframe[search|width:100px;]</code>. If no grouping is being used, then the <code>|</code> is still used and the format would be <code>lightframe[|width:100px;]</code>. The properties should all be of the format "property: value;" - note the closing semi-colon. If no iframe properties are set, then the default width and height of 400px will be used. See below for more detailed examples.') .'</p>';
$output .= '<p>'. t('Basic example:') .'<br />';
$output .= t('<code><a href="http://www.google.com" rel="lightframe">Search google</a></code>') .'</p>';
$output .= '<p>'. t('Grouped example:') .'<br />';
$output .= t('<code><a href="http://www.google.com" rel="lightframe[search]">Search google</a><br /><a href="http://www.yahoo.com" rel="lightframe[search]">Search yahoo</a></code>') .'</p>';
$output .= '<p>'. t('Controlling iframe property example:') .'<br />';
$output .= t('<code><a href="http://www.google.com" rel="lightframe[|width:400px; height:300px; scrolling: auto;]">Search google</a></code>') .'</p>';
$output .= '<p>'. t('Controlling iframe property when grouped example:') .'<br />';
$output .= t('<code><a href="http://www.google.com" rel="lightframe[search|width:400px; height:300px; scrolling: auto;]">Search google</a><br /><a href="http://www.yahoo.com" rel="lightframe[search|width:400px; height:300px;]">Search yahoo</a></code>') .'</p>';
return $output;
}
}
else if ($delta == 4) {
if (!$long) {
return t('Links to video content with \'rel="lightvideo"\' in the <a> tag will appear in a Lightbox when clicked on.');
}
else {
$output = '<p>'. t('It\'s possible to show video content in the lightbox. In this case the "rel" attribute should be set to <code>lightvideo</code>. It\'s not possible to group videos but it is possible to control the size of the lightbox by setting the "width" and "height" properties. The properties can be configured like <code>lightvideo[width:300px; height: 200px;]</code>. The properties should all be of the format "property: value;" - note the closing semi-colon. If no properties are set, then the default width and height of 400px will be used. See below for more detailed examples.') .'</p>';
$output .= '<p>'. t('Basic example:') .'<br />';
$output .= t('<code><a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo">Google video example - default size</a></code>') .'</p>';
$output .= '<p>'. t('Controlling lightbox size example:') .'<br />';
$output .= t('<code><a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo[width:400px; height:300px;]">Google video example - custom size</a></code>') .'</p>';
$output .= '<p>'. t('Supported video formats include asx, wmv, mov and swf. A number of online video providers are also supported, including YouTube and Google Video. For a full list of the current supported video providers please see the documentation on drupal.org.') .'</p>';
return $output;
}
}
}
/**
* Implementation of hook_filter().
*/
Stella Power
committed
function lightbox2_filter($op, $delta = 0, $format = -1, $text = '') {
switch ($op) {
case 'list':
return array(
0 => t('Lightbox filter'),
1 => t('Lightbox G2 filter'),
2 => t('Lightbox slideshow filter'),
3 => t('Lightbox iframe filter'),
4 => t('Lightbox video filter'),
Stella Power
committed
case 'description':
if ($delta == 0) {
return t('Image links with \'rel="lightbox"\' in the <a> tag will appear in a Lightbox when clicked on.');
}
else if ($delta == 1) {
Stella Power
committed
return t('Turns g2_filter links into Lightbox2 appropriate links');
Stella Power
committed
}
else if ($delta == 2) {
return t('Image links with \'rel="lightshow"\' in the <a> tag will appear in a Lightbox slideshow when clicked on.');
}
else if ($delta == 3) {
return t('Links to HTML content with \'rel="lightframe"\' in the <a> tag will appear in a Lightbox when clicked on.');
Stella Power
committed
}
else if ($delta == 4) {
return t('Links to video content with \'rel="lightvideo"\' in the <a> tag will appear in a Lightbox when clicked on.');
}
Stella Power
committed
case 'process':
if ($delta == 1) {
$text = preg_replace('/ShowItem/', 'DownloadItem', $text);
$text = preg_replace('/src="/', 'rel="lightbox" src="', $text);
$text = drupal_substr($text, 1, -1);
Stella Power
committed
}
return $text;
Stella Power
committed
default:
return $text;
}
}
* Provide links to the CSS stylesheet and JS file associated with
* this module.
*/
function lightbox2_add_files() {
static $already_added = FALSE;
if ($already_added) {
return; // Don't add the javascript and CSS multiple times.
// Load required js and css files.
$path = drupal_get_path('module', 'lightbox2');
// Initialise some variables.
$inline_image_handler = variable_get('lightbox2_inline', 2);
$flickr_image_handler = variable_get('lightbox2_flickr', 2);
$gallery2_block_handler = variable_get('lightbox2_gallery2_blocks', 2);
$image_assist_handler = variable_get('lightbox2_image_assist_custom', 2);
$image_node_handler = variable_get('lightbox2_image_node', 2);
// Set the list of image classes to format urls for.
$image_node_sizes = '';
$trigger_lightbox_classes = '';
$trigger_lightbox_group_classes = '';
$trigger_slideshow_classes = '';
Stella Power
committed
$trigger_lightframe_classes = '';
$trigger_lightframe_group_classes = '';
// Inline module images.
switch ($inline_image_handler) {
case 1:
Stella Power
committed
$trigger_lightbox_classes .= 'img.inline,';
break;
case 2:
Stella Power
committed
$trigger_lightbox_group_classes .= 'img.inline,';
break;
case 3:
Stella Power
committed
$trigger_slideshow_classes .= 'img.inline,';
break;
case 4:
$trigger_lightframe_classes .= 'img.inline,';
break;
case 5:
$trigger_lightframe_group_classes .= 'img.inline,';
break;
Stella Power
committed
}
// Flickr images.
switch ($flickr_image_handler) {
case 1:
Stella Power
committed
$trigger_lightbox_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
break;
case 2:
Stella Power
committed
$trigger_lightbox_group_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
break;
case 3:
Stella Power
committed
$trigger_slideshow_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
break;
case 4:
$trigger_lightframe_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
break;
case 5:
$trigger_lightframe_group_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
break;
// Gallery2 block images.
switch ($gallery2_block_handler) {
case 1:
Stella Power
committed
$trigger_lightbox_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
break;
case 2:
Stella Power
committed
$trigger_lightbox_group_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
break;
case 3:
Stella Power
committed
$trigger_slideshow_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
break;
case 4:
$trigger_lightframe_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
break;
case 5:
$trigger_lightframe_group_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
break;
Stella Power
committed
// Image Assist custom size images.
switch ($image_assist_handler) {
case 1:
Stella Power
committed
$trigger_lightbox_classes .= 'img.image-img_assist_custom,';
break;
case 2:
Stella Power
committed
$trigger_lightbox_group_classes .= 'img.image-img_assist_custom,';
break;
case 3:
Stella Power
committed
$trigger_slideshow_classes .= 'img.image-img_assist_custom,';
break;
case 4:
$trigger_lightframe_classes .= 'img.image-img_assist_custom,';
break;
case 5:
$trigger_lightframe_group_classes .= 'img.image-img_assist_custom,';
break;
Stella Power
committed
}
// Image nodes.
if ($image_node_handler) {
Stella Power
committed
$trigger_sizes = variable_get('lightbox2_trigger_image_size', array('thumbnail'));
foreach ($trigger_sizes as $size) {
$triggers = "img.$size, img.image-$size,";
Stella Power
committed
if (empty($size)) {
$triggers = "img._original, img.image-_original,";
Stella Power
committed
}
else {
$image_node_sizes .= "\.$size|";
}
switch ($image_node_handler) {
case 1:
$trigger_lightbox_classes .= $triggers;
break;
case 2:
$trigger_lightbox_group_classes .= $triggers;
break;
case 3:
$trigger_slideshow_classes .= $triggers;
break;
Stella Power
committed
case 4:
$trigger_lightframe_classes .= $triggers;
break;
case 5:
$trigger_lightframe_group_classes .= $triggers;
break;
// Custom images.
$custom_triggers = variable_get('lightbox2_custom_trigger_classes', '');
$custom_trigger_classes = '';
if (!empty($custom_triggers)) {
$trigger_classes = preg_split("/(\r\n|\n)/", $custom_triggers);
foreach ($trigger_classes as $class) {
if (!empty($class)) {
$custom_trigger_classes .= "img.$class,";
Stella Power
committed
}
$trigger_lightbox_classes = rtrim($trigger_lightbox_classes, ",");
$trigger_lightbox_group_classes = rtrim($trigger_lightbox_group_classes, ",");
$trigger_slideshow_classes = rtrim($trigger_slideshow_classes, ",");
Stella Power
committed
$trigger_lightframe_classes = rtrim($trigger_lightframe_classes, ",");
$trigger_lightframe_group_classes = rtrim($trigger_lightframe_group_classes, ",");
$custom_trigger_classes = rtrim($custom_trigger_classes, ",");
$image_node_sizes = '('. rtrim($image_node_sizes, "|") .')';
Stella Power
committed
// Find out if we're using a RTL language.
Stella Power
committed
$rtl = FALSE;
if (module_exists('i18n') && module_invoke('i18n', 'language_rtl')) {
Stella Power
committed
$rtl = TRUE;
Stella Power
committed
$js_settings = array(
Stella Power
committed
'file_path' => base_path() .'(\w\w/)'. file_directory_path(),
'base_path' => base_path(),
'default_image' => base_path() . $path .'/images/brokenimage.jpg',
Stella Power
committed
'overlay_opacity' => variable_get('lightbox2_overlay_opacity', '0.6'),
Stella Power
committed
'use_alt_layout' => variable_get('lightbox2_use_alt_layout', FALSE),
'disable_zoom' => variable_get('lightbox2_disable_zoom', FALSE),
'force_show_nav' => variable_get('lightbox2_force_show_nav', FALSE),
'node_link_text' => check_plain(variable_get('lightbox2_node_link_text', 'View Image Details')),
Stella Power
committed
'node_link_target' => variable_get('lightbox2_node_link_target', FALSE),
'image_count' => check_plain(variable_get('lightbox2_image_count_str', 'Image !current of !total')),
'page_count' => check_plain(variable_get('lightbox2_page_count_str', 'Page !current of !total')),
Stella Power
committed
'lite_press_x_close' => t('press !x to close', array('!x' => '<a href="#" onclick="hideLightbox(); return FALSE;"><kbd>x</kbd></a>')),
// Automatic image handling settings.
'display_image_size' => variable_get('lightbox2_display_image_size', ''),
'image_node_sizes' => $image_node_sizes,
'trigger_lightbox_classes' => $trigger_lightbox_classes,
'trigger_lightbox_group_classes' => $trigger_lightbox_group_classes,
'trigger_slideshow_classes' => $trigger_slideshow_classes,
Stella Power
committed
'trigger_lightframe_classes' => $trigger_lightframe_classes,
'trigger_lightframe_group_classes' => $trigger_lightframe_group_classes,
'custom_trigger_classes' => $custom_trigger_classes,
'disable_for_gallery_lists' => variable_get('lightbox2_disable_nested_galleries', TRUE),
'disable_for_acidfree_gallery_lists' => variable_get('lightbox2_disable_nested_acidfree_galleries', TRUE),
// Slideshow settings.
'slideshow_interval' => variable_get('lightbox2_slideshow_interval', 5) * 1000,
'slideshow_automatic_exit' => variable_get('lightbox2_slideshow_automatic_exit', TRUE),
'show_play_pause' => variable_get('lightbox2_slideshow_show_play_pause', TRUE),
'pause_on_next_click' => variable_get('lightbox2_slideshow_pause_on_next_click', FALSE),
'pause_on_previous_click' => variable_get('lightbox2_slideshow_pause_on_previous_click', TRUE),
Stella Power
committed
// Iframe settings.
'iframe_width' => variable_get('lightbox2_default_frame_width', 600),
'iframe_height' => variable_get('lightbox2_default_frame_height', 400),
'iframe_border' => variable_get('lightbox2_frame_border', 1),
Stella Power
committed
);
drupal_add_js(array('lightbox2' => $js_settings), 'setting');
// Check where we should load the javascript files - header or footer.
$js_location = variable_get('lightbox2_js_location', 'header');