colorbox.admin.inc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <?php
  2. /**
  3. * @file
  4. * Administrative page callbacks for the colorbox module.
  5. */
  6. /**
  7. * General configuration form for controlling the colorbox behaviour.
  8. */
  9. function colorbox_admin_settings() {
  10. drupal_add_js(drupal_get_path('module', 'colorbox') . '/js/colorbox_admin_settings.js', array('preprocess' => FALSE));
  11. $library = libraries_detect('colorbox');
  12. if (module_exists('insert')) {
  13. $form['colorbox_insert_module'] = array(
  14. '#type' => 'fieldset',
  15. '#title' => t('Insert module settings'),
  16. );
  17. $image_styles = image_style_options(FALSE);
  18. $form['colorbox_insert_module']['colorbox_image_style'] = array(
  19. '#type' => 'select',
  20. '#title' => t('Image style'),
  21. '#empty_option' => t('None (original image)'),
  22. '#options' => $image_styles,
  23. '#default_value' => variable_get('colorbox_image_style', ''),
  24. '#description' => t('Select which image style to use for viewing images in the colorbox.'),
  25. );
  26. $form['colorbox_insert_module']['colorbox_insert_gallery'] = array(
  27. '#type' => 'radios',
  28. '#title' => t('Insert image gallery'),
  29. '#default_value' => variable_get('colorbox_insert_gallery', 0),
  30. '#options' => array(0 => t('Per page gallery'), 3 => t('No gallery')),
  31. '#description' => t('Should the gallery be all images on the page (default) or disabled.'),
  32. );
  33. }
  34. $form['colorbox_extra_features'] = array(
  35. '#type' => 'fieldset',
  36. '#title' => t('Extra features'),
  37. );
  38. $form['colorbox_extra_features']['colorbox_load'] = array(
  39. '#type' => 'checkbox',
  40. '#title' => t('Enable Colorbox load'),
  41. '#default_value' => variable_get('colorbox_load', 0),
  42. '#description' => t('This enables custom links that can open forms and paths in a Colorbox. Add the class "colorbox-load" to the link and build the url like this for paths "[path]?width=500&height=500&iframe=true" or "[path]?width=500&height=500" if you don\'t want an iframe. Other modules may activate this for easy Colorbox integration.'),
  43. );
  44. $form['colorbox_extra_features']['colorbox_inline'] = array(
  45. '#type' => 'checkbox',
  46. '#title' => t('Enable Colorbox inline'),
  47. '#default_value' => variable_get('colorbox_inline', 0),
  48. '#description' => t('This enables custom links that can open inline content in a Colorbox. Add the class "colorbox-inline" to the link and build the url like this "?width=500&height=500&inline=true#id-of-content". Other modules may activate this for easy Colorbox integration.'),
  49. );
  50. $form['colorbox_custom_settings'] = array(
  51. '#type' => 'fieldset',
  52. '#title' => t('Styles and options'),
  53. );
  54. $colorbox_styles = array(
  55. 'default' => t('Default'),
  56. 'plain' => t('Plain (mainly for images)'),
  57. 'stockholmsyndrome' => t('Stockholm Syndrome'),
  58. $library['library path'] . '/example1' => t('Example 1'),
  59. $library['library path'] . '/example2' => t('Example 2'),
  60. $library['library path'] . '/example3' => t('Example 3'),
  61. $library['library path'] . '/example4' => t('Example 4'),
  62. $library['library path'] . '/example5' => t('Example 5'),
  63. 'none' => t('None'),
  64. );
  65. $form['colorbox_custom_settings']['colorbox_style'] = array(
  66. '#type' => 'select',
  67. '#title' => t('Style'),
  68. '#options' => $colorbox_styles,
  69. '#default_value' => variable_get('colorbox_style', 'default'),
  70. '#description' => t('Select the style to use for the Colorbox. The example styles are the ones that come with the Colorbox plugin. Select "None" if you have added Colorbox styles to your theme.'),
  71. );
  72. $form['colorbox_custom_settings']['colorbox_custom_settings_activate'] = array(
  73. '#type' => 'radios',
  74. '#title' => t('Options'),
  75. '#options' => array(0 => t('Default'), 1 => t('Custom')),
  76. '#default_value' => variable_get('colorbox_custom_settings_activate', 0),
  77. '#description' => t('Use the default or custom options for Colorbox.'),
  78. '#prefix' => '<div class="colorbox-custom-settings-activate">',
  79. '#suffix' => '</div>',
  80. );
  81. $js_hide = variable_get('colorbox_custom_settings_activate', 0) ? '' : ' js-hide';
  82. $form['colorbox_custom_settings']['wrapper_start'] = array(
  83. '#markup' => '<div class="colorbox-custom-settings' . $js_hide . '">',
  84. );
  85. $form['colorbox_custom_settings']['colorbox_transition_type'] = array(
  86. '#type' => 'radios',
  87. '#title' => t('Transition type'),
  88. '#options' => array('elastic' => t('Elastic'), 'fade' => t('Fade'), 'none' => t('None')),
  89. '#default_value' => variable_get('colorbox_transition_type', 'elastic'),
  90. '#description' => t('The transition type.'),
  91. );
  92. $form['colorbox_custom_settings']['colorbox_transition_speed'] = array(
  93. '#type' => 'select',
  94. '#title' => t('Transition speed'),
  95. '#options' => drupal_map_assoc(array(100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600)),
  96. '#default_value' => variable_get('colorbox_transition_speed', 350),
  97. '#description' => t('Sets the speed of the fade and elastic transitions, in milliseconds.'),
  98. );
  99. $form['colorbox_custom_settings']['colorbox_opacity'] = array(
  100. '#type' => 'select',
  101. '#title' => t('Opacity'),
  102. '#options' => drupal_map_assoc(array('0', '0.10', '0.15', '0.20', '0.25', '0.30', '0.35', '0.40', '0.45', '0.50', '0.55', '0.60', '0.65', '0.70', '0.75', '0.80', '0.85', '0.90', '0.95', '1')),
  103. '#default_value' => variable_get('colorbox_opacity', '0.85'),
  104. '#description' => t('The overlay opacity level. Range: 0 to 1.'),
  105. );
  106. $form['colorbox_custom_settings']['colorbox_text_current'] = array(
  107. '#type' => 'textfield',
  108. '#title' => t('Current'),
  109. '#default_value' => variable_get('colorbox_text_current', '{current} of {total}'),
  110. '#size' => 30,
  111. '#description' => t('Text format for the content group / gallery count. {current} and {total} are detected and replaced with actual numbers while Colorbox runs.'),
  112. );
  113. $form['colorbox_custom_settings']['colorbox_text_previous'] = array(
  114. '#type' => 'textfield',
  115. '#title' => t('Previous'),
  116. '#default_value' => variable_get('colorbox_text_previous', '« Prev'),
  117. '#size' => 30,
  118. '#description' => t('Text for the previous button in a shared relation group.'),
  119. );
  120. $form['colorbox_custom_settings']['colorbox_text_next'] = array(
  121. '#type' => 'textfield',
  122. '#title' => t('Next'),
  123. '#default_value' => variable_get('colorbox_text_next', 'Next »'),
  124. '#size' => 30,
  125. '#description' => t('Text for the next button in a shared relation group.'),
  126. );
  127. $form['colorbox_custom_settings']['colorbox_text_close'] = array(
  128. '#type' => 'textfield',
  129. '#title' => t('Close'),
  130. '#default_value' => variable_get('colorbox_text_close', 'Close'),
  131. '#size' => 30,
  132. '#description' => t('Text for the close button. The "Esc" key will also close Colorbox.'),
  133. );
  134. $form['colorbox_custom_settings']['colorbox_overlayclose'] = array(
  135. '#type' => 'checkbox',
  136. '#title' => t('Overlay close'),
  137. '#default_value' => variable_get('colorbox_overlayclose', 1),
  138. '#description' => t('Enable closing Colorbox by clicking on the background overlay.'),
  139. );
  140. $form['colorbox_custom_settings']['colorbox_maxwidth'] = array(
  141. '#type' => 'textfield',
  142. '#title' => t('Max width'),
  143. '#default_value' => variable_get('colorbox_maxwidth', '98%'),
  144. '#size' => 30,
  145. '#description' => t('Set a maximum width for loaded content. Example: "100%", 500, "500px".'),
  146. );
  147. $form['colorbox_custom_settings']['colorbox_maxheight'] = array(
  148. '#type' => 'textfield',
  149. '#title' => t('Max height'),
  150. '#default_value' => variable_get('colorbox_maxheight', '98%'),
  151. '#size' => 30,
  152. '#description' => t('Set a maximum height for loaded content. Example: "100%", 500, "500px".'),
  153. );
  154. $form['colorbox_custom_settings']['colorbox_initialwidth'] = array(
  155. '#type' => 'textfield',
  156. '#title' => t('Initial width'),
  157. '#default_value' => variable_get('colorbox_initialwidth', '300'),
  158. '#size' => 30,
  159. '#description' => t('Set the initial width, prior to any content being loaded. Example: "100%", 500, "500px".'),
  160. );
  161. $form['colorbox_custom_settings']['colorbox_initialheight'] = array(
  162. '#type' => 'textfield',
  163. '#title' => t('Initial height'),
  164. '#default_value' => variable_get('colorbox_initialheight', '250'),
  165. '#size' => 30,
  166. '#description' => t('Set the initial height, prior to any content being loaded. Example: "100%", 500, "500px".'),
  167. );
  168. $form['colorbox_custom_settings']['colorbox_fixed'] = array(
  169. '#type' => 'checkbox',
  170. '#title' => t('Fixed'),
  171. '#default_value' => variable_get('colorbox_fixed', 1),
  172. '#description' => t('If the Colorbox should be displayed in a fixed position within the visitor\'s viewport or relative to the document.'),
  173. );
  174. $form['colorbox_custom_settings']['colorbox_slideshow_settings'] = array(
  175. '#type' => 'fieldset',
  176. '#title' => t('Slideshow settings'),
  177. '#collapsible' => TRUE,
  178. '#collapsed' => TRUE,
  179. );
  180. $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshow'] = array(
  181. '#type' => 'radios',
  182. '#title' => t('Slideshow'),
  183. '#options' => array(0 => t('Off'), 1 => t('On')),
  184. '#default_value' => variable_get('colorbox_slideshow', 0),
  185. '#description' => t('An automatic slideshow to a content group / gallery.'),
  186. '#prefix' => '<div class="colorbox-slideshow-settings-activate">',
  187. '#suffix' => '</div>',
  188. );
  189. $form['colorbox_custom_settings']['colorbox_scrolling'] = array(
  190. '#type' => 'radios',
  191. '#title' => t('Scrollbars'),
  192. '#options' => array(1 => t('On'), 0 => t('Off')),
  193. '#default_value' => variable_get('colorbox_scrolling', 1),
  194. '#description' => t('If false, Colorbox will hide scrollbars for overflowing content. This could be used on conjunction with the resize method for a smoother transition if you are appending content to an already open instance of Colorbox.'),
  195. );
  196. $js_hide = variable_get('colorbox_slideshow', 0) ? '' : ' js-hide';
  197. $form['colorbox_custom_settings']['colorbox_slideshow_settings']['wrapper_start'] = array(
  198. '#markup' => '<div class="colorbox-slideshow-settings' . $js_hide . '">',
  199. );
  200. $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshowauto'] = array(
  201. '#type' => 'checkbox',
  202. '#title' => t('Slideshow autostart'),
  203. '#default_value' => variable_get('colorbox_slideshowauto', 1),
  204. '#description' => t('If the slideshow should automatically start to play.'),
  205. );
  206. $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshowspeed'] = array(
  207. '#type' => 'select',
  208. '#title' => t('Slideshow speed'),
  209. '#options' => drupal_map_assoc(array(1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000)),
  210. '#default_value' => variable_get('colorbox_slideshowspeed', 2500),
  211. '#description' => t('Sets the speed of the slideshow, in milliseconds.'),
  212. );
  213. $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_text_start'] = array(
  214. '#type' => 'textfield',
  215. '#title' => t('Start slideshow'),
  216. '#default_value' => variable_get('colorbox_text_start', 'start slideshow'),
  217. '#size' => 30,
  218. '#description' => t('Text for the slideshow start button.'),
  219. );
  220. $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_text_stop'] = array(
  221. '#type' => 'textfield',
  222. '#title' => t('Stop slideshow'),
  223. '#default_value' => variable_get('colorbox_text_stop', 'stop slideshow'),
  224. '#size' => 30,
  225. '#description' => t('Text for the slideshow stop button.'),
  226. );
  227. $form['colorbox_custom_settings']['colorbox_slideshow_settings']['wrapper_stop'] = array(
  228. '#markup' => '</div>',
  229. );
  230. $form['colorbox_custom_settings']['wrapper_stop'] = array(
  231. '#markup' => '</div>',
  232. );
  233. $form['colorbox_advanced_settings'] = array(
  234. '#type' => 'fieldset',
  235. '#title' => t('Advanced settings'),
  236. '#collapsible' => TRUE,
  237. '#collapsed' => TRUE,
  238. );
  239. $form['colorbox_advanced_settings']['colorbox_unique_token'] = array(
  240. '#type' => 'radios',
  241. '#title' => t('Unique per-request gallery token'),
  242. '#options' => array(1 => t('On'), 0 => t('Off')),
  243. '#default_value' => variable_get('colorbox_unique_token', 1),
  244. '#description' => t('If On (default), Colorbox will add a unique per-request token to the gallery id to avoid images being added manually to galleries. The token was added as a security fix but some see the old behavoiur as an feature and this settings makes it possible to remove the token.'),
  245. );
  246. $form['colorbox_advanced_settings']['colorbox_mobile_detect'] = array(
  247. '#type' => 'radios',
  248. '#title' => t('Mobile detection'),
  249. '#options' => array(1 => t('On'), 0 => t('Off')),
  250. '#default_value' => variable_get('colorbox_mobile_detect', 1),
  251. '#description' => t('If On (default), Colorbox will not be active for devices with the max width set below.'),
  252. );
  253. $form['colorbox_advanced_settings']['colorbox_mobile_device_width'] = array(
  254. '#type' => 'textfield',
  255. '#title' => t('Device with'),
  256. '#default_value' => variable_get('colorbox_mobile_device_width', '480px'),
  257. '#size' => 30,
  258. '#description' => t('Set the mobile device max with. Default: 480px.'),
  259. '#states' => array(
  260. 'visible' => array(
  261. ':input[name="colorbox_mobile_detect"]' => array('value' => '1'),
  262. ),
  263. ),
  264. );
  265. $form['colorbox_advanced_settings']['colorbox_caption_trim'] = array(
  266. '#type' => 'radios',
  267. '#title' => t('Caption shortening'),
  268. '#options' => array(0 => t('Default'), 1 => t('Yes')),
  269. '#default_value' => variable_get('colorbox_caption_trim', 0),
  270. '#description' => t('If the caption should be made shorter in the Colorbox to avoid layout problems. The default is to shorten for the example styles, they need it, but not for other styles.'),
  271. );
  272. $form['colorbox_advanced_settings']['colorbox_caption_trim_length'] = array(
  273. '#type' => 'select',
  274. '#title' => t('Caption max length'),
  275. '#options' => drupal_map_assoc(array(40, 45, 50, 55, 60, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120)),
  276. '#default_value' => variable_get('colorbox_caption_trim_length', 75),
  277. '#states' => array(
  278. 'visible' => array(
  279. ':input[name="colorbox_caption_trim"]' => array('value' => '1'),
  280. ),
  281. ),
  282. );
  283. $form['colorbox_advanced_settings']['colorbox_visibility'] = array(
  284. '#type' => 'radios',
  285. '#title' => t('Show Colorbox on specific pages'),
  286. '#options' => array(0 => t('All pages except those listed'), 1 => t('Only the listed pages')),
  287. '#default_value' => variable_get('colorbox_visibility', 0),
  288. );
  289. $form['colorbox_advanced_settings']['colorbox_pages'] = array(
  290. '#type' => 'textarea',
  291. '#title' => '<span class="element-invisible">' . t('Pages') . '</span>',
  292. '#default_value' => variable_get('colorbox_pages', "admin*\nimagebrowser*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*\nsystem/ajax\nsystem/ajax/*"),
  293. '#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
  294. );
  295. $form['colorbox_advanced_settings']['colorbox_compression_type'] = array(
  296. '#type' => 'radios',
  297. '#title' => t('Choose Colorbox compression level'),
  298. '#options' => array(
  299. 'minified' => t('Production (Minified)'),
  300. 'source' => t('Development (Uncompressed Code)'),
  301. ),
  302. '#default_value' => variable_get('colorbox_compression_type', 'minified'),
  303. );
  304. return system_settings_form($form);
  305. }