diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-09-12 12:13:29 -0400 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-09-12 12:13:29 -0400 |
commit | 82a686b2eec06bd084f89260eddb2a0114ab1605 (patch) | |
tree | f1d006df38f696064b7107566f7bbeeffcc3ee63 /pts-core/functions/pts-functions_config.php | |
parent | fcdc23e0f8c342b471498ed58e3cfe42172bb4e5 (diff) | |
download | phoronix-test-suite-upstream-82a686b2eec06bd084f89260eddb2a0114ab1605.tar.gz phoronix-test-suite-upstream-82a686b2eec06bd084f89260eddb2a0114ab1605.tar.xz phoronix-test-suite-upstream-82a686b2eec06bd084f89260eddb2a0114ab1605.zip |
pts-core: Add support for persistent configuration options that
end-users can easily adjust for PTS modules by running
"phoronix-test-suite module-setup MODULE-NAME" that are stored to
~/.phoronix-test-suite/modules-config.xml
Diffstat (limited to 'pts-core/functions/pts-functions_config.php')
-rw-r--r-- | pts-core/functions/pts-functions_config.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/pts-core/functions/pts-functions_config.php b/pts-core/functions/pts-functions_config.php index 81c09d3..97516a2 100644 --- a/pts-core/functions/pts-functions_config.php +++ b/pts-core/functions/pts-functions_config.php @@ -121,6 +121,58 @@ function pts_user_config_init($UserName = NULL, $UploadKey = NULL, $BatchOptions file_put_contents(PTS_USER_DIR . "user-config.xml", $config->getXML()); } +function pts_module_config_init($SetOptions = NULL) +{ + // Validate the config files, update them (or write them) if needed, and other configuration file tasks + + if(is_file(PTS_USER_DIR . "modules-config.xml")) + $file = file_get_contents(PTS_USER_DIR . "modules-config.xml"); + else + $file = ""; + + $module_config_parser = new tandem_XmlReader($file); + $option_module = $module_config_parser->getXMLArrayValues(P_MODULE_OPTION_NAME); + $option_identifier = $module_config_parser->getXMLArrayValues(P_MODULE_OPTION_IDENTIFIER); + $option_value = $module_config_parser->getXMLArrayValues(P_MODULE_OPTION_VALUE); + + if(is_array($SetOptions) && count($SetOptions) > 0) + { + foreach($SetOptions as $this_option_set => $this_option_value) + { + $replaced = false; + $this_option_set = explode("__", $this_option_set); + $this_option_module = $this_option_set[0]; + $this_option_identifier = $this_option_set[1]; + + for($i = 0; $i < count($option_module) && !$replaced; $i++) + { + if($option_module[$i] == $this_option_module && $option_identifier[$i] == $this_option_identifier) + { + $option_value[$i] = $this_option_value; + $replaced = true; + } + } + + if(!$replaced) + { + array_push($option_module, $this_option_module); + array_push($option_identifier, $this_option_identifier); + array_push($option_value, $this_option_value); + } + } + } + + $config = new tandem_XmlWriter(); + + for($i = 0; $i < count($option_module); $i++) + { + $config->addXmlObject(P_MODULE_OPTION_NAME, $i, $option_module[$i]); + $config->addXmlObject(P_MODULE_OPTION_IDENTIFIER, $i, $option_identifier[$i]); + $config->addXmlObject(P_MODULE_OPTION_VALUE, $i, $option_value[$i]); + } + + file_put_contents(PTS_USER_DIR . "modules-config.xml", $config->getXML()); +} function pts_config_bool_to_string($bool) { // Evaluate a string to boolean type |