diff --git a/includes/handlers.inc b/includes/handlers.inc index 8d57613..9f297f1 100644 --- a/includes/handlers.inc +++ b/includes/handlers.inc @@ -492,6 +492,15 @@ class views_handler extends views_object { function pre_query() { } /** + * Run after the view is executed, before the result is cached. + * + * This gives all the handlers some time to modify values. This is primarily + * used so that handlers that pull up secondary data can put it in the + * $values so that the raw data can be utilized externally. + */ + function post_execute(&$values) { } + + /** * Provides a unique placeholders for handlers. */ function placeholder() { @@ -1088,7 +1097,7 @@ function views_date_sql_field($field, $field_type = 'int', $set_offset = NULL) { if (isset($offset) && !is_numeric($offset)) { $dtz = new DateTimeZone($offset); $dt = new DateTime("now", $dtz); - $offset_seconds = $dtz->getOffset($dt); + $offset_seconds = $dtz->getOffset($dt); } switch ($db_type) { diff --git a/includes/view.inc b/includes/view.inc index c771455..5dddbf7 100644 --- a/includes/view.inc +++ b/includes/view.inc @@ -424,6 +424,18 @@ class view extends views_db_object { } /** + * Run the post_execute() on all active handlers. + */ + function _post_execute() { + foreach (views_object_types() as $key => $info) { + $handlers = &$this->$key; + foreach ($handlers as $id => $handler) { + $handlers[$id]->post_execute($this->result); + } + } + } + + /** * Attach all of the handlers for each type. * * @param $key @@ -795,6 +807,7 @@ class view extends views_db_object { } else { $this->query->execute($this); + $this->_post_execute(); if ($cache) { $cache->cache_set('results'); } diff --git a/modules/field/views_handler_field_field.inc b/modules/field/views_handler_field_field.inc index f51dc8f..48327ba 100644 --- a/modules/field/views_handler_field_field.inc +++ b/modules/field/views_handler_field_field.inc @@ -504,7 +504,7 @@ class views_handler_field_field extends views_handler_field { /** * Load the entities for all fields that are about to be displayed. */ - function pre_render(&$values) { + function post_execute(&$values) { if (!empty($values)) { // Divide the entity ids by entity type, so they can be loaded in bulk. $entities_by_type = array(); @@ -553,11 +553,14 @@ class views_handler_field_field extends views_handler_field { 'entity_type' => $entity_type, 'entity' => $entities[$entity_id], ); - // Push the field values directly into the results array to make themers the life a bit easier. - $values[$key]->{$this->definition['table'] . '_' . $entity_type . '_values'} = field_get_items($entity_type, $entities[$entity_id], $this->definition['field_name']); } } } + + // Now, transfer the data back into the resultset so it can be easily used. + foreach ($values as $key => &$value) { + $value->{'field_' . $this->options['id']} = $this->set_items($value); + } } } @@ -587,17 +590,14 @@ class views_handler_field_field extends views_handler_field { } } + function get_items($values) { + return $values->{'field_' . $this->options['id']}; + } + /** * Return an array of items for the field. - * - * Items should be stored in the result array, if possible, as an array - * with 'value' as the actual displayable value of the item, plus - * any items that might be found in the 'alter' options array for - * creating links, such as 'path', 'fragment', 'query' etc, such a thing - * is to be made. Additionally, items that might be turned into tokens - * should also be in this array. */ - function get_items($values) { + function set_items($values) { if (empty($values->_field_data[$this->field_alias]) || empty($values->_field_data[$this->field_alias]['entity'])) { return array(); }