Copyright (c) 2003, DM Solutions Group Inc. * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **/ /* ======================================================================== */ /* returns assoc array containing layer index, layer name, and field names */ /* works for mapfiles only, only returns layers with status ON */ /* ======================================================================== */ function getLayerList( $szConType = MS_WFS, $szSource="ns_wfsclient.map" ) { $oMap = ms_newMapObj($szSource); $nLayerCount = $oMap->numlayers; $aLayers = array(); $j=0; for($i=0; $i<$nLayerCount; $i++) { $oLayer = $oMap->GetLayer($i); if(isset($szConType)) { if($oLayer->connectiontype == MS_WFS) { if(!$oLayer->status == MS_OFF) { $oLayer->open(); $oShape = $oLayer->getShape( -1, 0 ); $aLayers[$j]['name'] = $oLayer->name; $aLayers[$j]['index'] = $oLayer->index; $aLayers[$j]['fld_arr'] = array_keys($oShape->values); $j++; } } } } return $aLayers; } /* ======================================================================== */ /* parses the FORM vars and returns an indexed array containing each filter */ /* each assoc array contains the necessary params for building a filter */ /* ======================================================================== */ function parseWFSURL( $HTTP_FORM_VARS, $nFilters, $szSearch = "__" ) { $aFilter = array(); if( $HTTP_FORM_VARS ) { for($i=0; $i $value) { $pos = strpos( $key, $szSearch ); if ($pos !== false) { $k = intval(substr($key, $pos+strlen($szSearch))); $aFilter[$k][substr($key,0,$pos)] = $value; } } } return $aFilter; } /* ======================================================================== */ /* input: indexed array returned from parseWFSURL() */ /* returns: indexed array of WFS-compliant filter strings */ /* ======================================================================== */ function buildFEString($aParams, $nLoop, $wildCard, $singleChar, $escapeChar) { /* EG ARRAY [0] => Array ( [layer] => popplace [field] => NAME [not] => NOT [operator] => EqualTo [value1] => Digby [value2] => ) */ $aTAG = array(); for( $i=0; $i<$nLoop; $i++ ) { if((strlen($aParams[$i]['operator']) < 3 ) || (strlen($aParams[$i]['field']) < 1 )) break; //create the operator tag //check the operator for 'PropertyIs' .. if not present then add it if( stristr($aParams[$i]['operator'], 'PropertyIs') ) { $szPropertyTAG = "<" . str_replace(' ','',$aParams[$i]['operator']) . ">"; $szPropertyCloseTAG = ""; } else { if( stristr($aParams[$i]['operator'], 'Like') ) { $szPropertyTAG = ""; } else { $szPropertyTAG = ""; } $szPropertyCloseTAG = "";; } //create the name tag $szPropertyNameTAG = "".$aParams[$i]['field'].""; //set the val literal|upper/lower bounds if( (stristr($aParams[$i]['operator'], 'Between')) ) $szValueTAG = "".$aParams[$i]['value1']. "". $aParams[$i]['value2'].""; else $szValueTAG = "".$aParams[$i]['value1'].""; //create the NOT tag if applicable if($aParams[$i]['not'] !== '') { $szNotTAG = ""; $szNotCloseTAG = ""; } else { $szNotTAG = ""; $szNotCloseTAG = ""; } $szWFS = $szNotTAG . $szPropertyTAG . $szPropertyNameTAG . $szValueTAG . $szPropertyCloseTAG . $szNotCloseTAG; $aTAG[$i] = $szWFS; } return $aTAG; } ?>