You are here

function _activeedit_prepare in Javascript Tools 5

1 call to _activeedit_prepare()
activeedit_get_targets in activeedit/activeedit.module

File

activeedit/activeedit.module, line 171

Code

function _activeedit_prepare(&$targets, $selectors, $settings) {
  foreach (element_children($targets) as $key) {

    // Convert to appropriate paths.
    $targets[$key]['#target'] = url($targets[$key]['#target']);

    // Allow overrides of the selectors.
    $targets[$key]['#selector'] = $selectors[$key] ? $selectors[$key] : variable_get('activeedit_selector_' . $key, $targets[$key]['#selector']);

    // Add form for bars.
    if ($settings['#send_form'] && $targets[$key]['#form_function'] && function_exists($targets[$key]['#form_function'])) {
      $node = new StdClass();

      // Set to an available node type.
      $node->type = key(node_get_types());
      $form = $targets[$key]['#form_function']($node);
      $targets[$key]['#form_data'] = drupal_get_form('activeedit_bars_form', $form);
    }

    // Unset the properties we don't need to pass to the client.
    foreach (element_properties($targets[$key]) as $property) {
      if (!in_array($property, array(
        '#selector',
        '#target',
        '#title',
        '#marker',
        '#parent',
        '#text',
        '#form_data',
        '#id_field',
      ))) {
        unset($targets[$key][$property]);
      }
    }
    _activeedit_prepare($targets[$key], $selectors, $settings);
  }
}