/[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.20, Fri Oct 13 13:22:51 2006 UTC revision 1.21, Sun Oct 15 22:37:26 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: carto.module,v 1.19 2006/10/07 22:12:05 openwereld Exp $  // $Id: carto.module,v 1.20 2006/10/13 13:22:51 openwereld Exp $
3    
4  define( 'DEFAULT_WMS_SEARCH_FIELDS', 'name,title,keywords,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 );
# Line 1263  function get_capabilities( $service ) Line 1263  function get_capabilities( $service )
1263              {              {
1264                  $params[ $matches[1][$i] ] = $matches[2][$i];                  $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' )              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')) );                  drupal_set_message( t('Converting capabilities encoding from %from to %to',array('%from'=>$params['encoding'],'%to'=>'UTF-8')) );
1270                  // convert encoding to UTF-8                  // convert encoding to UTF-8
1271                  if( $params['encoding'] == 'ISO-8859-1' )                  $str = mb_convert_encoding( $response->data, 'UTF-8', $params['encoding'] );
                     $str = utf8_encode( $response->data );  
                 else  
                     $str = mb_convert_encoding( $response->data, 'UTF-8', $params['encoding'] );  
1272                  // set encoding parameter in xml header to UTF-8                  // set encoding parameter in xml header to UTF-8
1273                  $result = preg_replace_callback( '/encoding=\".*\"/U', "replace_encoding", $str, 1 );                  $result = preg_replace_callback( '/encoding=\".*\"/U', "replace_encoding", $str, 1 );
1274              }              }
# Line 1291  function get_capabilities( $service ) Line 1288  function get_capabilities( $service )
1288    
1289  function carto_wms_validate( &$node )  function carto_wms_validate( &$node )
1290  {  {
     //print 'carto_wms_validate: ' . var_export(array("POST" => $_POST, "NODE" => $node),true) . '<hr>';  
     //drupal_set_message( 'carto_wms_validate' );  
   
1291      if( $node->getcapabilities == 0 && $node->capabilities == '' )      if( $node->getcapabilities == 0 && $node->capabilities == '' )
1292      {      {
1293          form_set_error( 'getcapabilities', 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.') );
# Line 1302  function carto_wms_validate( &$node ) Line 1296  function carto_wms_validate( &$node )
1296      {      {
1297          $node->capabilities = $_SESSION['capabilities'] = get_capabilities( $node->service );          $node->capabilities = $_SESSION['capabilities'] = get_capabilities( $node->service );
1298      }      }
   
     //form_set_error('capabilities','carto_wms_validate functie:' . var_export($node,true) );  
1299  }  }
1300    
1301  function carto_wms_submit( &$node )  function carto_wms_submit( &$node )
1302  {  {
1303      //drupal_set_message( 'carto_wms_submit' );      // nothing to do
     //print 'carto_wms_submit:' . var_export(array("NODE" => $node,"EDIT" => $_POST['edit']),true) . '<hr>';  
1304  }  }
1305    
1306  function carto_wms_insert( $node )  function carto_wms_insert( $node )
1307  {  {
1308      //drupal_set_message( 'carto_wms_insert' );      //drupal_set_message( 'carto_wms_insert; internal encoding ' . mb_internal_encoding() );
1309        //print( 'carto_wms_insert; internal encoding ' . mb_internal_encoding() );
1310    
     //print 'carto_wms_insert:' . var_export(array("NODE" => $node,"EDIT" => $_POST['edit']),true) . '<hr>';  
1311      $caps = & new CapabilitiesParser( );      $caps = & new CapabilitiesParser( );
1312    
     // @todo: do this (get capabilities) in validate function  
1313      if( $node->getcapabilities && $node->capabilities == '')      if( $node->getcapabilities && $node->capabilities == '')
1314      {      {
1315  //        carto_wms_validate( $node );  //        carto_wms_validate( $node );
# Line 1352  function insert_capabilities( $layer, $n Line 1342  function insert_capabilities( $layer, $n
1342      {      {
1343          $wms_version = $layer['wms_version'];          $wms_version = $layer['wms_version'];
1344    
1345          //print 'capabilities: ' . strlen($node->capabilities) . '<br/>';          // first create the wms node
         //ini_set('max_allowed_packet',strlen($node->capabilities) + 16000);  
         //print 'max_allowed_packet: ' . ini_get('max_allowed_packet') . '<br/>';  
   
1346          db_query( "INSERT INTO {carto_wms_node} ( nid, name, title, service, version, abstract, captime ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d )"          db_query( "INSERT INTO {carto_wms_node} ( nid, name, title, service, version, abstract, captime ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', %d )"
1347              , $node->nid              , $node->nid
1348              , $layer['Name']              , filter_xss( $layer['Name'] )
1349              , $layer['Title']              , filter_xss( $layer['Title'] )
1350              , $node->service              , $node->service
1351              , $layer['wms_version']              , filter_xss( $layer['wms_version'] )
1352              , $layer['Abstract']              , filter_xss( $layer['Abstract'] )
1353              , time()              , time()
1354              );              );
1355      }      }
# Line 1377  function insert_capabilities( $layer, $n Line 1364  function insert_capabilities( $layer, $n
1364              , $first_layer              , $first_layer
1365              );              );
1366          */          */
1367            // try to store the capabilities also
1368          db_query( "UPDATE {carto_wms_node} SET capabilities = '%s', bbox = '%s', layers = '%s' WHERE nid = %d"          db_query( "UPDATE {carto_wms_node} SET capabilities = '%s', bbox = '%s', layers = '%s' WHERE nid = %d"
1369              , $node->capabilities              , $node->capabilities
1370              , $layer['LatLonBoundingBox']['minx'] . ',' . $layer['LatLonBoundingBox']['miny'] . ',' . $layer['LatLonBoundingBox']['maxx'] . ',' . $layer['LatLonBoundingBox']['maxy']              , $layer['LatLonBoundingBox']['minx'] . ',' . $layer['LatLonBoundingBox']['miny'] . ',' . $layer['LatLonBoundingBox']['maxx'] . ',' . $layer['LatLonBoundingBox']['maxy']
1371              , $first_layer              , filter_xss( $layer['Name'] )
1372              , $node->nid );              , $node->nid );
1373      }      }
1374      if( $layer['Title'] != '' )      if( $layer['Title'] != '' )
# Line 1392  function insert_capabilities( $layer, $n Line 1380  function insert_capabilities( $layer, $n
1380          }          }
1381          if( FALSE == @db_query( "INSERT INTO {carto_wms_layer}( nid, lid, name, title, abstract, minx, miny, maxx, maxy, queryable, opaque, cascaded )"          if( FALSE == @db_query( "INSERT INTO {carto_wms_layer}( nid, lid, name, title, abstract, minx, miny, maxx, maxy, queryable, opaque, cascaded )"
1382              . " VALUES( %d, %d, '%s', '%s', '%s', %f, %f, %f, %f, %d, %d, %d )"              . " VALUES( %d, %d, '%s', '%s', '%s', %f, %f, %f, %f, %d, %d, %d )"
1383              , $node->nid, $layer['layer_id'], $layer['Name'], $layer['Title'], $layer['Abstract']              , $node->nid
1384              , $layer['LatLonBoundingBox']['minx'], $layer['LatLonBoundingBox']['miny'], $layer['LatLonBoundingBox']['maxx'], $layer['LatLonBoundingBox']['maxy']              , $layer['layer_id']
1385              , $layer['queryable'], $layer['opaque'], $layer['cascaded'] ) )              , filter_xss( $layer['Name'] )
1386                , filter_xss( $layer['Title'] )
1387                , filter_xss( $layer['Abstract'] )
1388                , floatval( $layer['LatLonBoundingBox']['minx'] )
1389                , floatval( $layer['LatLonBoundingBox']['miny'] )
1390                , floatval( $layer['LatLonBoundingBox']['maxx'] )
1391                , floatval( $layer['LatLonBoundingBox']['maxy'] )
1392                , intval( $layer['queryable'] )
1393                , intval( $layer['opaque'] )
1394                , intval( $layer['cascaded'] ) )
1395                )
1396          {          {
1397              // set watchdog message              // set watchdog message
1398              watchdog( "carto", "Insert into carto_wms_layer executed not correctly", WATCHDOG_WARNING );              watchdog( "carto", "Insert into carto_wms_layer executed not correctly", WATCHDOG_WARNING );
# Line 1428  function insert_capabilities( $layer, $n Line 1426  function insert_capabilities( $layer, $n
1426                          $value = implode( ' ', $value );                          $value = implode( ' ', $value );
1427                      if( FALSE == @db_query( "INSERT INTO {carto_wms_layer_properties}( nid, lid, property, name, value )"                      if( FALSE == @db_query( "INSERT INTO {carto_wms_layer_properties}( nid, lid, property, name, value )"
1428                          . " VALUES( %d, %d, '%s', '%s', '%s' )"                          . " VALUES( %d, %d, '%s', '%s', '%s' )"
1429                          , $node->nid, $layer['layer_id'], $property, $name, $value ) )                          , $node->nid
1430                            , $layer['layer_id']
1431                            , $property
1432                            , $name
1433                            , $value )
1434                            )
1435                      {                      {
1436                          // set watchdog message                          // set watchdog message
1437                          watchdog( "carto", "Insert into carto_wms_layer_properties executed not correctly", WATCHDOG_WARNING );                          watchdog( "carto", "Insert into carto_wms_layer_properties executed not correctly", WATCHDOG_WARNING );
# Line 1441  function insert_capabilities( $layer, $n Line 1444  function insert_capabilities( $layer, $n
1444    
1445  function carto_wms_update( $node )  function carto_wms_update( $node )
1446  {  {
1447      //drupal_set_message( 'carto_wms_update' );      //drupal_set_message( 'carto_wms_update; internal encoding ' . mb_internal_encoding() );
1448    
 //    print 'carto_wms_update:' . var_export(array($node,$_POST['edit']),true) . '<hr>';  
1449      $caps = & new CapabilitiesParser( );      $caps = & new CapabilitiesParser( );
1450    
     // @todo: do this (get capabilities) in validate function  
1451      if( $node->getcapabilities && $node->capabilities == '')      if( $node->getcapabilities && $node->capabilities == '')
1452      {      {
 //        carto_wms_validate( $node );  
1453          if( isset($_SESSION['capabilities']) )          if( isset($_SESSION['capabilities']) )
1454          {          {
1455              drupal_set_message( 'Using capabilities requested during validate..' );              drupal_set_message( 'Using capabilities requested during validate..' );
# Line 1523  function carto_wms_view( &$node, $teaser Line 1523  function carto_wms_view( &$node, $teaser
1523          // @todo: breadcrumb navigation          // @todo: breadcrumb navigation
1524          $breadcrumb = array();          $breadcrumb = array();
1525          $breadcrumb[] = array( 'path' => 'carto', 'title' => t('carto') );          $breadcrumb[] = array( 'path' => 'carto', 'title' => t('carto') );
1526          $breadcrumb[] = array( 'path' => 'carto/user/'. $node->uid, 'title' => t("%name's web mapping services", array('%name' => $node->name)) );          $breadcrumb[] = array( 'path' => 'carto/wms', 'title' => t('wms') );
1527            $breadcrumb[] = array( 'path' => 'carto/wms/user/'. $node->uid, 'title' => $node->name . "'s web mapping services" );
1528          $breadcrumb[] = array( 'path' => 'node/'. $node->nid );          $breadcrumb[] = array( 'path' => 'node/'. $node->nid );
1529          menu_set_location( $breadcrumb );          menu_set_location( $breadcrumb );
1530      }      }

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

  ViewVC Help
Powered by ViewVC 1.1.2