lightbox2.admin.inc

  1. cis7 sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc
  2. cle7 sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc
  3. ecd7 sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc
  4. elmsmedia7 sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc
  5. harmony7 sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc
  6. icor7 sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc
  7. meedjum_blog7 sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc
  8. mooc7 sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc

Administrative page callbacks for the lightbox2 module.

Functions

Namesort descending Description
lightbox2_auto_image_handling_settings_form Configuration form the automatic image handling functionality.
lightbox2_general_settings_form General configuration form for controlling the lightbox behaviour.
lightbox2_general_settings_form_submit Submit function for the general configuration form.
lightbox2_general_settings_form_validate Validation function for the general configuration form.
lightbox2_iframe_settings_form Configuration form for controlling the iframe behaviour.
lightbox2_iframe_settings_form_validate Validation function for the iframe configuration form.
lightbox2_settings_page The default lightbox2 settings page.
lightbox2_slideshow_settings_form Configuration form for controlling the slideshow behaviour.
lightbox2_slideshow_settings_form_validate Validation function for the slideshow configuration form.
_lightbox2_validate_hex_color Validate a hex color value.

File

sites/all/modules/ulmus/lightbox2/lightbox2.admin.inc
View source
  1. <?php
  2. // $Id: lightbox2.admin.inc,v 1.1.2.38 2010/09/24 08:41:02 snpower Exp $
  3. /**
  4. * @file
  5. * Administrative page callbacks for the lightbox2 module.
  6. */
  7. /**
  8. * The default lightbox2 settings page.
  9. */
  10. function lightbox2_settings_page($op = NULL) {
  11. $output = drupal_get_form('lightbox2_general_settings_form');
  12. return $output;
  13. }
  14. /**
  15. * General configuration form for controlling the lightbox behaviour.
  16. */
  17. function lightbox2_general_settings_form() {
  18. // Add the javascript which disables / enables form elements.
  19. drupal_add_js(drupal_get_path('module', 'lightbox2') . '/js/lightbox2.js', 'module');
  20. // Enable translation of default strings for potx.
  21. $default_strings = array(t('View Image Details'), t('Image !current of !total'), t('Page !current of !total'), t('Video !current of !total'), t('Download Original'));
  22. // Define Lightbox2 layout fieldset.
  23. /* --------------------------------- */
  24. $form['layout_fieldset'] = array(
  25. '#type' => 'fieldset',
  26. '#title' => t('Layout settings'),
  27. '#collapsible' => TRUE,
  28. '#collapsed' => FALSE,
  29. );
  30. // Define Lightbox2 Lite fieldset.
  31. /* ------------------------------- */
  32. $use_lite = variable_get('lightbox2_lite', FALSE);
  33. $form['layout_fieldset']['lightbox2_lite_options'] = array(
  34. '#type' => 'fieldset',
  35. '#title' => t('Lightbox2 lite'),
  36. '#collapsible' => TRUE,
  37. '#collapsed' => !$use_lite,
  38. );
  39. // Add checkbox for Lightbox2 Lite.
  40. $form['layout_fieldset']['lightbox2_lite_options']['lightbox2_lite'] = array(
  41. '#type' => 'checkbox',
  42. '#title' => t('Use lightbox2 lite'),
  43. '#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.'),
  44. '#default_value' => $use_lite,
  45. );
  46. // Add checkbox for alternative layout.
  47. $form['layout_fieldset']['lightbox2_use_alt_layout'] = array(
  48. '#type' => 'checkbox',
  49. '#title' => t('Use alternative layout'),
  50. '#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.'),
  51. '#default_value' => variable_get('lightbox2_use_alt_layout', FALSE),
  52. );
  53. // Add checkbox for force navigation display.
  54. $form['layout_fieldset']['lightbox2_force_show_nav'] = array(
  55. '#type' => 'checkbox',
  56. '#title' => t('Force visibility of navigation links'),
  57. '#description' => t('When viewing grouped images, 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.'),
  58. '#default_value' => variable_get('lightbox2_force_show_nav', FALSE),
  59. );
  60. // Show caption
  61. $form['layout_fieldset']['lightbox2_show_caption'] = array(
  62. '#type' => 'checkbox',
  63. '#title' => t('Show image caption'),
  64. '#description' => t('Unset this to always hide the image caption (usually the title).'),
  65. '#default_value' => variable_get('lightbox2_show_caption', TRUE),
  66. );
  67. // Add checkbox for "looping through images'.
  68. $form['layout_fieldset']['lightbox2_loop_items'] = array(
  69. '#type' => 'checkbox',
  70. '#title' => t('Continuous galleries'),
  71. '#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.'),
  72. '#default_value' => variable_get('lightbox2_loop_items', FALSE),
  73. );
  74. // Add checkbox for node link target.
  75. $form['layout_fieldset']['lightbox2_node_link_target'] = array(
  76. '#type' => 'checkbox',
  77. '#title' => t('Open image page in new window'),
  78. '#description' => t('This controls whether the link to the image page underneath the image is opened in a new window or the current window.'),
  79. '#default_value' => variable_get('lightbox2_node_link_target', FALSE),
  80. '#return_value' => '_blank',
  81. );
  82. // Define Lightbox2 text settings.
  83. /* ------------------------------- */
  84. $form['lightbox2_text_settings'] = array(
  85. '#type' => 'fieldset',
  86. '#title' => t('Text settings'),
  87. '#collapsible' => TRUE,
  88. '#collapsed' => TRUE,
  89. );
  90. // Add text box for link text to node.
  91. $form['lightbox2_text_settings']['lightbox2_node_link_text'] = array(
  92. '#type' => 'textfield',
  93. '#title' => t('Text for image page link'),
  94. '#description' => t('This is the text that will appear as the link to the image page underneath the image in the lightbox. Leave this blank for the link not to appear.'),
  95. '#default_value' => variable_get('lightbox2_node_link_text', 'View Image Details'),
  96. );
  97. // Add text box for link text to node.
  98. $form['lightbox2_text_settings']['lightbox2_download_link_text'] = array(
  99. '#type' => 'textfield',
  100. '#title' => t('Text for image original link'),
  101. '#description' => t('This is the text that will appear as the link to the original file underneath the image in the lightbox. Leave this blank for the link not to appear. It will only appear for images uploaded via the "image" or "imagefield" modules. Users will need the "download original image" permission, but also the "view original images" permission if using the "image" module.'),
  102. '#default_value' => variable_get('lightbox2_download_link_text', 'Download Original'),
  103. );
  104. // Add text box for image count for grouping.
  105. $form['lightbox2_text_settings']['lightbox2_image_count_str'] = array(
  106. '#type' => 'textfield',
  107. '#title' => t('Image count text'),
  108. '#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". Leave blank for text not to appear.'),
  109. '#default_value' => variable_get('lightbox2_image_count_str', 'Image !current of !total'),
  110. );
  111. // Add text box for page count for grouping.
  112. $form['lightbox2_text_settings']['lightbox2_page_count_str'] = array(
  113. '#type' => 'textfield',
  114. '#title' => t('Page count text'),
  115. '#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". Leave blank for text not to appear.'),
  116. '#default_value' => variable_get('lightbox2_page_count_str', 'Page !current of !total'),
  117. );
  118. // Add text box for video count for grouping.
  119. $form['lightbox2_text_settings']['lightbox2_video_count_str'] = array(
  120. '#type' => 'textfield',
  121. '#title' => t('Video count text'),
  122. '#description' => t('This text is used to display the count underneath video content displayed in the lightbox when using groups. Use !current as a placeholder for the number of the current video and !total for the total number of videos in the group. For example, "Video !current of !total". Leave blank for text not to appear.'),
  123. '#default_value' => variable_get('lightbox2_video_count_str', 'Video !current of !total'),
  124. );
  125. // Add text box for video count for grouping.
  126. $form['lightbox2_text_settings']['lightbox2_filter_xss_allowed_tags'] = array(
  127. '#type' => 'textfield',
  128. '#title' => t('Allowed HTML tags'),
  129. '#description' => t('A list of comma separated HTML tags which are allowed to be used in the caption text area.'),
  130. '#default_value' => variable_get('lightbox2_filter_xss_allowed_tags', 'p, br, a, em, strong, cite, code, ul, ol, li, dl, dt, dd'),
  131. );
  132. // Define Lightbox2 zoom fieldset.
  133. /* -------------------------------- */
  134. $form['zoom_fieldset'] = array(
  135. '#type' => 'fieldset',
  136. '#title' => t('Image resize settings'),
  137. '#collapsible' => TRUE,
  138. '#collapsed' => TRUE,
  139. );
  140. // Add checkbox for resize image.
  141. $form['zoom_fieldset']['lightbox2_disable_resize'] = array(
  142. '#type' => 'checkbox',
  143. '#title' => t('Disable resizing feature'),
  144. '#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.'),
  145. '#default_value' => variable_get('lightbox2_disable_resize', FALSE),
  146. );
  147. // Add checkbox for zoom image.
  148. $form['zoom_fieldset']['lightbox2_disable_zoom'] = array(
  149. '#type' => 'checkbox',
  150. '#title' => t('Disable zoom in / out feature'),
  151. '#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.'),
  152. '#default_value' => variable_get('lightbox2_disable_zoom', FALSE),
  153. );
  154. // Define Lightbox2 modal form fieldset.
  155. /* -------------------------------------- */
  156. $form['modal_form_fieldset'] = array(
  157. '#type' => 'fieldset',
  158. '#title' => t('Modal form settings'),
  159. '#collapsible' => TRUE,
  160. '#collapsed' => TRUE,
  161. );
  162. // Add checkbox for login support.
  163. $form['modal_form_fieldset']['lightbox2_enable_login'] = array(
  164. '#type' => 'checkbox',
  165. '#title' => t('Enable login support'),
  166. '#description' => t('Enabling this option will modify all login links so that the login form appears in a lightbox.'),
  167. '#default_value' => variable_get('lightbox2_enable_login', FALSE),
  168. );
  169. // Add checkbox for contact form support.
  170. $form['modal_form_fieldset']['lightbox2_enable_contact'] = array(
  171. '#type' => 'checkbox',
  172. '#title' => t('Enable contact form support'),
  173. '#description' => t('Enabling this option will modify all contact links so that the contact form appears in a lightbox.'),
  174. '#default_value' => variable_get('lightbox2_enable_contact', FALSE),
  175. );
  176. // Define Lightbox2 video fieldset.
  177. /* -------------------------------- */
  178. $form['video_fieldset'] = array(
  179. '#type' => 'fieldset',
  180. '#title' => t('Video settings'),
  181. '#collapsible' => TRUE,
  182. '#collapsed' => TRUE,
  183. );
  184. // Add checkbox for video support.
  185. $form['video_fieldset']['lightbox2_enable_video'] = array(
  186. '#type' => 'checkbox',
  187. '#title' => t('Enable video support'),
  188. '#description' => t('By default, video support is disabled in order to reduce the amount of javascript needed. Checking this box will enable it.'),
  189. '#default_value' => variable_get('lightbox2_enable_video', FALSE),
  190. );
  191. // Add textfield for FLV Player path.
  192. $form['video_fieldset']['lightbox2_flv_player_path'] = array(
  193. '#type' => 'textfield',
  194. '#title' => t('Path to FLV Player'),
  195. '#description' => t('The path to the FLV player, relative to Drupal root directory. No leading slashes.'),
  196. '#default_value' => variable_get('lightbox2_flv_player_path', 'flvplayer.swf'),
  197. );
  198. // Add textfield for FLV Player flashvars.
  199. $form['video_fieldset']['lightbox2_flv_player_flashvars'] = array(
  200. '#type' => 'textfield',
  201. '#title' => t('FLV Player flashvars'),
  202. '#description' => t('Flashvars for the FLV Player where supported, e.g. "autoplay=1&playerMode=normal".'),
  203. '#default_value' => variable_get('lightbox2_flv_player_flashvars', ''),
  204. );
  205. // Define Lightbox2 page specific settings fieldset.
  206. /* ------------------------------------------------ */
  207. $form['lightbox2_page_init'] = array(
  208. '#type' => 'fieldset',
  209. '#title' => t('Page specific lightbox2 settings'),
  210. '#collapsible' => TRUE,
  211. '#collapsed' => TRUE,
  212. );
  213. // Add radio buttons for the actions to take for the listed pages, i.e.
  214. // disable or enable the lightbox functionality.
  215. $page_options = array(
  216. 'page_enable' => t('Load only on the listed pages.'),
  217. 'page_disable' => t('Load on every page except the listed pages.'),
  218. );
  219. $form['lightbox2_page_init']['lightbox2_page_init_action'] = array(
  220. '#type' => 'radios',
  221. '#options' => $page_options,
  222. '#title' => t('Enable lightbox2 on specific pages'),
  223. '#default_value' => variable_get('lightbox2_page_init_action', 'page_disable'),
  224. );
  225. // Add text input for list of pages to take specific action on.
  226. $form['lightbox2_page_init']['lightbox2_page_list'] = array(
  227. '#type' => 'textarea',
  228. '#title' => t('Pages'),
  229. '#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 &lt;front&gt; to match the front page.'),
  230. '#default_value' => variable_get('lightbox2_page_list', ''),
  231. );
  232. // Define grouping settings fieldset.
  233. /* ------------------------------------ */
  234. $form['group_options'] = array(
  235. '#type' => 'fieldset',
  236. '#title' => t('Group display settings'),
  237. '#collapsible' => TRUE,
  238. '#collapsed' => TRUE,
  239. );
  240. $group_options = array(
  241. 0 => t('No grouping'),
  242. 1 => t('Group by field name'),
  243. 2 => t('Group by node id'),
  244. 3 => t('Group by field name and node id'),
  245. 4 => t('Group all nodes and fields'),
  246. );
  247. $form['group_options']['lightbox2_image_group_node_id'] = array(
  248. '#type' => 'select',
  249. '#title' => t('Select Imagefield grouping in Views'),
  250. '#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.'),
  251. '#options' => $group_options,
  252. '#default_value' => variable_get('lightbox2_image_group_node_id', 1),
  253. );
  254. // Define advanced settings fieldset.
  255. /* ---------------------------------- */
  256. $form['advanced_options'] = array(
  257. '#type' => 'fieldset',
  258. '#title' => t('Advanced settings'),
  259. '#collapsible' => TRUE,
  260. '#collapsed' => TRUE,
  261. );
  262. // Allow users to decide where javascript should be loaded - header or footer.
  263. // Header is recommended so user can click on images before page has finished
  264. // loading, but footer is needed for sites in IE which use SWFObject.
  265. $form['advanced_options']['lightbox2_js_location'] = array(
  266. '#type' => 'select',
  267. '#title' => t('Location of javscript'),
  268. '#options' => array('header' => t('Header'), 'footer' => t('Footer')),
  269. '#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.'),
  270. '#default_value' => variable_get('lightbox2_js_location', 'header'),
  271. );
  272. $form['advanced_options']['lightbox2_disable_close_click'] = array(
  273. '#type' => 'checkbox',
  274. '#title' => t('Click on overlay or lightbox to close it'),
  275. '#description' => t('Enable user to close lightbox by clicking on the lightbox itself or the overlay background.'),
  276. '#default_value' => variable_get('lightbox2_disable_close_click', TRUE),
  277. );
  278. // Define keyboard shortcuts fieldset.
  279. /* ---------------------------------- */
  280. $form['advanced_options']['keyboard_shortcuts'] = array(
  281. '#type' => 'fieldset',
  282. '#title' => t('Keyboard shortcuts'),
  283. '#description' => t('Configure the keyboard shortcuts for controlling the lightbox. These options do not apply to the Lightbox2 Lite version, which uses the default "Close keys" (c, x and esc) to close the lightbox.'),
  284. '#collapsible' => TRUE,
  285. '#collapsed' => TRUE,
  286. );
  287. $form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_close'] = array(
  288. '#type' => 'textfield',
  289. '#title' => t('Close keys'),
  290. '#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)."),
  291. '#default_value' => variable_get('lightbox2_keys_close', 'c x 27'),
  292. );
  293. $form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_previous'] = array(
  294. '#type' => 'textfield',
  295. '#title' => t('Previous keys'),
  296. '#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)."),
  297. '#default_value' => variable_get('lightbox2_keys_previous', 'p 37'),
  298. );
  299. $form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_next'] = array(
  300. '#type' => 'textfield',
  301. '#title' => t('Next keys'),
  302. '#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)."),
  303. '#default_value' => variable_get('lightbox2_keys_next', 'n 39'),
  304. );
  305. $form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_zoom'] = array(
  306. '#type' => 'textfield',
  307. '#title' => t('Zoom keys'),
  308. '#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'."),
  309. '#default_value' => variable_get('lightbox2_keys_zoom', 'z'),
  310. );
  311. $form['advanced_options']['keyboard_shortcuts']['lightbox2_keys_play_pause'] = array(
  312. '#type' => 'textfield',
  313. '#title' => t('Pause / play keys'),
  314. '#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)."),
  315. '#default_value' => variable_get('lightbox2_keys_play_pause', '32'),
  316. );
  317. // Define border settings fieldset.
  318. /* ---------------------------------- */
  319. $form['advanced_options']['skin_settings'] = array(
  320. '#type' => 'fieldset',
  321. '#title' => t('Skin settings'),
  322. '#collapsible' => TRUE,
  323. '#collapsed' => TRUE,
  324. );
  325. $form['advanced_options']['skin_settings']['lightbox2_border_size'] = array(
  326. '#type' => 'textfield',
  327. '#title' => t('Border size'),
  328. '#size' => 6,
  329. '#maxlength' => 6,
  330. '#description' => t('Enter the size of the border in pixels to display around the image.'),
  331. '#default_value' => variable_get('lightbox2_border_size', 10),
  332. );
  333. $form['advanced_options']['skin_settings']['lightbox2_box_color'] = array(
  334. '#type' => 'textfield',
  335. '#title' => t('Lightbox color'),
  336. '#field_prefix' => '#',
  337. '#size' => 6,
  338. '#maxlength' => 6,
  339. '#description' => t('Enter a hexadecimal color value for the border. For example <code>fff</code> or <code>ffffff</code> for white).'),
  340. '#default_value' => variable_get('lightbox2_box_color', 'fff'),
  341. );
  342. $form['advanced_options']['skin_settings']['lightbox2_font_color'] = array(
  343. '#type' => 'textfield',
  344. '#title' => t('Font color'),
  345. '#field_prefix' => '#',
  346. '#size' => 6,
  347. '#maxlength' => 6,
  348. '#description' => t('Enter a hexadecimal color value for the font. For example <code>000</code> or <code>000000</code> for black).'),
  349. '#default_value' => variable_get('lightbox2_font_color', '000'),
  350. );
  351. $form['advanced_options']['skin_settings']['lightbox2_top_position'] = array(
  352. '#type' => 'textfield',
  353. '#title' => t('Distance from top'),
  354. '#size' => 6,
  355. '#maxlength' => 6,
  356. '#description' => t('Enter the position of the top of the lightbox in pixels. Leave blank for automatic calculation.'),
  357. '#default_value' => variable_get('lightbox2_top_position', ''),
  358. );
  359. // Define overlay settings fieldset.
  360. /* ---------------------------------- */
  361. $form['advanced_options']['overlay_settings'] = array(
  362. '#type' => 'fieldset',
  363. '#title' => t('Overlay settings'),
  364. '#collapsible' => TRUE,
  365. '#collapsed' => TRUE,
  366. );
  367. // Add checkbox for overlay opacity.
  368. for ($i = 0; $i < 10; $i++) {
  369. $opacity_options["0.$i"] = "0.$i";
  370. }
  371. $opacity_options["1.0"] = "1.0";
  372. $form['advanced_options']['overlay_settings']['lightbox2_overlay_opacity'] = array(
  373. '#type' => 'select',
  374. '#title' => t('Overlay opacity'),
  375. '#options' => $opacity_options,
  376. '#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.'),
  377. '#default_value' => variable_get('lightbox2_overlay_opacity', 0.8),
  378. );
  379. $form['advanced_options']['overlay_settings']['lightbox2_overlay_color'] = array(
  380. '#type' => 'textfield',
  381. '#title' => t('Overlay color'),
  382. '#field_prefix' => '#',
  383. '#size' => 6,
  384. '#maxlength' => 6,
  385. '#description' => t('Enter a hexadecimal color value for the overlay. For example <code>000</code> or <code>000000</code> for black).'),
  386. '#default_value' => variable_get('lightbox2_overlay_color', '000'),
  387. );
  388. // Define animation settings fieldset.
  389. /* ----------------------------------- */
  390. $form['advanced_options']['animation_settings'] = array(
  391. '#type' => 'fieldset',
  392. '#title' => t('Animation settings'),
  393. '#collapsible' => TRUE,
  394. '#collapsed' => TRUE,
  395. );
  396. // Set animation help text.
  397. $form['advanced_options']['animation_settings']['animation_options_help'] = array(
  398. '#value' => '<p>' . t("These options aren't available when using Lightbox2 Lite.") . '</p>',
  399. );
  400. $resize_sequence_options = array(
  401. t('Simultaneous'),
  402. t('Width then height'),
  403. t('Height then width'),
  404. );
  405. $form['advanced_options']['animation_settings']['lightbox2_resize_sequence'] = array(
  406. '#type' => 'select',
  407. '#title' => t('Resize sequence'),
  408. '#options' => $resize_sequence_options,
  409. '#description' => t('The sequence to use for the resizing animation.'),
  410. '#default_value' => variable_get('lightbox2_resize_sequence', 0),
  411. );
  412. $form['advanced_options']['animation_settings']['lightbox2_resize_speed'] = array(
  413. '#type' => 'textfield',
  414. '#title' => t('Resize duration'),
  415. '#size' => 5,
  416. '#maxlength' => 5,
  417. '#description' => t('The duration (in seconds) of the resizing animation. Enter a value between 0 and 10.'),
  418. '#default_value' => variable_get('lightbox2_resize_speed', 0.4),
  419. );
  420. $form['advanced_options']['animation_settings']['lightbox2_fadein_speed'] = array(
  421. '#type' => 'textfield',
  422. '#title' => t('Appearance duration'),
  423. '#size' => 5,
  424. '#maxlength' => 5,
  425. '#description' => t('The duration (in seconds) of the lightbox appearance animation. Enter a positive number less than 10.'),
  426. '#default_value' => variable_get('lightbox2_fadein_speed', 0.4),
  427. );
  428. $form['advanced_options']['animation_settings']['lightbox2_slidedown_speed'] = array(
  429. '#type' => 'textfield',
  430. '#title' => t('Caption slide down duration'),
  431. '#size' => 5,
  432. '#maxlength' => 5,
  433. '#description' => t('The duration (in seconds) of the caption sliding-down animation. Enter a value between 0 and 10.'),
  434. '#default_value' => variable_get('lightbox2_slidedown_speed', 0.6),
  435. );
  436. return system_settings_form($form);
  437. }
  438. /**
  439. * Validation function for the general configuration form.
  440. *
  441. * Ensure that the hex color value submitted is valid and that the speeds are
  442. * numeric.
  443. */
  444. function lightbox2_general_settings_form_validate($form, &$form_state) {
  445. if ($form_state['values']['op'] == t('Save configuration')) {
  446. $border_size = $form_state['values']['lightbox2_border_size'];
  447. $box_hex_colour = $form_state['values']['lightbox2_box_color'];
  448. $font_hex_colour = $form_state['values']['lightbox2_font_color'];
  449. $top_position = $form_state['values']['lightbox2_top_position'];
  450. $overlay_hex_colour = $form_state['values']['lightbox2_overlay_color'];
  451. $resize_speed = $form_state['values']['lightbox2_resize_speed'];
  452. $fadein_speed = $form_state['values']['lightbox2_fadein_speed'];
  453. $slide_down_speed = $form_state['values']['lightbox2_slidedown_speed'];
  454. $flv_player_path = $form_state['values']['lightbox2_flv_player_path'];
  455. if (!empty($flv_player_path) && $form_state['values']['lightbox2_enable_video']) {
  456. if (strpos($flv_player_path, base_path()) === 0) {
  457. $flv_player_path = drupal_substr($flv_player_path, drupal_strlen(base_path()));
  458. }
  459. if (!file_exists($flv_player_path)) {
  460. form_set_error('lightbox2_flv_player_path', t("FLV player path doesn't exist."));
  461. }
  462. }
  463. if (!_lightbox2_validate_hex_color($overlay_hex_colour)) {
  464. form_set_error('lightbox2_overlay_color', t('You must enter a properly formed hex value.'));
  465. }
  466. if (!$form_state['values']['lightbox2_lite']) {
  467. if (!is_numeric($border_size) || $border_size < 0) {
  468. form_set_error('lightbox2_border_size', t('You must enter a size greater than 0 pixels.'));
  469. }
  470. if (!_lightbox2_validate_hex_color($box_hex_colour)) {
  471. form_set_error('lightbox2_box_color', t('You must enter a properly formed hex value.'));
  472. }
  473. if (!_lightbox2_validate_hex_color($font_hex_colour)) {
  474. form_set_error('lightbox2_font_color', t('You must enter a properly formed hex value.'));
  475. }
  476. if (!empty($top_position) && (!is_numeric($top_position) || $top_position < 0)) {
  477. form_set_error('lightbox2_top_position', t('You must enter a size greater than 0 pixels. Leave blank for default positioning.'));
  478. }
  479. if (!is_numeric($resize_speed) || $resize_speed <= 0 || $resize_speed >= 10) {
  480. form_set_error('lightbox2_resize_speed', t('You must enter a duration between 0 and 10 seconds.'));
  481. }
  482. if (!is_numeric($fadein_speed) || $fadein_speed < 0 || $fadein_speed >= 10) {
  483. form_set_error('lightbox2_fadein_speed', t('You must enter a duration between 0 and 10 seconds.'));
  484. }
  485. if (!is_numeric($slide_down_speed) || $slide_down_speed <= 0 || $slide_down_speed >= 10) {
  486. form_set_error('lightbox2_slidedown_speed', t('You must enter a duration between 0 and 10 seconds.'));
  487. }
  488. }
  489. }
  490. }
  491. /**
  492. * Submit function for the general configuration form.
  493. */
  494. function lightbox2_general_settings_form_submit($form, &$form_state) {
  495. cache_clear_all();
  496. }
  497. /**
  498. * Configuration form for controlling the slideshow behaviour.
  499. */
  500. function lightbox2_slideshow_settings_form() {
  501. // Add the javascript which disables / enables form elements.
  502. drupal_add_js(drupal_get_path('module', 'lightbox2') . '/js/lightbox2.js', 'module');
  503. // Set up a hidden variable.
  504. $form['lightbox2_lite'] = array(
  505. '#type' => 'hidden',
  506. '#value' => variable_get('lightbox2_lite', FALSE),
  507. );
  508. // Add text box for slideshow interval.
  509. $form['lightbox2_slideshow_interval'] = array(
  510. '#type' => 'textfield',
  511. '#title' => t('Interval seconds'),
  512. '#description' => t('The slideshow interval is the length of time in seconds an image is visible before the slideshow shows the next image.'),
  513. '#default_value' => variable_get('lightbox2_slideshow_interval', 5),
  514. '#size' => 20,
  515. );
  516. // Add checkbox for slideshow automatic start.
  517. $form['lightbox2_slideshow_automatic_start'] = array(
  518. '#type' => 'checkbox',
  519. '#title' => t('Automatically start slideshow'),
  520. '#description' => t('When enabled the slideshow will automatically start.'),
  521. '#default_value' => variable_get('lightbox2_slideshow_automatic_start', TRUE),
  522. );
  523. // Add checkbox for slideshow automatic exit.
  524. $form['lightbox2_slideshow_automatic_exit'] = array(
  525. '#type' => 'checkbox',
  526. '#title' => t('Automatically exit slideshow'),
  527. '#description' => t('When enabled the lightbox will automatically close after displaying the last image.'),
  528. '#default_value' => variable_get('lightbox2_slideshow_automatic_exit', TRUE),
  529. );
  530. // Add checkbox for showing hte play / pause button.
  531. $form['lightbox2_slideshow_show_play_pause'] = array(
  532. '#type' => 'checkbox',
  533. '#title' => t('Show play / pause button'),
  534. '#description' => t('When enabled, a play / pause button will be shown in the slideshow allowing the user more control over their viewing experience.'),
  535. '#default_value' => variable_get('lightbox2_slideshow_show_play_pause', TRUE),
  536. );
  537. // Add checkbox for "pausing on next click".
  538. $form['lightbox2_slideshow_pause_on_next_click'] = array(
  539. '#type' => 'checkbox',
  540. '#title' => t('Pause slideshow on "Next Image" click'),
  541. '#description' => t('When enabled the slideshow is automatically paused, and the following image shown, when the "Next" button is clicked.'),
  542. '#default_value' => variable_get('lightbox2_slideshow_pause_on_next_click', FALSE),
  543. );
  544. // Add checkbox for "pausing on prev click".
  545. $form['lightbox2_slideshow_pause_on_previous_click'] = array(
  546. '#type' => 'checkbox',
  547. '#title' => t('Pause slideshow on "Previous Image" click'),
  548. '#description' => t('When enabled the slideshow is automatically paused, and the previous image shown, when the "Previous" button is clicked.'),
  549. '#default_value' => variable_get('lightbox2_slideshow_pause_on_previous_click', TRUE),
  550. );
  551. // Add checkbox for "looping through slides'.
  552. $form['lightbox2_loop_slides'] = array(
  553. '#type' => 'checkbox',
  554. '#title' => t('Continuous loop'),
  555. '#description' => t('When enabled the slideshow will automatically start over after displaying the last slide. This prevents the slideshow from automatically exiting when enabled.'),
  556. '#default_value' => variable_get('lightbox2_loop_slides', FALSE),
  557. );
  558. return system_settings_form($form);
  559. }
  560. /**
  561. * Validation function for the slideshow configuration form.
  562. *
  563. * Ensure that the slideshow interval submitted is numeric.
  564. */
  565. function lightbox2_slideshow_settings_form_validate($form, &$form_state) {
  566. if (!is_numeric($form_state['values']['lightbox2_slideshow_interval'])) {
  567. form_set_error('lightbox2_slideshow_interval', t('The "interval seconds" value must be numeric.'));
  568. }
  569. }
  570. /**
  571. * Configuration form for controlling the iframe behaviour.
  572. */
  573. function lightbox2_iframe_settings_form() {
  574. // Add the javascript which disables / enables form elements.
  575. drupal_add_js(drupal_get_path('module', 'lightbox2') . '/js/lightbox2.js', 'module');
  576. // Set up a hidden variable.
  577. $form['lightbox2_lite'] = array(
  578. '#type' => 'hidden',
  579. '#value' => variable_get('lightbox2_lite', FALSE),
  580. );
  581. // Add text box for iframe width.
  582. $form['lightbox2_default_frame_width'] = array(
  583. '#type' => 'textfield',
  584. '#title' => t('Default width'),
  585. '#description' => t('The default width of the iframe in pixels.'),
  586. '#default_value' => variable_get('lightbox2_default_frame_width', 600),
  587. '#size' => 20,
  588. );
  589. // Add text box for iframe height.
  590. $form['lightbox2_default_frame_height'] = array(
  591. '#type' => 'textfield',
  592. '#title' => t('Default height'),
  593. '#description' => t('The default height of the iframe in pixels.'),
  594. '#default_value' => variable_get('lightbox2_default_frame_height', 400),
  595. '#size' => 20,
  596. );
  597. // Add option for iframe border.
  598. $form['lightbox2_frame_border'] = array(
  599. '#type' => 'checkbox',
  600. '#title' => t('Enable border'),
  601. '#description' => t('Enable iframe border. You can modify the border style in your theme\'s css file using the iframe\'s id "lightboxFrame".'),
  602. '#default_value' => variable_get('lightbox2_frame_border', 1),
  603. );
  604. return system_settings_form($form);
  605. }
  606. /**
  607. * Validation function for the iframe configuration form.
  608. *
  609. * Ensure that the iframe width and height submitted are numeric.
  610. */
  611. function lightbox2_iframe_settings_form_validate($form, &$form_state) {
  612. if (!is_numeric($form_state['values']['lightbox2_default_frame_width'])) {
  613. form_set_error('lightbox2_slideshow_interval', t('The "default width" value must be numeric.'));
  614. }
  615. if (!is_numeric($form_state['values']['lightbox2_default_frame_height'])) {
  616. form_set_error('lightbox2_slideshow_interval', t('The "default height" value must be numeric.'));
  617. }
  618. }
  619. /**
  620. * Configuration form the automatic image handling functionality.
  621. */
  622. function lightbox2_auto_image_handling_settings_form() {
  623. // Add the javascript which disables / enables form elements.
  624. drupal_add_js(drupal_get_path('module', 'lightbox2') . '/js/lightbox2.js', 'module');
  625. // Set up a hidden variable.
  626. $form['lightbox2_lite'] = array(
  627. '#type' => 'hidden',
  628. '#value' => variable_get('lightbox2_lite', FALSE),
  629. );
  630. $automatic_options = array(
  631. 0 => t('Disabled'),
  632. 1 => t('Lightbox'),
  633. 2 => t('Lightbox grouped'),
  634. 3 => t('Slideshow'),
  635. 4 => t('HTML content'),
  636. 5 => t('HTML content grouped'),
  637. );
  638. // Set image node options help text.
  639. $form['image_node_options'] = array(
  640. '#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.'),
  641. );
  642. // Define handler settings fieldset.
  643. /* --------------------------------- */
  644. $form['handler_options'] = array(
  645. '#type' => 'fieldset',
  646. '#title' => t('Automatic handlers'),
  647. '#collapsible' => TRUE,
  648. '#collapsed' => FALSE,
  649. );
  650. // Define image nodes settings fieldset.
  651. /* ------------------------------------- */
  652. $form['handler_options']['image_node_options'] = array(
  653. '#type' => 'fieldset',
  654. '#title' => t('Image node settings'),
  655. '#collapsible' => TRUE,
  656. '#collapsed' => TRUE,
  657. );
  658. // Add checkbox for image nodes.
  659. $form['handler_options']['image_node_options']['lightbox2_image_node'] = array(
  660. '#type' => 'select',
  661. '#title' => t('Automatic handler for image nodes'),
  662. '#options' => $automatic_options,
  663. '#description' => t('Choose how URLs for image nodes will be automatically handled.'),
  664. '#default_value' => variable_get('lightbox2_image_node', 0),
  665. );
  666. /*
  667. // Add drop-down for list of available image sizes.
  668. if (module_exists('image')) {
  669. $sizes = image_get_sizes();
  670. foreach ($sizes as $size_key => $size) {
  671. if ($size_key == 'original' or $size_key == '_original') {
  672. $size_key = 'original';
  673. }
  674. $size_options[$size_key] = $size['label'];
  675. }
  676. $form['handler_options']['image_node_options']['lightbox2_display_image_size'] = array(
  677. '#type' => 'select',
  678. '#title' => t('Lightbox image display size'),
  679. '#options' => $size_options,
  680. '#default_value' => variable_get('lightbox2_display_image_size', 'original'),
  681. '#description' => t('Select which image size will be loaded in the lightbox. This only applies to images uploaded with the Image module.'),
  682. );
  683. $form['handler_options']['image_node_options']['lightbox2_trigger_image_size'] = array(
  684. '#type' => 'select',
  685. '#multiple' => TRUE,
  686. '#title' => t('Image trigger size'),
  687. '#options' => $size_options,
  688. '#default_value' => variable_get('lightbox2_trigger_image_size', array('thumbnail')),
  689. '#description' => t('Select which image size, when clicked on, will automatically trigger the lightbox. This only applies to images uploaded with the Image module.'),
  690. );
  691. }
  692. */
  693. // Add checkbox for disabling lightbox for gallery lists.
  694. $form['handler_options']['image_node_options']['lightbox2_disable_nested_galleries'] = array(
  695. '#type' => 'checkbox',
  696. '#title' => t('Disable lightbox for gallery lists'),
  697. '#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.'),
  698. '#default_value' => variable_get('lightbox2_disable_nested_galleries', TRUE),
  699. );
  700. // Define flickr fieldset.
  701. /* ----------------------- */
  702. $form['handler_options']['flickr_options'] = array(
  703. '#type' => 'fieldset',
  704. '#title' => t('Flickr images'),
  705. '#collapsible' => TRUE,
  706. '#collapsed' => TRUE,
  707. );
  708. // Add checkbox for flickr image support.
  709. $form['handler_options']['flickr_options']['lightbox2_flickr'] = array(
  710. '#type' => 'select',
  711. '#title' => t('Automatic handler for Flickr images'),
  712. '#options' => $automatic_options,
  713. '#description' => t('Choose how URLs for Flickr images will be automatically handled.'),
  714. '#default_value' => variable_get('lightbox2_flickr', 0),
  715. );
  716. // Define gallery2 fieldset.
  717. /* ------------------------- */
  718. $form['handler_options']['gallery2_options'] = array(
  719. '#type' => 'fieldset',
  720. '#title' => t('Gallery2 images'),
  721. '#collapsible' => TRUE,
  722. '#collapsed' => TRUE,
  723. );
  724. // Add checkbox for gallery2 block image support.
  725. $form['handler_options']['gallery2_options']['lightbox2_gallery2_blocks'] = array(
  726. '#type' => 'select',
  727. '#title' => t('Automatic handler for Gallery2 block images'),
  728. '#options' => $automatic_options,
  729. '#description' => t('Choose how URLs for images, contained within Gallery2 image blocks, will be automatically handled.'),
  730. '#default_value' => variable_get('lightbox2_gallery2_blocks', 0),
  731. );
  732. // Define inline fieldset.
  733. /* ----------------------- */
  734. $form['handler_options']['inline_options'] = array(
  735. '#type' => 'fieldset',
  736. '#title' => t('Inline module images'),
  737. '#collapsible' => TRUE,
  738. '#collapsed' => TRUE,
  739. );
  740. // Add checkbox for inline image support.
  741. $form['handler_options']['inline_options']['lightbox2_inline'] = array(
  742. '#type' => 'select',
  743. '#title' => t('Automatic handler for Inline module images'),
  744. '#options' => $automatic_options,
  745. '#description' => t('Choose how URLs for Inline module images will be automatically handled.'),
  746. '#default_value' => variable_get('lightbox2_inline', 0),
  747. );
  748. // Define image assist fieldset.
  749. /* ----------------------------- */
  750. $form['handler_options']['img_assist_options'] = array(
  751. '#type' => 'fieldset',
  752. '#title' => t('Image Assist images'),
  753. '#collapsible' => TRUE,
  754. '#collapsed' => TRUE,
  755. );
  756. // Add checkbox for image assist custom size images.
  757. $form['handler_options']['img_assist_options']['lightbox2_image_assist_custom'] = array(
  758. '#type' => 'select',
  759. '#title' => t('Automatic handler for Image Assist custom size images'),
  760. '#options' => $automatic_options,
  761. '#description' => t('Choose how URLs for custom size images, displayed by the Image Assist module, will be automatically handled.'),
  762. '#default_value' => variable_get('lightbox2_image_assist_custom', 0),
  763. );
  764. // Define custom fieldset.
  765. /* ----------------------- */
  766. $form['handler_options']['custom_options'] = array(
  767. '#type' => 'fieldset',
  768. '#title' => t('Custom class images'),
  769. '#collapsible' => TRUE,
  770. '#collapsed' => TRUE,
  771. );
  772. // Add checkbox for custom class image support.
  773. $form['handler_options']['custom_options']['lightbox2_custom_class_handler'] = array(
  774. '#type' => 'select',
  775. '#title' => t('Automatic handler for custom class images'),
  776. '#options' => $automatic_options,
  777. '#description' => t('Choose how URLs for custom class images will be automatically handled.'),
  778. '#default_value' => variable_get('lightbox2_custom_class_handler', 0),
  779. );
  780. // Add text box for custom trigger classes.
  781. $form['handler_options']['custom_options']['lightbox2_custom_trigger_classes'] = array(
  782. '#type' => 'textarea',
  783. '#title' => t('Custom image trigger classes'),
  784. '#description' => t('List the image classes which should trigger the lightbox when clicked on. Put each class on a separate line.'),
  785. '#default_value' => variable_get('lightbox2_custom_trigger_classes', ''),
  786. );
  787. // Add checkbox for disabling lightbox for acidfree gallery lists.
  788. if (module_exists("acidfree")) {
  789. // Define acidfree settings fieldset.
  790. /* ---------------------------------- */
  791. $form['handler_options']['lightbox2_acidfree_options'] = array(
  792. '#type' => 'fieldset',
  793. '#title' => t('Acidfree settings'),
  794. '#collapsible' => TRUE,
  795. '#collapsed' => TRUE,
  796. );
  797. $form['handler_options']['lightbox2_acidfree_options']['lightbox2_disable_nested_acidfree_galleries'] = array(
  798. '#type' => 'checkbox',
  799. '#title' => t('Disable lightbox for Acidfree gallery lists'),
  800. '#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.'),
  801. '#default_value' => variable_get('lightbox2_disable_nested_acidfree_galleries', TRUE),
  802. );
  803. // Add checkbox for enabling lightbox for acidfree videos.
  804. if (module_exists("video")) {
  805. $form['handler_options']['lightbox2_acidfree_options']['lightbox2_enable_acidfree_videos'] = array(
  806. '#type' => 'checkbox',
  807. '#title' => t('Enable lightbox for Acidfree videos'),
  808. '#description' => t('Checking this box will enable the display of acidfree videos in a lightbox. This only applies to videos created by the "video" module and which appear in an acidfree gallery.'),
  809. '#default_value' => variable_get('lightbox2_enable_acidfree_videos', FALSE),
  810. );
  811. }
  812. }
  813. return system_settings_form($form);
  814. }
  815. /**
  816. * Validate a hex color value.
  817. *
  818. * @param $hex
  819. * The hex color string to validate.
  820. * @return
  821. * TRUE if $hex is a valid hex color value.
  822. */
  823. function _lightbox2_validate_hex_color($hex) {
  824. return preg_match('!^[a-f0-9]{3}([a-f0-9]{3})?$!i', $hex);
  825. }