/[drupal]/contributions/modules/weblinks/weblinks.admin.inc
ViewVC logotype

Contents of /contributions/modules/weblinks/weblinks.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.35 - (show annotations) (download) (as text)
Mon Jul 20 16:52:34 2009 UTC (4 months ago) by nancyw
Branch: MAIN
CVS Tags: HEAD
Changes since 1.34: +224 -188 lines
File MIME type: text/x-php
Update HEAD to start 7.x
1 <?php
2 // $Id: weblinks.admin.inc,v 1.34.2.43.2.28 2009/07/08 00:42:53 nancyw Exp $
3
4 /**
5 * @file
6 * Settings form.
7 */
8
9 /**
10 * Module settings page.
11 */
12 function weblinks_settings_page() {
13 return drupal_get_form('weblinks_admin_settings');
14 }
15
16 function weblinks_admin_settings() {
17 drupal_add_js(drupal_get_path('module', 'weblinks') .'/weblinks.admin.js');
18 drupal_add_css(drupal_get_path('module', 'weblinks') .'/weblinks.admin.css');
19 $form = array('#attributes' => array('class' => 'weblinks-settings'));
20 $taxo_avail = module_exists('taxonomy');
21
22 /**
23 * Overall settings.
24 */
25 $yesno = array(1 => t('Yes'), 0 => t('No'));
26
27 $vocabs = $taxo_avail ? taxonomy_get_vocabularies('weblinks') : array();
28 if (count($vocabs) > 1) {
29 $avail_vocs = array();
30 foreach ($vocabs as $vid => $vocabulary) {
31 $avail_vocs[$vid] = check_plain($vocabulary->name);
32 }
33 ksort($avail_vocs);
34 $form['weblinks_nav_vocabulary'] = array(
35 '#type' => 'radios',
36 '#title' => t('Vocabulary to use for Weblinks'),
37 '#default_value' => variable_get('weblinks_nav_vocabulary', ''),
38 '#options' => $avail_vocs,
39 '#required' => TRUE,
40 '#prefix' => '<div class="weblinks-radios">',
41 '#suffix' => '</div><div class="clear-block"></div>',
42 );
43 }
44 else {
45 if (count($vocabs) < 1 && $taxo_avail) {
46 variable_del('weblinks_nav_vocabulary');
47 _weblinks_get_vocid();
48 drupal_set_message(t('No vocabulary for the weblinks content type was found. A new vocabulary was created.'));
49 }
50 }
51
52 $len_opts = drupal_map_assoc(array(0, 10, 15, 20, 30, 40, 50, 60, 70, 80, 128, 256));
53
54 $form['weblinks_trim_block'] = array(
55 '#type' => 'select',
56 '#options' => $len_opts,
57 '#title' => t('Maximum block title length'),
58 '#default_value' => variable_get('weblinks_trim_block', 0),
59 '#description' => t('This controls how much of a node title will be shown in a block to conserve space. Zero (0) means unlimited.'),
60 );
61
62 $form['page'] = array(
63 '#type' => 'fieldset',
64 '#title' => t('Links page settings'),
65 '#description' => t('These settings control the main links page display.'),
66 '#attributes' => array('id' => 'weblinks-page-settings'),
67 '#collapsible' => TRUE,
68 '#collapsed' => FALSE,
69 );
70
71 /**
72 * Settings for the links page.
73 */
74 $form['page']['weblinks_collapsible'] = array(
75 '#type' => 'radios',
76 '#options' => $yesno,
77 '#title' => t('Make groups collapsible'),
78 '#default_value' => (int) variable_get('weblinks_collapsible', TRUE),
79 '#description' => t('Enable this if you want the groups to be collapsible on the main links page. Note that if the "Unclassified" title is empty, that group will not be collapsed.'),
80 '#required' => FALSE,
81 '#prefix' => '<div class="weblinks-radios">',
82 '#suffix' => '</div>',
83 );
84
85 $form['page']['weblinks_collapsed'] = array(
86 '#type' => 'radios',
87 '#options' => $yesno,
88 '#title' => t('Collapse all groups'),
89 '#default_value' => (int) variable_get('weblinks_collapsed', FALSE),
90 '#description' => t('Enable this if you want all the groups to be collapsed on the main links page.'),
91 '#required' => FALSE,
92 '#prefix' => '<div class="weblinks_collapse_hide weblinks-radios">',
93 '#suffix' => '</div>',
94 );
95
96 $form['page']['weblinks_linktitle'] = array(
97 '#type' => 'radios',
98 '#options' => $yesno,
99 '#title' => t('Link group title to group'),
100 '#default_value' => (int) variable_get('weblinks_linktitle', TRUE),
101 '#description' => t('Enable this if you want the group titles to be a link to show only that group.'),
102 '#required' => FALSE,
103 '#prefix' => '<div class="weblinks-link-title weblinks-radios">',
104 '#suffix' => '</div>',
105 );
106
107 $sort_options = array(
108 'standard' => t('Normal Drupal - by weight, sticky, created date.'),
109 'title' => t('Legacy - by weight, sticky, title.'),
110 );
111 $form['page']['weblinks_page_sort'] = array(
112 '#type' => 'radios',
113 '#options' => $sort_options,
114 '#title' => t('Page Sort order'),
115 '#default_value' => variable_get('weblinks_page_sort', 'title'),
116 '#description' => t('This determines how the links page will sort the links.'),
117 '#required' => FALSE,
118 '#prefix' => '<div class="weblinks-radios">',
119 '#suffix' => '</div><div class="clear-block"></div>',
120 );
121
122 $form['page']['weblinks_pagedesc'] = array(
123 '#type' => 'textarea',
124 '#title' => t('Page information'),
125 '#rows' => 3,
126 '#default_value' => variable_get('weblinks_pagedesc', NULL),
127 '#description' => t('This description will appear at the top of the links page. It will be filtered by your default input format.'),
128 '#required' => FALSE,
129 );
130
131 // Disallow blank setting.
132 $mfd_default = variable_get('weblinks_maxfrontdepth', 1);
133 if (!is_numeric($mfd_default)) {
134 $mfd_default = 1;
135 }
136 $form['page']['weblinks_maxfrontdepth'] = array(
137 '#type' => 'textfield',
138 '#title' => t('Maximum group depth (main links page)'),
139 '#default_value' => $mfd_default,
140 '#description' => t('This controls how many subgroups, if any, will display on the main links page. Blank, zero (0), and one (1) will all show only the top level.'),
141 '#required' => FALSE,
142 '#size' => 2,
143 );
144
145 // Add "rel=nofollow."
146 $form['page']['weblinks_nofollow'] = array(
147 '#type' => 'radios',
148 '#options' => $yesno,
149 '#prefix' => '<div class="weblinks-radios">',
150 '#suffix' => '</div>',
151 '#title' => t('Spam link deterrent'),
152 '#default_value' => (int) variable_get('weblinks_nofollow', FALSE),
153 '#description' => t('If enabled, Drupal will add rel="nofollow" to all links, as a measure to reduce the effectiveness of spam links. Note: this will also prevent valid links from being followed by search engines, therefore it is likely most effective when enabled for anonymous users.'),
154 );
155
156 /**
157 * Settings for group display.
158 */
159 $form['group'] = array(
160 '#type' => 'fieldset',
161 '#title' => t('Group settings'),
162 '#description' => t('These settings control the way the groups display on the main links page.'),
163 '#attributes' => array('id' => 'weblinks-group-settings'),
164 '#collapsible' => TRUE,
165 '#collapsed' => FALSE,
166 );
167
168 $form['group']['weblinks_catdesc'] = array(
169 '#type' => 'radios',
170 '#options' => $yesno,
171 '#title' => t('Display group descriptions'),
172 '#default_value' => (int) variable_get('weblinks_catdesc', TRUE),
173 '#description' => t('Generally recommended.'),
174 '#prefix' => '<div class="weblinks-radios">',
175 '#suffix' => '</div>',
176 );
177
178 $form['group']['weblinks_empty_text'] = array(
179 '#type' => 'textarea',
180 '#title' => t('Empty container text'),
181 '#rows' => 2,
182 '#default_value' => variable_get('weblinks_empty_text', NULL),
183 '#description' => t('This text will appear when a container is empty. Leave it blank to not show the group at all. It will be filtered by your default input format.'),
184 );
185
186 $form['group']['weblinks_unclassified_title'] = array(
187 '#type' => 'textfield',
188 '#title' => t('Title for unclassified links'),
189 '#default_value' => variable_get('weblinks_unclassified_title', t('Unclassified')),
190 '#description' => t('This will be used to describe the unclassified links. You may leave it blank for no title. It will not be translated.'),
191 );
192
193 $form['group']['weblinks_unclassified_desc'] = array(
194 '#type' => 'textfield',
195 '#title' => t('Description for unclassified links'),
196 '#default_value' => variable_get('weblinks_unclassified_desc', t('These links have not been assigned a group.')),
197 '#description' => t('This will be used as the description for the unclassified links group. If this group has no title, this text will not be shown either. It will not be translated.'),
198 );
199
200 $form['group']['weblinks_unpublished_title'] = array(
201 '#type' => 'textfield',
202 '#required' => TRUE,
203 '#title' => t('Title for unpublished links'),
204 '#default_value' => variable_get('weblinks_unpublished_title', t('Unpublished')),
205 '#description' => t('This will be used to describe the unclassified links. You may leave it blank for no title. It will not be translated.'),
206 );
207
208 $form['group']['weblinks_unpublished_desc'] = array(
209 '#type' => 'textfield',
210 '#title' => t('Description for unpublished links'),
211 '#default_value' => variable_get('weblinks_unpublished_desc', t('These links are not published and need to be reviewed.')),
212 '#description' => t('This will be used as the description for the unpublished links group. If this group has no title, this text will not be shown either. It will not be translated.'),
213 );
214
215 /**
216 * Settings for link display.
217 */
218 $form['link'] = array(
219 '#type' => 'fieldset',
220 '#title' => t('Link settings'),
221 '#description' => t('These settings control the way individual links display on the main links page.'),
222 '#attributes' => array('id' => 'weblinks-link-settings'),
223 '#collapsible' => TRUE,
224 '#collapsed' => FALSE,
225 );
226
227 $form['link']['weblinks_show_title'] = array(
228 '#type' => 'radios',
229 '#options' => $yesno,
230 '#prefix' => '<div class="weblinks-radios">',
231 '#suffix' => '</div>',
232 '#title' => t('Show the node title'),
233 '#default_value' => (int) variable_get('weblinks_show_title', TRUE),
234 '#description' => t('If your theme automatically provides a node title, set this to "No." If you see duplicated titles, then set this to "No" and see if that resolves the problem.'),
235 );
236
237 $form['link']['weblinks_title_link'] = array(
238 '#type' => 'radios',
239 '#options' => $yesno,
240 '#prefix' => '<div class="weblinks-radios">',
241 '#suffix' => '</div>',
242 '#title' => t('Link the title to the node'),
243 '#default_value' => (int) variable_get('weblinks_title_link', TRUE),
244 '#description' => t('This makes the node title link to the node. For some themes, this may not work without also making some simple theme changes.'),
245 );
246
247 $desc_opts = array(
248 'none' => t('No description'),
249 'teaser' => t('Teaser length'),
250 'body' => t('Full length'),
251 );
252 $form['link']['weblinks_linkdesc'] = array(
253 '#type' => 'radios',
254 '#options' => $desc_opts,
255 '#title' => t('Link description display'),
256 '#default_value' => variable_get('weblinks_linkdesc', 'teaser'),
257 '#description' => t('This sets how the description will be displayed on the main links page.'),
258 '#prefix' => '<div class="weblinks-radios">',
259 '#suffix' => '</div>',
260 );
261
262 $form['link']['weblinks_redirect'] = array(
263 '#type' => 'radios',
264 '#options' => $yesno,
265 '#prefix' => '<div class="weblinks-radios">',
266 '#suffix' => '</div>',
267 '#title' => t('Enable click-tracking'),
268 '#default_value' => (int) variable_get('weblinks_redirect', FALSE),
269 '#description' => t('This turns on the feature to record the number of times a link has been clicked upon. It is a requirement for the "Popular" block.'),
270 );
271
272 $form['link']['weblinks_external'] = array(
273 '#type' => 'radios',
274 '#options' => $yesno,
275 '#prefix' => '<div class="weblinks-radios">',
276 '#suffix' => '</div>',
277 '#title' => t('Open links in a new window'),
278 '#default_value' => (int) variable_get('weblinks_external', TRUE),
279 '#description' => t('Recommended to keep your vistors on your site. Note that this will cause HTML "Strict" validation errors if used.'),
280 );
281
282 $form['link']['weblinks_user_links'] = array(
283 '#type' => 'radios',
284 '#options' => $yesno,
285 '#prefix' => '<div class="weblinks-radios">',
286 '#suffix' => '</div>',
287 '#title' => t("Display a link to other users' links"),
288 '#default_value' => (int) variable_get('weblinks_user_links', FALSE),
289 '#description' => t("Shows a link to another user's links."),
290 );
291
292 $form['link']['weblinks_show_url'] = array(
293 '#type' => 'radios',
294 '#options' => $yesno,
295 '#prefix' => '<div class="weblinks-radios">',
296 '#suffix' => '</div>',
297 '#title' => t("Display URL/Visit on links page"),
298 '#default_value' => (int) variable_get('weblinks_show_url', TRUE),
299 '#description' => t("Determines whether the URL or invitational link (next setting) will be used on the links page. It will always be shown on a node view page."),
300 );
301
302 $form['link']['weblinks_view_as'] = array(
303 '#type' => 'radios',
304 '#title' => t('Link displays as'),
305 '#options' => array('url' => t('URL'), 'visit' => t('Visit')),
306 '#default_value' => variable_get('weblinks_view_as', 'url'),
307 '#description' => t('This option sets whether the URL itself will be displayed or will hide behind an invitational link, such as "Visit <em>title</em>".'),
308 '#prefix' => '<div class="weblinks-radios">',
309 '#suffix' => '</div>',
310 );
311
312 $token = module_exists('token');
313 $form['link']['weblinks_visit_text'] = array(
314 '#type' => 'textfield',
315 '#title' => t('"Visit" text'),
316 '#default_value' => variable_get('weblinks_visit_text', t('Visit [title]')),
317 '#description' => t('This is the text that will be used with the node title (indicated by "[title]") to invite a click.'),
318 '#prefix' => '<div class="weblinks_visit_hide">',
319 );
320
321 if ($token) {
322 $form['link']['token_help'] = array(
323 '#title' => t('Replacement patterns'),
324 '#type' => 'fieldset',
325 '#collapsible' => TRUE,
326 '#collapsed' => TRUE,
327 );
328
329 $form['link']['token_help']['help'] = array(
330 '#value' => theme('token_help', 'node'),
331 );
332 }
333
334 // The end div here ends the "weblinks_visit_hide" above.
335 $form['link']['weblinks_trim'] = array(
336 '#type' => 'select',
337 '#options' => $len_opts,
338 '#title' => t('Maximum link title length'),
339 '#default_value' => variable_get('weblinks_trim', 0),
340 '#description' => t('This controls how much of long URLs will be shown in a link in full node view. Zero (0) means unlimited.'),
341 '#prefix' => '</div><!-- /weblinks_visit_hide --><div class="weblinks_trim_hide">',
342 );
343
344 $form['link']['weblinks_strip'] = array(
345 '#type' => 'radios',
346 '#options' => $yesno,
347 '#prefix' => '<div class="weblinks-radios">',
348 // '#suffix' => '</div>',
349 '#title' => t('Strip protocol and "www"'),
350 '#default_value' => (int) variable_get('weblinks_strip', FALSE),
351 '#description' => t('If enabled, the protocol (e.g. "http://") and "www" (if present) will be removed before displaying the URL.'),
352 '#suffix' => '</div></div><!-- /weblinks_trim_hide -->',
353 );
354
355 /**
356 * Settings for field defaults.
357 */
358 $form['field'] = array(
359 '#type' => 'fieldset',
360 '#title' => t('Field defaults'),
361 '#description' => t("These settings provide various defaults for fields that may be entered. Be careful when changing these as they can interfere with a user's input."),
362 '#collapsible' => TRUE,
363 '#collapsed' => TRUE,
364 );
365
366 $form['field']['weblinks_url_stub'] = array(
367 '#type' => 'textfield',
368 '#title' => t('Default for URL'),
369 '#default_value' => variable_get('weblinks_url_stub', 'http://'),
370 '#description' => t('This will be used as a stub in the URL field.'),
371 );
372
373 $form['field']['weblinks_body_stub'] = array(
374 '#type' => 'textfield',
375 '#title' => t('Default for description'),
376 '#default_value' => variable_get('weblinks_body_stub', ''),
377 '#description' => t('This will be used as a stub in the "Link description" field.'),
378 );
379
380 $format_list = filter_formats();
381 $formats = array(FILTER_FORMAT_DEFAULT => '-default-');
382 foreach ($format_list as $number => $filter) {
383 $formats[$number] = $filter->name;
384 }
385 $form['field']['weblinks_format'] = array(
386 '#type' => 'radios',
387 '#options' => $formats,
388 '#title' => t('Default input format'),
389 '#default_value' => variable_get('weblinks_format', FILTER_FORMAT_DEFAULT),
390 '#description' => t('This will be used as the default input format.'),
391 '#prefix' => '<div class="weblinks-radios">',
392 '#suffix' => '</div>',
393 );
394
395 $form['#redirect'] = 'weblinks';
396 return system_settings_form($form);
397 }
398

  ViewVC Help
Powered by ViewVC 1.1.2