| 1 |
<?php
|
| 2 |
// $Id: active_tags.module,v 1.1 2008/09/12 08:31:03 darrenmuk Exp $
|
| 3 |
|
| 4 |
function active_tags_init() {
|
| 5 |
if (arg(2) == 'edit' || arg(1) == 'add') {
|
| 6 |
drupal_add_css(drupal_get_path('module', 'active_tags') . '/active_tags.css', 'module');
|
| 7 |
$settings = array();
|
| 8 |
foreach (taxonomy_get_vocabularies() as $id => $values) {
|
| 9 |
if (variable_get('active_tags_'.$id, 0) == 1) {
|
| 10 |
$settings[] = "#edit-taxonomy-tags-$id-wrapper";
|
| 11 |
}
|
| 12 |
}
|
| 13 |
drupal_add_js(array('active_tags' => $settings), 'setting');
|
| 14 |
drupal_add_js(drupal_get_path('module', 'active_tags') . '/active_tags.js', 'module');
|
| 15 |
}
|
| 16 |
}
|
| 17 |
|
| 18 |
function active_tags_form_alter(&$form, $form_state, $form_id) {
|
| 19 |
if ($form_id == 'taxonomy_form_vocabulary') {
|
| 20 |
$form['settings']['active_tags'] = array(
|
| 21 |
'#type' => 'checkbox',
|
| 22 |
'#title' => t('Active Tags'),
|
| 23 |
'#default_value' => (isset($form['vid'])) ? variable_get('active_tags_'.$form['vid']['#value'], 0) : 0,
|
| 24 |
'#description' => t('Swaps this vocabulary widget for an enhanced tag field if browser supports javascript.'),
|
| 25 |
);
|
| 26 |
$form['#submit'][] = 'active_tags_form_vocabulary_submit';
|
| 27 |
}
|
| 28 |
}
|
| 29 |
|
| 30 |
function active_tags_form_vocabulary_submit($form, &$form_state) {
|
| 31 |
variable_set('active_tags_'.$form_state['values']['vid'], $form_state['values']['active_tags']);
|
| 32 |
return true;
|
| 33 |
}
|
| 34 |
|
| 35 |
|
| 36 |
|