updated to 7.x-1.11

This commit is contained in:
Bachir Soussi Chiadmi
2014-02-07 10:01:18 +01:00
parent a30917d1d2
commit cf03e9ca52
69 changed files with 4629 additions and 1557 deletions

View File

@@ -1,5 +1,10 @@
<?php
/**
* @file
* Views hook implementations for the Search API Views module.
*/
/**
* Implements hook_views_data().
*/
@@ -28,7 +33,7 @@ function search_api_views_views_data() {
}
try {
$wrapper = $index->entityWrapper(NULL, TRUE);
$wrapper = $index->entityWrapper(NULL, FALSE);
}
catch (EntityMetadataWrapperException $e) {
watchdog_exception('search_api_views', $e, "%type while retrieving metadata for index %index: !message in %function (line %line of %file).", array('%index' => $index->name), WATCHDOG_WARNING);
@@ -43,6 +48,14 @@ function search_api_views_views_data() {
}
}
try {
$wrapper = $index->entityWrapper(NULL);
}
catch (EntityMetadataWrapperException $e) {
watchdog_exception('search_api_views', $e, "%type while retrieving metadata for index %index: !message in %function (line %line of %file).", array('%index' => $index->name), WATCHDOG_WARNING);
continue;
}
// Add handlers for all indexed fields.
foreach ($index->getFields() as $key => $field) {
$tmp = $wrapper;
@@ -69,7 +82,7 @@ function search_api_views_views_data() {
if ($group) {
// @todo Entity type label instead of $group?
$table[$id]['group'] = $group;
$name = t('@field (indexed)', array('@field' => $name));
$name = t('!field (indexed)', array('!field' => $name));
}
$table[$id]['title'] = $name;
$table[$id]['help'] = empty($info['description']) ? t('(No information available)') : $info['description'];
@@ -145,8 +158,18 @@ function search_api_views_views_data() {
}
/**
* Helper function that returns an array of handler definitions to add to a
* views field definition.
* Adds handler definitions for a field to a Views data table definition.
*
* Helper method for search_api_views_views_data().
*
* @param $id
* The internal identifier of the field.
* @param array $field
* Information about the field.
* @param EntityMetadataWrapper $wrapper
* A wrapper providing further metadata about the field.
* @param array $table
* The existing Views data table definition, as a reference.
*/
function _search_api_views_add_handlers($id, array $field, EntityMetadataWrapper $wrapper, array &$table) {
$type = $field['type'];
@@ -170,9 +193,9 @@ function _search_api_views_add_handlers($id, array $field, EntityMetadataWrapper
return;
}
if ($options = $wrapper->optionsList('view')) {
$info = $wrapper->info();
if (isset($info['options list']) && is_callable($info['options list'])) {
$table[$id]['filter']['handler'] = 'SearchApiViewsHandlerFilterOptions';
$table[$id]['filter']['options'] = $options;
$table[$id]['filter']['multi-valued'] = search_api_is_list_type($type);
}
elseif ($inner_type == 'boolean') {
@@ -181,6 +204,27 @@ function _search_api_views_add_handlers($id, array $field, EntityMetadataWrapper
elseif ($inner_type == 'date') {
$table[$id]['filter']['handler'] = 'SearchApiViewsHandlerFilterDate';
}
elseif (isset($field['entity_type']) && $field['entity_type'] === 'user') {
$table[$id]['filter']['handler'] = 'SearchApiViewsHandlerFilterUser';
}
elseif (isset($field['entity_type']) && $field['entity_type'] === 'taxonomy_term') {
$table[$id]['filter']['handler'] = 'SearchApiViewsHandlerFilterTaxonomyTerm';
$info = $wrapper->info();
$field_info = field_info_field($info['name']);
// For the "Parent terms" and "All parent terms" properties, we can
// extrapolate the vocabulary from the parent in the selector. (E.g.,
// for "field_tags:parent" we can use the information of "field_tags".)
// Otherwise, we can't include any vocabulary information.
if (!$field_info && ($info['name'] == 'parent' || $info['name'] == 'parents_all')) {
if (!empty($table[$id]['real field'])) {
$parts = explode(':', $table[$id]['real field']);
$field_info = field_info_field($parts[count($parts) - 2]);
}
}
if (isset($field_info['settings']['allowed_values'][0]['vocabulary'])) {
$table[$id]['filter']['vocabulary'] = $field_info['settings']['allowed_values'][0]['vocabulary'];
}
}
else {
$table[$id]['filter']['handler'] = 'SearchApiViewsHandlerFilter';
}
@@ -188,6 +232,9 @@ function _search_api_views_add_handlers($id, array $field, EntityMetadataWrapper
if ($inner_type == 'string' || $inner_type == 'uri') {
$table[$id]['argument']['handler'] = 'SearchApiViewsHandlerArgumentString';
}
elseif ($inner_type == 'date') {
$table[$id]['argument']['handler'] = 'SearchApiViewsHandlerArgumentDate';
}
else {
$table[$id]['argument']['handler'] = 'SearchApiViewsHandlerArgument';
}