MCPcopy Index your code
hub / github.com/MapServer/MapServer / msProcessTemplate

Function msProcessTemplate

maptemplate.c:4662–4710  ·  view source on GitHub ↗

** Utility function to open a template file, process it and ** and return into a buffer the processed template. Uses the ** template file from the web object. Returns NULL if there is ** an error. */

Source from the content-addressed store, hash-verified

4660** an error.
4661*/
4662char *msProcessTemplate(mapObj *map, int bGenerateImages, char **names, char **values, int numentries)
4663{
4664 char *pszBuffer = NULL;
4665
4666 if(map) {
4667
4668 /* Initialize object and set appropriate defaults. */
4669 mapservObj *mapserv = NULL;
4670 mapserv = msAllocMapServObj();
4671
4672 mapserv->map = map;
4673 mapserv->Mode = BROWSE;
4674
4675 if(names && values && numentries > 0) {
4676 msFreeCharArray(mapserv->request->ParamNames, mapserv->request->NumParams);
4677 msFreeCharArray(mapserv->request->ParamValues, mapserv->request->NumParams);
4678 mapserv->request->ParamNames = names;
4679 mapserv->request->ParamValues = values;
4680 mapserv->request->NumParams = numentries;
4681 }
4682
4683 /*
4684 ** ISSUE/TODO : some of the name/values should be extracted and
4685 ** processed (ex imgext, layers, ...) as it is done in function
4686 ** loadform.
4687 */
4688
4689 if(bGenerateImages)
4690 msGenerateImages(mapserv, MS_FALSE, MS_FALSE);
4691
4692 /*
4693 ** Process the template.
4694 **
4695 ** TODO : use web minscaledenom/maxscaledenom depending on the scale.
4696 */
4697 if(msReturnPage(mapserv, mapserv->map->web.template, BROWSE, &pszBuffer) != MS_SUCCESS) {
4698 msFree(pszBuffer);
4699 pszBuffer = NULL;
4700 }
4701
4702 /* Don't free the map and names and values arrays since they were passed by reference. */
4703 mapserv->map = NULL;
4704 mapserv->request->ParamNames = mapserv->request->ParamValues = NULL;
4705 mapserv->request->NumParams = 0;
4706 msFreeMapServObj(mapserv);
4707 }
4708
4709 return pszBuffer;
4710}
4711
4712/*
4713** Utility method to process the legend template.

Callers 1

mapObj_processTemplateFunction · 0.85

Calls 6

msAllocMapServObjFunction · 0.85
msFreeCharArrayFunction · 0.85
msGenerateImagesFunction · 0.85
msReturnPageFunction · 0.85
msFreeFunction · 0.85
msFreeMapServObjFunction · 0.85

Tested by

no test coverage detected