| 1 |
<?php //$Id: views_handler_field_geo_field.inc,v 1.3 2009/08/06 04:09:32 vauxia Exp $ |
<?php //$Id: views_handler_field_geo_field.inc,v 1.4 2009/08/06 04:58:33 vauxia Exp $ |
| 2 |
|
|
| 3 |
class views_handler_field_geo_field extends content_handler_field_multiple { |
class views_handler_field_geo_field extends content_handler_field_multiple { |
| 4 |
function query() { |
function query() { |
| 13 |
$this->query->add_field(NULL, geo('field_select', $this->geo_field), NULL, array('aggregate' => TRUE)); |
$this->query->add_field(NULL, geo('field_select', $this->geo_field), NULL, array('aggregate' => TRUE)); |
| 14 |
} |
} |
| 15 |
|
|
| 16 |
function render($values) { |
function pre_render(&$values) { |
| 17 |
|
foreach ($values as $i => $row) { |
| 18 |
|
// Re-assemble the components of the selected item. |
| 19 |
|
$item = array(); |
| 20 |
|
$base = substr($this->field_alias, 0, -4); |
| 21 |
|
foreach (array('wkb', 'bbox', 'srid') as $key) { |
| 22 |
|
$column = $base .'_'. $key; |
| 23 |
|
$item[$key] = db_decode_blob($row->$column); |
| 24 |
|
} |
| 25 |
|
$values[$i]->{$this->field_alias} = $item; |
| 26 |
|
} |
| 27 |
|
} |
| 28 |
|
|
| 29 |
|
function render(&$values) { |
| 30 |
$values->build_mode = 'views'; |
$values->build_mode = 'views'; |
| 31 |
|
|
| 32 |
// Get the formatter's theme name. This will be used by geo_set_value(). |
// Get the formatter's theme name. This will be used by geo_set_value(). |
| 34 |
$formatter = _content_get_formatter($name, $this->content_field['type']); |
$formatter = _content_get_formatter($name, $this->content_field['type']); |
| 35 |
$theme = $formatter['module'] .'_formatter_'. $name; |
$theme = $formatter['module'] .'_formatter_'. $name; |
| 36 |
|
|
|
// Re-assemble the components of the selected item. |
|
|
$item = array(); |
|
|
$base = substr($this->field_alias, 0, -4); |
|
|
foreach (array('wkb', 'bbox', 'srid') as $key) { |
|
|
$column = $base .'_'. $key; |
|
|
$item[$key] = db_decode_blob($values->$column); |
|
|
} |
|
|
|
|
| 37 |
// Convert the resulting output to a format recognized by the theme function |
// Convert the resulting output to a format recognized by the theme function |
| 38 |
$item = geo_set_value($item, $theme); |
$item = geo_set_value($values->{$this->field_alias}, $theme); |
| 39 |
|
|
| 40 |
// Do what the field module was going to do. |
// Do what the field module was going to do. |
| 41 |
$item['#delta'] = !empty($values->{$this->table_alias . '_delta'}) ? $values->{$this->table_alias . '_delta'} : 0; |
$item['#delta'] = !empty($values->{$this->table_alias . '_delta'}) ? $values->{$this->table_alias . '_delta'} : 0; |