Projet

Général

Profil

Paste
Télécharger (9,93 ko) Statistiques
| Branche: | Révision:

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

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
  /* Forum / topic list settings */
98
  $form['advanced_forum_lists'] = array(
99
    '#type' => 'fieldset',
100
    '#title' => t('Forum and topic lists'),
101
    '#collapsible' => TRUE,
102
    '#collapsed' => FALSE,
103
  );
104

    
105
  // Disable breadcrumbs.
106
  $form['advanced_forum_lists']['advanced_forum_disable_breadcrumbs'] = array(
107
    '#type' => 'checkbox',
108
    '#title' => t('Disable breadcrumbs'),
109
    '#default_value' => variable_get('advanced_forum_disable_breadcrumbs', 0),
110
    '#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.'),
111
  );
112

    
113
  $form['advanced_forum_lists']['advanced_forum_collapsible_containers'] = array(
114
    '#type' => 'select',
115
    '#title' => t('Collapsible forum containers'),
116
    '#options' => array(
117
      'none' => t("None"),
118
      'toggle' => t("Toggle"),
119
      'fade' => t("Fade"),
120
      'slide' => t("Slide"),
121
    ),
122
    '#description' => t('Select whether or not to enable collapsible forum containers and what type of animation to use.'),
123
    '#default_value' => variable_get('advanced_forum_collapsible_containers', 'toggle'),
124
  );
125

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

    
144
  if (module_exists('image')) {
145

    
146
    /* Forum image settings */
147
    $form['advanced_forum_forum_image'] = array(
148
      '#type' => 'fieldset',
149
      '#title' => t('Forum image settings'),
150
      '#collapsible' => TRUE,
151
      '#collapsed' => FALSE,
152
    );
153

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

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

    
191
    $form['advanced_forum_general']['advanced_forum_user_picture_preset'] = array(
192
      '#type' => 'select',
193
      '#title' => t('User picture preset'),
194
      '#options' => $options,
195
      '#description' => t('Image preset to use for forum avatars. Leave blank to not use this feature.'),
196
      '#default_value' => variable_get('advanced_forum_user_picture_preset', ''),
197
    );
198
  }
199
  else {
200
    variable_set('advanced_forum_user_picture_preset', '');
201
  }
202

    
203
  if (module_exists('author_pane')) {
204
    $join_date_options = array();
205
    foreach (system_get_date_types() as $date_type) {
206
      $join_date_options[$date_type['type']] = $date_type['title'];
207
    }
208

    
209
    $form['advanced_forum_general']['advanced_forum_author_pane_join_date_type'] = array(
210
      '#type' => 'select',
211
      '#title' => t('Author Pane - Join date, date type'),
212
      '#options' => $join_date_options,
213
      '#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'))),
214
      '#default_value' => variable_get('advanced_forum_author_pane_join_date_type', 'short'),
215
    );
216
  }
217

    
218
  // Retrieve new comments on forum listing.
219
  $form['advanced_forum_lists']['advanced_forum_get_new_comments'] = array(
220
    '#type' => 'checkbox',
221
    '#title' => t('Get the number of new comments per forum on the forum list'),
222
    '#default_value' => variable_get('advanced_forum_get_new_comments', 0),
223
    '#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.'),
224
  );
225

    
226
  // Title length max.
227
  $form['advanced_forum_lists']['advanced_forum_topic_title_length'] = array(
228
    '#type' => 'textfield',
229
    '#title' => t('Number of characters to display for the topic title'),
230
    '#size' => 5,
231
    '#description' => t('Used on main forum page. Enter 0 to use the full title.'),
232
    '#default_value' => variable_get('advanced_forum_topic_title_length', 20),
233
  );
234

    
235
  // Send our form to Drupal to make a settings page.
236
  return system_settings_form($form);
237
}