[Chameleon] custom query results. Stumped..
Eric O'Neal
ericoneal at gmail.com
Thu Oct 12 17:17:30 EDT 2006
I read a thread here earlier regarding the removal of extra fields from the
results as well as searching for links in the field values. All is going
well, but I seem to have an extra column being added at the start of the
headers for the table and this is making all of the results be off by one
field. Code follows. Any help would be GREATLY appreciated.
// read map file: header -> definition of table header
// the order of the columns are important, there will be shown in this order
// HEADER
"AREA^|PERIMETER^|POPPLACE_^|POPPLACE_I^|UNIQUE_KEY^Code|NAME^Name|NAME_E^|NAME_F^|REG_CODE^|NTS50^|LAT^|LONG^|SGC_CODE^|CAPITAL^|POP_RANGE^|SHAPE_INDEX^|TILE_INDEX^|LAYER_INDEX"
// the seperator of a column '|'
// the seperator between column and displayname '^'
// if the displayname is missing the column is not be shown
$oLayer = $oMap->getLayerByName($aszLayers[$i]);
$szHeader = $oLayer->header;
$aszHeaderNames = array();
if (trim($szHeader) != '' && strpos($szHeader, "^") !== false)
{
$aszHeader = explode('|', $szHeader);
foreach ($aszHeader as $value)
{
$title = explode('^', $value);
if (trim($title[1]) != '')
{
$aszHeaderNames[strtolower($title[0])] = $title[1];
}
else
$aszHeaderNames[strtolower($title[0])] = $title[0];
}
}
else
{
foreach ($aRows[0] as $key => $value)
{
if (strcasecmp($key, "SHAPE_INDEX") == 0 ||
strcasecmp($key, "TILE_INDEX") == 0 ||
strcasecmp($key, "LAYER_INDEX") == 0)
continue;
$szReturnValue .= "<td class=\"subContentArea\"><p
class=\"text\">".$key."</p></td>\n";
}
$szReturnValue .= "</tr>\n";
// loop through the results and format each row
foreach ( $aRows as $aRow )
{
// add a row for each
$szReturnValue .= "<tr>\n";
// loop and add a cell for each result
foreach ( $aRow as $key => $xCell )
{
//String comparison to search for fields that should NOT be returnedin query
results.
if (strcasecmp($key, "SHAPE_INDEX") == 0 ||
strcasecmp($key, "TILE_INDEX") == 0 ||
strcasecmp($key, "LAYER_INDEX") == 0)
continue;
{
//Look for strings containing an http header. If exists thenformat as a
link, if not format as normal text.
if ( stristr ($xCell, 'http://' ))
$szReturnValue .= "<td class=\"subContentArea1\"><pclass=\"text\"><img
src='". $xCell."' ></p></td>\n";
else
$szReturnValue .= "<td class=\"subContentArea1\"><pclass=\"text\">".
$xCell."</p></td>\n";
}
}
$szReturnValue .= "</tr>\n";
}
}}
else
{
// check if no results on local layer
if ( strcasecmp(substr( $aRows, 0, 26 ), "no results found for layer" ) == 0
)
{
/*
* non-wms no results
*/
array_push( $aszNoResults, $aszLayers[$i] );
}
else
{
/*
* THIS IS FOR WMS RESULTS
*/
$szTitle = $aszLayers[$i];
if (isset($aszTitles[$i]))
$szTitle = $aszTitles[$i];
$nTmpCount = count( $gaszWMSResults );
$gaszWMSResults[$nTmpCount][0] = $aRows;
$gaszWMSResults[$nTmpCount][1] = $szTitle;
}
}
// end loop of layers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/chameleon/attachments/20061012/1f690e1b/attachment.html
More information about the Chameleon
mailing list