You are here

function fieldset_helper_state_manager_get_element_path in Fieldset helper 7.2

Same name and namespace in other branches
  1. 6.2 fieldset_helper.module \fieldset_helper_state_manager_get_element_path()

Check if a fieldset id matches any global id patterns.

Parameters

$element_id: The DOM element id.

$path: Default path if no match is found.

Return value

The elements path (*, $_GET['q'], or custom).

1 call to fieldset_helper_state_manager_get_element_path()
fieldset_helper_state_manager_get_lookup_id in ./fieldset_helper.module
Get the lookup id for the $element_id in the current path.

File

./fieldset_helper.module, line 258

Code

function fieldset_helper_state_manager_get_element_path($element_id, $path) {
  static $global_patterns;
  if (!isset($global_patterns)) {
    $global_ids = variable_get('fieldset_helper_global_ids', '');
    $global_patterns = '/^(' . preg_replace(array(
      '/(\\r\\n?|\\n)/',
      '/\\\\\\*/',
    ), array(
      '|',
      '.*',
    ), preg_quote($global_ids, '/')) . ')$/';
  }
  $path = preg_match($global_patterns, $element_id) ? '*' : $path;

  // Run all hook implementations for hook_fieldset_helper_element_path_alter().
  foreach (module_implements('fieldset_helper_element_path_alter') as $module) {
    $function = $module . '_fieldset_helper_element_path_alter';
    $function($element_id, $path);
  }
  return $path;
}