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

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

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


Revision 1.61 - (show annotations) (download) (as text)
Fri Oct 23 20:19:37 2009 UTC (4 weeks, 5 days ago) by rjerome
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-7--1
Changes since 1.60: +8 -8 lines
File MIME type: text/x-php
merged changes from DRUPAL-6--1 branch
1 <?php
2 // $Id: biblio.admin.inc,v 1.60 2009/10/01 01:45:42 rjerome Exp $
3 /**
4 * biblio.admin.inc
5 *
6 * Copyright (C) 2006-2008 Ron Jerome
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23 /**
24 * Default page callback for batches.
25 */
26
27 function biblio_admin_ahah($form, $element, $value) {
28 switch ($form) {
29
30 }
31 }
32 /**
33 * Implementation of hook_settings().
34 */
35 function biblio_admin_settings() {
36 $version = '$Revision: 1.60 $ $Date: 2009/10/01 01:45:42 $';
37 $version = str_replace('$', '', $version);
38 $form['biblio_rev'] = array(
39 '#value' => $version,
40
41 );
42 $form['biblio_base'] = array(
43 '#type' => 'textfield',
44 '#title' => t('Base URL'),
45 '#size' => 20,
46 '#default_value' => variable_get('biblio_base', 'biblio'),
47 '#description' => t('This sets the base URL used to access the biblio module (e.g. /biblio ).')
48 );
49 $form['biblio_base_title'] = array(
50 '#type' => 'textfield',
51 '#title' => t('Biblio page title'),
52 '#size' => 20,
53 '#default_value' => variable_get('biblio_base_title', 'Biblio'),
54 '#description' => t('The page title shown on the base URL.')
55 );
56
57 $form['biblio_rowsperpage'] = array(
58 '#type' => 'textfield',
59 '#title' => t('Number of results per page'),
60 '#default_value' => variable_get('biblio_rowsperpage', 25),
61 '#size' => 6,
62 '#maxlength' => 6,
63 '#description' => t('This sets the number of results that will be displayed per page.')
64 );
65 $form['biblio_view_only_own'] = array(
66 '#type' => 'checkbox',
67 '#title' => t('Restrict users such that they can only view their own biblio entries'),
68 '#return_value' => 1,
69 '#default_value' => variable_get('biblio_view_only_own', 0),
70 '#description' => t('This option restricts the users capability to view biblio entries. They will only be able to see the entries which they have created and own.')
71 );
72 $form['authors'] = array(
73 '#type' => 'fieldset',
74 '#collapsible' => TRUE,
75 '#collapsed' => TRUE,
76 '#title' => t('Authors'),
77 '#description' => ''
78 );
79 $form['authors']['biblio_auto_orphaned_author_delete'] = array(
80 '#type' => 'checkbox',
81 '#title' => t('Automatically delete orphaned authors'),
82 '#return_value' => 1,
83 '#default_value' => variable_get('biblio_auto_orphaned_author_delete', 0),
84 '#description' => t('Orphaned authors are those which are no longer linked to any entries as the result of a biblio update or delete.')
85 );
86 $form['bibtex'] = array(
87 '#type' => 'fieldset',
88 '#collapsible' => TRUE,
89 '#collapsed' => TRUE,
90 '#title' => t('BibTex settings'),
91 '#description' => ''
92 );
93 $form['bibtex']['biblio_hide_bibtex_braces'] = array(
94 '#type' => 'checkbox',
95 '#title' => t('Retain bibtex\'s {Protected} capitalization in the title string, but hide the braces on display'),
96 '#return_value' => 1,
97 '#default_value' => variable_get('biblio_hide_bibtex_braces', 0),
98 '#description' =>''
99 );
100
101 $form['block'] = array(
102 '#type' => 'fieldset',
103 '#collapsible' => TRUE,
104 '#collapsed' => TRUE,
105 '#title' => t('Block settings'),
106 '#description' => ''
107 );
108 $form['block']['biblio_block_title'] = array(
109 '#type' => 'textfield',
110 '#title' => t('Title for the "New Publications" block'),
111 '#default_value' => variable_get('biblio_block_title', 'New Publications'),
112 '#size' => 40,
113 '#maxlength' => 40,
114 '#description' => ''
115 );
116 $form['block']['biblio_rowsperblock'] = array(
117 '#type' => 'textfield',
118 '#title' => t('Number of results in the "New Publications" block'),
119 '#default_value' => variable_get('biblio_rowsperblock', 4),
120 '#size' => 2,
121 '#maxlength' => 2,
122 '#description' => t('This sets the number of results that will be displayed in the "New Publications" block.')
123 );
124 $form['block']['biblio_block_order'] = array(
125 '#type' => 'radios',
126 '#title' => t('Order by'),
127 '#default_value' => variable_get('biblio_block_order', 'n.created'),
128 '#options' => array(
129 'n.created' => t('Date Created'),
130 'b.biblio_year' => t('Year Published')
131 )
132 );
133 $result = db_query("SELECT b.name, bftd.title FROM {biblio_fields} b
134 INNER JOIN {biblio_field_type} bt ON bt.fid=b.fid
135 INNER JOIN {biblio_field_type_data} bftd ON bftd.ftdid=bt.ftdid
136 WHERE bt.tid=0 ORDER by bftd.title ASC ");
137 $schema = drupal_get_schema('biblio');
138 $keys = array_keys($schema['fields']);
139 $options = array();
140 $options['nid'] = t('Node ID');
141 while ($row = db_fetch_array($result)) {
142 $options[$row['name']] = $row['title'];
143 }
144 $form['citekey'] = array(
145 '#type' => 'fieldset',
146 '#collapsible' => TRUE,
147 '#collapsed' => TRUE,
148 '#title' => t('Citekey'),
149 '#description' => t('You can alter citekey related settings here.')
150 );
151 $form['citekey']['biblio_display_citation_key'] = array(
152 '#type' => 'checkbox',
153 '#title' => t('Show citation key in results'),
154 '#return_value' => 1,
155 '#default_value' => variable_get('biblio_display_citation_key', 0),
156 '#description' => t('This will output the citekey as the first item in the citation string')
157 );
158 $form['citekey']['biblio_auto_citekey'] = array(
159 '#type' => 'checkbox',
160 '#title' => t('Auto generate citekeys if not given'),
161 '#return_value' => 1,
162 '#default_value' => variable_get('biblio_auto_citekey', 1),
163 '#description' => t('This option will cause "citekey" entries to be automatically generated if a value is not provided.')
164 );
165 $form['citekey']['biblio_citekey_prefix'] = array(
166 '#type' => 'textfield',
167 '#title' => t('Citekey prefix'),
168 '#default_value' => variable_get('biblio_citekey_prefix', ''),
169 '#size' => 10,
170 '#maxlength' => 10,
171 '#description' => t('This text will be combined with the field choosen below to form the auto generated citekey.')
172 );
173 $form['citekey']['biblio_citekey_field1'] = array(
174 '#type' => 'select',
175 '#title' => t('Primary Citekey field'),
176 '#default_value' => variable_get('biblio_citekey_field1', 'nid'),
177 '#options' => $options,
178 '#description' => t('Select the field to be used when generating citekeys.')
179 );
180 $form['citekey']['biblio_citekey_field2'] = array(
181 '#type' => 'select',
182 '#title' => t('Secondary Citekey field'),
183 '#default_value' => variable_get('biblio_citekey_field2', 'nid'),
184 '#options' => $options,
185 '#description' => t('If the field above has no value this field will be used.')
186 );
187 // Allow only users to modify PHP code which have PHP block visibility permissions
188 if (user_access('use PHP for block visibility')) {
189 $form['citekey']['biblio_citekey_phpcode'] = array(
190 '#type' => 'textarea',
191 '#title' => t('PHP code for citekey generation'),
192 '#default_value' => variable_get('biblio_citekey_phpcode', ''),
193 '#description' => t('Advanced usage only: PHP code that returns the citekey. Should not include &lt;?php ?&gt; delimiters.')
194 );
195 }
196
197 $form['footnotes'] = array(
198 '#type' => 'fieldset',
199 '#collapsible' => TRUE,
200 '#collapsed' => TRUE,
201 '#title' => t('Footnotes'),
202 '#description' => t('You can integrate with the !url module here.', array('!url' => l('footnotes', url("http://www.drupal.org/project/footnotes", array('query' => NULL, 'fragment' => NULL, 'absolute' => TRUE)))))
203 );
204 if (!module_exists('footnotes')) {
205 $additional_text = '<div class="admin-dependencies">'. t('Depends on') .': '. t('Footnotes') .' (<span class="admin-disabled">'. t('disabled') .'</span>)</div>';
206 $disabled = TRUE;
207 variable_set('biblio_footnotes_integration', 0);
208 }
209 else {
210 $additional_text = '<div class="admin-dependencies">'. t('Depends on') .': '. t('Footnotes') .' (<span class="admin-enabled">'. t('enabled') .'</span>)</div>';
211 $disabled = FALSE;
212 }
213 $form['footnotes']['biblio_footnotes_integration'] = array(
214 '#type' => 'checkbox',
215 '#title' => t('Integration with the footnotes module') . $additional_text,
216 '#disabled' => $disabled,
217 '#return_value' => 1,
218 '#default_value' => variable_get('biblio_footnotes_integration', 0),
219 '#description' => t('This will convert &lt;bib&gt; tags into &lt;fn&gt; tags. This will cause intermingled &lt;bib&gt; and &lt;fn&gt; tags to be sequentially numbered. For this to work, you must put the &lt;bib&gt; filter ahead of the &lt;fn&gt; filter in the filter chain. If this option is not set, &lt;bib&gt; and &lt;fn&gt; tags will be handled separately.')
220 );
221 $form['isi_wok'] = array(
222 '#type' => 'fieldset',
223 '#collapsible' => TRUE,
224 '#collapsed' => TRUE,
225 '#title' => t('ISI Web of Knowledge'),
226 '#description' => ''
227 );
228 $form['isi_wok']['biblio_fix_isi_links'] = array(
229 '#type' => 'checkbox',
230 '#title' => t('Automatically replace "Go to ISI" links with the URL below'),
231 '#return_value' => 1,
232 '#default_value' => variable_get('biblio_fix_isi_links', 0),
233 '#description' => t('This option automatically replaces any fake "Go to ISI" links with the supplied URL to ISI Web of Knowledge. Note a subscription with ISI is required for these links to function.')
234 );
235 $form['isi_wok']['biblio_isi_url'] = array(
236 '#type' => 'textfield',
237 '#title' => t('ISI Web of Knowledge URL'),
238 '#size' => 128,
239 '#maxlength' => 512,
240 '#default_value' => variable_get('biblio_isi_url', 'http://apps.isiknowledge.com/InboundService.do?Func=Frame&product=WOS&action=retrieve&SrcApp=EndNote&Init=Yes&SrcAuth=ResearchSoft&mode=FullRecord&UT='),
241 '#description' => t('Enter the URL which will replace the "Go to ISI" fake links imported from EndNote')
242 );
243 $form['keywords'] = array(
244 '#type' => 'fieldset',
245 '#collapsible' => TRUE,
246 '#collapsed' => TRUE,
247 '#title' => t('Keywords'),
248 '#description' => ''
249 );
250 $form['keywords']['biblio_keyword_sep'] = array(
251 '#type' => 'textfield',
252 '#title' => t('Keyword separator'),
253 '#size' => 2,
254 '#default_value' => variable_get('biblio_keyword_sep', ','),
255 '#description' => t('Enter the character which will be used to separate multiple keywords in the keyword field')
256 );
257 $form['keywords']['biblio_keyword_orphan_autoclean'] = array(
258 '#type' => 'checkbox',
259 '#title' => t('Automatically remove orphaned keywords'),
260 '#return_value' => 1,
261 '#default_value' => variable_get('biblio_keyword_orphan_autoclean', 1),
262 '#description' => t('This option automatically deletes keywords which are no longer associated with any publications (primarily due to the due to the removal of a publication or editing a keyword).')
263 );
264 $taxo_mesg = '<div class="admin-dependencies">'. t('Depends on') .': '. t('Taxonomy') .' (<span class="admin-disabled">'. t('disabled') .'</span>)</div>';
265 $form['keywords']['biblio_copy_taxo_terms_to_keywords'] = array(
266 '#type' => 'checkbox',
267 '#title' => t('Copy any selected taxonomy terms to the biblio keyword database'),
268 '#return_value' => 1,
269 '#default_value' => module_exists('taxonomy') ? variable_get('biblio_copy_taxo_terms_to_keywords', 0) : 0,
270 '#disabled' => (!module_exists('taxonomy')),
271 '#description' => module_exists('taxonomy') ? t('If this option is selected, the selected taxonomy terms will be copied to the '.variable_get('biblio_base_title', 'Biblio').' keyword database and be displayed as keywords (as well as taxonomy terms) for this entry.') : $taxo_mesg
272 );
273 $form['keywords']['biblio_keyword_freetagging'] = array(
274 '#type' => 'checkbox',
275 '#title' => t('Use keywords from biblio entries as taxonomy "free tags"'),
276 '#return_value' => 1,
277 '#default_value' => module_exists('taxonomy') ? variable_get('biblio_keyword_freetagging', 0) : 0,
278 '#disabled' => (!module_exists('taxonomy')),
279 '#description' => module_exists('taxonomy') ? t('This option allows user to add keywords (free tags) to describe their documents. These keywords will be registered as taxonomy.') : $taxo_mesg
280 );
281 $vocabularies = module_invoke('taxonomy', 'get_vocabularies');
282 // ... and print a form to select the terms in each of them
283 $taxo_options = array();
284 $taxo_options[0]= '<'. t('none') .'>';
285 if (count($vocabularies)) {
286 foreach ($vocabularies as $voc) {
287 $taxo_options[$voc->vid] = $voc->name;
288 }
289 $form['keywords']['biblio_keyword_vocabulary'] = array(
290 '#type' => 'select',
291 '#title' => t('Vocabulary'),
292 '#default_value' => variable_get('biblio_keyword_vocabulary', 0),
293 '#options' => $taxo_options,
294 '#description' => t('Select vocabulary (category) to use for free tags.'),
295 '#multiple' => FALSE,
296 // '#disabled' => (!variable_get('biblio_keyword_freetagging', 0)),
297 // '#size' => $multiple ? min(9, count($taxo_options)) : 0,
298 '#weight' => 15
299 );
300 }
301
302 $form['links'] = array(
303 '#type' => 'fieldset',
304 '#collapsible' => TRUE,
305 '#collapsed' => TRUE,
306 '#title' => t('Links')
307 );
308 $form['links']['export'] = array(
309 '#type' => 'fieldset',
310 '#collapsible' => TRUE,
311 '#collapsed' => FALSE,
312 '#title' => t('Export Links')
313 );
314 $form['links']['export']['biblio_export_links'] = array(
315 '#type' => 'checkboxes',
316 '#title' => t('Show export links'),
317 '#default_value' => variable_get('biblio_export_links', array('tagged', 'xml', 'bibtex')),
318 '#options' => array(
319 'tagged' => t('EndNote Tagged'),
320 'xml' => t('EndNote XML'),
321 'bibtex' => t('BibTex'),
322 ),
323 '#description' => t('You can select which export links to display here.')
324 );
325 $form['links']['google'] = array(
326 '#type' => 'fieldset',
327 '#collapsible' => TRUE,
328 '#collapsed' => FALSE,
329 '#title' => t('Google Scholar Link')
330 );
331 $form['links']['google']['biblio_google_link'] = array(
332 '#type' => 'checkbox',
333 '#title' => t('Show Google Scholar links'),
334 '#return_value' => 1,
335 '#default_value' => variable_get('biblio_google_link', 1),
336 '#description' => t('Selecting this option will display a link to Google Scholar beside each entry. Clicking this link searches Google Scholar using the title and first author of the current biblio entry.')
337 );
338
339 $form['links']['biblio_links_target_new_window'] = array(
340 '#type' => 'checkbox',
341 '#title' => t('Links open in new browser'),
342 '#return_value' => 1,
343 '#default_value' => variable_get('biblio_links_target_new_window', 0),
344 '#description' => t('This causes related URLs to open in a new browser window')
345 );
346 $form['links']['biblio_inlinemode_in_links'] = array(
347 '#type' => 'checkbox',
348 '#title' => t('Carry "inline" mode through to all links'),
349 '#return_value' => 1,
350 '#default_value' => variable_get('biblio_inlinemode_in_links', 0),
351 '#description' => t('This causes the "inline" mode to be applied to all links such as titles, authors and keywords')
352 );
353
354 $form['links']['biblio_link_title_url'] = array(
355 '#type' => 'checkbox',
356 '#title' => t('Hyperlink titles using supplied URL if available'),
357 '#return_value' => 1,
358 '#default_value' => variable_get('biblio_link_title_url', 0),
359 '#description' => t('Selecting this links the titles to the supplied URL (if available) rather than the "node" view.')
360 );
361 $form['links']['biblio_author_links'] = array(
362 '#type' => 'checkbox',
363 '#title' => t('Hyperlink author names'),
364 '#return_value' => 1,
365 '#default_value' => variable_get('biblio_author_links', 1),
366 '#description' => t('This creates a hyperlink on author names which, when clicked, will select entries which contain that author')
367 );
368 $form['openurl'] = array(
369 '#type' => 'fieldset',
370 '#collapsible' => TRUE,
371 '#collapsed' => TRUE,
372 '#title' => t('OpenURL'),
373 '#description' => t('You can set an <a href="http://en.wikipedia.org/wiki/OpenURL">openurl</a> link here')
374 );
375 $form['openurl']['biblio_baseopenurl'] = array(
376 '#type' => 'textfield',
377 '#title' => t('OpenURL Base URL'),
378 '#size' => 95,
379 '#default_value' => variable_get('biblio_baseopenurl', ''),
380 '#description' => t('This sets your institution\'s base <a href="http://en.wikipedia.org/wiki/OpenURL">OpenURL</a> gateway, which is used to generate OpenURL links. To implement a "Universal" OpenURL system, try using OCLC\'s <a href="http://www.oclc.org/productworks/urlresolver.htm">OpenURL Resolver Registry</a> gateway: <a href="http://worldcatlibraries.org/registry/gateway">http://worldcatlibraries.org/registry/gateway</a>')
381 );
382 $sid = "Biblio:". variable_get('site_name', 'Drupal');
383 $form['openurl']['biblio_openurl_sid'] = array(
384 '#type' => 'textfield',
385 '#title' => t('OpenURL Site ID'),
386 '#size' => 95,
387 '#default_value' => variable_get('biblio_openurl_sid', $sid),
388 '#description' => t('This sets your institution\'s site name, some link resolvers will require a specific Site ID in order to process your requests.')
389 );
390 $form['openurl']['biblio_openurlimage'] = array(
391 '#type' => 'textfield',
392 '#title' => t('OpenURL Image'),
393 '#size' => 95,
394 '#default_value' => variable_get('biblio_openurlimage', ''),
395 '#description' => t('Enter a path to your image here, this image will be used as button which when clicked will find the entry via the OpenURL link')
396 );
397 // Add profile page settings... this is done in a fucntion so it can be reused elsewhere
398 _biblio_get_user_profile_form($form);
399 //
400 if (!module_exists('search')) {
401 $search_text = '<div class="admin-dependencies">'. t('Depends on') .': '. t('Search') .' (<span class="admin-disabled">'. t('disabled') .'</span>)</div>';
402 $search_disabled = TRUE;
403 variable_set('biblio_footnotes_integration', 0);
404 }
405 else {
406 $search_text = '<div class="admin-dependencies">'. t('Depends on') .': '. t('Search') .' (<span class="admin-enabled">'. t('enabled') .'</span>)</div>';
407 $search_disabled = FALSE;
408 }
409 $form['search'] = array(
410 '#type' => 'fieldset',
411 '#collapsible' => TRUE,
412 '#collapsed' => TRUE,
413 '#description' => $search_text,
414 '#title' => t('Search'),
415 );
416 $form['search']['biblio_search'] = array(
417 '#type' => 'checkbox',
418 '#disabled' => $search_disabled,
419 '#title' => t('Enable a search box on the biblio page.'),
420 '#return_value' => 1,
421 '#default_value' => variable_get('biblio_search', 0),
422 '#description' => t('Shows a search box on the biblio page that returns drupal search results in the biblio style.')
423 );
424 $form['search']['biblio_search_button_text'] = array(
425 '#type' => 'textfield',
426 '#title' => t('Search button text'),
427 '#disabled' => $search_disabled,
428 '#size' => 95,
429 '#default_value' => variable_get('biblio_search_button_text', t('Biblio search')),
430 '#description' => t('This allows you to customize the text on the search button, it defaults to "Biblio search".')
431 );
432 $form['search']['biblio_index'] = array(
433 '#type' => 'checkbox',
434 '#disabled' => $search_disabled,
435 '#title' => t('Re-/Index a biblio node when creating or updating.'),
436 '#return_value' => 1,
437 '#default_value' => variable_get('biblio_index', 0),
438 '#description' => t('A biblio node must be indexed for the drupal search to know its content. You need to check this option if you want to search for a biblio node that you just created or updated. Otherwise you must wait for the cron job to reindex nodes.')
439 );
440 $form['sort'] = array(
441 '#type' => 'fieldset',
442 '#collapsible' => TRUE,
443 '#collapsed' => TRUE,
444 '#title' => t('Sorting'),
445 '#description' => t('You can set the default sorting and ordering for the /biblio page here.')
446 );
447 $form['sort']['biblio_sort'] = array(
448 '#type' => 'radios',
449 '#title' => t('Sort by'),
450 '#default_value' => variable_get('biblio_sort', 'year'),
451 '#options' => array(
452 'author' => t('Author'),
453 'keyword' => t('Keyword'),
454 'title' => t('Title'),
455 'type' => t('Type'),
456 'year' => t('Year')
457 )
458 );
459 $form['sort']['biblio_sort_tabs'] = array(
460 '#type' => 'checkboxes',
461 '#title' => t('Show sort links'),
462 '#default_value' => variable_get('biblio_sort_tabs', array('author', 'title', 'type', 'year')),
463 '#options' => array(
464 'author' => t('Author'),
465 'keyword' => t('Keyword'),
466 'title' => t('Title'),
467 'type' => t('Type'),
468 'year' => t('Year')
469 ),
470 '#description' => t('You turn the sorting links at the top of the /biblio page here.')
471 );
472 $form['sort']['biblio_sort_tabs_style'] = array(
473 '#type' => 'checkbox',
474 '#title' => t('Show sort links as "tabs"'),
475 '#default_value' => variable_get('biblio_sort_tabs_style', 0),
476 '#return_value' => 1,
477 '#description' => t('This changes the sort links from text links to tabs')
478 );
479 $form['sort']['biblio_order'] = array(
480 '#type' => 'radios',
481 '#title' => t('Order'),
482 '#default_value' => variable_get('biblio_order', 'DESC'),
483 '#options' => array(
484 'DESC' => t('Descending'),
485 'ASC' => t('Ascending')
486 )
487 );
488 $form['style'] = array(
489 '#type' => 'fieldset',
490 '#collapsible' => TRUE,
491 '#collapsed' => TRUE,
492 '#title' => t('Styling'),
493 '#description' => t('You can set the default style for the /biblio page here.')
494 );
495 $form['style']['biblio_no_year_text'] = array(
496 '#type' => 'textfield',
497 '#title' => t('Text to display if no year of publication is available'),
498 '#size' => 95,
499 '#default_value' => variable_get('biblio_no_year_text', t('Submitted')),
500 '#description' => t('The text that is displayed when no date of publication is given or it is deliberately set to <b>9999</b>, it defaults to "Submitted".')
501 );
502 $form['style']['biblio_inpress_year_text'] = array(
503 '#type' => 'textfield',
504 '#title' => t('Text to display if year of publication is set to 9998'),
505 '#size' => 95,
506 '#default_value' => variable_get('biblio_inpress_year_text', t('In Press')),
507 '#description' => t('The text that is displayed when the date of publication is deliberately set to <b>9998</b>, it defaults to "In Press".')
508 );
509
510 $form['style']['biblio_style'] = array(
511 '#type' => 'radios',
512 '#title' => t('Style'),
513 '#default_value' => variable_get('biblio_style', 'cse'),
514 '#options' => _biblio_admin_get_styles(),
515 '#description' => t('Set the bibliographic style of the "list" view.')
516 );
517
518 $form['style']['biblio_node_layout'] = array(
519 '#type' => 'radios',
520 '#title' => t('Node Layout'),
521 '#default_value' => variable_get('biblio_node_layout', 'tabular'),
522 '#options' => array(
523 'orig' => t('Original'),
524 'ft' => t('Only Fulltext if available'),
525 'tabular' => t('Tabular')
526 ),
527 '#description' => t('This alters the layout of the "node" (full) view.')
528 );
529 $form['style']['biblio_annotations'] = array(
530 '#type' => 'select',
531 '#title' => t('Annotations'),
532 '#default_value' => variable_get('biblio_annotations', 'none'),
533 '#options' => array(
534 'none' => t('none'),
535 'biblio_notes' => t('notes'),
536 'biblio_custom1' => t('custom1'),
537 'biblio_custom2' => t('custom2'),
538 'biblio_custom3' => t('custom3'),
539 'biblio_custom4' => t('custom4'),
540 'biblio_custom5' => t('custom5'),
541 'biblio_custom6' => t('custom6'),
542 'biblio_custom7' => t('custom7')
543 ),
544 '#description' => t('Select a field from which an annotation will be displayed below biblo entry in "short" listings'),
545 '#multiple' => FALSE,
546 '#size' => 0
547 );
548 $form['syndication'] = array(
549 '#type' => 'fieldset',
550 '#collapsible' => TRUE,
551 '#collapsed' => TRUE,
552 '#title' => t('Syndication'),
553 '#description' => t('You can set the RSS defaults here.')
554 );
555 $form['syndication']['biblio_rss'] = array(
556 '#type' => 'checkbox',
557 '#title' => t('Allow RSS feeds of new biblio entries'),
558 '#return_value' => 1,
559 '#default_value' => variable_get('biblio_rss', 0),
560 '#description' => t('This will create an rss feed of the 10 most recent biblio entries. It will be available at /biblio/rss.xml')
561 );
562 $form['syndication']['biblio_rss_number_of_entries'] = array(
563 '#type' => 'textfield',
564 '#title' => t('Number of items in the RSS feed.'),
565 '#default_value' => variable_get('biblio_rss_number_of_entries', 10),
566 '#size' => 6,
567 '#maxlength' => 6,
568 '#description' => t('Limits the number of items in the /biblio/rss.xml feed to this number.')
569 );
570
571 $form = system_settings_form($form);
572 $form['#submit'][] = 'biblio_admin_settings_form_submit';
573 // our submit handler is added after the call to system settings form so that it gets
574 // called after system_settings_form_submit, and thus the variables have been stored already
575 // and the menu will be rebuilt correctly.
576 return ($form);
577 }
578 function biblio_admin_settings_form_submit($form, $form_state) {
579 if ($form_state['values']['biblio_keyword_freetagging'] && $form_state['values']['biblio_keyword_vocabulary']) {
580 if ($vocabulary = taxonomy_vocabulary_load(variable_get('biblio_keyword_vocabulary', 0))) {
581 $vocabulary = (array) $vocabulary;
582 $vocabulary['nodes']['biblio'] = 1;
583 taxonomy_save_vocabulary($vocabulary);
584 }
585 }
586
587 menu_rebuild();
588 }
589 function biblio_admin_types_edit_form() {
590 $tid = 0;
591 $arg_list = func_get_args();
592 $tid = is_numeric($arg_list[1]) ? $arg_list[1] : 0;
593 $msg = '<div>'. t('On this page you can set type specific "Titles" and "Hints" which will display on the input form. ');
594 if ($tid) {
595 $msg .= t('Checking the "Visible" box will add the field to the input form, checking "Required" will force the user to supply a value for this field and the weight value changes the order which it is rendered on the form with smaller values floating to the top of the form. ');
596 $msg .= '<p>'. t('Fields which are grayed out on this page have been set to "common" on the ');
597 $msg .= l("admin/settings/biblio/fields", "admin/settings/biblio/fields");
598 $msg .= t(' page.').'</p>';
599 }
600 else {
601 $msg .= t('Checking the "Common" box will add the field to all the different publication types. Checking "Required" will force the user to supply a value for the field, checking "Autocomplete" will enable AJAX type auto complete look up for the field when the user is entering data and the weight value changes the order which it is rendered on the form with smaller values floating to the top of the form. ');
602 }
603 $msg .= t('Finally, for each author field you can choose a set of author roles. Assigning different roles to authors within the same field, e.g. primary and secondary authors within the authors field, allows to theme them differently.');
604 $msg .= '</div>';
605 $form['#redirect'] = 'admin/settings/biblio/type';
606 $form['help'] = array(
607 '#type' => 'fieldset',
608 '#title' => t('Help'),
609 '#collapsible' => TRUE,
610 '#collapsed' => TRUE
611 );
612 $form['help']['message'] = array(
613 '#type' => 'markup',
614 '#value' => $msg
615 );
616 // get author types
617 $result = db_query("SELECT * FROM {biblio_contributor_type_data} b");
618 $contrib_options = array();
619 while($contrib_type = db_fetch_object($result)) {
620 $contrib_options[$contrib_type->auth_type] = $contrib_type->title;
621 $contrib_hints[$contrib_type->auth_type] = $contrib_type->hint;
622 }
623
624 // first get all of the field info
625 if ($tid) {
626 $result = db_query("SELECT bf.*, bftd.*, bft.common, bft.visible, bft.autocomplete, bft.weight, bft.required, bt.name AS type_name
627 FROM {biblio_fields} AS bf
628 INNER JOIN {biblio_field_type} AS bft ON bft.fid=bf.fid
629 INNER JOIN {biblio_field_type_data} AS bftd ON bftd.ftdid=bft.ftdid
630 INNER JOIN {biblio_types} AS bt ON bt.tid=bft.tid
631 WHERE bft.tid=$tid");
632 }
633 else {
634 $result = db_query("SELECT bf.*, bftd.*, bft.common, bft.visible, bft.autocomplete, bft.weight, bft.required
635 FROM {biblio_fields} AS bf
636 INNER JOIN {biblio_field_type} AS bft ON bft.fid=bf.fid
637 INNER JOIN {biblio_field_type_data} AS bftd ON bftd.ftdid=bft.ftdid
638 WHERE bft.tid=$tid");
639 }
640 while ($row = db_fetch_array($result)) {
641 $fields[$row['fid']] = $row;
642 }
643 $form['configured_flds'] = array('#tree' => 1);
644 if ($tid) { // show an existing type
645 $typename = $fields[1]['type_name'];
646 $form['type_name'] = array(
647 '#type' => 'value',
648 '#title' => 'tid',
649 '#value' => $typename
650
651 );
652 $form['top_message'] = array(
653 '#value' => t('Field settings related to @type publications',array('@type' => $typename))
654 );
655 $form['type_id'] = array(
656 '#type' => 'value',
657 '#title' => 'tid',
658 '#value' => $tid
659 );
660 } else {
661 $form['top_message'] = array(
662 '#value' => t('Field settings common to all publication types')
663 );
664
665 }
666 uasort($fields, "biblio_form_sort"); // resort the fields since the weight may have changed
667 $vis_comm = $tid ? 'visible' : 'common';
668 $options["$vis_comm"] = '';
669 $options['required'] = '';
670 if ($tid == 0)
671 $options['autocomplete'] = '';
672 foreach ($fields as $key => $fld) {
673 $def_values[$fld['name']] = array();
674 if ($tid) {
675 if ($fld['visible'] )
676 array_push($def_values[$fld['name']], 'visible');
677 if ($fld['required'])
678 array_push($def_values[$fld['name']], 'required');
679 }
680 else {
681 if ($fld['common'])
682 array_push($def_values[$fld['name']], 'common');
683 if ($fld['required'])
684 array_push($def_values[$fld['name']], 'required');
685 if ($fld['autocomplete'])
686 array_push($def_values[$fld['name']], 'autocomplete');
687 }
688 $disabled = $tid ? ($fld['common'] ? 1 : 0) : 0;
689 $form['configured_flds'][$key]['name'] = array(
690 '#type' => 'markup',
691 '#value' => $fld['name'],
692 '#weight' => $fld['weight']
693 );
694 $form['configured_flds'][$key]['title'] = array(
695 '#type' => 'textfield',
696 '#default_value' => $fld['title'],
697 '#size' => 15,
698 '#weight' => $fld['weight'],
699 '#disabled' => $disabled
700 );
701 $form['configured_flds'][$key]['hint'] = array(
702 '#type' => 'textfield',
703 '#default_value' => $fld['hint'],
704 '#size' => 20,
705 '#weight' => $fld['weight'],
706 '#disabled' => $disabled
707 );
708 $form['configured_flds'][$key]['weight'] = array(
709 '#type' => 'textfield',
710 '#default_value' => $fld['weight'],
711 '#size' => 2,
712 '#weight' => $fld['weight'],
713 //'#disabled' => $disabled
714 );
715 $form['configured_flds'][$key]['checkboxes'] = array(
716 '#type' => 'checkboxes',
717 '#options' => $options,
718 '#default_value' => $def_values[$fld['name']],
719 '#weight' => $fld['weight'],
720 //'#disabled' => $disabled
721 );
722 $form['configured_flds'][$key]['ftdid'] = array(
723 '#type' => '#value',
724 '#value' => $fld['ftdid']
725 );
726 if ($fld['type'] == 'contrib_widget') {
727 $cur = _biblio_get_auth_types($fld['fid'], $tid ? $tid : $fld['fid']);
728 $form['configured_flds'][$key]['auth_type'] = array(
729 '#type' => 'select',
730 '#options' => $contrib_options,
731 '#size' => min(count($contrib_options), 4),
732 '#multiple' => TRUE,
733 '#default_value' => _biblio_get_auth_types($fld['fid'], $disabled ? 0 : $tid),
734 '#disabled' => $disabled
735 );
736 }
737 }
738 $form['submit'] = array(
739 '#type' => 'submit',
740 '#value' => t('Save')
741 );
742
743 return $form;
744 }
745
746 function biblio_admin_types_edit_form_submit($form, & $form_state) {
747 $tid = $form_state['values']['type_id'];
748 if (empty($tid)) $tid = 0;
749 // save author types
750 $link['biblio_type'] = $tid;
751 db_query('DELETE FROM {biblio_contributor_type} WHERE biblio_type=%d', $link['biblio_type']);
752 for($i=1; $i<=5; $i++) {
753 $link['auth_category'] = $i;
754 $auth_types = (array)$form_state['values']['configured_flds'][$i]['auth_type'];
755 // if default values have not changed, do not store to the database explicitly
756 if ($link['biblio_type'] &&
757 (array_values($auth_types) == array_values((array)$form['configured_flds'][$i]['auth_type']['#default_value']))) continue;
758 foreach ($auth_types as $type) {
759 $link['auth_type'] = $type;
760 drupal_write_record('biblio_contributor_type', $link);
761 }
762 }
763 // save other field data
764 foreach ($form_state['values']['configured_flds'] as $fid => $values) {
765 $update = FALSE;
766 $val = array();
767 $link = array();
768 $link['fid'] = $fid;
769 $link['tid'] = $tid;
770 foreach ($values as $name => $value) {
771 if (!$form['configured_flds'][$fid][$name]['#disabled']) {
772 $default_value = $form['configured_flds'][$fid][$name]['#default_value'];
773 if ($name == 'checkboxes') {
774 $link['visible'] = (!empty($value['visible'])) ? 1 : 0;
775 $link['required'] = (!empty($value['required'])) ? 1 : 0;
776 if ($tid == 0) {
777 $link['common'] = (!empty($value['common'])) ? 1 : 0;
778 $link['autocomplete'] = (!empty($value['autocomplete'])) ? 1 : 0;
779 }
780 }
781 elseif ($name == weight) {
782 $link['weight'] = $value;
783 } else {
784 $val[$name] = $value;
785 if (!$update)
786 $update = ($default_value != $val[$name]) ? $form['configured_flds'][$fid]['ftdid']['#value'] : FALSE;
787 }
788 }
789 }
790 if ($update == $fid && $link['tid']) { // we just changed a default value, so create a new entry in biblio_field_type_data
791 $new_ftdid = variable_get('biblio_last_ftdid', 100);
792 variable_set('biblio_last_ftdid', $new_ftdid + 1);
793 $val['ftdid'] = $new_ftdid;
794 $link['ftdid'] = $new_ftdid;
795 $link['cust_tdid'] = $new_ftdid;
796 drupal_write_record('biblio_field_type_data', $val);
797
798 } elseif ($update >= 100 && $link['tid']) { // we are updating an existing entry
799 $val['ftdid'] = $form['configured_flds'][$fid]['ftdid']['#value'];
800 drupal_write_record('biblio_field_type_data', $val, 'ftdid');
801
802 } elseif ($update == $fid) { // changing the defaults
803 $val['ftdid'] = $fid;
804 drupal_write_record('biblio_field_type_data', $val, 'ftdid');
805 }
806
807 drupal_write_record('biblio_field_type', $link, array('fid','tid'));
808
809 if($tid == 0) {
810 if ($link['common']) {
811 $query = "UPDATE {biblio_field_type} SET ftdid = %d, common = %d, visible = %d WHERE fid = %d";
812 db_query($query, array($fid, 1, 1, $fid));
813 }
814 else { // not common, so change pointer back to customizations if available
815 $query = "UPDATE {biblio_field_type} SET ftdid = cust_tdid, common = %d WHERE fid = %d";
816 db_query($query, array(0, $fid));
817 }
818 // set the autocomplete bit on this field for all the types
819 $query = "UPDATE {biblio_field_type} SET autocomplete = %d WHERE fid = %d";
820 db_query($query, array($link['autocomplete'], $fid));
821 }
822 }
823 drupal_set_message(t("The changes have been saved."));
824
825 // Clear the cached pages and menus:
826 menu_rebuild();
827 }
828
829 function biblio_admin_type_mapper_page() {
830 $output .= '<h3>'.t('Choose a file format to modify').'</h3><p />';
831 $output .= l('BibTex', 'admin/settings/biblio/fields/typemap/bibtex').'<br>';
832 $output .= l('RIS', 'admin/settings/biblio/fields/typemap/ris').'<br>';
833 $output .= l('EndNote Tagged', 'admin/settings/biblio/fields/typemap/tagged').'<br>';
834 $output .= l('EndNote 7 XML', 'admin/settings/biblio/fields/typemap/endnote7').'<br>';
835 $output .= l('EndNote X3 XML', 'admin/settings/biblio/fields/typemap/endnote8').'<br>';;
836 $output .= l('CrossRef XML', 'admin/settings/biblio/fields/typemap/unixref').'<br>';
837 return $output;
838 }
839
840 function biblio_admin_type_mapper_form($form_state, $format = 'bibtex', $op = 'map') {
841 module_load_include('inc', 'biblio', 'biblio.type.mapper');
842 $names = biblio_get_type_names($format);
843 $map = biblio_get_type_map($format);
844 ksort($names);
845 $form['fileformat'] = array(
846 '#type' => 'hidden',
847 '#value' => $format,
848 );
849 $form['submit'] = array(
850 '#type' => 'submit',
851 '#value' => t('Save'),
852 );
853 $form['reset'] = array(
854 '#type' => 'submit',
855 '#value' => t('Reset to Defaults'),
856 );
857 $form['#redirect'] = 'admin/settings/biblio/fields/typemap';
858
859 if ($op == 'map') {
860 $result = db_query('SELECT t.* FROM {biblio_types} as t WHERE t.tid > 0');
861 while ($type = db_fetch_object($result)) {
862 $biblio_type_options[$type->tid] = $type->name;
863 }
864 asort($biblio_type_options);
865 $biblio_type_select = array(
866 '#type' => 'select',
867 '#options' => $biblio_type_options,
868 );
869 foreach ($names as $key => $value) {
870 $biblio_type_select['#default_value'] = $map[$key];
871 $form['type'][$key] = array(
872 'format' => array('#value' => "<b>$key</b> (<i>$value</i>)"),
873 'biblio' => $biblio_type_select,
874 '#tree' => 1,
875 );
876
877 }
878 }
879 elseif($op == 'add') {
880 $form['type_name'] = array(
881 '#type' => 'textfield',
882 '#title' => 'Publication Type',
883 '#required' => TRUE,
884 '#description' => t('This is the name of the type identifier, exactly as it appears in the file'),
885 );
886 $form['type_desc'] = array(
887 '#type' => 'textfield',
888 '#title' => 'Description'
889 );
890 $form['submit']['#value'] = t('Add');
891 unset($form['reset']);
892 $form['#redirect'] = 'admin/settings/biblio/fields/typemap/'.$format;
893 }
894
895 return $form;
896 }
897
898 function theme_biblio_admin_type_mapper_form($form) {
899 switch ($form['fileformat']['#value']) {
900 case 'bibtex':
901 $title = 'BibTex';
902 break;
903 case 'ris':
904 $title = 'RIS';
905 break;
906 case 'tagged':
907 $title = 'EndNote Tagged';
908 break;
909 case 'endnote7':
910 $title = 'EndNote 7 and earlier XML';
911 break;
912 case 'endnote8':
913 $title = 'EndNote 8 and later XML';
914 break;
915 }
916 if ($form['submit']['#value'] == t('Save')) {
917 drupal_set_title($title.' '.t('Type Mapping'));
918 foreach(element_children($form['type']) as $key ){
919 $rows[] = array(
920 drupal_render($form['type'][$key]['format']),
921 drupal_render($form['type'][$key])
922 );
923 }
924 $header = array(
925 $title .' '.t('Publication Types'),
926 t('Biblio Publication Type')
927 );
928 $output .= theme('table', $header, $rows);
929 $output .= l('['.t('Add New'). " $title ".t('Publication Type').']','admin/settings/biblio/fields/typemap/'.$form['fileformat']['#value'].'/add').' ';
930 $output .= l('['.t('Add New Biblio Publication Type').']','admin/settings/biblio/fields/type/new').'<br />';
931 }
932 elseif($form['submit']['#value'] == t('Add')) {
933 drupal_set_title(t('Add new publication type to '). $title.' '.t('file type'));
934 $output .= drupal_render($form['type_name']);
935 $output .= drupal_render($form['type_desc']);
936 }
937 $output .= drupal_render($form['submit']);
938 $output .= drupal_render($form['reset']);
939 $output .= drupal_render($form);
940
941 return $output;
942 }
943
944 function biblio_admin_type_mapper_form_submit($form, $form_state) {
945 if ($form_state['values']['op'] == t('Save')) {
946 foreach($form_state['values'] as $key => $value) {
947 if (is_array($value)) {
948 $map[$key]=$value['biblio'];
949 }
950 }
951 variable_set('biblio_'.$form_state['values']['fileformat'] .'_type_map', $map);
952 }
953 elseif ($form_state['values']['op'] == t('Reset to Defaults')) {
954 variable_del('biblio_'. $form_state['values']['fileformat'] .'_type_map');
955 variable_del('biblio_'. $form_state['values']['fileformat'] .'_type_names');
956 }
957 elseif ($form_state['values']['op'] == t('Add')) {
958 $names = biblio_get_type_names($form_state['values']['fileformat']);
959 $names[$form_state['values']['type_name']] = $form_state['values']['type_desc'];
960 variable_set('biblio_'.$form_state['values']['fileformat'] .'_type_names', $names);
961 }
962 //drupal_goto('admin/settings/biblio/fields/typemap');
963 }
964
965 function biblio_admin_types_form() {
966 $result = db_query('SELECT t.* FROM {biblio_types} as t WHERE t.tid > 0');
967 //$rows[] = array('',t('Fields Common To All Types'),l('edit', 'admin/settings/biblio/types/edit'),'');
968 while ($row = db_fetch_object($result)) {
969 if ($row->tid < 999) {
970 $rows[] = array(
971 $row->tid,
972 $row->name,
973 ($row->visible) ? l(t('edit'), 'admin/settings/biblio/fields/type/edit/'. $row->tid) : '', ($row->visible) ? l(t('hide'), 'admin/settings/biblio/fields/type/hide/'. $row->tid) : l(t('show'), 'admin/settings/biblio/fields/type/show/'. $row->tid)
974 );
975 }
976 else {
977 $rows[] = array(
978 $row->tid,
979 $row->name,
980 l(t('edit'), 'admin/settings/biblio/fields/type/edit/'. $row->tid), l(t('delete'), 'admin/settings/biblio/fields/type/delete/'. $row->tid)
981 );
982 }
983 }
984 $header = array(
985 t('Type Id'),
986