You are here

function finder_view in Finder 7

Same name and namespace in other branches
  1. 6 finder.module \finder_view()

Generate display of a given finder.

@todo Take better advantage of Drupal 7's render array.

Parameters

$finder: The finder object to generate the output for.

$display: The type of display ('page', or 'block').

$ajax: Whether in the context of an ajax request.

Return value

Themed output of a finder.

3 calls to finder_view()
finder_ajax in ./finder.module
Menu callback; get finder ajax output.
theme_finder_block in includes/finder.theme.inc
Theme the finder block wrapper.
theme_finder_page in includes/finder.theme.inc
Theme the finder page wrapper.
1 string reference to 'finder_view'
finder_i18nstrings_finderapi in modules/finder_i18nstrings/finder_i18nstrings.module
Implements hook_finderapi().

File

./finder.module, line 598
The finder module.

Code

function finder_view($finder, $display, $ajax = FALSE) {
  finder_inc('form');
  finder_invoke_finderapi($finder, 'finder_view', $display);
  $output_array = array();
  $finder->finder_view_build_id = 'finder-' . $display . '-' . $finder->finder_id . '-wrapper';
  $finder->finder_view_build_display = $display;

  // Always get the form in order to populate the form_state in case there are results we need to present.
  // The form building function will not spend resources building elements if it doesn't need to.
  // to do: this non form_on_page get_form may only be needed when hiding url args?
  $form = drupal_get_form('finder_form_' . $finder->finder_id, $finder);
  if ($finder->settings['advanced']['show_admin_links'] && user_access('administer finder')) {
    $output['admin_links'] = theme('finder_admin_links', array(
      'finder' => $finder,
    ));
  }
  if ($display != 'page' || $display == 'page' && $finder->settings['form_on_page']) {
    $output['form'] = drupal_render($form);
  }
  if ($finder->settings['advanced']['show_links']) {
    $output['links'] = theme('finder_links', array(
      'finder' => $finder,
    ));
  }
  if ($display != 'block' || $display == 'block' && $ajax) {
    $output['results'] = finder_results($finder);
  }
  $rendered = '';
  $rendered .= $ajax ? '' : '<div id="' . $finder->finder_view_build_id . '" class="finder-view-wrapper">';
  $rendered .= theme('finder_view', array(
    'finder' => $finder,
    'display' => $display,
    'output_array' => $output,
  ));
  $rendered .= $ajax ? '' : '</div>';
  return $rendered;
}