Projet

Général

Profil

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

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

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
  /* Forum / topic list settings */
91
  $form['advanced_forum_lists'] = array(
92
    '#type' => 'fieldset',
93
    '#title' => t('Forum and topic lists'),
94
    '#collapsible' => TRUE,
95
    '#collapsed' => FALSE,
96
  );
97

    
98
  // Disable breadcrumbs
99
  $form['advanced_forum_lists']['advanced_forum_disable_breadcrumbs'] = array(
100
    '#type' => 'checkbox',
101
    '#title' => t('Disable breadcrumbs'),
102
    '#default_value' => variable_get('advanced_forum_disable_breadcrumbs', 0),
103
    '#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.'),
104
  );
105

    
106
  $form['advanced_forum_lists']['advanced_forum_collapsible_containers'] = array(
107
    '#type' => 'select',
108
    '#title' => t('Collapsible forum containers'),
109
    '#options' => array(
110
      'none' => t("None"),
111
      'toggle' => t("Toggle"),
112
      'fade' => t("Fade"),
113
      'slide' => t("Slide"),
114
    ),
115
    '#description' => t('Select whether or not to enable collapsible forum containers and what type of animation to use.'),
116
    '#default_value' => variable_get('advanced_forum_collapsible_containers', 'toggle'),
117
  );
118

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

    
137
  if (module_exists('image')) {
138

    
139
    /* Forum image settings */
140
    $form['advanced_forum_forum_image'] = array(
141
      '#type' => 'fieldset',
142
      '#title' => t('Forum image settings'),
143
      '#collapsible' => TRUE,
144
      '#collapsed' => FALSE,
145
    );
146

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

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

    
184
    $form['advanced_forum_general']['advanced_forum_user_picture_preset'] = array(
185
      '#type' => 'select',
186
      '#title' => t('User picture preset'),
187
      '#options' => $options,
188
      '#description' => t('Image preset to use for forum avatars. Leave blank to not use this feature.'),
189
      '#default_value' => variable_get('advanced_forum_user_picture_preset', ''),
190
    );
191
  }
192
  else {
193
    variable_set('advanced_forum_user_picture_preset', '');
194
  }
195

    
196
  if (module_exists('author_pane')) {
197
    $join_date_options = array();
198
    foreach (system_get_date_types() as $date_type) {
199
      $join_date_options[$date_type['type']] = $date_type['title'];
200
    }
201

    
202
    $form['advanced_forum_general']['advanced_forum_author_pane_join_date_type'] = array(
203
      '#type' => 'select',
204
      '#title' => t('Author Pane - Join date, date type'),
205
      '#options' => $join_date_options,
206
      '#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'))),
207
      '#default_value' => variable_get('advanced_forum_author_pane_join_date_type', 'short'),
208
    );
209
  }
210

    
211
  // Retrieve new comments on forum listing
212
  $form['advanced_forum_lists']['advanced_forum_get_new_comments'] = array(
213
    '#type' => 'checkbox',
214
    '#title' => t('Get the number of new comments per forum on the forum list'),
215
    '#default_value' => variable_get('advanced_forum_get_new_comments', 0),
216
    '#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.'),
217
  );
218

    
219
  // Title length max
220
  $form['advanced_forum_lists']['advanced_forum_topic_title_length'] = array(
221
    '#type' => 'textfield',
222
    '#title' => t('Number of characters to display for the topic title'),
223
    '#size' => 5,
224
    '#description' => t('Used on main forum page. Enter 0 to use the full title.'),
225
    '#default_value' => variable_get('advanced_forum_topic_title_length', 20),
226
  );
227

    
228
  // Send our form to Drupal to make a settings page
229
  return system_settings_form($form);
230
}