function mathfield_get_tokens in Math Field 7
Get the element details for mathfield expression tokens.
Parameters
array $element: The mathfield element.
Return value
array An associative array of elements keyed by token. Each element is an associative array with the following keys:
- selector: The jQuery selector to watch for changes.
- event: The jQuery event to trigger the reevaluation of the mathfield.
1 call to mathfield_get_tokens()
- mathfield_widget_afterbuild in ./
mathfield.module - Afterbuild callback for the mathfield widgets.
File
- ./
mathfield.module, line 558 - Adds a dynamic math expression field.
Code
function mathfield_get_tokens($element) {
$return = array();
$expression = $element['#settings']['expression'];
$tokens = _mathfield_extract_tokens($expression);
foreach ($tokens as $token => $context) {
$field = field_info_field($context['field_name']);
$context += array(
'token' => $token,
'field' => $field,
'instance' => field_info_instance($element['#entity_type'], $context['field_name'], $element['#bundle']),
'element' => $element,
);
// Allow modules to add mathfield support.
$data = module_invoke($field['module'], 'mathfield_get_token', $context);
drupal_alter(array(
'mathfield_get_token',
"mathfield_get_token_{$field['module']}",
), $data, $context);
if (!empty($data)) {
$return[$token] = $data;
}
}
return $return;
}