| 1 |
<?php |
<?php |
| 2 |
// $Id: activeselect.module,v 1.6 2006/03/29 12:51:48 jaza Exp $ |
// $Id: activeselect.module,v 1.7 2006/04/09 05:11:52 jaza Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* Defines the activeselect form element, which allows modules to have |
* Defines the activeselect form element, which allows modules to have |
| 7 |
* AJAX-enabled select boxes. |
* AJAX-enabled select boxes. |
| 8 |
*/ |
*/ |
| 9 |
|
|
| 29 |
} |
} |
| 30 |
|
|
| 31 |
/** |
/** |
| 32 |
* Converts the string of values passed to an activeselect callback function |
* Converts the string of values passed to an activeselect callback function |
| 33 |
* into an array. |
* into an array. |
| 34 |
* |
* |
| 35 |
* @param $string |
* @param $string |
| 36 |
* The string of values passed to an activeselect callback. |
* The string of values passed to an activeselect callback. |
| 37 |
* |
* |
| 38 |
* @return |
* @return |
| 39 |
* An array of values, in the form $key => $value. |
* An array of values, in the form $key => $value. |
| 40 |
*/ |
*/ |
| 45 |
$array[$match[0]] = html_entity_decode($match[1]); |
$array[$match[0]] = html_entity_decode($match[1]); |
| 46 |
unset($array[$key]); |
unset($array[$key]); |
| 47 |
} |
} |
| 48 |
|
|
| 49 |
return $array; |
return $array; |
| 50 |
} |
} |
| 51 |
|
|
| 76 |
$extra = ''; |
$extra = ''; |
| 77 |
if ($element['#activeselect_path'] && $element['#activeselect_targets']) { |
if ($element['#activeselect_path'] && $element['#activeselect_targets']) { |
| 78 |
$module_path = drupal_get_path('module', 'activeselect'). '/'; |
$module_path = drupal_get_path('module', 'activeselect'). '/'; |
| 79 |
theme('add_style', $module_path. 'activeselect.css'); |
theme_add_style($module_path. 'activeselect.css'); |
| 80 |
drupal_add_js($module_path. 'activeselect.js'); |
drupal_add_js($module_path. 'activeselect.js'); |
| 81 |
$class[] = ' form-activeselect'; |
$class[] = ' form-activeselect'; |
| 82 |
$extra = '<input class="activeselect-path" type="hidden" id="'. $element['#id'] .'-activeselect-path" value="'. check_url(url($element['#activeselect_path'], NULL, NULL, TRUE)) .'" disabled="disabled" />'. "\n"; |
$extra = '<input class="activeselect-path" type="hidden" id="'. $element['#id'] .'-activeselect-path" value="'. check_url(url($element['#activeselect_path'], NULL, NULL, TRUE)) .'" disabled="disabled" />'. "\n"; |
| 88 |
$extra .= '<input class="activeselect-extra" type="hidden" id="'. $element['#id'] .'-activeselect-extra" value="'. check_plain($element['#activeselect_extra']) .'" disabled="disabled" />'. "\n"; |
$extra .= '<input class="activeselect-extra" type="hidden" id="'. $element['#id'] .'-activeselect-extra" value="'. check_plain($element['#activeselect_extra']) .'" disabled="disabled" />'. "\n"; |
| 89 |
} |
} |
| 90 |
_form_set_class($element, $class); |
_form_set_class($element, $class); |
| 91 |
|
|
| 92 |
return theme('form_element', $element['#title'], '<select name="'. $element['#name'] .''. ($element['#multiple'] ? '[]' : '') .'"'. ($element['#multiple'] ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="' . $element['#id'] .'" '. $size. '>'. form_select_options($element) .'</select>', $element['#description'], $element['#id'], $element['#required'], form_get_error($element)). $extra; |
return theme('form_element', $element['#title'], '<select name="'. $element['#name'] .''. ($element['#multiple'] ? '[]' : '') .'"'. ($element['#multiple'] ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="' . $element['#id'] .'" '. $size. '>'. form_select_options($element) .'</select>', $element['#description'], $element['#id'], $element['#required'], form_get_error($element)). $extra; |
| 93 |
} |
} |