Updating instructions.
[project/gallery.git] / gallery_settings.inc
1 <?php
2 // $Id$
3
4 /**
5 * gallery.module : gallery_settings.inc
6 * Settings functions
7 */
8
9 /**
10 * Implementation of hook_settings
11 */
12 function _gallery_settings() {
13 $output = '';
14 $extra = l(t('More information about directory settings (including examples).'),
15 'admin/help/gallery');
16 $form['directory'] = array(
17 '#type' => 'fieldset',
18 '#title' => t('Directory settings'),
19 '#description' => $extra,
20 '#collapsible' => TRUE,
21 '#collapsed' => variable_get('gallery_valid', 0),
22 );
23
24 $form['directory']['gallery_uri'] = array(
25 '#type' => 'textfield',
26 '#title' => t('URI of Gallery2'),
27 '#default_value' => variable_get('gallery_uri', '/gallery2/'),
28 '#size' => 64,
29 '#maxlength' => 128,
30 '#description' => t('URI of the G2 standalone location. Path from docroot to the
31 Gallery2 directory where main.php is located. Protocol/hostname are
32 both optional.'),
33 );
34
35 $form['directory']['gallery_autodetect_dir'] = array(
36 '#type' => 'checkbox',
37 '#title' => t('Autodetect Settings'),
38 '#return_value' => 1,
39 '#default_value' => variable_get('gallery_autodetect_dir', 1),
40 '#description' => t('Autodetect the Gallery2 and Drupal settings (recommended). When
41 selected the values below are updated with the autodetect settings
42 when the submit button is clicked.'),
43 );
44
45 if (variable_get('gallery_autodetect_dir', 1)) {
46 $extra = t(' (Autodetected value)');
47 } else {
48 $extra = t(' (Manually entered value)');
49 }
50 $form['directory']['gallery_dir'] = array(
51 '#type' => 'textfield',
52 '#title' => t('Location of Gallery2') . $extra,
53 '#default_value' => variable_get('gallery_dir', './gallery2/'),
54 '#size' => 64,
55 '#maxlength' => 128,
56 '#description' => t('Location of your gallery2 directory (absolute path or relative to the root
57 directory of your drupal installation).'),
58 );
59
60 $form['directory']['gallery_embed_uri'] = array(
61 '#type' => 'textfield',
62 '#title' => t('Embed URI') . $extra,
63 '#default_value' => variable_get('gallery_embed_uri', '?q=gallery'),
64 '#size' => 64,
65 '#maxlength' => 128,
66 '#description' => t('URI to access G2 via drupal. Don\'t worry if you are using clean urls in drupal and this still ends in \'index.php?q=gallery\'. This is needed to get the Gallery2 URL rewrite module to work correctly and will not be visible.'),
67 );
68
69 /**
70 * Remove this for now. It is not necessary when URL rewrite is working. Without URL rewrite there
71 * can still be issues, but these will be addressed in the documentation for now.
72 */
73 /*
74 $form['directory']['gallery_cookie_path'] = array(
75 '#type' => 'textfield',
76 '#title' => t('Cookie Path') . $extra,
77 '#default_value' => variable_get('gallery_cookie_path', ''),
78 '#size' => 64,
79 '#maxlength' => 128,
80 '#description' => t('Cookie path for embedded Gallery2 sessions.'),
81 ); */
82
83 // Fullname settings
84 if (module_exist('profile')) {
85 $form['fullname'] = array(
86 '#type' => 'fieldset',
87 '#title' => t('Full Name settings'),
88 '#description' => '',
89 '#collapsible' => TRUE,
90 '#collapsed' => TRUE,
91 );
92
93 $form['fullname']['gallery_use_full_name'] = array(
94 '#type' => 'checkbox',
95 '#title' => t('Enable Full Name support'),
96 '#return_value' => 1,
97 '#default_value' => variable_get('gallery_use_full_name', 0),
98 '#description' => t('Use full name from profile module in Gallery2 user data. Note that
99 enabling/disabling this only updates Gallery2 user data when the
100 Drupal user is updated (ie no sync is done immediately).'),
101 );
102
103 $form['fullname']['gallery_profile_full_name_field'] = array(
104 '#type' => 'textfield',
105 '#title' => t('Full name profile field'),
106 '#default_value' => variable_get('gallery_profile_full_name_field', 'profile_full_name'),
107 '#size' => 64,
108 '#maxlength' => 64,
109 '#description' => t('Name of "Full Name" field in profile module.'),
110 );
111 } else {
112 $form['fullname'] = array(
113 '#type' => 'fieldset',
114 '#title' => t('Full Name settings'),
115 '#description' => t('Full names in G2 can be supported using the profile module
116 with a "Full Name" field. However the profile module is not
117 installed, so this functionality is not available. If you install
118 it you will have more options here.'),
119 '#collapsible' => TRUE,
120 '#collapsed' => FALSE,
121 );
122 }
123
124 // Image Block settings
125 $typeMap = array(
126 'randomImage' => t('Random image'),
127 'recentImage' => t('Recent image'),
128 'viewedImage' => t('Viewed image'),
129 'randomAlbum' => t('Random album'),
130 'recentAlbum' => t('Recent album'),
131 'viewedAlbum' => t('Viewed album'),
132 'dailyImage' => t('Daily image'),
133 'weeklyImage' => t('Weekly image'),
134 'monthlyImage' => t('Monthly image'),
135 'dailyAlbum' => t('Daily album'),
136 'weeklyAlbum' => t('Weekly album'),
137 'monthlyAlbum' => t('Monthly album'),
138 );
139
140 $paramMap = array(
141 'title' => t('Title'),
142 'date' => t('Date'),
143 'views' => t('View Count'),
144 'owner' => t('Item owner'),
145 'heading' => t('Heading'),
146 'fullSize' => t('Full Size'),
147 );
148
149 $form['block'] = _gallery_block_settings($typeMap , $paramMap);
150 $form['grid'] = _gallery_grid_block_settings($typeMap , $paramMap);
151 $form['filter'] = _gallery_filter_settings($typeMap , $paramMap);
152 $form['g2image'] = _gallery_g2image_settings();
153 $form['search'] = _gallery_search_settings($typeMap , $paramMap);
154 $form['links'] = _gallery_links_settings();
155
156 // Debug Settings
157 $form['error'] = array(
158 '#type' => 'fieldset',
159 '#title' => t('Error Logging settings'),
160 '#description' => '',
161 '#collapsible' => TRUE,
162 '#collapsed' => TRUE,
163 );
164
165 $form['error']['gallery_error_mode'] = array(
166 '#type' => 'checkboxes',
167 '#title' => t('Error logging'),
168 '#default_value' => variable_get('gallery_error_mode', array(1)),
169 '#options' => array(1 => t('Watchdog'),
170 2 => t('Output to the browser')),
171 '#description' => t('Choose where errors are displayed.'),
172 );
173
174 $form['gallery_valid'] = array(
175 '#type' => 'value',
176 '#value' => variable_get('gallery_valid', 0),
177 );
178
179 return $form;
180 }
181
182 /**
183 * Settings for gallery image block
184 *
185 */
186 function _gallery_block_settings($typeMap , $paramMap) {
187 $form['block'] = array(
188 '#type' => 'fieldset',
189 '#title' => t('Gallery Image Block settings'),
190 '#description' => '',
191 '#collapsible' => TRUE,
192 '#collapsed' => TRUE,
193 );
194
195 $numimages = variable_get('gallery_block_num_images', 3);
196 $form['block']['gallery_block_num_images'] = array(
197 '#type' => 'textfield',
198 '#title' => t('Number of images in block'),
199 '#default_value' => $numimages,
200 '#size' => 20,
201 '#maxlength' => 20,
202 '#description' => t('Choose the number of images to appear. You will need to submit the form if you have increased the number in order to choose the image types.'),
203 );
204
205 $gallery_block_block = variable_get('gallery_block_block', array('randomImage'));
206 $form['block']['gallery_block_block'] = array(
207 '#tree' => 1,
208 );
209 $typeMap2 = array_merge(array('none' => t('None')), $typeMap);
210 for ($i=0; $i<$numimages; $i++) {
211 $form['block']['gallery_block_block'][$i] = array(
212 '#type' => 'select',
213 '#title' => '',
214 '#default_value' => $gallery_block_block[$i],
215 '#options' => $typeMap2,
216 '#description' => '',
217 );
218 }
219 $form['block']['gallery_block_block'][0]['#title'] = t('Image types');
220 $form['block']['gallery_block_block'][$i-1]['#description'] =
221 t('Pick the type of images you\'d like to see. You can select the same type more than once.');
222
223 $form['block']['gallery_item_id'] = array(
224 '#type' => 'textfield',
225 '#title' => t('Album or Item ID'),
226 '#default_value' => variable_get('gallery_item_id', ''),
227 '#size' => 20,
228 '#maxlength' => 20,
229 '#description' => t('Enter the Gallery image or album ID (or blank). If an album or item ID is specified, random images will only be selected from that album and its sub-albums.'),
230 );
231
232 $form['block']['gallery_block_show'] = array(
233 '#type' => 'checkboxes',
234 '#title' => t('Image data'),
235 '#default_value' => variable_get('gallery_block_show', array('title', 'heading')),
236 '#options' => $paramMap,
237 '#description' => t('Choose the item metadata you\'d like to display.'),
238 );
239
240 $form['block']['gallery_maxsize'] = array(
241 '#type' => 'textfield',
242 '#title' => t('Thumbnail size'),
243 '#default_value' => variable_get('gallery_maxsize', 150),
244 '#size' => 10,
245 '#maxlength' => 10,
246 '#description' => t('If you want your size to be bigger than the thumbnail size for that image as defined in your Gallery2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
247 );
248
249 $form['block']['gallery_album_frame'] = array(
250 '#type' => 'textfield',
251 '#title' => t('Album frame'),
252 '#default_value' => variable_get('gallery_album_frame', 'none'),
253 '#size' => 20,
254 '#maxlength' => 20,
255 '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your Gallery2 install for a complete list. Use "none" or blank for no frame.'),
256 );
257
258 $form['block']['gallery_item_frame'] = array(
259 '#type' => 'textfield',
260 '#title' => t('Item frame'),
261 '#default_value' => variable_get('gallery_item_frame', 'none'),
262 '#size' => 20,
263 '#maxlength' => 20,
264 '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your Gallery2 install for a complete list. Use "none" or blank for no frame.'),
265 );
266
267 $form['block']['gallery_link_target'] = array(
268 '#type' => 'textfield',
269 '#title' => t('Link target'),
270 '#default_value' => variable_get('gallery_link_target', ''),
271 '#size' => 20,
272 '#maxlength' => 20,
273 '#description' => t('Enter a link target (eg "_blank", "_new").'),
274 );
275 return $form['block'];
276 }
277
278 /**
279 * Settings for gallery grid block
280 *
281 */
282 function _gallery_grid_block_settings($typeMap , $paramMap) {
283 $form['grid'] = array(
284 '#type' => 'fieldset',
285 '#title' => t('Gallery Grid Image Block settings'),
286 '#description' => '',
287 '#collapsible' => TRUE,
288 '#collapsed' => TRUE,
289 );
290
291 $form['grid']['gallery_grid_num_cols'] = array(
292 '#type' => 'select',
293 '#title' => t('Number of columns'),
294 '#default_value' => variable_get('gallery_grid_num_cols', 2),
295 '#options' => array(1=>1, 2=>2, 3=>3, 4=>4, 5=>5),
296 '#description' => t('Enter the number of columns in the grid.'),
297 );
298
299 $form['grid']['gallery_grid_num_rows'] = array(
300 '#type' => 'select',
301 '#title' => t('Number of rows'),
302 '#default_value' => variable_get('gallery_grid_num_rows', 2),
303 '#options' => array(1=>1, 2=>2, 3=>3, 4=>4, 5=>5),
304 '#description' => t('Enter the number of rows in the grid.'),
305 );
306
307 $form['grid']['gallery_grid_block_block'] = array(
308 '#type' => 'select',
309 '#title' => 'Image types',
310 '#default_value' => variable_get('gallery_grid_block_block', 'randomImage'),
311 '#options' => $typeMap,
312 '#description' => 'Pick the type of images you\'d like to see in the grid.',
313 );
314
315 $form['grid']['gallery_grid_item_id'] = array(
316 '#type' => 'textfield',
317 '#title' => t('Album or Item ID'),
318 '#default_value' => variable_get('gallery_grid_item_id', ''),
319 '#size' => 20,
320 '#maxlength' => 20,
321 '#description' => t('Enter the Gallery image or album ID (or blank). If an album or item ID is specified, random images will only be selected from that album and its sub-albums.'),
322 );
323
324 $form['grid']['gallery_grid_block_show'] = array(
325 '#type' => 'checkboxes',
326 '#title' => t('Image data'),
327 '#default_value' => variable_get('gallery_grid_block_show', array()),
328 '#options' => $paramMap,
329 '#description' => t('Choose the item metadata you\'d like to display.'),
330 );
331
332 $form['grid']['gallery_grid_maxsize'] = array(
333 '#type' => 'textfield',
334 '#title' => t('Thumbnail size'),
335 '#default_value' => variable_get('gallery_grid_maxsize', 90),
336 '#size' => 10,
337 '#maxlength' => 10,
338 '#description' => t('If you want your size to be bigger than the thumbnail size for that image as defined in your Gallery2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
339 );
340
341 $form['grid']['gallery_grid_album_frame'] = array(
342 '#type' => 'textfield',
343 '#title' => t('Album frame'),
344 '#default_value' => variable_get('gallery_grid_album_frame', 'none'),
345 '#size' => 20,
346 '#maxlength' => 20,
347 '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your Gallery2 install for a complete list. Use "none" or blank for no frame.'),
348 );
349
350 $form['grid']['gallery_grid_item_frame'] = array(
351 '#type' => 'textfield',
352 '#title' => t('Item frame'),
353 '#default_value' => variable_get('gallery_grid_item_frame', 'none'),
354 '#size' => 20,
355 '#maxlength' => 20,
356 '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your Gallery2 install for a complete list. Use "none" or blank for no frame.'),
357 );
358
359 $form['grid']['gallery_grid_link_target'] = array(
360 '#type' => 'textfield',
361 '#title' => t('Link target'),
362 '#default_value' => variable_get('gallery_grid_link_target', ''),
363 '#size' => 20,
364 '#maxlength' => 20,
365 '#description' => t('Enter a link target (eg "_blank", "_new").'),
366 );
367 return $form;
368 }
369
370 /**
371 * Settings for gallery filter
372 *
373 */
374 function _gallery_filter_settings($typeMap , $paramMap) {
375 $form['filter'] = array(
376 '#type' => 'fieldset',
377 '#title' => t('Gallery Filter settings'),
378 '#description' => '',
379 '#collapsible' => TRUE,
380 '#collapsed' => TRUE,
381 );
382 //we don't include specificItem, since it can be selected automatically if n=1
383 $form['filter']['gallery_filter_prefix'] = array(
384 '#type' => 'textfield',
385 '#title' => t('Filter prefix'),
386 '#default_value' => variable_get('gallery_filter_prefix', 'G2'),
387 '#size' => 10,
388 '#maxlength' => 10,
389 '#description' => t('Prefix to use with filter. Example: \'G2\' means you use [G2: 999].'),
390 );
391
392 $form['filter']['gallery_filter_default_block_type'] = array(
393 '#type' => 'select',
394 '#title' => t('Image Block Type'),
395 '#default_value' => variable_get('gallery_filter_default_block_type', 'viewedImage'),
396 '#options' => $typeMap,
397 '#description' => t('Pick default type of image block you\'d like to use, default is Recent image. Viewed image is by most clicks.'),
398 );
399
400 $form['filter']['gallery_filter_can_cache'] = array(
401 '#type' => 'checkbox',
402 '#title' => t('Cache gallery filter pages'),
403 '#default_value' => variable_get('gallery_filter_can_cache', 1),
404 '#description' => t('By default the gallery filter output is cached by Drupal to speed up page loading. However, it will not cache the css class info for the frames. The best approach is the make sure that the sidebar image block and the gallery filter images use the same frames. If you are unable to do this you will have to deselect this option to force Drupal not to cache the pages, or else your frames will not appear. If you change this option you will need to go to <a href="%link">admin/filters</a> and re-save the image formats that use gallery filter.', array('%link' => url('admin/filters'))),
405 );
406
407 $form['filter']['gallery_filter_n_images'] = array(
408 '#type' => 'textfield',
409 '#title' => t('Default Number of Images'),
410 '#default_value' => variable_get('gallery_filter_n_images', 1),
411 '#size' => 3,
412 '#maxlength' => 3,
413 '#description' => t('How many images you want the default block to show. Best to keep at 1 and use the n parameter.'),
414 );
415 //////*********in fact, should we remove this option all together? because the way it is now, if you change this to n>1
416 //then instances where n was not specified and item_id is a specific item, the block breaks and nothing is shown.
417 $form['filter']['gallery_filter_default_show'] = array(
418 '#type' => 'checkboxes',
419 '#title' => t('Default Image Block Settings'),
420 '#default_value' => variable_get('gallery_filter_default_show', array('none')),
421 '#options' => $paramMap,
422 '#description' => t('Choose the item metadata you\'d like to display by default. This will change all instances where show parameter was not specified.'),
423 );
424
425 $form['filter']['gallery_filter_default_size'] = array(
426 '#type' => 'textfield',
427 '#title' => t('Default thumbnail size'),
428 '#default_value' => variable_get("gallery_filter_default_size", "150"),
429 '#size' => 10,
430 '#maxlength' => 10,
431 '#description' => t('If no size is specified when calling the filter, this size will be used. If you want your size to be bigger than the thumbnail size for that image as defined in your Gallery2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
432 );
433
434 $form['filter']['gallery_filter_default_album_frame'] = array(
435 '#type' => 'textfield',
436 '#title' => t('Default album frame'),
437 '#default_value' => variable_get('gallery_filter_default_album_frame', 'none'),
438 '#size' => 20,
439 '#maxlength' => 20,
440 '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame. '),
441 );
442
443 $form['filter']['gallery_filter_default_item_frame'] = array(
444 '#type' => 'textfield',
445 '#title' => t('Default item frame'),
446 '#default_value' => variable_get('gallery_filter_default_item_frame', 'none'),
447 '#size' => 20,
448 '#maxlength' => 20,
449 '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame.'),
450 );
451
452 $form['filter']['gallery_filter_default_link_target'] = array(
453 '#type' => 'textfield',
454 '#title' => t('Default Link target'),
455 '#default_value' => variable_get('gallery_filter_default_link_target', ''),
456 '#size' => 20,
457 '#maxlength' => 20,
458 '#description' => t('Enter a link target (eg "_blank", "_new").'),
459 );
460
461 $form['filter']['gallery_filter_default_div_class'] = array(
462 '#type' => 'textfield',
463 '#title' => t('Default class'),
464 '#default_value' => variable_get('gallery_filter_default_div_class', 'nowrap'),
465 '#size' => 20,
466 '#maxlength' => 20,
467 '#description' => t('left, right, or nowrap. (See gallery_filter.css to add more or modify these.)'),
468 );
469 return $form['filter'];
470 }
471
472 /**
473 * Settings for gallery search
474 *
475 */
476 function _gallery_search_settings($typeMap , $paramMap) {
477 $form['search'] = array(
478 '#type' => 'fieldset',
479 '#title' => t('Search settings'),
480 '#description' => '',
481 '#collapsible' => TRUE,
482 '#collapsed' => TRUE,
483 );
484
485 $form['search']['gallery_search_max_items'] = array(
486 '#type' => 'select',
487 '#title' => t('Max number of search results'),
488 '#default_value' => variable_get('gallery_search_max_items', 50),
489 '#options' => array(25=>25, 50=>50, 100=>100, 250=>250),
490 '#description' => t('Enter the maximum number of search results returned per Gallery2 Module. Higher numbers will give slower searching.'),
491 );
492
493 $form['search']['gallery_search_num_per_row'] = array(
494 '#type' => 'select',
495 '#title' => t('Number of search results per table row'),
496 '#default_value' => variable_get('gallery_search_num_per_row', 3),
497 '#options' => array(1=>1, 2=>2, 3=>3, 4=>4, 5=>5),
498 '#description' => t('Enter the number of search results per row in the paged table.'),
499 );
500
501 $form['search']['gallery_search_max_rows_per_pager'] = array(
502 '#type' => 'textfield',
503 '#title' => t('Number of rows per page'),
504 '#default_value' => variable_get('gallery_search_max_rows_per_pager', 5),
505 '#size' => 10,
506 '#maxlength' => 10,
507 '#description' => t('Enter the number of search results per row in the paged table.'),
508 );
509
510 $form['search']['gallery_search_show_thumbs'] = array(
511 '#type' => 'checkbox',
512 '#title' => t('Display thumbnails'),
513 '#default_value' => variable_get('gallery_search_show_thumbs', 1),
514 '#description' => t('Display thumbnail images for the search results.'),
515 );
516
517 $form['search']['gallery_search_block_show'] = array(
518 '#type' => 'checkboxes',
519 '#title' => t('Image data'),
520 '#default_value' => variable_get('gallery_search_block_show', array('title' => t('Title'))),
521 '#options' => $paramMap,
522 '#description' => t('Choose the item metadata you\'d like to display.'),
523 );
524
525 $form['search']['gallery_search_maxsize'] = array(
526 '#type' => 'textfield',
527 '#title' => t('Thumbnail size'),
528 '#default_value' => variable_get('gallery_search_maxsize', 150),
529 '#size' => 10,
530 '#maxlength' => 10,
531 '#description' => t('If you want your size to be bigger than the thumbnail size for that image as defined in your G2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
532 );
533
534 // Add album frames, item frames and link target (using modified code from MichelleC)
535 $form['search']['gallery_search_album_frame'] = array(
536 '#type' => 'textfield',
537 '#title' => t('Album frame'),
538 '#default_value' => variable_get('gallery_search_album_frame', 'none'),
539 '#size' => 20,
540 '#maxlength' => 20,
541 '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use "none" or blank for no frame.'),
542 );
543
544 $form['search']['gallery_search_item_frame'] = array(
545 '#type' => 'textfield',
546 '#title' => t('Item frame'),
547 '#default_value' => variable_get('gallery_search_item_frame', 'none'),
548 '#size' => 20,
549 '#maxlength' => 20,
550 '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use "none" or blank for no frame.'),
551 );
552
553 $form['search']['gallery_search_link_target'] = array(
554 '#type' => 'textfield',
555 '#title' => t('Link target'),
556 '#default_value' => variable_get('gallery_search_link_target_', ''),
557 '#size' => 20,
558 '#maxlength' => 20,
559 '#description' => t('Enter a link target (eg "_blank", "_new").'),
560 );
561 return $form['search'];
562 }
563
564 /**
565 * Settings for g2image
566 *
567 */
568 function _gallery_g2image_settings() {
569 $form['g2image'] = array(
570 '#type' => 'fieldset',
571 '#title' => t('Gallery Image Assist (g2image) settings'),
572 '#description' => '',
573 '#collapsible' => TRUE,
574 '#collapsed' => TRUE,
575 );
576
577 $form['g2image']['gallery_g2image_mode'] = array(
578 '#type' => 'select',
579 '#title' => t('Mode'),
580 '#default_value' => variable_get('gallery_g2image_mode', 'disabled'),
581 '#options' => array(
582 'disabled' => t('Disabled'),
583 'standalone' => t('Standalone'),
584 'tinymce' => t('TinyMCE'),
585 ),
586 '#description' => t('Determines the mode of operation. For anything other than \'Disabled\' the g2image application has to be installed. See the INSTALL.txt instructions. In \'Standalone\' mode a button will be visible under textfields to launch the g2image window. In \'TinyMCE\' mode the g2image button can be used in the tinymce toolbar. Note that the TinyMCE version will NOT work wih Safari - use the standalone version instead.'),
587 );
588
589 $options = array(
590 t('Show on every page except the listed pages.'),
591 t('Show on only the listed pages.')
592 );
593 $description = t("Enter one page per line as Drupal paths. 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' => theme('placeholder', 'blog'), '%blog-wildcard' => theme('placeholder', 'blog/*'), '%front' => theme('placeholder', '<front>')));
594
595 $form['g2image']['gallery_g2image_only_listed_pages'] = array(
596 '#type' => 'radios',
597 '#title' => t('Show g2image link on specific pages (Standalone mode only)'),
598 '#default_value' => variable_get('gallery_g2image_only_listed_pages', 1),
599 '#options' => $options,
600 );
601
602 $form['g2image']['gallery_g2image_std_pages'] = array(
603 '#type' => 'textarea',
604 '#title' => t('Pages (Standalone mode only)'),
605 '#default_value' => variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages')),
606 '#description' => $description
607 );
608
609 $form['g2image']['gallery_g2image_regex'] = array(
610 '#type' => 'textfield',
611 '#title' => t('Image Types Regular Expression'),
612 '#default_value' => variable_get('gallery_g2image_regex', '@(jpg|jpeg|png|gif|bmp|svg|mov|mpg|mpeg)$@i'),
613 '#size' => 50,
614 '#maxlength' => 50,
615 '#description' => t('Images with these file extensions will be displayed in g2image'),
616 );
617
618 $form['g2image']['gallery_g2image_sortby'] = array(
619 '#type' => 'select',
620 '#title' => t('Default Sort Order'),
621 '#default_value' => variable_get('gallery_g2image_sortby', 'title_asc'),
622 '#options' => array(
623 'title_asc' => t('Gallery2 Title (A-z)'),
624 'title_desc' => t('Gallery2 Title (z-A)'),
625 'name_asc' => t('Filename (A-z)'),
626 'name_desc' => t('Filename (z-A)'),
627 'mtime_desc' => t('Last Modification (newest first)'),
628 'mtime_asc' => t('Last Modification (oldest first)'),
629 ),
630 '#description' => t('Determines the default sorting order.'),
631 );
632
633 $form['g2image']['gallery_g2image_images_per_page'] = array(
634 '#type' => 'select',
635 '#title' => t('Default Number of images per page'),
636 '#default_value' => variable_get('gallery_g2image_images_per_page', 20),
637 '#options' => array(10=>10, 20=>20, 30=>30, 40=>40, 50=>50, 60=>60),
638 '#description' => t('Choose the default number of images per page.'),
639 );
640
641 $form['g2image']['gallery_g2image_display_filenames'] = array(
642 '#type' => 'select',
643 '#title' => t('Default Display Options'),
644 '#default_value' => variable_get('gallery_g2image_display_filenames', 'thumbnails'),
645 '#options' => array(
646 'thumbnails' => t('Thumbnails only'),
647 'filenames' => t('Thumbnails with title and filename'),
648 ),
649 '#description' => t('Choose the default display option for images.'),
650 );
651
652 $form['g2image']['gallery_g2image_click_mode'] = array(
653 '#type' => 'select',
654 '#title' => t('Default Click Mode'),
655 '#default_value' => variable_get('gallery_g2image_click_mode', 'one_click_insert'),
656 '#options' => array(
657 'one_click_insert' => t('Insert using Default settings'),
658 'show_advanced_options' => t('Open the Advanced Options Menu'),
659 ),
660 '#description' => t('The default settings for the "Results of clicking on an image:" option'),
661 );
662
663 $form['g2image']['gallery_g2image_click_mode_variable'] = array(
664 '#type' => 'checkbox',
665 '#title' => t('"Results of clicking on an image:" option is available to user'),
666 '#default_value' => variable_get('gallery_g2image_click_mode_variable', 1),
667 '#description' => t('Determines if the user can change the "Results of clicking on an image:" option.'),
668 );
669
670 $form['g2image']['gallery_g2image_default_action'] = array(
671 '#type' => 'select',
672 '#title' => t('Default Action'),
673 '#default_value' => variable_get('gallery_g2image_default_action', 'drupal_g2_filter'),
674 '#options' => array(
675 'drupal_g2_filter' => t('Gallery Filter ID'),
676 'thumbnail_image' => t('Thumbnail with link to image'),
677 'thumbnail_album' => t('Thumbnail with link to parent album'),
678 'thumbnail_custom_url' => t('Thumbnail with link to custom URL'),
679 'thumbnail_only' => t('Thumbnail only'),
680 'link_image' => t('Text link to image'),
681 'link_parent' => t('Text link to parent album'),
682 ),
683 '#description' => t('Choose the default method of inserting the image info.'),
684 );
685
686 $form['g2image']['gallery_g2image_custom_url'] = array(
687 '#type' => 'textfield',
688 '#title' => t('Default custom url'),
689 '#default_value' => variable_get('gallery_g2image_custom_url', 'http://'),
690 '#size' => 50,
691 '#maxlength' => 50,
692 '#description' => t('The default custom url. Used with \'Thumbnail with link to custom URL\' action setting'),
693 );
694
695 // Fix - G2 prefix
696
697 $gallery_g2image_custom_class = variable_get('gallery_g2image_custom_class', array());
698 $css_options = array(
699 'none' => t('None'),
700 'g2image_normal' => t('Normal'),
701 'g2image_float_left' => t('Float Left'),
702 'g2image_float_right' => t('Float Right'),
703 'g2image_centered' => t('Centered'),
704 );
705
706 $add_css_options = array();
707 foreach ($gallery_g2image_custom_class as $key => $value) {
708 if ($value) {
709 $add_css_options[$value] = $value;
710 }
711 }
712 $css_options = array_merge($css_options, $add_css_options);
713
714 $form['g2image']['gallery_g2image_default_alignment'] = array(
715 '#type' => 'select',
716 '#title' => t('Default Alignment'),
717 '#default_value' => variable_get('gallery_g2image_default_alignment', 'none'),
718 '#options' => $css_options,
719 '#description' => t('Choose the default alignment of images.'),
720 );
721
722 $form['g2image']['gallery_g2image_custom_class'] = array(
723 '#tree' => 1,
724 );
725
726 for ($i=1; $i<=4; $i++) {
727 $form['g2image']['gallery_g2image_custom_class'][$i] = array(
728 '#type' => 'textfield',
729 '#title' => t('Custom Class %index', array('%index' => $i)),
730 '#default_value' => $gallery_g2image_custom_class[$i],
731 '#size' => 20,
732 '#maxlength' => 50,
733 );
734 }
735 $form['g2image']['gallery_g2image_custom_class'][$i-1]['#description'] =
736 t('Additional css classes to be available for selection (must be defined in .css file).');
737
738 $form['g2image']['gallery_g2image_class_mode'] = array(
739 '#type' => 'select',
740 '#title' => t('Alignment Class Insertion Point'),
741 '#default_value' => variable_get('gallery_g2image_class_mode', 'img'),
742 '#options' => array(
743 'img' => t('<img class=...>'),
744 'div' => t('<div class=...><img ...>'),
745 ),
746 '#description' => t('Determines where the alignment class will be inserted. If you choose \'&lt;div class=...&gt;&lt;img ...&gt;\', you will have to manually delete any &lt;div&gt; tags manually after deleting images from the TinyMCE window.'),
747 );
748 return $form['g2image'];
749 }
750
751 /**
752 * Settings for links section
753 *
754 */
755 function _gallery_links_settings() {
756 if (variable_get('gallery_valid', 0)) {
757 $g2Uri = variable_get('gallery_embed_uri', '?q=gallery');
758 $desc = t('Here are some links to the parts of Gallery2 Site Admin most relevant to gallery.module.');
759 $desc .= '<ul>';
760 $desc .= '<li><a href= "' . $g2Uri . '&g2_view=core.SiteAdmin&g2_subView=core.AdminModules">Modules</a> : ' . t('To install, activate or configure the required and optional modules relating to gallery.module (Image Block, Image Frame, URL Rewrite, Album Select).') . '</li>';
761 $desc .= '<li><a href= "' . $g2Uri . '&g2_view=core.SiteAdmin&g2_subView=core.AdminThemes&g2_mode=defaults">Themes</a> : ' . t('To add/remove blocks in the sidebar.') . '</li>'; $desc .= '<li><a href= "' . $g2Uri . '&g2_view=core.SiteAdmin&g2_subView=rewrite.AdminRewrite&g2_mode=setup">Embedded URL Rewrite settings</a> : ' . t('To configure the correct .htaccess path and define the rewrite rules.') . '</li>';
762 $desc .= '<li><a href= "' . $g2Uri . '&g2_view=core.SiteAdmin&g2_subView=core.AdminCore">Cookie Settings</a> : '. t('Only needed for a small number of site configurations, such as the use of different subdomains for Gallery2 and Drupal.') . '</li>';
763 $desc .= '</ul>';
764 } else {
765 $desc = t('This section will contain links to the parts of Gallery2 Site Admin most relevant to gallery.module. It is only available when your Embedded Gallery installation is valid, which it currently is not.');
766 }
767 $form['links'] = array(
768 '#type' => 'fieldset',
769 '#title' => t('Links to Gallery2 Site Admin sections most relevant to Drupal (advanced)'),
770 '#description' => $desc,
771 '#collapsible' => TRUE,
772 '#collapsed' => TRUE,
773 );
774 return $form['links'];
775 }
776
777
778 /**
779 * Validate the gallery form settings
780 */
781 function gallery_settings_form_validate($form_id, &$form) {
782 global $form_values;
783 include_once(drupal_get_path('module', 'gallery') . '/G2EmbedDiscoveryUtilities.class');
784 include_once(drupal_get_path('module', 'gallery') . '/G2EmbedTestUtilities.class');
785
786 $gallery_valid = 1;
787
788 // Store the original values for the variables
789 $orig['g2Uri'] = $form_values['gallery_uri'];
790 $orig['g2EmbedPath'] = $form_values['gallery_dir'];
791 $orig['embedUri'] = $form_values['gallery_embed_uri'];
792
793 // Check these variables
794 list($num_errors, $num_warnings, $new, $results) =
795 G2EmbedTestUtilities::checkLocations($orig, $form_values['gallery_autodetect_dir']);
796 if ($num_errors) {
797 $gallery_valid = 0;
798 }
799
800 // Update the variables with the new validated ones
801 $form_values['gallery_uri'] = $new['g2Uri'];
802 $form_values['gallery_dir'] = $new['g2EmbedPath'];
803 $form_values['gallery_embed_uri'] = $new['embedUri'];
804
805 // Perform pre-init tests. If they fail then do not init the gallery as there may be an issue
806 list($num_errors, $num_warnings, $pre_init_results) = G2EmbedTestUtilities::preInitTests();
807 $results = array_merge($results, $pre_init_results);
808 if ($num_errors) {
809 $gallery_valid = 0;
810 }
811
812 // If the filepaths seem correct then check Gallery2 works and has the correct module configs
813 // This code is modified from the WPG2 integration code -- Thanks.
814 if ($gallery_valid) {
815 // Gallery install is thought valid, so init it.
816 $title = t('Gallery2 Init:');
817 $vars['gallery_uri'] = $form_values['gallery_uri'];
818 $vars['gallery_dir'] = $form_values['gallery_dir'];
819 $vars['gallery_embed_uri'] = $form_values['gallery_embed_uri'];
820 $vars['gallery_valid'] = true;
821 list ($success, $ret) = _gallery_init(true, $vars);
822 if (!$success) {
823 // Gallery install was supposed to be valid, but it still failed. Something is wrong.
824 $results['gallery_init']['title'] = $title;
825 $results['gallery_init']['error'] = true;
826 $results['gallery_init']['notice'] = t('Everything seemed OK, but the Gallery could still not be initialised. Perhaps a manually entered value is incorrect.');
827 $gallery_valid = 0;
828 } else {
829 $results['gallery_init']['title'] = $title;
830 $results['gallery_init']['success'] = true;
831
832 list($num_errors, $num_warnings, $post_init_results) = G2EmbedTestUtilities::postInitTests();
833 if ($num_errors) {
834 $gallery_valid = 0;
835 }
836 // Check for changed embedUri
837 /* No longer needed as the URL Rewrite config below will do it
838 if ($form_values['gallery_embed_uri'] != variable_get('gallery_embed_uri', '?q=gallery')) {
839 $post_init_results['urlrewrite3']['title'] = t('Gallery2 URL Rewrite rules:');
840 $post_init_results['urlrewrite3']['warning'] = true;
841 $post_init_results['urlrewrite3']['notice'] = t('The \'Embed URI\' setting has changed. If you are using the URL Rewrite module in Gallery2 you will need to regenerate the rules (just click the \'save\' button on the Embedded URL Rewrite page).');
842 }*/
843
844 // Update the URL Rewrite Configuration
845 if ($post_init_results['urlrewrite']['success']) {
846 list($url_conf_num_errors, $url_conf_num_warnings, $post_init_results['urlrewrite2']) =
847 _gallery_configure_url_rewrite();
848 }
849
850 $results = array_merge($results, $post_init_results);
851
852 // Setup the cookie path - removed for now (see above)
853 /*
854 $path = $form_values['gallery_cookie_path'];
855 $ret = GalleryCoreApi::setPluginParameter('module', 'core', 'cookie.path', $path);
856 */
857
858 GalleryEmbed::done();
859 }
860 }
861 // Validate the g2image settings
862 list($num_errors, $num_warnings, $results_g2image) =
863 _gallery_g2image_settings_form_validate($form_values);
864 if ($results_g2image) {
865 $results['gallery_g2image'] = $results_g2image;
866 }
867
868 // Test again for validity
869 if ($gallery_valid) {
870 $results['gallery_valid']['title'] = t('Overall Status:');
871 $results['gallery_valid']['success'] = true;
872 } else {
873 $results['gallery_valid']['title'] = t('Overall Status:');
874 $results['gallery_valid']['error'] = true;
875 $results['gallery_valid']['notice'] = t('You need to fix the above errors before Gallery2 will be embedded in Drupal.');
876 }
877
878 $message = t('Embedded Gallery2 Status: ').'<ul>';
879 foreach ($results as $key=>$result) {
880 $message .= '<li>' . t($result['title']) . ' ';
881 if (isset($result['success']) && $result['success']) {
882 $message .= '<span class=\'g2_embed_success\'>' . t('Success') . '</span>';
883 } else if (isset($result['warning']) && $result['warning']) {
884 $message .= '<span class=\'g2_embed_warning\'>' . t('Warning') . '</span>';
885 $message .= '<ul><li>' . t($result['notice']) . '</li></ul>';
886 } else if (isset($result['error']) && $result['error']) {
887 $message .= '<span class=\'g2_embed_error\'>' . t('Error') . '</span>';
888 $message .= '<ul><li>' . t($result['notice']) . '</li></ul>';
889 } else if (isset($result['advise']) && $result['advise']) {
890 $message .= '<span class=\'g2_embed_warning\'>' . t('Advisory') . '</span>';
891 $message .= '<ul><li>' . t($result['notice']) . '</li></ul>';
892 }
893 }
894 $message .= '</ul>';
895 drupal_set_message($message);
896 $form_values['gallery_valid'] = $gallery_valid;
897
898 // Gallery Image Block Settings validation
899 // Need to truncate the gallery_block_block variable to the entered number of blocks
900 if (count($form_values['gallery_block_block']) != $form_values['gallery_block_num_images']) {
901 $form_values['gallery_block_block'] = array_slice(
902 $form_values['gallery_block_block'], 0, $form_values['gallery_block_num_images']);
903 }
904 }
905
906 /**
907 * Configure URL rewrite (from WPG2 code)
908 */
909 function _gallery_configure_url_rewrite() {
910 $num_errors = 0;
911 $num_warnings = 0;
912
913 // Find the public path to drupal from the base_url
914 global $base_url;
915 $http = 'http' . (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] == 'on' ? 's' : '' : '');
916 $public_path = str_replace($http . '://' . $_SERVER['HTTP_HOST'],'', $base_url) . '/';
917
918 // Find the path to drupal. Will this always work?
919 $htaccess_path = realpath(".") . '/';
920
921 $title = t('Gallery2 URL Rewrite Module Auto-Configuration:');
922 $results['urlrewrite']['title'] = $title;
923
924 list ($ret, $rewriteApi) = GalleryCoreApi::newFactoryInstance('RewriteApi');
925 if ($ret) {
926 /* G2 Error handling */
927 // All other tests were run already
928 $results['urlrewrite']['error'] = true;
929 $results['urlrewrite']['notice'] =t(
930 'Gallery2 Error when trying to access URL Rewrite Module status. %ret',
931 array('%ret' => $ret->getAsHtml()));
932 }
933 list ($ret, $params) = $rewriteApi->fetchEmbedConfig();
934
935 // Check if .htaccess exists. If not and path is writable, create it.
936 // This should only occur for multi-site installs as the main drupal dir always has a .htaccess
937 if (!file_exists($htaccess_path . '.htaccess')) {
938 // Better to check for the file, not the dir as if not writable fopen returns a visible warning
939 if (is_writable($htaccess_path . '.htaccess')) {
940 $f = fopen($htaccess_path . '.htaccess', 'w');
941 fclose($f);
942 } else {
943 $results['urlrewrite']['error'] = true;
944 $results['urlrewrite']['notice'] = t('There is no .htaccess file in your defined Drupal directory (%dir) and the directory is not writable. Please create a writable .htaccess file in that directory.', array('%dir' => $htaccess_path));
945 $num_errors++;
946 return array($num_errors, $num_warnings, $results['urlrewrite']);
947 }
948 }
949
950 if (file_exists($htaccess_path . '.htaccess')) {
951 if (is_writable($htaccess_path . '.htaccess')) {
952
953 // Set the G2 rewrite Values
954 $params['embeddedLocation'] = $public_path;
955 $params['embeddedHtaccess'] = $htaccess_path;
956
957 // Save the G2 rewrite Values
958 list ($ret, $code, $err) = $rewriteApi->saveEmbedConfig($params);
959 if ($code != REWRITE_STATUS_OK) {
960 list ($ret, $errstr) = $err;
961 $errstr = $code." - ".$errstr;
962 $results['urlrewrite']['error'] = true;
963 $results['urlrewrite']['notice'] = t('The Gallery2 URL Rewrite module returned the following error:') . '<pre>' . $errstr . '</pre>';
964 $num_errors++;
965 } else {
966 $results['urlrewrite']['success'] = true;
967 }
968 } else {
969 $results['urlrewrite']['error'] = true;
970 $results['urlrewrite']['notice'] = t('The .htaccess file in your defined Drupal directory (%dir) is not writable. Please CHMOD it to 644 (or 666 if 644 does not work).', array('%dir' => $htaccess_path));
971 $num_errors++;
972 }
973 }
974 return array($num_errors, $num_warnings, $results['urlrewrite']);
975 }
976
977 /**
978 * Validate the gallery g2image settings and saves the config file if needed.
979 */
980 function _gallery_g2image_settings_form_validate(&$form_values) {
981 switch ($form_values['gallery_g2image_mode']) {
982 case 'tinymce':
983 $mode = t('TinyMCE');
984 $path = drupal_get_path('module', 'tinymce');
985 $path .= '/tinymce/jscripts/tiny_mce/plugins/g2image';
986 break;
987 case 'standalone':
988 $mode = t('Standalone');
989 $path = drupal_get_path('module', 'gallery');
990 $path .= '/g2image';
991 break;
992 default:
993 return array(0, 0, array());
994 }
995 $title = 'Gallery2 Image Assist (g2image) Status:';
996 // Note that file_check_directory uses &$path and will strip the trailing '/'
997 $filename = $path . '/config.php';
998 if (is_writable($filename) == false && !file_check_directory($path)) {
999 $results['gallery_g2image']['title'] = $title;
1000 $results['gallery_g2image']['warning'] = true;
1001 $results['gallery_g2image']['notice'] = t('g2image does not seem to be installed for %mode mode in the required directory (%dir), or the directory is not writable. Please see the INSTALL.txt for instructions.', array('%mode' => $mode, '%dir' => '&lt;drupal_path&gt;'.$path));
1002 $num_warnings++;
1003 return array($num_errors, $num_warnings, $results['gallery_g2image']);
1004 }
1005 $cr = "\n";
1006 $g2ic_gallery2_path = $form_values['gallery_dir'];
1007 $g2ic_use_full_path = (substr($g2ic_gallery2_path, 0, 1) == '/') ? 'TRUE' : 'FALSE';
1008 $form_values['gallery_g2image_custom_url'] =
1009 check_url($form_values['gallery_g2image_custom_url']);
1010 $g2ic_display_filenames = ($form_values['gallery_g2image_display_filenames'] == 'filenames') ?
1011 'TRUE' : 'FALSE';
1012 $g2ic_custom_class = array();
1013 foreach ($form_values['gallery_g2image_custom_class'] as $key => $value) {
1014 $g2ic_custom_class[$key] = ($value) ? $value : 'not_used';
1015 }
1016
1017 $g2ic_custom_class_1 = ($form_values['gallery_g2image_custom_class_1']) ?
1018 $form_values['gallery_g2image_custom_class_1'] : 'not_used';
1019 $g2ic_custom_class_2 = ($form_values['gallery_g2image_custom_class_2']) ?
1020 $form_values['gallery_g2image_custom_class_2'] : 'not_used';
1021 $g2ic_custom_class_3 = ($form_values['gallery_g2image_custom_class_3']) ?
1022 $form_values['gallery_g2image_custom_class_3'] : 'not_used';
1023 $g2ic_custom_class_4 = ($form_values['gallery_g2image_custom_class_4']) ?
1024 $form_values['gallery_g2image_custom_class_4'] : 'not_used';
1025
1026 $content = '<?php' .$cr;
1027 $content .= '// Configuration File for Gallery 2 Image Chooser for TinyMCE' . $cr;
1028 $content .= '// Version 2.0 RC4 and above' . $cr;
1029 $content .= '// By Kirk Steffensen - http://g2image.steffensenfamily.com/' . $cr;
1030 $content .= '// Released under the GPL version 2.' . $cr;
1031 $content .= '// A copy of the license is in the root folder of this plugin.' . $cr;
1032 $content .= $cr . '// Automatically generated by gallery.module (admin/settings/gallery).' . $cr;
1033 $content .= '// DO NOT EDIT' . $cr;
1034 $content .= '$g2ic_image_ext_regex = \'' . $form_values['gallery_g2image_regex'] . '\';' . $cr;
1035 $content .= '$g2ic_gallery2_path = \'' . $g2ic_gallery2_path . '\';' . $cr;
1036 $content .= '$g2ic_embedded_mode = TRUE;' . $cr;
1037 $content .= '$g2ic_use_full_path = ' . $g2ic_use_full_path. ';' . $cr;
1038 $content .= '$g2ic_gallery2_uri = \'' . $form_values['gallery_uri'] . '\';' . $cr;
1039 $content .= '$g2ic_embed_uri = \'' . $form_values['gallery_embed_uri'] . '\';' . $cr;
1040 $content .= '$g2ic_drupal_g2_filter = TRUE;' . $cr;
1041 $content .= '$g2ic_drupal_g2_filter_prefix = \'' . $form_values['gallery_filter_prefix'] . '\';' . $cr;
1042 $content .= '$g2ic_language = \'en\';' . $cr;
1043 $content .= '$g2ic_images_per_page = ' . $form_values['gallery_g2image_images_per_page'] . ';' . $cr;
1044 $content .= '$g2ic_display_filenames = ' . $g2ic_display_filenames . ';' . $cr;
1045 $content .= '$g2ic_default_alignment = \'' . $form_values['gallery_g2image_default_alignment'] . '\';' . $cr;
1046 $content .= '$g2ic_custom_class_1 = \'' . $g2ic_custom_class[1] . '\';' . $cr;
1047 $content .= '$g2ic_custom_class_2 = \'' . $g2ic_custom_class[2] . '\';' . $cr;
1048 $content .= '$g2ic_custom_class_3 = \'' . $g2ic_custom_class[3] . '\';' . $cr;
1049 $content .= '$g2ic_custom_class_4 = \'' . $g2ic_custom_class[4] . '\';' . $cr;
1050 $content .= '$g2ic_class_mode = \'' . $form_values['gallery_g2image_class_mode'] . '\';' . $cr;
1051 $content .= '$g2ic_click_mode = \'' . $form_values['gallery_g2image_click_mode'] . '\';' . $cr;
1052 $content .= '$g2ic_click_mode_variable = ' . $form_values['gallery_g2image_click_mode_variable'] . ';' . $cr;
1053 $content .= '$g2ic_default_action = \'' . $form_values['gallery_g2image_default_action'] . '\';' . $cr;
1054 $content .= '$g2ic_sortby = \'' . $form_values['gallery_g2image_sortby'] . '\';' . $cr;
1055 $content .= '$g2ic_custom_url = \'' . $form_values['gallery_g2image_custom_url'] . '\';' . $cr;
1056
1057 $filename = $path . '/config.php';
1058 if (is_writable($filename) == false) {
1059 $results['gallery_g2image']['title'] = $title;
1060 $results['gallery_g2image']['warning'] = true;
1061 $results['gallery_g2image']['notice'] = t('Could not write to g2image config file. Please check the permissions for %filename.', array('%filename' => $filename));
1062 $num_warnings++;
1063 return array($num_errors, $num_warnings, $results['gallery_g2image']);
1064 }
1065 $handle = fopen($filename, "w");
1066 if (fwrite($handle, $content) === FALSE) {
1067 $results['gallery_g2image']['title'] = $title;
1068 $results['gallery_g2image']['warning'] = true;
1069 $results['gallery_g2image']['notice'] = t('Could not write to g2image config file. Please check the permissions for %filename.', array('%filename' => $filename));
1070 $num_warnings++;
1071 return array($num_errors, $num_warnings, $results['gallery_g2image']);
1072 } else {
1073 $results['gallery_g2image']['title'] = $title;
1074 $results['gallery_g2image']['success'] = true;
1075 }
1076 fclose($handle);
1077 return array($num_errors, $num_warnings, $results['gallery_g2image']);
1078 }
1079 ?>