Projet

Général

Profil

Paste
Télécharger (17,2 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / colorbox / colorbox.admin.inc @ b433176d

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Administrative page callbacks for the colorbox module.
6
 */
7
8
/**
9
 * General configuration form for controlling the colorbox behaviour.
10
 */
11
function colorbox_admin_settings() {
12
  drupal_add_js(drupal_get_path('module', 'colorbox') . '/js/colorbox_admin_settings.js', array('preprocess' => FALSE));
13
14
  $library = libraries_detect('colorbox');
15
16
  if (module_exists('insert')) {
17
    $form['colorbox_insert_module'] = array(
18
      '#type' => 'fieldset',
19
      '#title' => t('Insert module settings'),
20
    );
21
    $image_styles = image_style_options(FALSE);
22
    $form['colorbox_insert_module']['colorbox_image_style'] = array(
23
      '#type' => 'select',
24
      '#title' => t('Image style'),
25
      '#empty_option' => t('None (original image)'),
26
      '#options' => $image_styles,
27
      '#default_value' => variable_get('colorbox_image_style', ''),
28
      '#description' => t('Select which image style to use for viewing images in the colorbox.'),
29
    );
30
    $form['colorbox_insert_module']['colorbox_insert_gallery'] = array(
31
      '#type' => 'radios',
32
      '#title' => t('Insert image gallery'),
33
      '#default_value' => variable_get('colorbox_insert_gallery', 0),
34
      '#options' => array(0 => t('Per page gallery'), 3 => t('No gallery')),
35
      '#description' => t('Should the gallery be all images on the page (default) or disabled.'),
36
    );
37
  }
38
39
  $form['colorbox_extra_features'] = array(
40
    '#type' => 'fieldset',
41
    '#title' => t('Extra features'),
42
  );
43
  $form['colorbox_extra_features']['colorbox_load'] = array(
44
    '#type' => 'checkbox',
45
    '#title' => t('Enable Colorbox load'),
46
    '#default_value' => variable_get('colorbox_load', 0),
47
    '#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.'),
48
  );
49
  $form['colorbox_extra_features']['colorbox_inline'] = array(
50
    '#type' => 'checkbox',
51
    '#title' => t('Enable Colorbox inline'),
52
    '#default_value' => variable_get('colorbox_inline', 0),
53 b433176d Assos Assos
    '#description' => t('<a href="https://www.drupal.org/files/druplicon-small.png" class="colorbox">This</a> 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.'),
54 85ad3d82 Assos Assos
  );
55
56
  $form['colorbox_custom_settings'] = array(
57
    '#type' => 'fieldset',
58
    '#title' => t('Styles and options'),
59
  );
60
  $colorbox_styles = array(
61
    'default' => t('Default'),
62
    'plain' => t('Plain (mainly for images)'),
63
    'stockholmsyndrome' => t('Stockholm Syndrome'),
64
    $library['library path'] . '/example1' => t('Example 1'),
65
    $library['library path'] . '/example2' => t('Example 2'),
66
    $library['library path'] . '/example3' => t('Example 3'),
67
    $library['library path'] . '/example4' => t('Example 4'),
68
    $library['library path'] . '/example5' => t('Example 5'),
69
    'none' => t('None'),
70
  );
71
  $form['colorbox_custom_settings']['colorbox_style'] = array(
72
    '#type' => 'select',
73
    '#title' => t('Style'),
74
    '#options' => $colorbox_styles,
75
    '#default_value' => variable_get('colorbox_style', 'default'),
76 b433176d Assos Assos
    '#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. <br> <strong>Examples</strong>: <ul><li><a href="/sites/all/modules/colorbox/images/admin/example_default.png" target="blank">Default</a></li><li><a href="/sites/all/modules/colorbox/images/admin/example_plain.png" target="blank">Plain</a></li><li><a href="/sites/all/modules/colorbox/images/admin/example_stockholm_syndrome.png" target="blank">Stockholm Syndrome</a></li><li><a href="/sites/all/modules/colorbox/images/admin/colorbox_example_1.png" target="blank">Example 1</a></li><li><a href="/sites/all/modules/colorbox/images/admin/colorbox_example_2.png" target="blank">Example 2</a></li><li><a href="/sites/all/modules/colorbox/images/admin/colorbox_example_3.png" target="blank">Example 3</a></li><li><a href="/sites/all/modules/colorbox/images/admin/colorbox_example_4.png" target="blank">Example 4</a></li><li><a href="/sites/all/modules/colorbox/images/admin/colorbox_example_5.png" target="blank">Example 5</a></li><li><a href="/sites/all/modules/colorbox/images/admin/example_none.png" target="blank">None</a></li></ul>'),
77 85ad3d82 Assos Assos
  );
