# # Profile Management Subroutines # This duplicates node destination, putting its subnodes (recursively) into node source. subroutine(duplicate_node(string source, string destination), ( # debug_message("Duplicating node $source into $destination\n"); node subnode; foreach subnode source ( string partial_node_name = substr(subnode, length(source)); # debug_message("partial_node_name: $partial_node_name\n"); (destination . partial_node_name) = node_value(subnode); if (num_subnodes(subnode) != 0) then duplicate_node(subnode, (destination . partial_node_name)); ); )); # This applies a change from profile to newprofile. subroutine(apply_change(string profile, string newprofile, string change), ( # Don't do anything if the node doesn't exist if (node_exists(change)) then ( # If this change is actually a group node, then apply the changes below it bool group = false; if (num_subnodes(change) > 0) then ( group = true; node subnode; foreach subnode change ( apply_change(profile, newprofile, subnode); ); ); # Change the value of this node string change_partial_node_name = substr(change, length(profile . ".changes")); string change_value = node_value(change); if (!group or (node_value(change) ne "")) then " Applying change: " . newprofile . change_partial_node_name . " = '" . change_value . "'\n"; (newprofile . change_partial_node_name) = change_value; ); # If change node exists )); # subroutine apply_changes() # # get_default_field_label() # # Purpose: This gets a default label for a field, and returns it. # # Parameter: dbfield_name: the internal name of the database field # log_format: the log format, or "none" if not applicable # returns a label for the field # subroutine(get_default_field_label(string dbfield_name, string log_format), ( string dbfield_label = ""; if (?("lang_stats.field_labels_by_log_format." . log_format . "." . dbfield_name)) then ( dbfield_label = "$lang_stats.field_labels_by_log_format." . log_format . "." . dbfield_name; ) else if (?("lang_stats.field_labels." . log_format . "." . dbfield_name)) then ( dbfield_label = "$lang_stats.field_labels." . log_format . "." . dbfield_name; ) else if (?("lang_stats.field_labels." . dbfield_name)) then ( dbfield_label = "$lang_stats.field_labels." . dbfield_name; ) # else if (?(profile . ".log.fields." . dbfield_name . ".label")) then ( # # dbfield_label = @(profile . ".log.fields." . dbfield_name . ".label"); # ) else ( dbfield_label = dbfield_name; ); dbfield_label; )); #### get_default_field_label() ####