You are here

function finder_format_wheres in Finder 7.2

Format the wheres.

1 call to finder_format_wheres()
finder_build_display_query in includes/build.inc
Does stuff during the display handler's query.

File

includes/build.inc, line 247
The finder build functions.

Code

function finder_format_wheres($finder, $element_ids, $wheres) {
  $formatted_wheres = array();
  foreach ($element_ids as $element_id) {
    $element = $finder->elements[$element_id];
    $children = $finder
      ->element_children($element);
    if (!empty($children)) {
      $operator = $element->settings['element_logic'];
      $child_wheres = finder_format_wheres($finder, $children, $wheres);
      $child_where_snippets = array();
      $child_where_args = array();
      foreach ($child_wheres as $child_where) {
        if (!empty($child_where['snippet'])) {
          $child_where_snippets[] = $child_where['snippet'];
        }
        foreach ($child_where['args'] as $child_where_arg_key => $child_where_arg_val) {
          $child_where_args[$child_where_arg_key] = $child_where_arg_val;
        }
      }

      //$formatted_wheres[] = array(

      //  'snippet' => !empty($child_where_snippets) ? finder_implode_wheres($operator, $child_where_snippets) : '',
      //  'args' => $child_where_args,

      //);
      if (!empty($child_where_snippets)) {
        $formatted_wheres[] = array(
          'snippet' => finder_implode_wheres($operator, $child_where_snippets),
          'args' => $child_where_args,
        );
      }
    }
    if (!empty($wheres[$element_id])) {
      foreach ($wheres[$element_id] as $where) {
        $formatted_wheres[] = $where;
      }
    }
  }
  return $formatted_wheres;
}