Projet

Général

Profil

Paste
Télécharger (11,7 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / advanced_forum / includes / settings.inc @ fc2c1c7a

1
<?php
2

    
3
/**
4
 * @file
5
 * Advanced forum settings / configuration page.
6
 */
7

    
8
/**
9
 * Defines the Advanced Forum settings form.
10
 */
11
function advanced_forum_settings_page() {
12
  /* General settings */
13
  $form['advanced_forum_general'] = array(
14
    '#type' => 'fieldset',
15
    '#title' => t('General'),
16
    '#collapsible' => TRUE,
17
    '#collapsed' => FALSE,
18
  );
19

    
20
  // Choose style.
21
  $options = array();
22
  $available_styles = advanced_forum_get_all_styles();
23
  foreach ($available_styles as $style_machine_name => $style) {
24
    $options[$style_machine_name] = $style['name'];
25
  }
26
  asort($options);
27

    
28
  $form['advanced_forum_general']['advanced_forum_style'] = array(
29
    '#type' => 'select',
30
    '#title' => t('Advanced forum style'),
31
    '#options' => $options,
32
    '#description' => t('Choose which style to use for your forums. This will apply independent of site theme.'),
33
    '#default_value' => variable_get('advanced_forum_style', 'silver_bells'),
34
  );
35

    
36
  // Choose node types that are styled.
37
  $node_types = _node_types_build()->types;
38
  $options = array();
39
  foreach ($node_types as $node_machine_name => $node_type) {
40
    $options[$node_machine_name] = $node_type->name;
41
  }
42

    
43
  $form['advanced_forum_general']['advanced_forum_styled_node_types'] = array(
44
    '#type' => 'select',
45
    '#title' => t('Node types to style'),
46
    '#options' => $options,
47
    '#multiple' => TRUE,
48
    '#description' => t('Choose which node types will have the forum style applied.'),
49
    '#default_value' => variable_get('advanced_forum_styled_node_types', array('forum')),
50
  );
51

    
52
  // Style nodes presented in teaser form.
53
  $form['advanced_forum_general']['advanced_forum_style_teasers'] = array(
54
    '#type' => 'checkbox',
55
    '#title' => t('Style nodes when being displayed as teasers.'),
56
    '#default_value' => variable_get('advanced_forum_style_teasers', 0),
57
    '#description' => t('If checked, selected node types will be styled even when they are in a teaser list.'),
58
  );
59

    
60
  // Style nodes only if tagged for the forum.
61
  $form['advanced_forum_general']['advanced_forum_style_only_forum_tagged'] = array(
62
    '#type' => 'checkbox',
63
    '#title' => t('Style nodes only if they have a forum term attached.'),
64
    '#default_value' => variable_get('advanced_forum_style_only_forum_tagged', 1),
65
    '#description' => t('If checked, selected node types will be only styled if they are associated with a forum term.'),
66
  );
67

    
68
  // Style all site comments as forums.
69
  $form['advanced_forum_general']['advanced_forum_style_all_comments'] = array(
70
    '#type' => 'checkbox',
71
    '#title' => t('Style all comments like forum replies.'),
72
    '#default_value' => variable_get('advanced_forum_style_all_comments', 0),
73
    '#description' => t('If checked, every comment will be styled as if it were a forum reply.'),
74
  );
75

    
76
  $form['advanced_forum_general']['advanced_forum_add_local_task'] = array(
77
    '#type' => 'checkbox',
78
    '#title' => t('Add a tab for forum view page.'),
79
    '#default_value' => variable_get('advanced_forum_add_local_task', TRUE),
80
    '#description' => t('If checked, this will add a local task tab for "View forums". Use this in conjunction with making the included views have local tasks. If you don\'t know what this means, leave it unchecked. You must clear the cache before this will take effect.'),
81
  );
82

    
83
  $form['advanced_forum_general']['advanced_forum_views_as_tabs'] = array(
84
    '#type' => 'checkbox',
85
    '#title' => t('Add a tab for included views that have their own pages.'),
86
    '#default_value' => variable_get('advanced_forum_views_as_tabs', TRUE),
87
    '#description' => t('If checked, this will add a local task tab for "Active topics," "New posts," "My posts," and "Unanswered topics." If you don\'t know what this means, leave it unchecked. You must clear the cache before this will take effect.'),
88
  );
89

    
90
  $form['advanced_forum_general']['advanced_forum_keep_classes'] = array(
91
    '#type' => 'checkbox',
92
    '#title' => t('Keep default CSS classes (For experts only).'),
93
    '#default_value' => variable_get('advanced_forum_keep_classes', FALSE),
94
    '#description' => t('If checked, all CSS classes generated by Drupal core and other modules/themes will be kept'),
95
  );
96

    
97
  $form['advanced_forum_general']['advanced_forum_forum_user_term_fields'] = array(
98
    '#title' => t('Use fields from taxonomy term in forum'),
99
    '#type' => 'checkbox',
100
    '#description' => t('Allows to use fields from taxonomy term on the form of creation or editing of the forum'),
101
    '#default_value' => variable_get('advanced_forum_forum_user_term_fields'),
102
  );
103

    
104
  /* Forum / topic list settings */
105
  $form['advanced_forum_lists'] = array(
106
    '#type' => 'fieldset',
107
    '#title' => t('Forum and topic lists'),
108
    '#collapsible' => TRUE,
109
    '#collapsed' => FALSE,
110
  );
111

    
112
  // Disable breadcrumbs.
113
  $form['advanced_forum_lists']['advanced_forum_disable_breadcrumbs'] = array(
114
    '#type' => 'checkbox',
115
    '#title' => t('Disable breadcrumbs'),
116
    '#default_value' => variable_get('advanced_forum_disable_breadcrumbs', 0),
117
    '#description' => t('Check this to disable breadcrumbs in the forum if you are using another module to customize them. Does not affect node pages and does not work when Page Manager is overriding forum pages.'),
118
  );
119

    
120
  $form['advanced_forum_lists']['advanced_forum_collapsible_containers'] = array(
121
    '#type' => 'select',
122
    '#title' => t('Collapsible forum containers'),
123
    '#options' => array(
124
      'none' => t("None"),
125
      'toggle' => t("Toggle"),
126
      'fade' => t("Fade"),
127
      'slide' => t("Slide"),
128
    ),
129
    '#description' => t('Select whether or not to enable collapsible forum containers and what type of animation to use.'),
130
    '#default_value' => variable_get('advanced_forum_collapsible_containers', 'toggle'),
131
  );
132

    
133
  // For default collapsed state configuration.
134
  $collapsed_list_name = variable_get('forum_containers', array());
135
  $collapsed_list_description = array();
136
  foreach ($collapsed_list_name as $id) {
137
    $term = taxonomy_term_load($id);
138
    if (!empty($term)) {
139
      $collapsed_list_description[$id] = empty($term->name) ? '' : $term->name;
140
    }
141
  }
142
  $form['advanced_forum_lists']['advanced_forum_default_collapsed_list'] = array(
143
    '#type' => 'select',
144
    '#title' => t('Containers collapsed by default'),
145
    '#default_value' => variable_get('advanced_forum_default_collapsed_list', array()),
146
    '#options' => $collapsed_list_description,
147
    '#multiple' => TRUE,
148
    '#description' => t('Select containers which should be collapsed by default.'),
149
  );
150

    
151
  if (module_exists('image')) {
152

    
153
    /* Forum image settings */
154
    $form['advanced_forum_forum_image'] = array(
155
      '#type' => 'fieldset',
156
      '#title' => t('Forum image settings'),
157
      '#collapsible' => TRUE,
158
      '#collapsed' => FALSE,
159
    );
160

    
161
    $forum_vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0));
162
    $field_info = field_info_instances('taxonomy_term', $forum_vocabulary->machine_name);
163
    $image_fields = array();
164
    foreach ($field_info as $bundle => $field) {
165
      if (!empty($field['display']['default']['type']) && ($field['display']['default']['type'] == 'image')) {
166
        $image_fields[$bundle] = $bundle;
167
      }
168
    }
169
    $form['advanced_forum_forum_image']['advanced_forum_forum_image_field'] = array(
170
      '#title' => t('Image field'),
171
      '#description' => t('The image field to use to display forum images.'),
172
      '#type' => 'select',
173
      '#default_value' => variable_get('advanced_forum_forum_image_field', ''),
174
      '#empty_option' => t('None'),
175
      '#options' => $image_fields,
176
    );
177

    
178
    $form['advanced_forum_forum_image']['advanced_forum_forum_image_preset'] = array(
179
      '#title' => t('Forum image style'),
180
      '#description' => t('The image style to apply to the images.'),
181
      '#type' => 'select',
182
      '#default_value' => variable_get('advanced_forum_forum_image_preset', ''),
183
      '#empty_option' => t('None (original image)'),
184
      '#options' => image_style_options(FALSE),
185
    );
186
  }