78
  $form['colorbox_custom_settings']['colorbox_custom_settings_activate'] = array(
79
    '#type' => 'radios',
80
    '#title' => t('Options'),
81
    '#options' => array(0 => t('Default'), 1 => t('Custom')),
82
    '#default_value' => variable_get('colorbox_custom_settings_activate', 0),
83
    '#description' => t('Use the default or custom options for Colorbox.'),
84
    '#prefix' => '<div class="colorbox-custom-settings-activate">',
85
    '#suffix' => '</div>',
86
  );
87
88
  $js_hide = variable_get('colorbox_custom_settings_activate', 0) ? '' : ' js-hide';
89
  $form['colorbox_custom_settings']['wrapper_start'] = array(
90
    '#markup' => '<div class="colorbox-custom-settings' . $js_hide . '">',
91
  );
92
93
  $form['colorbox_custom_settings']['colorbox_transition_type'] = array(
94
    '#type' => 'radios',
95
    '#title' => t('Transition type'),
96 b433176d Assos Assos
    '#options' => array(
97
      'elastic' => t('Elastic'),
98
      'fade' => t('Fade'),
99
      'none' => t('None'),
100
    ),
101 85ad3d82 Assos Assos
    '#default_value' => variable_get('colorbox_transition_type', 'elastic'),
102
    '#description' => t('The transition type.'),
103
  );
104
  $form['colorbox_custom_settings']['colorbox_transition_speed'] = array(
105
    '#type' => 'select',
106
    '#title' => t('Transition speed'),
107 b433176d Assos Assos
    '#options' => drupal_map_assoc(array(
108
      100,
109
      150,
110
      200,
111
      250,
112
      300,
113
      350,
114
      400,
115
      450,
116
      500,
117
      550,
118
      600,
119
    )),
120 85ad3d82 Assos Assos
    '#default_value' => variable_get('colorbox_transition_speed', 350),
121
    '#description' => t('Sets the speed of the fade and elastic transitions, in milliseconds.'),
122
  );
123
  $form['colorbox_custom_settings']['colorbox_opacity'] = array(
124
    '#type' => 'select',
125
    '#title' => t('Opacity'),
126 b433176d Assos Assos
    '#options' => drupal_map_assoc(array(
127
      '0',
128
      '0.10',
129
      '0.15',
130
      '0.20',
131
      '0.25',
132
      '0.30',
133
      '0.35',
134
      '0.40',
135
      '0.45',
136
      '0.50',
137
      '0.55',
138
      '0.60',
139
      '0.65',
140
      '0.70',
141
      '0.75',
142
      '0.80',
143
      '0.85',
144
      '0.90',
145
      '0.95',
146
      '1',
147
    )),
148 85ad3d82 Assos Assos
    '#default_value' => variable_get('colorbox_opacity', '0.85'),
149
    '#description' => t('The overlay opacity level. Range: 0 to 1.'),
150
  );
151
  $form['colorbox_custom_settings']['colorbox_text_current'] = array(
152
    '#type' => 'textfield',
153
    '#title' => t('Current'),
154
    '#default_value' => variable_get('colorbox_text_current', '{current} of {total}'),
155
    '#size' => 30,
156
    '#description' => t('Text format for the content group / gallery count. {current} and {total} are detected and replaced with actual numbers while Colorbox runs.'),
157
  );
