| 1 |
<?php //$Id: views_handler_field_geo_field.inc,v 1.1 2009/03/03 02:16:30 vauxia Exp $ |
<?php //$Id: views_handler_field_geo_field.inc,v 1.2 2009/06/04 02:02:20 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() { |
| 9 |
} |
} |
| 10 |
|
|
| 11 |
// geo_field_select will return the SRID, Envelope, Centroid, and WKB data. |
// geo_field_select will return the SRID, Envelope, Centroid, and WKB data. |
| 12 |
$geo_field = $table .'.'. $this->content_field['field_name'] .'_geo'; |
$this->geo_field = $table .'.'. $this->content_field['field_name'] .'_geo'; |
| 13 |
$this->query->add_field(NULL, geo('field_select', $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 not_render($values) { |
function render($values) { |
|
$field = $this->content_field; |
|
|
$options = $this->options; |
|
|
$db_info = content_database_info($field); |
|
|
|
|
|
// $values will be used as a fake $node object; |
|
|
// we provide a build_mode for rendering. |
|
|
// TODO: we can stick any value in there - |
|
|
// what would make most sense ? row_style ? |
|
| 17 |
$values->build_mode = 'views'; |
$values->build_mode = 'views'; |
| 18 |
|
|
| 19 |
|
// Get the formatter's theme name. This will be used by geo_set_value(). |
| 20 |
|
$name = $this->options['format']; |
| 21 |
|
$formatter = _content_get_formatter($name, $this->content_field['type']); |
| 22 |
|
$theme = $formatter['module'] .'_formatter_'. $name; |
| 23 |
|
|
| 24 |
|
// Re-assemble the components of the selected item. |
| 25 |
$item = array(); |
$item = array(); |
| 26 |
|
$base = substr($this->field_alias, 0, -4); |
| 27 |
|
foreach (array('wkb', 'bbox', 'srid') as $key) { |
| 28 |
|
$column = $base .'_'. $key; |
| 29 |
|
$item[$key] = db_decode_blob($values->$column); |
| 30 |
|
unset($values->$column); |
| 31 |
|
} |
| 32 |
|
|
| 33 |
$item['wkb'] = $values->{$geo_table.'_wkb'}; |
// Convert the resulting output to a format recognized by the theme function |
| 34 |
$item['bbox'] = $values->{$geo_table.'_bbox'}; |
$item = geo_set_value($item, $theme); |
| 35 |
|
|
| 36 |
foreach ($this->content_field['geo_data_value'] as $column) { |
// Do what the field module was going to do. |
|
$value = $values->{$geo_table.'_'. $column}; |
|
|
$item['geo_data_'. $column] = $value; |
|
|
if (!isset($item['label']) && in_array($column, $field['geo_data_value'])) { |
|
|
$item['label'] = $value; |
|
|
} |
|
|
} |
|
| 37 |
$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; |
| 38 |
return $this->render_link(content_format($field, $item, $options['format'], $values), $values); |
return $this->render_link(content_format($this->content_field, $item, $this->options['format'], $values), $values); |
| 39 |
} |
} |
| 40 |
} |
} |