187
  else {
188
    variable_set('advanced_forum_forum_image_field', '');
189
  }
190
  // Picture preset.
191
  if (module_exists('image') && module_exists('author_pane')) {
192
    $options = array('' => '');
193
    $styles = image_styles();
194
    foreach ($styles as $style) {
195
      $options[$style['name']] = $style['name'];
196
    }
197

    
198
    $form['advanced_forum_general']['advanced_forum_user_picture_preset'] = array(
199
      '#type' => 'select',
200
      '#title' => t('User picture preset'),
201
      '#options' => $options,
202
      '#description' => t('Image preset to use for forum avatars. Leave blank to not use this feature.'),
203
      '#default_value' => variable_get('advanced_forum_user_picture_preset', ''),
204
    );
205
  }
206
  else {
207
    variable_set('advanced_forum_user_picture_preset', '');
208
  }
209

    
210
  if (module_exists('author_pane')) {
211
    $join_date_options = array();
212
    foreach (system_get_date_types() as $date_type) {
213
      $join_date_options[$date_type['type']] = $date_type['title'];
214
    }
215

    
216
    $form['advanced_forum_general']['advanced_forum_author_pane_join_date_type'] = array(
217
      '#type' => 'select',
218
      '#title' => t('Author Pane - Join date, date type'),
219
      '#options' => $join_date_options,
220
      '#description' => t('Select which <a href="@date-type-url">date type</a> to use for displaying the join date in the Author Pane.', array('@date-type-url' => url('admin/config/regional/date-time'))),
221
      '#default_value' => variable_get('advanced_forum_author_pane_join_date_type', 'short'),
222
    );
223
  }
