Permalink
Browse files

Added the option to set a default value for variable substitution in …

…the map's WEB section. To do that there is a new method applyHashTableDefaultSubstitutions that is being called in msApplyDefaultSubstitutions with the map's WEB section as the hash table to work on
  • Loading branch information...
micking committed Nov 10, 2017
1 parent 3735c36 commit 572bd765e7a0f55b8826a9bdbd2b661e07ff44b9
Showing with 20 additions and 0 deletions.
  1. +20 −0 mapfile.c
View
@@ -7140,6 +7140,25 @@ static void applyLayerDefaultSubstitutions(layerObj *layer, hashTableObj *table)
return;
}
static void applyHashTableDefaultSubstitutions(hashTableObj *hashTab, hashTableObj *table)
{
int i;
const char *default_key = msFirstKeyFromHashTable(table);
while (default_key) {
if (!strncmp(default_key, "default_", 8)) {
size_t buffer_size = (strlen(default_key) - 5);
char *to = msLookupHashTable(table, default_key);
char *tag = (char *)msSmallMalloc(buffer_size);
snprintf(tag, buffer_size, "%%%s%%", &(default_key[8]));
hashTableSubstituteString(hashTab, tag, to);
free(tag);
}
default_key = msNextKeyFromHashTable(table, default_key);
}
return;
}
/*
** Loop through layer metadata for keys that have a default_%key% pattern to replace
** remaining %key% entries by their default value.
@@ -7165,6 +7184,7 @@ void msApplyDefaultSubstitutions(mapObj *map)
applyLayerDefaultSubstitutions(layer, &(layer->validation)); /* ...then layer settings... */
applyLayerDefaultSubstitutions(layer, &(map->web.validation)); /* ...and finally web settings */
}
applyHashTableDefaultSubstitutions(&map->web.metadata, &(map->web.validation));
}
char *_get_param_value(const char *key, char **names, char **values, int npairs) {

0 comments on commit 572bd76

Please sign in to comment.