158
  $form['colorbox_custom_settings']['colorbox_text_previous'] = array(
159
    '#type' => 'textfield',
160
    '#title' => t('Previous'),
161
    '#default_value' => variable_get('colorbox_text_previous', '« Prev'),
162
    '#size' => 30,
163
    '#description' => t('Text for the previous button in a shared relation group.'),
164
  );
165
  $form['colorbox_custom_settings']['colorbox_text_next'] = array(
166
    '#type' => 'textfield',
167
    '#title' => t('Next'),
168
    '#default_value' => variable_get('colorbox_text_next', 'Next »'),
169
    '#size' => 30,
170
    '#description' => t('Text for the next button in a shared relation group.'),
171
  );
172
  $form['colorbox_custom_settings']['colorbox_text_close'] = array(
173
    '#type' => 'textfield',
174
    '#title' => t('Close'),
175
    '#default_value' => variable_get('colorbox_text_close', 'Close'),
176
    '#size' => 30,
177
    '#description' => t('Text for the close button. The "Esc" key will also close Colorbox.'),
178
  );
179
  $form['colorbox_custom_settings']['colorbox_overlayclose'] = array(
180
    '#type' => 'checkbox',
181
    '#title' => t('Overlay close'),
182
    '#default_value' => variable_get('colorbox_overlayclose', 1),
183
    '#description' => t('Enable closing Colorbox by clicking on the background overlay.'),
184
  );
185 b08fce64 Assos Assos
  $form['colorbox_custom_settings']['colorbox_returnfocus'] = array(
186
    '#type' => 'checkbox',
187
    '#title' => t('Return focus'),
188
    '#default_value' => variable_get('colorbox_returnfocus', 1),
189
    '#description' => t('Return focus when Colorbox exits to the element it was launched from.'),
190
  );
191 85ad3d82 Assos Assos
  $form['colorbox_custom_settings']['colorbox_maxwidth'] = array(
192
    '#type' => 'textfield',
193
    '#title' => t('Max width'),
194
    '#default_value' => variable_get('colorbox_maxwidth', '98%'),
195
    '#size' => 30,
196
    '#description' => t('Set a maximum width for loaded content. Example: "100%", 500, "500px".'),
197
  );
198
  $form['colorbox_custom_settings']['colorbox_maxheight'] = array(
199
    '#type' => 'textfield',
200
    '#title' => t('Max height'),
201
    '#default_value' => variable_get('colorbox_maxheight', '98%'),
202
    '#size' => 30,
203
    '#description' => t('Set a maximum height for loaded content. Example: "100%", 500, "500px".'),
204
  );
205
  $form['colorbox_custom_settings']['colorbox_initialwidth'] = array(
206
    '#type' => 'textfield',
207
    '#title' => t('Initial width'),
208
    '#default_value' => variable_get('colorbox_initialwidth', '300'),
209
    '#size' => 30,
210
    '#description' => t('Set the initial width, prior to any content being loaded. Example: "100%", 500, "500px".'),
211
  );
212
  $form['colorbox_custom_settings']['colorbox_initialheight'] = array(
213
    '#type' => 'textfield',
214
    '#title' => t('Initial height'),
215
    '#default_value' => variable_get('colorbox_initialheight', '250'),
216
    '#size' => 30,
217
    '#description' => t('Set the initial height, prior to any content being loaded. Example: "100%", 500, "500px".'),
218
  );
219
  $form['colorbox_custom_settings']['colorbox_fixed'] = array(
220
    '#type' => 'checkbox',
221
    '#title' => t('Fixed'),
222
    '#default_value' => variable_get('colorbox_fixed', 1),
223 b433176d Assos Assos
    '#description' => t("If the Colorbox should be displayed in a fixed position within the visitor's viewport or relative to the document."),
224 85ad3d82 Assos Assos
  );
