/[drupal]/contributions/modules/geo/geo.module
ViewVC logotype

Diff of /contributions/modules/geo/geo.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.30 by vauxia, Tue Nov 17 22:09:57 2009 UTC revision 1.31 by vauxia, Mon Nov 23 20:35:54 2009 UTC
# Line 1  Line 1 
1  <?php // $Id: geo.module,v 1.29 2009/11/17 19:07:21 vauxia Exp $  <?php // $Id: geo.module,v 1.30 2009/11/17 22:09:57 vauxia Exp $
2    
3  /**  /**
4   * Geo: Geospatial storage and retrieval.   * Geo: Geospatial storage and retrieval.
# Line 109  function geo_field_types() { Line 109  function geo_field_types() {
109  }  }
110    
111  /**  /**
112     * API Function: Return a list of CCK fields that contain geospatial data.
113     */
114    function geo_fields($reset = FALSE) {
115      static $fields;
116      if (!$reset || !isset($fields)) {
117        $field_types = geo_field_types();
118        $fields = array();
119        if (function_exists('content_fields')) {
120          foreach (content_fields() as $field) {
121            if (in_array($field['type'], $field_types)) {
122              $fields[$field['field_name']] = array(
123                'label' => $field['widget']['label'],
124                'gis type' => $field['geo_type'],
125                'srid' => $field['srid'] ? $field['srid'] : GEO_SRID_DEFAULT,
126                'module' => $field['module'],
127                'gis format' => 'wkb', // TODO hard-coded.
128              );
129            }
130          }
131        }
132      }
133      return $fields;
134    }
135    
136    /**
137   * Implementation of hook_content_fieldapi().   * Implementation of hook_content_fieldapi().
138   */   */
139  function geo_content_fieldapi($op, $field) {  function geo_content_fieldapi($op, $field) {
# Line 207  function geo_unit_convert($val, $from_un Line 232  function geo_unit_convert($val, $from_un
232   * Implementation of hook_nodeapi().   * Implementation of hook_nodeapi().
233   */   */
234  function geo_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {  function geo_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
235    // Append microformats onto geo node feeds.  
236    if ($op == 'rss item' && isset($node->geo_fields)) {    switch ($op) {
237      $rss = array();  
238      foreach ($node->geo_fields as $field_name => $type) {      case 'rss item':
239        foreach ($node->$field_name as $item) {        // Append microformats on geo node feeds.
240          $rss[] = geo('rss_item', $item['wkb']);        $rss = array();
241          foreach (geo_fields() as $field_name => $field) {
242            if (!isset($node->$field_name)) continue;
243    
244            foreach ($node->$field_name as $item) {
245              $rss[] = geo('rss_item', $item['wkb']);
246            }
247        }        }
248      }        return $rss;
249      return $rss;  
250        case 'view':
251          // Add a #pre_render callback to convert geo values to a format
252          // understood by the theme function in use by that field.
253          $node->content['#pre_render'][] = 'geo_field_convert_value';
254          return;
255    }    }
256  }  }
257    
# Line 231  function geo_elements() { Line 267  function geo_elements() {
267    );    );
268  }  }
269    
 function theme_geo_fields($element) {  
   return isset($element['#children']) ? $element['#children'] : '';  
 }  
   
270  /**  /**
271   * A #process handler for the latlon element.   * A #process handler for the latlon element.
272   */   */
# Line 258  function geo_latlon_process($element, $e Line 290  function geo_latlon_process($element, $e
290    return $element;    return $element;
291  }  }
292    
 function theme_geo_latlon($element) {  
   $output = '<div class="container-inline">'. $element['#children'] .'</div>';  
   return theme('form_element', $element, $output);  
 }  
   
293  function geo_value_convert($value, $in = 'array', $out = 'wkt') {  function geo_value_convert($value, $in = 'array', $out = 'wkt') {
294    // TODO We are taking the element's requested input and output formats, and    // TODO We are taking the element's requested input and output formats, and
295    // making the necessary adjustments.  This needs to be refactored and set up    // making the necessary adjustments.  This needs to be refactored and set up
# Line 306  function geo_gis_input_info($gis_type = Line 333  function geo_gis_input_info($gis_type =
333    return $inputs;    return $inputs;
334  }  }
335    
336  function geo_set_pre_render(&$element) {  function geo_field_convert_value(&$element) {
   if (!isset($element['#pre_render'])  
     || !in_array('geo_field_convert_value', $element['#pre_render'])) {  
     $element['#pre_render'][] = 'geo_field_convert_value';  
   }  
 }  
   
 function geo_field_convert_value($element) {  
337    foreach (element_children($element) as $key) {    foreach (element_children($element) as $key) {
338      if (isset($element[$key]['field']) && $element[$key]['field']['#access']) {      if (isset($element[$key]['field']) && $element[$key]['field']['#access']) {
339        $field = $element[$key]['field'];        $field = $element[$key]['field'];

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.3