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

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

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

revision 1.25, Fri Aug 7 16:54:23 2009 UTC revision 1.26, Mon Nov 9 17:44:40 2009 UTC
# Line 1  Line 1 
1  <?php // $Id: geo_field.module,v 1.24 2009/08/06 04:09:32 vauxia Exp $  <?php // $Id: geo_field.module,v 1.25 2009/08/07 16:54:23 vauxia Exp $
2    
3  /**  /**
4   * @file   * @file
# Line 21  function geo_field_info() { Line 21  function geo_field_info() {
21   * Implementation of hook_field_settings().   * Implementation of hook_field_settings().
22   */   */
23  function geo_field_settings($op, $field) {  function geo_field_settings($op, $field) {
   $field_name = $field['field_name'];  
   
24    switch ($op) {    switch ($op) {
25      case 'form':      case 'form':
26        $form = array();        $form = array();
# Line 45  function geo_field_settings($op, $field) Line 43  function geo_field_settings($op, $field)
43    
44      case 'save':      case 'save':
45        return array('srid', 'geo_type');        return array('srid', 'geo_type');
46    
47      case 'database columns':      case 'database columns':
48        return geo('schema_field', $field['geo_type']);        if (!empty($field['geo_type'])) {
49            return geo('schema_field', $field['geo_type']);
50          }
51          break;
52    
53      case 'views data':      case 'views data':
54        // Start with default views data, as constructed by CCK.        // Start with default views data, as constructed by CCK.
55        $data = content_views_field_views_data($field);        $data = content_views_field_views_data($field);
# Line 107  function geo_field($op, &$node, $field, Line 108  function geo_field($op, &$node, $field,
108          FROM {". $db_info['table'] ."} WHERE vid = %d", $node->vid);          FROM {". $db_info['table'] ."} WHERE vid = %d", $node->vid);
109    
110        $ret = array();        $ret = array();
111        while ($row = db_fetch_array($res)) {        while ($row = db_fetch_array($res)) {
112          $delta = isset($row['delta']) ? $row['delta'] : 0;          $delta = isset($row['delta']) ? $row['delta'] : 0;
113          $ret[$delta]['gis type'] = $field['geo_type'];          $ret[$delta]['gis type'] = $field['geo_type'];
114          foreach ($row as $k => $v) {          foreach ($row as $k => $v) {
115            $k = str_replace($field['field_name'] .'_', '', $k);            $k = str_replace($field['field_name'] .'_', '', $k);
116            if ($k != 'delta') $ret[$delta][$k] = db_decode_blob($v);            if ($k != 'delta') $ret[$delta][$k] = db_decode_blob($v);
117          }          }
118            // Unset the value if it's not actually populated.
119            if (empty($ret[$delta]['wkb'])) {
120              unset($ret[$delta]);
121            }
122        }        }
123    
124        // Identify ourselves on the node level for RSS and other postprocessing.        // Identify ourselves on the node level for RSS and other postprocessing.
# Line 187  function geo_field_widget(&$form, &$form Line 192  function geo_field_widget(&$form, &$form
192    foreach ($items as $key => $item) {    foreach ($items as $key => $item) {
193      // Convert from the storage format (wkb) to the element's expected format.      // Convert from the storage format (wkb) to the element's expected format.
194      if ($info['gis input']) {      if ($info['gis input']) {
195        $data = geo_wkb_get_data($item['wkb'], $info['gis input']);        if (isset($item['wkb'])) {
196        $items[$key] = $data['value'];          $data = geo_wkb_get_data($item['wkb'], $info['gis input']);
197            $items[$key] = $data['value'];
198          }
199          else {
200            $items[$key] = '';
201          }
202      }      }
203    }    }
204    

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.2