225
226
  $form['colorbox_custom_settings']['colorbox_slideshow_settings'] = array(
227
    '#type' => 'fieldset',
228
    '#title' => t('Slideshow settings'),
229
    '#collapsible' => TRUE,
230
    '#collapsed' => TRUE,
231
  );
232
  $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshow'] = array(
233
    '#type' => 'radios',
234
    '#title' => t('Slideshow'),
235
    '#options' => array(0 => t('Off'), 1 => t('On')),
236
    '#default_value' => variable_get('colorbox_slideshow', 0),
237
    '#description' => t('An automatic slideshow to a content group / gallery.'),
238
    '#prefix' => '<div class="colorbox-slideshow-settings-activate">',
239
    '#suffix' => '</div>',
240
  );
241
  $form['colorbox_custom_settings']['colorbox_scrolling'] = array(
242
    '#type' => 'radios',
243
    '#title' => t('Scrollbars'),
244
    '#options' => array(1 => t('On'), 0 => t('Off')),
245
    '#default_value' => variable_get('colorbox_scrolling', 1),
246
    '#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.'),
247
  );
248
249
  $js_hide = variable_get('colorbox_slideshow', 0) ? '' : ' js-hide';
250
  $form['colorbox_custom_settings']['colorbox_slideshow_settings']['wrapper_start'] = array(
251
    '#markup' => '<div class="colorbox-slideshow-settings' . $js_hide . '">',
252
  );
253
254
  $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshowauto'] = array(
255
    '#type' => 'checkbox',
256
    '#title' => t('Slideshow autostart'),
257
    '#default_value' => variable_get('colorbox_slideshowauto', 1),
258
    '#description' => t('If the slideshow should automatically start to play.'),
259
  );
260
  $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_slideshowspeed'] = array(
261
    '#type' => 'select',
262
    '#title' => t('Slideshow speed'),
263 b433176d Assos Assos
    '#options' => drupal_map_assoc(array(
264
      1000,
265
      1500,
266
      2000,
267
      2500,
268
      3000,
269
      3500,
270
      4000,
271
      4500,
272
      5000,
273
      5500,
274
      6000,
275
    )),
276 85ad3d82 Assos Assos
    '#default_value' => variable_get('colorbox_slideshowspeed', 2500),
277
    '#description' => t('Sets the speed of the slideshow, in milliseconds.'),
278
  );
279
  $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_text_start'] = array(
280
    '#type' => 'textfield',
281
    '#title' => t('Start slideshow'),
282
    '#default_value' => variable_get('colorbox_text_start', 'start slideshow'),
283
    '#size' => 30,
284
    '#description' => t('Text for the slideshow start button.'),
285
  );
286
  $form['colorbox_custom_settings']['colorbox_slideshow_settings']['colorbox_text_stop'] = array(
287
    '#type' => 'textfield',
288
    '#title' => t('Stop slideshow'),
289
    '#default_value' => variable_get('colorbox_text_stop', 'stop slideshow'),
290
    '#size' => 30,
291
    '#description' => t('Text for the slideshow stop button.'),
292
  );
293
294
  $form['colorbox_custom_settings']['colorbox_slideshow_settings']['wrapper_stop'] = array(
295
    '#markup' => '</div>',
296
  );
297
298
  $form['colorbox_custom_settings']['wrapper_stop'] = array(
299
    '#markup' => '</div>',
300
  );
301
302
  $form['colorbox_advanced_settings'] = array(
303
    '#type' => 'fieldset',
304
    '#title' => t('Advanced settings'),
305
    '#collapsible' => TRUE,
306
    '#collapsed' => TRUE,
307
  );
308 39a3d70c Assos Assos
  $form['colorbox_advanced_settings']['colorbox_unique_token'] = array(
309
    '#type' => 'radios',
310
    '#title' => t('Unique per-request gallery token'),
311
    '#options' => array(1 => t('On'), 0 => t('Off')),
312
    '#default_value' => variable_get('colorbox_unique_token', 1),
313
    '#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.'),
