function apachesolr_views_views_data in Apache Solr Views 6
Same name and namespace in other branches
- 7 apachesolr_views.views.inc \apachesolr_views_views_data()
Implementation of hook_views_data().
File
- ./
apachesolr_views.views.inc, line 126
Code
function apachesolr_views_views_data() {
foreach (module_invoke_all('apachesolr_entities') as $base_table => $definition) {
$name = $definition['name'];
$base_field = $definition['base_field'];
$data['apachesolr_' . $base_table]['table']['group'] = t('Apache Solr');
$data['apachesolr_' . $base_table]['table']['base'] = array(
'query class' => 'apachesolr_views_query',
'title' => t('Apache Solr @name', array(
'@name' => $name,
)),
'help' => t('Searches the site with the Apache Solr search engine for @name', array(
'@name' => $name,
)),
'field' => $base_field,
);
$data['apachesolr_' . $base_table]['nid'] = array(
'title' => t('Nid'),
'help' => t('The node ID of the node.'),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
);
$data['apachesolr_' . $base_table]['title'] = array(
'title' => t('Title'),
'help' => t('The title of the node.'),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument',
),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
);
$data['apachesolr_' . $base_table]['created'] = array(
'title' => t('Creation date'),
'help' => t('The date the node was created.'),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
);
$data['apachesolr_' . $base_table]['changed'] = array(
'title' => t('Updated date'),
'help' => t('The date the node was last updated.'),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
);
$data['apachesolr_' . $base_table]['type'] = array(
'title' => t('Type'),
'help' => t('The type of a node (for example, "blog entry", "forum post", "story", etc).'),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument_node_type',
),
'field' => array(
'handler' => 'views_handler_field_node_type',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'apachesolr_views_handler_filter_type',
),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
);
$data['apachesolr_' . $base_table]['name'] = array(
'title' => t('Author'),
'help' => t("The node's author."),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
);
$data['apachesolr_' . $base_table]['uid'] = array(
'title' => t('Author Uid'),
'help' => t("The node's author's user ID."),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument',
),
);
$data['apachesolr_' . $base_table]['comment_count'] = array(
'title' => t('Comment count'),
'help' => t('The number of comments that were posted to the node.'),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
);
// TODO Get taxonomy fields to work
if (module_exists('taxonomy')) {
$data['apachesolr_' . $base_table]['tid'] = array(
'title' => t('Taxonomy terms'),
'help' => t('Taxonomy terms associated with the node.'),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument_tid',
),
);
}
$data['apachesolr_' . $base_table]['sticky'] = array(
'title' => t('Sticky'),
'help' => t("Sort and filter by a node's sticky flag."),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
'filter' => array(
'handler' => 'apachesolr_views_handler_filter_boolean',
),
);
// @TODO: handle language field.
$data['apachesolr_' . $base_table]['text'] = array(
'title' => t('Search'),
'help' => t('Searches the content with Solr'),
'filter' => array(
'handler' => 'apachesolr_views_handler_filter_search',
),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument_search',
),
);
// score field. Useful for when combining sorts. So you sort by score, creation etc.
$data['apachesolr_' . $base_table]['score'] = array(
'title' => t('Search Score'),
'help' => t('The score of the search for this item. When no sorts are present this is the default sort'),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
'field' => array(
'handler' => 'apachesolr_views_handler_field_score',
),
);
// comment_count field useful for sorting
$data['apachesolr_' . $base_table]['comment_count'] = array(
'title' => t('Comment Count'),
'help' => t('The number of comments on a node'),
'sort' => array(
'handler' => 'apachesolr_views_handler_sort',
),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => FALSE,
),
);
// snippet field
$data['apachesolr_' . $base_table]['snippet'] = array(
'title' => t('Search Snippet'),
'help' => t('The return snippet that matches the query sent to Solr.'),
'field' => array(
'handler' => 'apachesolr_views_handler_field_snippet',
),
);
$data['apachesolr_' . $base_table]['mlt'] = array(
'title' => t('More Like This Node id'),
'help' => t('Do a more like this query based on the provided nid'),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument_mlt',
),
);
// node access
if (module_exists('apachesolr_nodeaccess')) {
$data['apachesolr_' . $base_table]['access'] = array(
'title' => t('Node Access Control'),
'help' => t('Return results from Apache Solr that respect node access'),
'filter' => array(
'handler' => 'apachesolr_views_handler_filter_node_access',
),
);
}
$data['apachesolr_' . $base_table]['promote'] = array(
'title' => t('Promoted to Front Page'),
'help' => t('Whether or not this node was promoted to the front page'),
'filter' => array(
'handler' => 'apachesolr_views_handler_filter_boolean',
'label' => t('Promoted'),
'type' => 'yes-no',
),
);
$data['apachesolr_' . $base_table]['status'] = array(
'title' => t('Published'),
'help' => t('Whether or not this node has been published'),
'filter' => array(
'handler' => 'apachesolr_views_handler_filter_boolean',
'label' => t('Published'),
'type' => 'yes-no',
),
);
// provide CCK mappings filters
foreach (apachesolr_cck_fields() as $name => $field) {
// TODO: can we make use of CCK's mapping already and just override
// the query part???
$options = content_allowed_values(content_fields($field['field_name']));
if (!empty($options)) {
$data['apachesolr_' . $base_table][apachesolr_index_key($field)] = array(
'title' => t($field['label']),
'help' => t('CCK Mapping for @fieldname', array(
'@fieldname' => $field['field_name'],
)),
'filter' => array(
'handler' => 'apachesolr_views_handler_optionwidget_filter',
'cck_field' => $field,
),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument_optionwidget',
'cck_field' => $field,
),
);
}
elseif ($field['type'] == 'number_decimal') {
$data['apachesolr_' . $base_table][apachesolr_index_key($field)] = array(
'title' => t($field['widget']['label']),
'help' => t('CCK Mapping for @fieldname', array(
'@fieldname' => $field['field_name'],
)),
'argument' => array(
'handler' => 'apachesolr_views_handler_argument',
),
);
}
// end: if
}
}
return $data;
}