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>Login Support: ability to modify all user/login links so the login form appears in a lightbox.</li>
<li>Skin and Animation Configuration: configure the order and speed of the lightbox animations, along with the lightbox colors, border size and overlay opacity.</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">image #1</a></p>
<p><a href="image-1.jpg" rel="lightbox[][my caption]">image #1</a></p>
<p>Optional: To show a caption either use the title attribute or put in the second set of [] of the rel attribute.</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][caption 2]">image
<a href="images/image-3.jpg" rel="lightbox[roadtrip][caption 3]">image
<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][caption 3]" 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][caption 2]">image #2</a><br />
<a href="images/image-3.jpg" rel="lightshow[roadtrip][caption 3]">image #3</a></p>
<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> and <code>lightvideo[width:300px; height: 200px;][my caption]</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>Basic example with caption:<br />
<code>
<a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo[][my caption]">Google video example - default size</a><br />
</code></p>
<a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo[width:400px; height:300px;][my caption]">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> and <code>lightframe[search|width:120px][my caption]</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>
<a href="http://www.google.com" rel="lightframe[][Search Google]">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]">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 />
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<a href="http://www.yahoo.com" rel="lightframe[search|width:400px; height:300px;][Search Yahoo]">Search yahoo</a>
</code></p>
<h5 style="text-decoration: underline;">Inline Content Support</h5>
<p>It\'s possible to show HTML snippets in the lightbox, that is on the same domain. In this case the "rel" attribute should be set to <code>lightmodal</code>. Again it\'s possible to group the content, (e.g. <code>lightmodal[search]</code>) but in addition to that, it\'s possible to control some of the inline / modal properties. It\'s possible to set the \'width\', \'height\' and \'scrolling\' properties of the inline content. The properties are separated from the group name by a <code>|</code>, for example <code>lightmodal[search|width:100px;]</code> and <code>lightmodal[search|width:100px;][my caption]</code>. If no grouping is being used, then the <code>|</code> is still used and the format would be <code>lightmodal[|width:100px;]</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="search.php" rel="lightmodal">Search</a>
</code></p>
<p>Basic example with caption:<br />
<code>
<a href="search.php" rel="lightmodal[][my caption]">Search</a>
</code></p>
<p>Grouped example:<br />
<code>
<a href="search.php" rel="lightmodal[search]">Search</a><br />
<a href="search.php?status=1" rel="lightmodal[search][published]">Search published content</a>
</code></p>
<p>Controlling modal property example:<br />
<code>
<a href="search.php" rel="lightmodal[|width:400px; height:300px; scrolling: auto;]">Search</a>
</code></p>
<p>Controlling modal property when grouped example:<br />
<code>
<a href="search.php" rel="lightmodal[search|width:400px; height:300px; scrolling: auto;]">Search</a><br />
<a href="search.php?status=1" rel="lightmodal[search|width:400px; height:300px;][Search published]">Search published content</a><br />
<a href="search.php?status=0" rel="lightmodal[search|width:400px; height:300px;][Search Unpublished]">Search unpublished content</a>
<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');
}
/**
global $user;
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,
);
}
$items[] = array('path' => 'user/login/lightbox2',
'title' => t('Login'),
'callback' => 'lightbox2_login',
'access' => !$user->uid,
'type' => MENU_CALLBACK,
);
}
else {
if (lightbox2_exclude_these_paths() != 1) {
lightbox2_add_files();
}
if (module_exists('acidfree') && module_exists('video')) {
if (arg(0) == 'node' && arg(2) == 'lightframevideo' && is_numeric(arg(1))) {
$items[] = array(
'path' => 'node/'. arg(1) .'/lightframevideo',
'callback' => 'lightbox2_acidfree_video',
'callback arguments' => array(arg(1)),
'access' => user_access('play video'),
'type' => MENU_CALLBACK,
);
}
}
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 layout fieldset.
/* --------------------------------- */
$form['layout_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Layout Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// Define Lightbox2 Lite fieldset.
/* ------------------------------- */
Stella Power
committed
$use_lite = variable_get('lightbox2_lite', FALSE);
$form['layout_fieldset']['lightbox2_lite_options'] = array(
Stella Power
committed
'#title' => t('Lightbox2 Lite'),
Stella Power
committed
'#collapsed' => !$use_lite,
// Add checkbox for Lightbox2 Lite.
$form['layout_fieldset']['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['layout_fieldset']['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['layout_fieldset']['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),
);
Stella Power
committed
// Add checkbox for "looping through images'.
$form['layout_fieldset']['lightbox2_loop_items'] = array(
'#type' => 'checkbox',
'#title' => t('Continuous Galleries'),
'#description' => t('When viewing grouped images, the Next button on the last image will display the first image, while the Previous button on the first image will display the last image.'),
'#default_value' => variable_get('lightbox2_loop_items', FALSE),
);
// Add text box for image count for grouping.
$form['layout_fieldset']['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['layout_fieldset']['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'),
);
// Define Lightbox2 zoom fieldset.
/* -------------------------------- */
$form['zoom_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Image Resize Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Add checkbox for resize image.
$form['zoom_fieldset']['lightbox2_disable_resize'] = array(
'#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.'),
'#default_value' => variable_get('lightbox2_disable_resize', FALSE),
);
// Add checkbox for zoom image.
$form['zoom_fieldset']['lightbox2_disable_zoom'] = array(
'#type' => 'checkbox',
'#title' => t('Disable Zoom In / Out Feature'),
'#description' => t('When the image being displayed in the lightbox is resized to fit in the browser window, a "zoom in" button is shown. This allows the user to zoom in to see the original full size image. They will then see a "zoom out" button which will allow them to see the smaller resized version. Checking this box will prevent these buttons from appearing.'),
Stella Power
committed
'#default_value' => variable_get('lightbox2_disable_zoom', FALSE),
Stella Power
committed
// Define Lightbox2 login fieldset.
/* -------------------------------- */
$form['login_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Login Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Add checkbox for login support.
$form['login_fieldset']['lightbox2_enable_login'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Login Support'),
'#description' => t('Enabling this option will modify all login links so that the login form appears in a lightbox.'),
'#default_value' => variable_get('lightbox2_enable_login', FALSE),
);
// Define Lightbox2 video fieldset.
/* -------------------------------- */
$form['video_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Video Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
Stella Power
committed
// Add checkbox for video support.
$form['video_fieldset']['lightbox2_enable_video'] = array(
Stella Power
committed
'#type' => 'checkbox',
'#title' => t('Enable Video Support'),
'#description' => t('By default, video support is disabled in order to reduce the amount of javascript needed. Checking this box will enable it.'),
'#default_value' => variable_get('lightbox2_enable_video', FALSE),
);
Stella Power
committed
// Add fieldset for page specific lightbox2 settings.
$form['lightbox2_page_init'] = array(
'#type' => 'fieldset',
'#title' => t('Page Specific Lightbox2 Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
Stella Power
committed
);
// Add radio buttons for the actions to take for the listed pages, i.e.
// disable or enable the lightbox functionality.
$page_options = array(
'page_enable' => t('Load only on the listed pages.'),
'page_disable' => t('Load on every page except the listed pages.'),
);
$form['lightbox2_page_init']['lightbox2_page_init_action'] = array(
'#type' => 'radios',
'#options' => $page_options,
'#title' => t('Enable Lightbox2 on Specific Pages'),
'#default_value' => variable_get('lightbox2_page_init_action', 'page_disable'),
);
// Add text input for list of pages to take specific action on.
$form['lightbox2_page_init']['lightbox2_page_list'] = array(
Stella Power
committed
'#title' => t('Pages'),
'#description' => t('List one page per line as Drupal paths. The % character is a wildcard. Example paths are "node/add/page" and "node/add/%". Use <front> to match the front page.'),
'#default_value' => variable_get('lightbox2_page_list', ''),
if ((module_exists('emfield') && module_exists('image_ncck')) || (module_exists('imagefield') && module_exists('imagecache'))) {
$form['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['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['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),
);
$form['cck_options']['lightbox2_imagefield_use_node_title'] = array(
Stella Power
committed
'#type' => 'checkbox',
'#title' => t('Use Node Title as Caption'),
'#description' => t('By default, the caption for imagefields is the image title text configured. If no title is configured, then the alt text will be used. This option allows you to override that and always display the node title as the image caption.'),
'#default_value' => variable_get('lightbox2_imagefield_use_node_title', FALSE),
);
// Define advanced settings fieldset.
$form['advanced_options'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// 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['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'),
);
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
// Define keyboard shortcuts fieldset.
/* ---------------------------------- */
$form['advanced_options']['keyboard_shortcuts'] = array(
'#type' => 'fieldset',
'#title' => t('Keyboard Shortcuts'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_close'] = array(
'#type' => 'textfield',
'#title' => t('Close keys'),
'#description' => t("A list of keys (or key codes) that a user may use to close the lightbox. Values should be separated by a space. Defaults to 'c x 27' (c, x, or esc)."),
'#default_value' => variable_get('lightbox2_keys_close', 'c x 27'),
);
$form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_previous'] = array(
'#type' => 'textfield',
'#title' => t('Previous keys'),
'#description' => t("A list of keys (or key codes) that a user may use to navigate to the previous item in the lightbox. Values should be separated by a space. Defaults to 'p 37' (p or left arrow)."),
'#default_value' => variable_get('lightbox2_keys_previous', 'p 37'),
);
$form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_next'] = array(
'#type' => 'textfield',
'#title' => t('Next keys'),
'#description' => t("A list of keys (or key codes) that a user may use to navigate to the next item in the lightbox. Values should be separated by a space. Defaults to 'n 39' (n or right arrow)."),
'#default_value' => variable_get('lightbox2_keys_next', 'n 39'),
);
$form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_zoom'] = array(
'#type' => 'textfield',
'#title' => t('Zoom keys'),
'#description' => t("A list of keys (or key codes) that a user may use to zoom in / out of images in the lightbox. Values should be separated by a space. Defaults to 'z'."),
'#default_value' => variable_get('lightbox2_keys_zoom', 'z'),
);
$form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_play_pause'] = array(
'#type' => 'textfield',
'#title' => t('Pause / Play keys'),
'#description' => t("A list of keys (or key codes) that a user may use to pause / play the lightbox. Values should be separated by a space. Defaults to '32' (spacebar)."),
'#default_value' => variable_get('lightbox2_keys_play_pause', '32'),
);
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
// Define border settings fieldset.
/* ---------------------------------- */
$form['advanced_options']['skin_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Skin settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['advanced_options']['skin_settings']['lightbox2_border_size'] = array(
'#type' => 'textfield',
'#title' => t('Border Size'),
'#size' => 6,
'#maxlength' => 6,
'#description' => t('Enter the size of the border in pixels to display around the image.'),
'#default_value' => variable_get('lightbox2_border_size', 10),
);
$form['advanced_options']['skin_settings']['lightbox2_box_color'] = array(
'#type' => 'textfield',
'#title' => t('Lightbox Color'),
'#field_prefix' => '#',
'#size' => 6,
'#maxlength' => 6,
'#description' => t('Enter a hexadecimal color value for the border. For example <code>fff</code> or <code>ffffff</code> for white).'),
'#default_value' => variable_get('lightbox2_box_color', 'fff'),
);
$form['advanced_options']['skin_settings']['lightbox2_font_color'] = array(
'#type' => 'textfield',
'#title' => t('Font Color'),
'#field_prefix' => '#',
'#size' => 6,
'#maxlength' => 6,
'#description' => t('Enter a hexadecimal color value for the font. For example <code>000</code> or <code>000000</code> for black).'),
'#default_value' => variable_get('lightbox2_font_color', '000'),
);
$form['advanced_options']['skin_settings']['lightbox2_top_position'] = array(
'#type' => 'textfield',
'#size' => 6,
'#maxlength' => 6,
'#description' => t('Enter the position of the top of the lightbox in
pixels. Leave blank for automatic calculation.'),
'#default_value' => variable_get('lightbox2_top_position', ''),
);
// Define overlay settings fieldset.
/* ---------------------------------- */
$form['advanced_options']['overlay_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Overlay 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['advanced_options']['overlay_settings']['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.'),
'#default_value' => variable_get('lightbox2_overlay_opacity', 0.8),
);
$form['advanced_options']['overlay_settings']['lightbox2_overlay_color'] = array(
'#type' => 'textfield',
'#title' => t('Overlay Color'),
'#field_prefix' => '#',
'#size' => 6,
'#maxlength' => 6,
'#description' => t('Enter a hexadecimal color value for the overlay. For example <code>000</code> or <code>000000</code> for black).'),
'#default_value' => variable_get('lightbox2_overlay_color', '000'),
Stella Power
committed
);
// Define animation settings fieldset.
/* ----------------------------------- */
$form['advanced_options']['animation_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Animation settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Set animation help text.
$form['advanced_options']['animation_settings']['animation_options_help'] = array(
'#value' => '<p>'. t("These options aren't available when using Lightbox2 Lite.") .'</p>',
);
$resize_sequence_options = array(
t('Simultaneous'),
t('Width then height'),
t('Height then width'),
);
$form['advanced_options']['animation_settings']['lightbox2_resize_sequence'] = array(
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
'#title' => t('Resize Sequence'),
'#options' => $resize_sequence_options,
'#description' => t('The sequence to use for the resizing animation.'),
'#default_value' => variable_get('lightbox2_resize_sequence', 0),
);
$form['advanced_options']['animation_settings']['lightbox2_resize_speed'] = array(
'#type' => 'textfield',
'#title' => t('Resize Duration'),
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The duration (in seconds) of the resizing animation. Enter a value between 0 and 10.'),
'#default_value' => variable_get('lightbox2_resize_speed', 0.4),
);
$form['advanced_options']['animation_settings']['lightbox2_fadein_speed'] = array(
'#type' => 'textfield',
'#title' => t('Appearance Duration'),
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The duration (in seconds) of the lightbox appearance animation. Enter a value between 0 and 10.'),
'#default_value' => variable_get('lightbox2_fadein_speed', 0.4),
);
$form['advanced_options']['animation_settings']['lightbox2_slidedown_speed'] = array(
'#type' => 'textfield',
'#title' => t('Caption Slide Down Duration'),
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The duration (in seconds) of the caption sliding-down animation. Enter a value between 0 and 10.'),
'#default_value' => variable_get('lightbox2_slidedown_speed', 0.6),
Stella Power
committed
* Configuration form for controlling the slideshow behaviour.
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
*/
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),
);
Stella Power
committed
// Add checkbox for "looping through slides'.
$form['lightbox2_loop_slides'] = array(
'#type' => 'checkbox',
'#title' => t('Continuous Loop'),
'#description' => t('When enabled the slideshow will automatically start over after displaying the last slide. This prevents the slideshow from automatically exiting when enabled.'),
'#default_value' => variable_get('lightbox2_loop_slides', FALSE),
);
return system_settings_form($form);
}
/**
* Validation function for the general configuration form.
*
* Ensure that the hex color value submitted is valid and that the speeds are
* numeric.
*/
function lightbox2_general_settings_form_validate($form_id, $form_values) {
$border_size = $form_values['lightbox2_border_size'];
$box_hex_colour = $form_values['lightbox2_box_color'];
$font_hex_colour = $form_values['lightbox2_font_color'];
$top_position = $form_values['lightbox2_top_position'];
$overlay_hex_colour = $form_values['lightbox2_overlay_color'];
$resize_speed = $form_values['lightbox2_resize_speed'];
$fadein_speed = $form_values['lightbox2_fadein_speed'];
$slide_down_speed = $form_values['lightbox2_slidedown_speed'];
if (!_lightbox2_validate_hex_color($overlay_hex_colour)) {
form_set_error('lightbox2_overlay_color', t('You must enter a properly formed hex value.'));
}
if (!$form_values['lightbox2_lite']) {
if (!is_numeric($border_size) || $border_size < 0) {
form_set_error('lightbox2_border_size', t('You must enter a size greater than 0 pixels.'));
}
if (!_lightbox2_validate_hex_color($box_hex_colour)) {
form_set_error('lightbox2_border_color', t('You must enter a properly formed hex value.'));
}
if (!_lightbox2_validate_hex_color($font_hex_colour)) {
form_set_error('lightbox2_font_color', t('You must enter a properly formed hex value.'));
}
if (!empty($top_position) && (!is_numeric($top_position) || $top_position < 0)) {
form_set_error('lightbox2_top_position', t('You must enter a size greater than 0 pixels. Leave blank for default positioning.'));
}
if (!is_numeric($resize_speed) || $resize_speed <= 0 || $resize_speed >= 10) {
form_set_error('lightbox2_resize_speed', t('You must enter a duration between 0 and 10 seconds.'));
}
if (!is_numeric($fadein_speed) || $fadein_speed <= 0 || $fadein_speed >= 10) {
form_set_error('lightbox2_fadein_speed', t('You must enter a duration between 0 and 10 seconds.'));
}
if (!is_numeric($slide_down_speed) || $slide_down_speed <= 0 || $slide_down_speed >= 10) {
form_set_error('lightbox2_slidedown_speed', t('You must enter a duration between 0 and 10 seconds.'));
}
}
}
* 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
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
/**
* 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
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
// Define general settings fieldset.
/* --------------------------------- */
$form['lightbox2_general_options'] = array(
'#type' => 'fieldset',
'#title' => t('General settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// Add text box for link text to node.
$form['lightbox2_general_options']['lightbox2_node_link_text'] = array(
'#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.'),
'#default_value' => variable_get('lightbox2_node_link_text', 'View Image Details'),
);
// Add checkbox for node link target.
$form['lightbox2_general_options']['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.'),
'#default_value' => variable_get('lightbox2_node_link_target', FALSE),
'#return_value' => '_blank',
);
// Define handler settings fieldset.
/* --------------------------------- */
$form['handler_options'] = array(
'#type' => 'fieldset',
'#title' => t('Automatic Handlers'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// Define image nodes settings fieldset.
$form['handler_options']['image_node_options'] = array(
'#type' => 'fieldset',
'#title' => t('Image node settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
// Add checkbox for image nodes.
$form['handler_options']['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', 0),
// 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['handler_options']['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['handler_options']['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.'),
);