function template_preprocess_views_view_row_search

Same name in other branches
  1. 6.x-3.x modules/search.views.inc \template_preprocess_views_view_row_search()

Template helper for theme_views_view_row_search.

File

modules/search.views.inc, line 164

Code

function template_preprocess_views_view_row_search(&$vars) {
    $vars['node'] = '';
    // Make sure var is defined.
    $nid = $vars['row']->nid;
    if (!is_numeric($nid)) {
        return;
    }
    // @todo Once the search row is fixed this node_load should be replace by a
    // node_load_multiple().
    $node = node_load($nid);
    if (empty($node)) {
        return;
    }
    // Build the node body.
    $node = node_build_content($node, FALSE, FALSE);
    $node->body = drupal_render($node->content);
    // Fetch comments for snippet.
    $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');
    // Fetch terms for snippet.
    $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index');
    $vars['url'] = url('node/' . $nid);
    $vars['title'] = check_plain($node->title);
    $info = array();
    $info['type'] = node_type_get_name($node);
    $info['user'] = theme('username', array(
        'acccount' => $node,
    ));
    $info['date'] = format_date($node->changed, 'small');
    $extra = module_invoke_all('node_search_result', $node);
    if (isset($extra) && is_array($extra)) {
        $info = array_merge($info, $extra);
    }
    $vars['info_split'] = $info;
    $vars['info'] = implode(' - ', $info);
    $vars['node'] = $node;
    // @todo Where does the score come from?
    // $vars['score'] = $item->score;
    $vars['snippet'] = search_excerpt($vars['view']->value, $node->body);
}