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

Diff of /contributions/modules/carto/carto.module

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

revision 1.19, Sat Oct 7 22:12:05 2006 UTC revision 1.20, Fri Oct 13 13:22:51 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: carto.module,v 1.18 2006/10/05 20:13:05 openwereld Exp $  // $Id: carto.module,v 1.19 2006/10/07 22:12:05 openwereld Exp $
3    
4  define( 'DEFAULT_WMS_SEARCH_FIELDS', 'name,title,abstract' );  define( 'DEFAULT_WMS_SEARCH_FIELDS', 'name,title,keywords,abstract' );
5  define( 'DEFAULT_CARTO_WMS_TEASER_MAP', 1 );  define( 'DEFAULT_CARTO_WMS_TEASER_MAP', 1 );
6    
7  /**  /**
8   * Implementation of hook_help().   * Implementation of hook_help().
9   *   *
# Line 105  function _carto_is_bootstrap( ) Line 106  function _carto_is_bootstrap( )
106      return ! function_exists('drupal_get_headers');      return ! function_exists('drupal_get_headers');
107  }  }
108    
 /**  
  * Implementation of hook_access().  
  */  
 /*function carto_access( $op, $node )  
 {  
     global $user;  
   
     drupal_set_message( 'carto_access: ' . $op );  
     if( $op == 'create' )  
     {  
         return user_access( 'create wms nodes' ) && $user->uid;  
     }  
   
     if( $op == 'update' || $op == 'delete' )  
     {  
         if( user_access( 'create wms nodes' ) && ( $user->uid == $node->uid ))  
         {  
             return TRUE;  
         }  
     }  
 }*/  
   
