From eefa8c81a3f3857d45b1b206f8281ee11d5752c5 Mon Sep 17 00:00:00 2001 From: Michael Larabel Date: Thu, 13 Nov 2008 11:07:32 -0500 Subject: pts-core: Add static/info-strings-replace.txt to contain a list of all information strings to replace with another value if found, instead of having it coded within an array --- TYDAL-CHANGE-LOG | 1 + pts-core/functions/pts-functions.php | 17 ++++++++++++++--- pts-core/static/info-strings-replace.txt | 5 +++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 pts-core/static/info-strings-replace.txt diff --git a/TYDAL-CHANGE-LOG b/TYDAL-CHANGE-LOG index 2526f84..450f83b 100644 --- a/TYDAL-CHANGE-LOG +++ b/TYDAL-CHANGE-LOG @@ -19,3 +19,4 @@ Phoronix Test Suite (Git) - pts-core: Add STATIC_DIR (pts-core/static/) for some static files - pts-core: Add static/hal-values-remove.txt to contain a list of all HAL strings to remove if found, instead of having it coded within an array - pts-core: Add static/info-strings-remove.txt to contain a list of all information strings to remove if found, instead of having it coded within an array +- pts-core: Add static/info-strings-replace.txt to contain a list of all information strings to replace with another value if found, instead of having it coded within an array diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php index a59dd66..fab549e 100644 --- a/pts-core/functions/pts-functions.php +++ b/pts-core/functions/pts-functions.php @@ -388,18 +388,29 @@ function pts_clean_information_string($str) { // Clean a string containing hardware information of some common things to change/strip out static $remove_phrases = null; + static $change_phrases = null; if(empty($remove_phrases) && is_file(STATIC_DIR . "info-strings-remove.txt")) { $word_file = trim(file_get_contents(STATIC_DIR . "info-strings-remove.txt")); $remove_phrases = array_map("trim", explode("\n", $word_file)); } + if(empty($change_phrases) && is_file(STATIC_DIR . "info-strings-replace.txt")) + { + $word_file = trim(file_get_contents(STATIC_DIR . "info-strings-replace.txt")); + $phrases_r = array_map("trim", explode("\n", $word_file)); + $change_phrases = array(); - $str = str_ireplace($remove_phrases, " ", $str); + foreach($phrases_r as $phrase) + { + $phrase_r = explode("=", $phrase); + $change_phrases[trim($phrase_r[1])] = trim($phrase_r[0]); + } + } - $change_phrases = array("Memory Controller Hub" => "MCH", "Advanced Micro Devices" => "AMD", "MICRO-STAR INTERNATIONAL" => "MSI", "Silicon Integrated Systems" => "SiS", "Integrated Graphics Controller" => "IGP"); + $str = str_ireplace($remove_phrases, " ", $str); - foreach($change_phrases as $original_phrase => $new_phrase) + foreach($change_phrases as $new_phrase => $original_phrase) { $str = str_ireplace($original_phrase, $new_phrase, $str); } diff --git a/pts-core/static/info-strings-replace.txt b/pts-core/static/info-strings-replace.txt new file mode 100644 index 0000000..b6c21f9 --- /dev/null +++ b/pts-core/static/info-strings-replace.txt @@ -0,0 +1,5 @@ +Memory Controller Hub = MCH +Advanced Micro Devices = AMD +MICRO-STAR INTERNATIONAL = MSI +Silicon Integrated Systems = SiS +Integrated Graphics Controller = IGP -- cgit