/[drupal]/contributions/modules/carto/wms-parser.php
ViewVC logotype

Diff of /contributions/modules/carto/wms-parser.php

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

revision 1.1, Fri Jan 13 07:54:00 2006 UTC revision 1.2, Fri Oct 13 13:22:51 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2    // $Id$
3    
4  // CubeWerx requires at least 10M for wms capabilities  // CubeWerx requires at least 10M for wms capabilities
5  //    ini_set( 'memory_limit', '10M' );  ini_set( 'memory_limit', '20M' );
6    
7  /**  /**
8   *   *
# Line 32  class CapabilitiesParser Line 33  class CapabilitiesParser
33    
34      function CapabilitiesParser( )      function CapabilitiesParser( )
35      {      {
36          $this->parser = xml_parser_create( );          $this->parser = xml_parser_create( "UTF-8" );
37          xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );          xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
38          xml_set_element_handler( $this->parser, array(&$this,"_startElement"), array(&$this,"_endElement") );          xml_set_element_handler( $this->parser, array(&$this,"_startElement"), array(&$this,"_endElement") );
39          xml_set_character_data_handler( $this->parser, array(&$this,"_characterData") );          xml_set_character_data_handler( $this->parser, array(&$this,"_characterData") );
# Line 61  class CapabilitiesParser Line 62  class CapabilitiesParser
62    
63      function _startElement( $parser, $name, $attrs )      function _startElement( $parser, $name, $attrs )
64      {      {
65    //print '_startElement ' . $name . "\n";
66          if( ! $this->root )          if( ! $this->root )
67          {          {
68              $this->root = $name;              $this->root = $name;
69              $this->version = $attrs['version'];              $this->version = $attrs['version'];
70                $this->layer_props[ $this->layer_level ]['wms_version'] = $this->version;
71          }          }
72          else          else
73          {          {
# Line 142  class CapabilitiesParser Line 145  class CapabilitiesParser
145    
146      function _characterData( $parser, $data )      function _characterData( $parser, $data )
147      {      {
148    //print '_characterData ' . $this->element . ':' . $data . "\n";
149          if( $this->element != '' )          if( $this->element != '' )
150          {          {
151              $text = trim($data);              $text = trim($data);
152                if( $this->layer_level == 0 )
153                {
154                    switch( $this->element )
155                    {
156                        case 'Title':
157                        case 'Name':
158                        case 'Abstract':
159        //print 'abstract=' . $test . '<br/>';
160                            $this->layer_props[ $this->layer_level][ $this->element ] .= $text;
161                            break;
162                    }
163                }
164              if( $this->layer_level > 0 && ! $this->inSomething() )              if( $this->layer_level > 0 && ! $this->inSomething() )
165              {              {
166                  switch( $this->element )                  switch( $this->element )
167                  {                  {
168                      case 'Title':                      case 'Title':
169                      case 'Name':                      case 'Name':
170                            // if not a style name!!
171                            $this->layer_props[ $this->layer_level][ $this->element ] .= $text;
172                            break;
173                      case 'Abstract':                      case 'Abstract':
174        //print 'abstract=' . $test . '<br/>';
175                          // if not a style name!!                          // if not a style name!!
176                          $this->layer_props[ $this->layer_level][ $this->element ] = $text;                          $this->layer_props[ $this->layer_level][ $this->element ] .= $text;
177                          break;                          break;
178                      case 'SRS':                      case 'SRS':
179                          if( isset($this->layer_props[ $this->layer_level][ $this->element ])                          if( isset($this->layer_props[ $this->layer_level][ $this->element ])
# Line 170  class CapabilitiesParser Line 190  class CapabilitiesParser
190                  switch( $this->element )                  switch( $this->element )
191                  {                  {
192                      case 'Name':                      case 'Name':
193                          $this->inStyle = $text;                          $this->inStyle .= $text;
194                          break;                          break;
195                  }                  }
196              }              }
197  //            print $this->path . ':<b>' . $this->element . '=' . $text . '|</b><br>';  //            print $this->path . ':<b>' . $this->element . '=' . $text . '|</b><br>';
198  //            print '---> ' . $this->layer_level . '/' . var_export($this->layer_props[ $this->layer_level],true) . '<br>';  //            print '---> ' . $this->layer_level . '/' . var_export($this->layer_props[ $this->layer_level],true) . '<br>';
199              $this->element = '';  
200                //$this->element = ''; // previously here instead of at start of _endElement
201          }          }
202      }      }
203    
204      function _endElement( $parser, $name )      function _endElement( $parser, $name )
205      {      {
206    //print '_endElement ' . $name . "\n";
207            $this->element = ''; // instead of at end of _characterData function
208    
209          $this->path = substr( $this->path, 0, -(1+strlen($name)) );          $this->path = substr( $this->path, 0, -(1+strlen($name)) );
210          switch( $name )          switch( $name )
211          {          {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2