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