- <?php
- * @file
- * Provide views data and handlers for search.module.
- *
- * @ingroup views_module_handlers
- */
-
- * Implements hook_views_data().
- */
- function search_views_data() {
-
-
-
-
- $data['search_index']['table']['group'] = t('Search');
-
-
- $data['search_index']['table']['join'] = array(
- 'node' => array(
- 'left_field' => 'nid',
- 'field' => 'sid',
- ),
- );
-
- $data['search_total']['table']['join'] = array(
- 'node' => array(
- 'left_table' => 'search_index',
- 'left_field' => 'word',
- 'field' => 'word',
- ),
- 'users' => array(
- 'left_table' => 'search_index',
- 'left_field' => 'word',
- 'field' => 'word',
- )
- );
-
- $data['search_dataset']['table']['join'] = array(
- 'node' => array(
- 'left_table' => 'search_index',
- 'left_field' => 'sid',
- 'field' => 'sid',
- 'extra' => 'search_index.type = search_dataset.type',
- 'type' => 'INNER',
- ),
- 'users' => array(
- 'left_table' => 'search_index',
- 'left_field' => 'sid',
- 'field' => 'sid',
- 'extra' => 'search_index.type = search_dataset.type',
- 'type' => 'INNER',
- ),
- );
-
-
-
-
-
- $data['search_index']['score'] = array(
- 'title' => t('Score'),
- 'help' => t('The score of the search item. This will not be used if the search filter is not also present.'),
- 'field' => array(
- 'handler' => 'views_handler_field_search_score',
- 'click sortable' => TRUE,
- 'float' => TRUE,
- 'no group by' => TRUE,
- ),
-
- 'sort' => array(
- 'handler' => 'views_handler_sort_search_score',
- 'no group by' => TRUE,
- ),
- );
-
-
- $data['search_node_links_from']['table']['group'] = t('Search');
- $data['search_node_links_from']['table']['join'] = array(
- 'node' => array(
- 'arguments' => array('search_node_links', 'node', 'nid', 'nid', NULL, 'INNER'),
- ),
- );
- $data['search_node_links_from']['sid'] = array(
- 'title' => t('Links from'),
- 'help' => t('Other nodes that are linked from the node.'),
- 'argument' => array(
- 'handler' => 'views_handler_argument_node_nid',
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_equality',
- ),
- );
-
-
- $data['search_node_links_to']['table']['group'] = t('Search');
- $data['search_node_links_to']['table']['join'] = array(
- 'node' => array(
- 'arguments' => array('search_node_links', 'node', 'nid', 'sid', NULL, 'INNER'),
- ),
- );
- $data['search_node_links_to']['nid'] = array(
- 'title' => t('Links to'),
- 'help' => t('Other nodes that link to the node.'),
- 'argument' => array(
- 'handler' => 'views_handler_argument_node_nid',
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_equality',
- ),
- );
-
-
- $data['search_index']['keys'] = array(
- 'title' => t('Search Terms'),
- 'help' => t('The terms to search for.'),
-
- 'filter' => array(
- 'handler' => 'views_handler_filter_search',
- 'no group by' => TRUE,
- ),
- 'argument' => array(
- 'handler' => 'views_handler_argument_search',
- 'no group by' => TRUE,
- ),
- );
-
- return $data;
- }
-
- * Implements hook_views_plugins().
- */
- function search_views_plugins() {
- return;
-
- return array(
- 'module' => 'views',
- 'row' => array(
- 'search' => array(
- 'title' => t('Search'),
- 'help' => t('Display the results with standard search view.'),
- 'handler' => 'views_plugin_row_search_view',
- 'theme' => 'views_view_row_search',
- 'path' => backdrop_get_path('module', 'views') . '/modules/search',
- 'base' => array('node'),
- 'type' => 'normal',
- ),
- 'views_handler_argument_search' => array(
- 'parent' => 'views_handler_argument',
- ),
- ),
- );
- }
-
- * Template helper for theme_views_view_row_search
- */
- function template_preprocess_views_view_row_search(&$variables) {
- $variables['node'] = '';
- $nid = $variables['row']->nid;
- if (!is_numeric($nid)) {
- return;
- }
-
-
- $node = node_load($nid);
-
- if (empty($node)) {
- return;
- }
-
-
- $node = node_build_content($node, FALSE, FALSE);
- $node->body = backdrop_render($node->content);
-
-
- $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');
-
-
- $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index');
-
- $variables['url'] = url('node/' . $nid);
- $variables['title'] = check_plain($node->title);
-
- $info = array();
- $info['type'] = node_type_get_name($node);
- $info['user'] = theme('username', array('account' => $node));
- $info['date'] = format_date($node->changed, 'short');
- $extra = module_invoke_all('node_search_result', $node);
- if (isset($extra) && is_array($extra)) {
- $info = array_merge($info, $extra);
- }
- $variables['info_split'] = $info;
- $variables['info'] = implode(' - ', $info);
-
- $variables['node'] = $node;
-
- $variables['snippet'] = search_excerpt($variables['view']->value, $node->body);
- }