[mapserver-commits] r10170 - branches/branch-5-4/mapserver
svn at osgeo.org
svn at osgeo.org
Thu May 20 17:10:40 EDT 2010
Author: sdlime
Date: 2010-05-20 17:10:37 -0400 (Thu, 20 May 2010)
New Revision: 10170
Modified:
branches/branch-5-4/mapserver/maptemplate.c
Log:
Support multiple resultset tags on a single line. (#3455)
Modified: branches/branch-5-4/mapserver/maptemplate.c
===================================================================
--- branches/branch-5-4/mapserver/maptemplate.c 2010-05-19 21:04:54 UTC (rev 10169)
+++ branches/branch-5-4/mapserver/maptemplate.c 2010-05-20 21:10:37 UTC (rev 10170)
@@ -941,73 +941,80 @@
return(MS_FAILURE);
}
- tagStart = findTag(*line, "resultset");
- if(!tagStart) return(MS_SUCCESS); /* OK, just return; */
-
if(!stream) {
msSetError(MS_WEBERR, "Invalid file pointer.", "processResultSetTag()");
return(MS_FAILURE);
}
- /* check for any tag arguments */
- if(getTagArgs("resultset", tagStart, &tagArgs) != MS_SUCCESS) return(MS_FAILURE);
- if(tagArgs) {
- layerName = msLookupHashTable(tagArgs, "layer");
- }
+ tagStart = findTag(*line, "resultset");
+ if(!tagStart) return(MS_SUCCESS); /* OK, just return; */
- if(!layerName) {
- msSetError(MS_WEBERR, "[resultset] tag missing required 'layer' argument.", "processResultSetTag()");
- return(MS_FAILURE);
- }
+ while (tagStart) {
+ /* initialize the tag arguments */
+ layerName = NULL;
- layerIndex = msGetLayerIndex(mapserv->map, layerName);
- if(layerIndex>=mapserv->map->numlayers || layerIndex<0) {
- msSetError(MS_MISCERR, "Layer named '%s' does not exist.", "processResultSetTag()", layerName);
- return MS_FAILURE;
- }
- lp = GET_LAYER(mapserv->map, layerIndex);
+ /* check for any tag arguments */
+ if(getTagArgs("resultset", tagStart, &tagArgs) != MS_SUCCESS) return(MS_FAILURE);
+ if(tagArgs) {
+ layerName = msLookupHashTable(tagArgs, "layer");
+ }
- if(strstr(*line, "[/resultset]") == NULL) { /* read ahead */
- foundTagEnd = MS_FALSE;
- while(!foundTagEnd) {
- if(fgets(lineBuffer, MS_BUFFER_LENGTH, stream) != NULL) {
- *line = msStringConcatenate(*line, lineBuffer);
- if(strstr(*line, "[/resultset]") != NULL)
- foundTagEnd = MS_TRUE;
- } else
- break; /* ran out of file */
- }
- if(foundTagEnd == MS_FALSE) {
- msSetError(MS_WEBERR, "[resultset] tag found without closing [/resultset].", "processResultSetTag()");
+ if(!layerName) {
+ msSetError(MS_WEBERR, "[resultset] tag missing required 'layer' argument.", "processResultSetTag()");
return(MS_FAILURE);
}
- }
- if(getInlineTag("resultset", *line, &tag) != MS_SUCCESS) {
- msSetError(MS_WEBERR, "Malformed resultset tag.", "processResultSetTag()");
- return MS_FAILURE;
- }
+ layerIndex = msGetLayerIndex(mapserv->map, layerName);
+ if(layerIndex>=mapserv->map->numlayers || layerIndex<0) {
+ msSetError(MS_MISCERR, "Layer named '%s' does not exist.", "processResultSetTag()", layerName);
+ return MS_FAILURE;
+ }
+ lp = GET_LAYER(mapserv->map, layerIndex);
- preTag = getPreTagText(*line, "[resultset"); /* TODO: need to handle tags in these */
- postTag = getPostTagText(*line, "[/resultset]");
+ if(strstr(*line, "[/resultset]") == NULL) { /* read ahead */
+ foundTagEnd = MS_FALSE;
+ while(!foundTagEnd) {
+ if(fgets(lineBuffer, MS_BUFFER_LENGTH, stream) != NULL) {
+ *line = msStringConcatenate(*line, lineBuffer);
+ if(strstr(*line, "[/resultset]") != NULL)
+ foundTagEnd = MS_TRUE;
+ } else
+ break; /* ran out of file */
+ }
+ if(foundTagEnd == MS_FALSE) {
+ msSetError(MS_WEBERR, "[resultset] tag found without closing [/resultset].", "processResultSetTag()");
+ return(MS_FAILURE);
+ }
+ }
- /* start rebuilding **line */
- free(*line); *line = preTag;
+ if(getInlineTag("resultset", *line, &tag) != MS_SUCCESS) {
+ msSetError(MS_WEBERR, "Malformed resultset tag.", "processResultSetTag()");
+ return MS_FAILURE;
+ }
- if(lp->resultcache && lp->resultcache->numresults > 0) {
- /* probably will need a while-loop here to handle multiple instances of [feature ...] tags */
- if(processFeatureTag(mapserv, &tag, lp) != MS_SUCCESS)
- return(MS_FAILURE); /* TODO: how to handle */
- *line = msStringConcatenate(*line, tag);
- }
+ preTag = getPreTagText(*line, "[resultset"); /* TODO: need to handle tags in these */
+ postTag = getPostTagText(*line, "[/resultset]");
- *line = msStringConcatenate(*line, postTag);
+ /* start rebuilding **line */
+ free(*line); *line = preTag;
- /* clean up */
- msFreeHashTable(tagArgs); tagArgs=NULL;
- free(postTag);
- free(tag);
+ if(lp->resultcache && lp->resultcache->numresults > 0) {
+ /* probably will need a while-loop here to handle multiple instances of [feature ...] tags */
+ if(processFeatureTag(mapserv, &tag, lp) != MS_SUCCESS)
+ return(MS_FAILURE); /* TODO: how to handle */
+ *line = msStringConcatenate(*line, tag);
+ }
+ *line = msStringConcatenate(*line, postTag);
+
+ /* clean up */
+ msFreeHashTable(tagArgs); tagArgs=NULL;
+ free(postTag);
+ free(tag);
+
+ tagStart = findTag(*line, "resultset");
+ }
+
return(MS_SUCCESS);
}
@@ -3420,6 +3427,7 @@
for(j=0;j<mapserv->resultlayer->joins[i].numitems;j++) {
/* by default let's encode attributes for HTML presentation */
snprintf(substr, PROCESSLINE_BUFLEN, "[%s_%s]", mapserv->resultlayer->joins[i].name, mapserv->resultlayer->joins[i].items[j]);
+
if(strstr(outstr, substr) != NULL) {
encodedstr = msEncodeHTMLEntities(mapserv->resultlayer->joins[i].values[j]);
outstr = msReplaceSubstring(outstr, substr, encodedstr);
More information about the mapserver-commits
mailing list