You are here

function finder_build_style_render in Finder 7.2

Does stuff during the style plugin's render.

Parameters

&$style_plugin: A reference to the views style plugin object.

1 call to finder_build_style_render()
finder_plugin_style::render in views/finder_plugin_style.inc
Render the display in this style.

File

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

Code

function finder_build_style_render(&$style_plugin) {
  $results = array();

  // Group the rows according to the grouping field, if specified.
  $sets = $style_plugin
    ->render_grouping($style_plugin->view->result, $style_plugin->options['grouping']);
  $finder = $style_plugin->display->display_options['finder'];
  foreach (array_keys($finder->find) as $key) {
    ${$key} =& $finder->find[$key];
  }
  $style_plugin->view->row_index = 0;
  foreach ($sets as $title => $records) {
    foreach ($records as $label => $row) {
      if ($mode == 'choices') {
        foreach ($field_info[$element->id] as $key => $field) {
          $format = isset($field->format) ? $field->format : 'filter_xss';
          foreach (array_keys($field->field_alias) as $delta) {

            // If there is no match field, or if there is and it's set.
            if (!isset($field->field_matched[$delta]) || !empty($field->field_matched[$delta]) && !empty($row->{$field->field_matched[$delta]})) {
              if (!empty($row->{$field->field_alias[$delta]}) && !isset($results[$row->{$field->field_alias[$delta]}])) {
                $value = $row->{$field->field_alias[$delta]};
                if ($finder
                  ->esetting($element, 'choice_display', 'field') == 'rendered') {
                  $display = $style_plugin->row_plugin
                    ->render($row);
                }
                else {
                  $display = $row->{$field->field_alias[$delta]};
                }
                if ($finder
                  ->esetting($element, 'choices_rewrite')) {
                  $variables = array(
                    'element' => $element,
                    'value' => $value,
                    'display' => $display,
                    'row' => $row,
                    'field' => $field,
                    'delta' => $delta,
                  );
                  $display = finder_eval($finder
                    ->esetting($element, 'choices_rewrite'), $variables);
                }
                if ($finder
                  ->esetting($element, 'value_rewrite')) {
                  $variables = array(
                    'element' => $element,
                    'value' => $value,
                    'display' => $display,
                    'row' => $row,
                    'field' => $field,
                    'delta' => $delta,
                  );
                  $value = finder_eval($finder
                    ->esetting($element, 'value_rewrite'), $variables);
                }
                $results[$value] = finder_sanitize($display, $format);
              }
            }
          }
        }
      }
      else {
        if ($finder
          ->setting('results_style') == 'views' || $finder
          ->setting('results_style') == 'custom' && $finder
          ->setting('custom_results_style_render')) {
          $row->render = $style_plugin->row_plugin
            ->render($row);

          // This is code to get rid of extra whitespace, could be useful for some future feature?

          //$row->render = preg_replace('/\s+/', ' ', trim($row->render));
          $row->display_key = 'render';
        }
        $results[] = $row;
      }
      $style_plugin->view->row_index++;
    }
  }
  unset($style_plugin->view->row_index);
  if ($mode == 'results' && empty($results)) {
    return $style_plugin->view->display_handler
      ->render_empty();
  }
  elseif ($mode == 'choices' || $mode == 'results' && $finder
    ->setting('results_style') == 'custom' && !$finder
    ->setting('custom_results_style_render')) {
    return $results;
  }
  else {
    return "[%FINDER_RESULTS%]";
  }
}