summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--date_views/date_views.module25
-rw-r--r--date_views/includes/date_views_fields.inc10
2 files changed, 19 insertions, 16 deletions
diff --git a/date_views/date_views.module b/date_views/date_views.module
index 1662e49..9a42fee 100644
--- a/date_views/date_views.module
+++ b/date_views/date_views.module
@@ -230,27 +230,30 @@ function date_field_views_data_alter(&$result, $field, $module) {
if ($module == 'date') {
foreach ($result as $table => $data) {
$additional = array();
- $key = array_key_exists('entity_id', $data) ? 'entity_id' : 'revision_id';
+ $field_name = $field['field_name'];
+ $key = array_key_exists('entity_id', $data) ? $field_name : $field_name . '-revision_id';
+ $field_name_data = $data[$key]['field'];
foreach ($data as $column => $value) {
if (array_key_exists('argument', $value)) {
$result[$table][$column]['argument']['handler'] = 'date_views_argument_handler';
- $additional = $result[$table][$column]['argument']['additional fields'];
+ // The following code would add a FIELDNAME_value and FIELDNAME_value2 field as well as the basic FIELDNAME field.
+ // Not sure yet if that is desirable.
+ //$result[$table][$column]['field'] = $field_name_data;
+ //$result[$table][$column]['field']['field'] = $value['argument']['field'];
+ //$result[$table][$column]['field']['add fields to query'] = TRUE;
}
if (array_key_exists('filter', $value)) {
$result[$table][$column]['filter']['handler'] = 'date_views_filter_handler';
}
- // Not sure yet if we still need this in D7 now that custom formatters are available.
- // Might still need it to handle grouping of multiple value dates.
- if (array_key_exists($key, $value)) {
+ // The old 'entity_id' and 'revision_id' values got rewritten in Views.
+ // The old values are still there with a 'moved to' key, so ignore them.
+ if (array_key_exists('field', $value) && !array_key_exists('moved to', $value['field'])) {
+ // Not sure yet if we still need a custom field handler in D7 now that custom formatters are available.
+ // Might still need it to handle grouping of multiple value dates.
//$result[$table][$column]['field']['handler'] = 'date_handler_field_date';
+ $result[$table][$column]['field']['add fields to query'] = TRUE;
}
}
- // Add additional fields to the field as well as the argument and filter.
- // @TODO Is this the best fix? We only need the fields if we're using arguments or filters.
- // Do this for now to get date views working again.
-
- $result[$table][$key]['field']['additional fields'] = array_merge($result[$table][$key]['field']['additional fields'], $additional);
- $result[$table][$key]['field']['add fields to query'] = TRUE;
}
}
}
diff --git a/date_views/includes/date_views_fields.inc b/date_views/includes/date_views_fields.inc
index ec27294..35f138e 100644
--- a/date_views/includes/date_views_fields.inc
+++ b/date_views/includes/date_views_fields.inc
@@ -26,6 +26,7 @@ function _date_views_fields($base = 'node') {
cache_clear_all($cid, 'cache_views');
$all_fields = date_views_views_fetch_fields($base, 'field');
$content_fields = field_views_data();
+
// Iterate over all the fields that Views knows about.
$fields = array();
foreach ((array) $all_fields as $alias => $val) {
@@ -52,14 +53,14 @@ function _date_views_fields($base = 'node') {
if (!$handler = views_get_handler($table_name, $field_name, 'field')) {
continue;
}
-
+ $handler = views_get_handler($table_name, $field_name, 'field');
$handler_name = $handler->definition['handler'];
// For Field module fields, get the date type.
$custom = array();
- if ($field_name == 'entity_id') {
+ if ($handler->definition['group'] == 'Fields') {
- $field_name = $content_fields[$table_name]['entity_id']['field']['field_name'];
+ //$field_name = $content_fields[$table_name]['entity_id']['field']['field_name'];
$field = field_info_field($field_name);
switch ($field['type']) {
@@ -79,7 +80,7 @@ function _date_views_fields($base = 'node') {
// If this is not a date field, nothing more to do.
continue;
}
-
+
$db_info = date_api_database_info($field);
$name = $table_name . "." . $field_name . "_value";
$granularity = !empty($field['granularity']) ? $field['granularity'] : array('year', 'month', 'day', 'hour', 'minute');
@@ -163,7 +164,6 @@ function _date_views_fields($base = 'node') {
// The D7 field handling is funny, there is only a single record
// with a field name of 'entity_id'. We need the real names for our queries.
// Fields also need an extra record so we have both from and to values.
-
if (strstr($alias, 'entity_id')) {
$field_name .= '_value';
$fields['name'][$name]['field_name'] = $field_name;