109  function carto_wms_access( $op, $node )  function carto_wms_access( $op, $node )
110  {  {
111      global $user;      global $user;
# Line 268  function carto_menu( $may_cache ) Line 247  function carto_menu( $may_cache )
247                      );                      );
248              }              }
249          }          }
250          drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'core');          //drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'core');
251      }      }
252      return $items;      return $items;
253  }  }
# Line 1189  function carto_node_info() Line 1168  function carto_node_info()
1168      return array(      return array(
1169          'cartowms' => array( 'name' => t('web mapping service')          'cartowms' => array( 'name' => t('web mapping service')
1170                              , 'module' => 'carto_wms'                              , 'module' => 'carto_wms'
1171                              , 'description' => t('todo: description of carto-wms node type')                              , 'description' => t('A web mapping service is a page that displays selected layers of an OpenGIS web mapping service. The node can also be used as a proxy to make e.g. map requests to that service.')
1172                              //, 'has_body' => TRUE                              //, 'has_body' => TRUE
1173                              //, 'body_label' => t('Capabilities')                              //, 'body_label' => t('Capabilities')
1174                              )                              )
# Line 1198  function carto_node_info() Line 1177  function carto_node_info()
1177    
1178  function carto_wms_form( &$node )  function carto_wms_form( &$node )
1179  {  {
1180      //print 'carto_wms_form: ' . var_export(array('POST'=>$_POST,'NODE'=>$node),true) . '<hr>';  //    print 'carto_wms_form: ' . var_export(array('POST'=>$_POST,'capabilities.len'=>strlen($_SESSION['capabilities'])),true) . '<hr>';
1181      $type = node_get_types('type', $node);      $type = node_get_types('type', $node);
1182    
1183      $form['title'] = array( '#type' => 'textfield'      $form['title'] = array( '#type' => 'textfield'
# Line 1209  function carto_wms_form( &$node ) Line 1188  function carto_wms_form( &$node )
1188      $form['service'] = array( '#type' => 'textfield', '#title' => t('Web mapping service')      $form['service'] = array( '#type' => 'textfield', '#title' => t('Web mapping service')
1189          , '#size' => 100          , '#size' => 100
1190          , '#maxlength' => 1000          , '#maxlength' => 1000
1191          , '#required' => TRUE, '#default_value' => $node->service );          , '#required' => TRUE
1192      $form['getcapabilities'] = array( '#type' => 'checkbox', '#title' => t('Get capabilities')          , '#default_value' => $node->service
1193          , '#required' => FALSE          , '#description' => t('Enter the url of the opengis web mapping service without request/service parameters')
1194            );
1195        $form['getcapabilities'] = array( '#type' => 'checkbox'
1196            , '#title' => t('Get capabilities')
1197            , '#required' => FALSE
1198            , '#default_value' => 0
1199            , '#description' => t('Check this option if the capabilities should be requested from the service')
1200          );          );
1201      $form['capabilities'] = array( '#type' => 'textarea'      $form['capabilities'] = array( '#type' => 'textarea'
1202          , '#title' => t('Capabilities')          , '#title' => t('Capabilities')
1203          , '#required' => FALSE          , '#required' => FALSE
1204          , '#rows' => 20          , '#rows' => 20
1205          , '#default_value' => $node->capabilities ? $node->capabilities : $_SESSION['capabilities']          , '#default_value' => $node->capabilities != NULL && $node->capabilities != '' ? $node->capabilities : $_SESSION['capabilities']
1206          );          );
1207      if( isset($_SESSION['capabilities']) )  
1208          $form['capabilities']['#value'] = $_SESSION['capabilities'];      if( $_POST['op'] == t('Preview') && $_POST['getcapabilities'] == 1 )
1209  //    drupal_set_message( 'sessie: ' . var_export($_SESSION['capabilities'],true) );      {
1210  //    drupal_set_message( 'default: ' . var_export($form['capabilities']['#default_value'],true) );          // Get capabilities during preview and toggle checkbox off
1211            $form['capabilities']['#value'] = get_capabilities($_POST['service']);
1212            $form['getcapabilities']['#value'] = 0;
1213        }
1214    
1215      // set format to carto filter      // set format to carto filter
1216      $results = db_query('SELECT ff.format FROM {filter_formats} ff JOIN {filters} f ON ff.format = f.format WHERE f.module = \'carto\' and f.delta = 0' );      $results = db_query('SELECT ff.format FROM {filter_formats} ff JOIN {filters} f ON ff.format = f.format WHERE f.module = \'carto\' and f.delta = 0' );
# Line 1232  function carto_wms_form( &$node ) Line 1220  function carto_wms_form( &$node )
1220      return $form;      return $form;
1221  }  }
1222    
1223    function replace_encoding( $matches )
1224    {
1225        //drupal_set_message( "replace_encoding " . var_export($matches,true) );
1226        return 'encoding="UTF-8"';
1227    }
1228    
1229    function append_url( $service, $params )
1230    {
1231        $result = $service;
1232        if( strpos( $service, '?' ) === FALSE )
1233            $result .= "?";
1234        else if( substr( $service, -1 ) != '&' && substr( $service, -1 ) != '?' )
1235            $result .= '&';
1236        if( substr( $params, 0, 1 ) == '&' )
1237            $params = substr( $params, 1 );
1238        $result .= $params;
1239    //drupal_set_message( 'append_url ' . $service . ' + ' . $params . ' -> ' . $result);
1240        return $result;
1241    }
1242    
1243    function get_capabilities( $service )
1244    {
1245        $url = append_url( $service, "service=wms&request=GetCapabilities" );
1246        ini_set( 'max_execution_time', 120 );
1247        $result = NULL;
1248        $response = drupal_http_request( $url );
1249        if( $response->code == 200 )
1250        {
1251            $xmldecl = substr($response->data, 0, strpos($response->data,'?>')+2);
1252            if( 0 == preg_match( '/\<\?xml(.*)\?\>/', $xmldecl, $matches ) )
1253            {
1254                drupal_set_message( 'No xml version tag in capabilities' );
1255            }
1256            else
1257            {
1258                //drupal_set_message( 'xml header: ' . var_export($matches,true) );
1259                $params = $matches[1];
1260                preg_match_all( '/(\w*)\=[\'\"](.*)[\'\"]/U', $params, $matches );
1261                $params = array();
1262                for( $i = 0; $i < count($matches[1]); $i++ )
1263                {
1264                    $params[ $matches[1][$i] ] = $matches[2][$i];
1265                }
1266                //drupal_set_message( 'xml params: ' . var_export($params,true) );
1267                if( isset($params['encoding']) && strtoupper($params['encoding']) != 'UTF-8' )
1268                {
1269                    drupal_set_message( t('Converting capabilities encoding from %from to %to',array('%from'=>$params['encoding'],'%to'=>'UTF-8')) );
1270                    // convert encoding to UTF-8
1271                    if( $params['encoding'] == 'ISO-8859-1' )
1272                        $str = utf8_encode( $response->data );
1273                    else
1274                        $str = mb_convert_encoding( $response->data, 'UTF-8', $params['encoding'] );
1275                    // set encoding parameter in xml header to UTF-8
1276                    $result = preg_replace_callback( '/encoding=\".*\"/U', "replace_encoding", $str, 1 );
1277                }
1278                else
1279                {
1280                    $result = $response->data;
1281                }
1282                drupal_set_message( t('Size of capabilities is %count bytes.',array('%count'=>strlen($result))) );
1283            }
1284        }
1285        else
1286        {
1287            form_set_error( 'getcapabilities', t('Failed to retrieve capabilities from server') . var_export($response,true) );
1288        }
1289        return $result;
1290    }
1291    
1292  function carto_wms_validate( &$node )  function carto_wms_validate( &$node )
1293  {  {
1294      //print 'carto_wms_validate: ' . var_export(array("POST" => $_POST, "NODE" => $node),true) . '<hr>';      //print 'carto_wms_validate: ' . var_export(array("POST" => $_POST, "NODE" => $node),true) . '<hr>';
1295        //drupal_set_message( 'carto_wms_validate' );
1296    
1297      if( $node->getcapabilities == 0 && $node->capabilities == '' )      if( $node->getcapabilities == 0 && $node->capabilities == '' )
1298      {      {
1299          form_set_error( 'capabilities', t('Either the capabilities must be inserted, or the \'Get capabilities\' option must be checked.') );          form_set_error( 'getcapabilities', t('Either the capabilities must be inserted, or the \'Get capabilities\' option must be checked.') );
1300      }      }
1301      if( $node->capabilities == '' && $node->getcapabilities == 1 )//&& $_POST['edit']['capabilities'] == '' )      if( $node->getcapabilities == 1 )//&& $_POST['edit']['capabilities'] == '' )
1302      {      {
1303          $url = $node->service . "&service=wms&request=GetCapabilities";          $node->capabilities = $_SESSION['capabilities'] = get_capabilities( $node->service );
         $response = drupal_http_request( $url );  
         //drupal_set_message( var_export($response,true) );  
         if( $response->code == 200 )  
         {  
             // Set capabilities value in $_POST  
             // Note: form value is determined by 1) $_POST (if set) or else  
             // by 2) #default_value. An alternative is to use #value?  
             $node->capabilities = $response->data;  
             $_SESSION['capabilities'] = $response->data;  
             //drupal_set_message( 'Capabilities were requested in carto_wms_validate' );  
         }  
         else  
         {  
             form_set_error('capabilities', t('The capabilities must be present!'));  
         }  
1304      }      }
1305    
1306      //form_set_error('capabilities','carto_wms_validate functie:' . var_export($node,true) );      //form_set_error('capabilities','carto_wms_validate functie:' . var_export($node,true) );
# Line 1265  function carto_wms_validate( &$node ) Line 1308  function carto_wms_validate( &$node )
1308    
1309  function carto_wms_submit( &$node )  function carto_wms_submit( &$node )
1310  {  {
1311        //drupal_set_message( 'carto_wms_submit' );
1312      //print 'carto_wms_submit:' . var_export(array("NODE" => $node,"EDIT" => $_POST['edit']),true) . '<hr>';      //print 'carto_wms_submit:' . var_export(array("NODE" => $node,"EDIT" => $_POST['edit']),true) . '<hr>';
1313  }  }
1314    
1315  function carto_wms_insert( $node )  function carto_wms_insert( $node )
1316  {  {
1317        //drupal_set_message( 'carto_wms_insert' );
1318    
1319      //print 'carto_wms_insert:' . var_export(array("NODE" => $node,"EDIT" => $_POST['edit']),true) . '<hr>';      //print 'carto_wms_insert:' . var_export(array("NODE" => $node,"EDIT" => $_POST['edit']),true) . '<hr>';
1320      $caps = & new CapabilitiesParser( );      $caps = & new CapabilitiesParser( );
1321    
# Line 1279  function carto_wms_insert( $node ) Line 1325  function carto_wms_insert( $node )
1325  //        carto_wms_validate( $node );  //        carto_wms_validate( $node );
1326          if( isset($_SESSION['capabilities']) )          if( isset($_SESSION['capabilities']) )
1327          {          {
1328                drupal_set_message( 'Using capabilities that were requested during validate..' );
1329              $node->capabilities = $_SESSION['capabilities'];              $node->capabilities = $_SESSION['capabilities'];
1330          }          }
1331          else          else
1332          {          {
1333              $url = $node->service . "&service=wms&request=GetCapabilities";              drupal_set_message( 'Requesting capabilities..' );
1334              $response = drupal_http_request( $url );              $node->capabilities = get_capabilities( $node->service );
             //drupal_set_message( var_export($response,true) );  
             if( $response->code == 200 )  
             {  
                 // Set capabilities value in $_POST  
                 // Note: form value is determined by 1) $_POST (if set) or else  
                 // by 2) #default_value. An alternative is to use #value?  
                 $node->capabilities = $response->data;  
                 drupal_set_message( 'Capabilities were requested in carto_wms_insert' );  
             }  
1335          }          }
1336      }      }
1337    
# Line 1313  function insert_capabilities( $layer, $n Line 1351  function insert_capabilities( $layer, $n
1351      if( $layer['layer_id'] == 0 )      if( $layer['layer_id'] == 0 )
1352      {      {
1353          $wms_version = $layer['wms_version'];          $wms_version = $layer['wms_version'];
1354    
1355            //print 'capabilities: ' . strlen($node->capabilities) . '<br/>';
1356            //ini_set('max_allowed_packet',strlen($node->capabilities) + 16000);
1357            //print 'max_allowed_packet: ' . ini_get('max_allowed_packet') . '<br/>';
1358    
1359            db_query( "INSERT INTO {carto_wms_node} ( nid, name, title, service, version, abstract, captime ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d )"
1360                , $node->nid
1361                , $layer['Name']
1362                , $layer['Title']
1363                , $node->service
1364                , $layer['wms_version']
1365                , $layer['Abstract']
1366                , time()
1367                );
1368      }      }
1369      if( $layer['layer_id'] == 1 )      if( $layer['layer_id'] == 1 )
1370      {      {
1371          $first_layer = $layer['Name'];          $first_layer = $layer['Name'];
1372            /*
1373          db_query( "INSERT INTO {carto_wms_node} ( nid, service, version, capabilities, bbox, layers )"          db_query( "INSERT INTO {carto_wms_node} ( nid, service, version, capabilities, bbox, layers )"
1374              . " VALUES( %d, '%s', '%s', '%s', '%s', '%s' )"              . " VALUES( %d, '%s', '%s', '%s', '%s', '%s' )"
1375              , $node->nid, $node->service, $wms_version, $node->capabilities              , $node->nid, $node->service, $wms_version, $node->capabilities
1376              , $layer['LatLonBoundingBox']['minx'] . ',' . $layer['LatLonBoundingBox']['miny'] . ',' . $layer['LatLonBoundingBox']['maxx'] . ',' . $layer['LatLonBoundingBox']['maxy']              , $layer['LatLonBoundingBox']['minx'] . ',' . $layer['LatLonBoundingBox']['miny'] . ',' . $layer['LatLonBoundingBox']['maxx'] . ',' . $layer['LatLonBoundingBox']['maxy']
1377              , $first_layer              , $first_layer
1378              );              );
1379            */
1380            db_query( "UPDATE {carto_wms_node} SET capabilities = '%s', bbox = '%s', layers = '%s' WHERE nid = %d"
1381                , $node->capabilities
1382                , $layer['LatLonBoundingBox']['minx'] . ',' . $layer['LatLonBoundingBox']['miny'] . ',' . $layer['LatLonBoundingBox']['maxx'] . ',' . $layer['LatLonBoundingBox']['maxy']
1383                , $first_layer
1384                , $node->nid );
1385      }      }
1386      if( $layer['Title'] != '' )      if( $layer['Title'] != '' )
1387      {      {
# Line 1383  function insert_capabilities( $layer, $n Line 1441  function insert_capabilities( $layer, $n
1441    
1442  function carto_wms_update( $node )  function carto_wms_update( $node )
1443  {  {
1444        //drupal_set_message( 'carto_wms_update' );
1445    
1446  //    print 'carto_wms_update:' . var_export(array($node,$_POST['edit']),true) . '<hr>';  //    print 'carto_wms_update:' . var_export(array($node,$_POST['edit']),true) . '<hr>';
1447      $caps = & new CapabilitiesParser( );      $caps = & new CapabilitiesParser( );
1448    
# Line 1390  function carto_wms_update( $node ) Line 1450  function carto_wms_update( $node )
1450      if( $node->getcapabilities && $node->capabilities == '')      if( $node->getcapabilities && $node->capabilities == '')
1451      {      {
1452  //        carto_wms_validate( $node );  //        carto_wms_validate( $node );
1453            if( isset($_SESSION['capabilities']) )
1454            {
1455                drupal_set_message( 'Using capabilities requested during validate..' );
1456                $node->capabilities = $_SESSION['capabilities'];
1457            }
1458            else
1459            {
1460                drupal_set_message( 'Requesting capabilities..' );
1461                $node->capabilities = get_capabilities( $node->service );
1462            }
1463      }      }
1464    
1465      $caps->parse( $node->capabilities, "update_capabilities", & $node );      $caps->parse( $node->capabilities, "update_capabilities", & $node );
1466  //    print 'caps:' . var_export($caps,true) . '<br>';  //    print 'caps:' . var_export($caps,true) . '<br>';
1467        unset( $_SESSION['capabilities'] );
1468      $caps->free_parser( );      $caps->free_parser( );
1469  }  }
1470    
1471  function update_capabilities( $layer, $node )  function update_capabilities( $layer, $node )
1472  {  {
1473  //    print 'update: ' . var_export($layer,true) . '<br>';  //    print 'update: ' . var_export($layer,true) . '<br>';
1474      if( $layer['layer_id'] == 1 )      if( $layer['layer_id'] == 0 )
1475      {      {
1476          db_query( "DELETE FROM {carto_wms_node} WHERE nid = %d", $node->nid );          db_query( "DELETE FROM {carto_wms_node} WHERE nid = %d", $node->nid );
1477      }      }
# Line 1433  function carto_wms_delete( &$node ) Line 1504  function carto_wms_delete( &$node )
1504    
1505  function carto_wms_load( $node )  function carto_wms_load( $node )
1506  {  {
1507      $additions = db_fetch_object(db_query('SELECT service, version, capabilities, layers, bbox, srs FROM {carto_wms_node} WHERE nid = %d', $node->nid));      $additions = db_fetch_object(db_query('SELECT name as wms_name, title as wms_title, abstract, service, version, capabilities, layers, bbox, srs FROM {carto_wms_node} WHERE nid = %d', $node->nid));
1508    
1509      //if( ! $additions->layers ) $additions->layers = 'Countries';      //if( ! $additions->layers ) $additions->layers = 'Countries';
1510      //if( ! $additions->bbox ) $additions->bbox = '-180,-90,180,90';      //if( ! $additions->bbox ) $additions->bbox = '-180,-90,180,90';
# Line 1499  function carto_wms_content($node, $tease Line 1570  function carto_wms_content($node, $tease
1570          $layers = explode( ',', $node->layers );          $layers = explode( ',', $node->layers );
1571      }      }
1572    
1573      $content .= '<p>Web service: ' . $node->service . "</p>\n";      $header = array( t('Property'), t('Value') );
1574      $content .= '<p>Capabilities: <a href="' . $node->service . '&service=wms&request=GetCapabilities">click there</a>'      $rows = array();
1575      . " or <a href=\"" . base_path() . "carto/wms/node/{$node->nid}?request=GetCapabilities\">here</a>"      $rows[] = array( t('Title'), $node->wms_title );
1576          . "</p>\n";      $rows[] = array( t('Name'), $node->wms_name );
1577      $content .= '<p>Layers: ' . $node->layers . "</p>\n";      $rows[] = array( 'data' => array(t('Abstract'), $node->abstract ) , 'valign' => 'top' );
1578        $rows[] = array( t('Visible layers'), $node->layers );
1579        $rows[] = array( t('Web service'), $node->service );
1580        $rows[] = array( t('Capabilities'), l('link to remote capabilities',append_url( $node->service, "service=wms&request=GetCapabilities" ),array('target'=>'_blank')) );
1581        $rows[] = array( '', l('link to local capabilities', "carto/wms/node/{$node->nid}", array('target'=>'_blank'), "request=GetCapabilities" ) );
1582        $content .= theme( 'table', $header, $rows );
1583    
1584        //$content .= '<p>Web service: ' . $node->service . "</p>\n";
1585        //$content .= '<p>Title: ' . $node->title . "</p>\n";
1586        //$content .= '<p>Name: ' . $node->name . "</p>\n";
1587        //$content .= '<p>Abstract: ' . $node->abstract . "</p>\n";
1588    //    $content .= '<p>Capabilities: <a href="' . $node->service . '&service=wms&request=GetCapabilities">click there</a>'
1589    //    . " or <a href=\"" . base_path() . "carto/wms/node/{$node->nid}?request=GetCapabilities\">here</a>"
1590    //        . "</p>\n";
1591        //$content .= '<p>Layers: ' . $node->layers . "</p>\n";
1592    
1593        // TODO: ADD TITLE,NAME,ABSTRACT?
1594    
1595      if( variable_get('carto_wms_teaser_map',1) )//! $teaser )      if( variable_get('carto_wms_teaser_map',1) )//! $teaser )
1596      {      {
# Line 1537  function carto_wms_content($node, $tease Line 1624  function carto_wms_content($node, $tease
1624    
1625          $imageformat = "image/png";          $imageformat = "image/png";
1626    
1627          $widget_text = "{mappingwidget type=\"SimpleMap\" service=\"{$node->service}&version={$node->version}\"          $wms_service = append_url( $node->service, "version={$node->version}" );
1628            $widget_text = "{mappingwidget type=\"SimpleMap\" service=\"{$wms_service}\"
1629      width=\"$width\" height=\"$height\"      width=\"$width\" height=\"$height\"
1630      layers=\"{$node->layers}\"      layers=\"{$node->layers}\"
1631      extent=\"{$extent}\" srs=\"{$node->srs}\"      extent=\"{$extent}\" srs=\"{$node->srs}\"
# Line 1574  function carto_wms_content($node, $tease Line 1662  function carto_wms_content($node, $tease
1662    
1663  if( file_exists(variable_get('carto_mappingwidgets_dir',MAPPINGWIDGETS_DIR) . 'wms-parser.php') )  if( file_exists(variable_get('carto_mappingwidgets_dir',MAPPINGWIDGETS_DIR) . 'wms-parser.php') )
1664  {  {
1665  include_once( variable_get('carto_mappingwidgets_dir',MAPPINGWIDGETS_DIR) . 'wms-parser.php' );  //include_once( variable_get('carto_mappingwidgets_dir',MAPPINGWIDGETS_DIR) . 'wms-parser.php' );
1666    include_once( 'wms-parser.php' );
1667    
1668  function carto_search( $op = 'search', $keys = NULL )  function carto_form_alter( $form_id, &$form )
1669  {  {
1670  //            print 'carto search: ' . $op . "<br>\n";      //drupal_set_message( 'carto_form_alter ' . $form_id );
1671      switch( $op )      if( $form_id == 'search_form' && arg(1) == 'carto' )
1672      {      {
1673          case 'name':          $form['bbox'] = array('#type' => 'fieldset'
1674              return t('web mapping services');              , '#title' => t('Bounding box')
1675                , '#collapsible' => TRUE, '#collapsed' => TRUE );
1676          case 'form': // starting drupal 4.7          $form['bbox']['srs'] = array( '#type' => 'select'
1677              $fields = array();              , '#title' => t('SRS')
1678              $fields['bbox'] = array('#type' => 'fieldset', '#title' => t('Bounding box'), '#collapsible' => TRUE, '#collapsed' => TRUE );              , '#options' => array( 'EPSG:4326' => 'Geographic coordinates (EPSG:4326)' )
             $fields['bbox']['x'] = array('#type' => 'markup', '#prefix' => '<div class="container-inline">', '#suffix' => '</div>');  
             $fields['bbox']['x']['xmin'] = array('#type' => 'textfield', '#title' => 'Minimum x coordinate', '#default_value' => '-180', '#size' => 10, '#maxlength' => 10  
 //            , '#prefix' => '<div>', '#suffix' => '</div>'  
1679              );              );
1680              $fields['bbox']['x']['xmax'] = array('#type' => 'textfield', '#title' => 'Maximum x coordinate', '#default_value' => '180', '#size' => 10, '#maxlength' => 10          $form['bbox']['xmin'] = array('#type' => 'textfield'
1681                , '#title' => t('Minimum x coordinate')
1682                , '#default_value' => '-180'
1683                , '#size' => 10, '#maxlength' => 10
1684  //            , '#prefix' => '<div>', '#suffix' => '</div>'  //            , '#prefix' => '<div>', '#suffix' => '</div>'
1685              );              );
1686              $fields['bbox']['ymin'] = array('#type' => 'textfield', '#title' => 'Minimum y coordinate', '#default_value' => '-90', '#size' => 10, '#maxlength' => 10 );          $form['bbox']['ymin'] = array('#type' => 'textfield'
1687              $fields['bbox']['ymax'] = array('#type' => 'textfield', '#title' => 'Maximum y coordinate', '#default_value' => '90', '#size' => 10, '#maxlength' => 10 );              , '#title' => t('Minimum y coordinate')
1688              return $fields;              , '#default_value' => '-90'
1689                , '#size' => 10, '#maxlength' => 10 );
1690            $form['bbox']['xmax'] = array('#type' => 'textfield'
1691                , '#title' => t('Maximum x coordinate')
1692                , '#default_value' => '180'
1693                , '#size' => 10, '#maxlength' => 10
1694    //            , '#prefix' => '<div>', '#suffix' => '</div>'
1695            );
1696            $form['bbox']['ymax'] = array('#type' => 'textfield'
1697                , '#title' => t('Maximum y coordinate')
1698                , '#default_value' => '90'
1699                , '#size' => 10, '#maxlength' => 10 );
1700        }
1701    }
1702    
1703    function carto_search( $op = 'search', $keys = NULL )
1704    {
1705        drupal_set_message( 'carto search: ' . $op . '/' . var_export($keys,true) );
1706        // name/reset/search/status
1707        switch( $op )
1708        {
1709            case 'name':
1710                return t('maps');
1711    
1712          case 'post':  /*        case 'post':
1713              $results = array();              $results = array();
1714    
1715              $item = array();              $item = array();
# Line 1608  function carto_search( $op = 'search', $ Line 1719  function carto_search( $op = 'search', $
1719              $results[] = $item;              $results[] = $item;
1720    
1721              return $results;              return $results;
1722                */
1723          case 'status': // in admin/settings/search page (1st)          case 'status': // in admin/settings/search page (1st)
1724          case 'admin': // in admin/settings/search page (2nd)          case 'admin': // in admin/settings/search page (2nd)
1725              $fields = array();              $fields = array();
1726              $fields['carto'] = array('#type' => 'fieldset', '#title' => t('Maps'), '#collapsible' => FALSE, '#collapsed' => FALSE );              $fields['carto'] = array('#type' => 'fieldset'
1727                    , '#title' => t('Maps')
1728                    , '#collapsible' => TRUE, '#collapsed' => FALSE );
1729              $fields['carto']['fields'] = array( '#type' => 'textfield'              $fields['carto']['fields'] = array( '#type' => 'textfield'
1730                  , '#title' => 'Search fields'                  , '#title' => 'Search fields'
1731                  , '#default_value' => variable_get( 'carto_wms_search_fields', DEFAULT_WMS_SEARCH_FIELDS )                  , '#default_value' => variable_get( 'carto_wms_search_fields', DEFAULT_WMS_SEARCH_FIELDS )
# Line 1633  function carto_search( $op = 'search', $ Line 1746  function carto_search( $op = 'search', $
1746      }      }
1747  }  }
1748    
1749    function carto_update_index( )
1750    {
1751        //watchdog( 'debug', 'carto_update_index' );
1752        // index layers of wms node
1753        $result = db_query( "SELECT n.nid, l.lid, l.name, l.title, l.abstract FROM {carto_wms_node} n JOIN {carto_wms_layer} l ON n.nid = l.nid" );
1754        while( $node = db_fetch_object( $result ) )
1755        {
1756            search_index( $node->nid, 'node', $node->abstract );
1757        }
1758    }
1759    
1760  /**  /**
1761   * Implementation of hook_search_item.   * Implementation of hook_search_item.
1762   */   */
1763  function carto_search_item($item)  function carto_search_item( $item )
1764  {  {
1765        drupal_set_message( 'carto_search_item ' . var_export($item) );
1766    
1767      $output .= ' <b><u><a href="'. $item['link']      $output .= ' <b><u><a href="'. $item['link']
1768          .'">'. $item['title'] .'</a></u></b><br />';          .'">'. $item['title'] .'</a></u></b><br />';
1769      $output .= ' <small>' . $item['description'] . '</small>';      $output .= ' <small>' . $item['description'] . '</small>';
# Line 2075  function get_common_srs( $other = NULL ) Line 2201  function get_common_srs( $other = NULL )
2201      }      }
2202      return $common_srs;      return $common_srs;
2203  }  }
2204    
2205  ?>  ?>

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.2