You are here

function _botcha_search_buttons in BOTCHA Spam Prevention 6.3

Same name and namespace in other branches
  1. 6 botcha.inc \_botcha_search_buttons()
  2. 6.2 botcha.inc \_botcha_search_buttons()
  3. 7 botcha.inc \_botcha_search_buttons()
  4. 7.2 botcha.inc \_botcha_search_buttons()
  5. 7.3 botcha.module \_botcha_search_buttons()

Helper function for searching the buttons in a form.

Parameters

$form the form to search button elements in:

Return value

an array of paths to the buttons. A path is an array of keys leading to the button, the last item in the path is the weight of the button element (or NULL if undefined).

1 call to _botcha_search_buttons()
_botcha_get_botcha_placement in ./botcha.module
Helper function to get placement information for a given form_id.

File

./botcha.module, line 308
BOTCHA - Spam Prevention It modifies forms by adding various botcha's.

Code

function _botcha_search_buttons($form) {
  $buttons = array();
  foreach (element_children($form) as $key) {

    // Look for submit or button type elements.
    if (isset($form[$key]['#type']) && ($form[$key]['#type'] == 'submit' || $form[$key]['#type'] == 'button')) {
      $weight = isset($form[$key]['#weight']) ? $form[$key]['#weight'] : NULL;
      $buttons[] = array(
        'path' => array(),
        'key' => $key,
        'weight' => $weight,
      );
    }

    // Process children recurively.
    $children_buttons = _botcha_search_buttons($form[$key]);
    foreach ($children_buttons as $b) {
      $b['path'] = array_merge(array(
        $key,
      ), $b['path']);
      $buttons[] = $b;
    }
  }
  return $buttons;
}