You are here

function asset_widget_get_search_results in Asset 7

Build search results renderable array.

1 string reference to 'asset_widget_get_search_results'
asset_widget_get_tabs_info in modules/asset_widget/asset_widget.module
Return all possible widget tabs to render.

File

modules/asset_widget/asset_widget.module, line 525
Code for the Asset widget module.

Code

function asset_widget_get_search_results($filter_params = array(), $dom_id = FALSE) {
  $view = views_get_view(variable_get('asset_widget_search_view_name', 'asset_widget_search'));

  // Store same dom_id on widget on tab reloads.
  if ($dom_id) {
    $view->dom_id = $dom_id;
  }

  // If we have filter params e.g. for saved search, we set it to view.
  if (!empty($filter_params)) {
    parse_str($filter_params, $filter_params);
    $view->exposed_input = $filter_params;
  }
  $view
    ->set_display('default');
  $views_result = $view
    ->preview();
  asset_widget_set_current_command(array(
    'command' => 'assetWidgetSetTabViewDomID',
    'data' => array(
      'results' => $view->dom_id,
    ),
  ));

  // Initially fill params block.
  asset_widget_set_current_command(array(
    'command' => 'assetWidgetShowFiltersBlock',
    'data' => theme('asset_widget_search_filters_block', array(
      'search_params' => _asset_widget_views_filters_extract_labels($view),
      'results' => count($view->result),
    )),
  ));
  asset_widget_set_current_command(array(
    'command' => 'assetWidgetResetSizeMode',
    'data' => 'results',
  ));
  return array(
    '#markup' => $views_result,
  );
}