314
  );
315 85ad3d82 Assos Assos
  $form['colorbox_advanced_settings']['colorbox_mobile_detect'] = array(
316
    '#type' => 'radios',
317
    '#title' => t('Mobile detection'),
318
    '#options' => array(1 => t('On'), 0 => t('Off')),
319
    '#default_value' => variable_get('colorbox_mobile_detect', 1),
320 39a3d70c Assos Assos
    '#description' => t('If On (default), Colorbox will not be active for devices with the max width set below.'),
321 85ad3d82 Assos Assos
  );
322
  $form['colorbox_advanced_settings']['colorbox_mobile_device_width'] = array(
323
    '#type' => 'textfield',
324 b08fce64 Assos Assos
    '#title' => t('Device width'),
325 85ad3d82 Assos Assos
    '#default_value' => variable_get('colorbox_mobile_device_width', '480px'),
326
    '#size' => 30,
327 b08fce64 Assos Assos
    '#description' => t('Set the mobile device max width. Default: 480px.'),
328 85ad3d82 Assos Assos
    '#states' => array(
329
      'visible' => array(
330
        ':input[name="colorbox_mobile_detect"]' => array('value' => '1'),
331
      ),
332
    ),
333
  );
334
  $form['colorbox_advanced_settings']['colorbox_caption_trim'] = array(
335
    '#type' => 'radios',
336
    '#title' => t('Caption shortening'),
337
    '#options' => array(0 => t('Default'), 1 => t('Yes')),
338
    '#default_value' => variable_get('colorbox_caption_trim', 0),
339
    '#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.'),
340
  );
341
  $form['colorbox_advanced_settings']['colorbox_caption_trim_length'] = array(
342
    '#type' => 'select',
343
    '#title' => t('Caption max length'),
344 b433176d Assos Assos
    '#options' => drupal_map_assoc(array(
345
      40,
346
      45,
347
      50,
348
      55,
349
      60,
350
      70,
351
      75,
352
      80,
353
      85,
354
      90,
355
      95,
356
      100,
357
      105,
358
      110,
359
      115,
360
      120,
361
    )),
362 85ad3d82 Assos Assos
    '#default_value' => variable_get('colorbox_caption_trim_length', 75),
363
    '#states' => array(
364
      'visible' => array(
365
        ':input[name="colorbox_caption_trim"]' => array('value' => '1'),
366
      ),
367
    ),
368
  );
369
  $form['colorbox_advanced_settings']['colorbox_visibility'] = array(
370
    '#type' => 'radios',
371
    '#title' => t('Show Colorbox on specific pages'),
372
    '#options' => array(0 => t('All pages except those listed'), 1 => t('Only the listed pages')),
373
    '#default_value' => variable_get('colorbox_visibility', 0),
374
  );
375
  $form['colorbox_advanced_settings']['colorbox_pages'] = array(
376
    '#type' => 'textarea',
377
    '#title' => '<span class="element-invisible">' . t('Pages') . '</span>',
378
    '#default_value' => variable_get('colorbox_pages', "admin*\nimagebrowser*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*\nsystem/ajax\nsystem/ajax/*"),
379 b433176d Assos Assos
    '#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. <p><a href=\"#\" class=\"colorbox-reset-specific-pages-default\">Reset to default</a></p>", array(
380
      '%blog' => 'blog',
381
      '%blog-wildcard' => 'blog/*',
382
      '%front' => '<front>',
383
    )),
384 85ad3d82 Assos Assos
  );
385
  $form['colorbox_advanced_settings']['colorbox_compression_type'] = array(
386
    '#type' => 'radios',
387
    '#title' => t('Choose Colorbox compression level'),
388
    '#options' => array(
389
      'minified' => t('Production (Minified)'),
390
      'source' => t('Development (Uncompressed Code)'),
391
    ),
392
    '#default_value' => variable_get('colorbox_compression_type', 'minified'),
393
  );
394
395
  return system_settings_form($form);
396
}