224

    
225
  // Retrieve new comments on forum listing.
226
  $form['advanced_forum_lists']['advanced_forum_get_new_comments'] = array(
227
    '#type' => 'checkbox',
228
    '#title' => t('Get the number of new comments per forum on the forum list'),
229
    '#default_value' => variable_get('advanced_forum_get_new_comments', 0),
230
    '#description' => t('Core forum shows the number of new topics. If checked, Advanced Forum will get the number of new comments as well and show it under "posts" on the forum overview. Slow query not recommended on large forums.'),
231
  );
232

    
233
  // Title length max.
234
  $form['advanced_forum_lists']['advanced_forum_topic_title_length'] = array(
235
    '#type' => 'textfield',
236
    '#title' => t('Number of characters to display for the topic title'),
237
    '#size' => 5,
238
    '#description' => t('Used on main forum page. Enter 0 to use the full title.'),
239
    '#default_value' => variable_get('advanced_forum_topic_title_length', 20),
240
  );
241

    
242
  // Last Post optimization.
243
  $form['advanced_forum_lists']['advanced_forum_last_post_query'] = array(
244
    '#type' => 'textfield',
245
    '#title' => t('Number of last topics which will be used in search for "Last Post"'),
246
    '#size' => 5,
247
    '#description' => t('Optimization for large sites. Used on main forum page.'),
248
    '#default_value' => variable_get('advanced_forum_last_post_query', 10000),
249
  );
250

    
251
  // Auto loading.
252
  $form['advanced_forum_autoload'] = array(
253
    '#type' => 'fieldset',
254
    '#title' => t('Auto-loading'),
255
    '#collapsible' => TRUE,
256
    '#collapsed' => TRUE,
257
    '#description' => t('Changing these settings may require multiple cache clears to take effect.'),
258
  );
259

    
260
  // Auto load included page variants
261
  $form['advanced_forum_autoload']['advanced_forum_autoload_page_handlers'] = array(
262
    '#type' => 'checkbox',
263
    '#title' => t('Auto load included page handlers'),
264
    '#description' => t('Uncheck to use Features or manual imports.'),
265
    '#default_value' => variable_get('advanced_forum_autoload_page_handlers', TRUE),
266
  );
267

    
268
  // Auto load included views
269
  $form['advanced_forum_autoload']['advanced_forum_autoload_views'] = array(
270
    '#type' => 'checkbox',
271
    '#title' => t('Auto load included views'),
272
    '#description' => t('Uncheck to use Features or manual imports.'),
273
    '#default_value' => variable_get('advanced_forum_autoload_views', TRUE),
274
  );
275

    
276
  // Send our form to Drupal to make a settings page.
277
  return system_settings_form($form);
278
}