Fixed a filtering issue, it is now possible to search and filter for strings with + in it.

You need replace a + with a ++, and spaces need to be replaced with a single + sign.
This commit is contained in:
Andre Lorbach 2008-09-19 14:45:07 +02:00
parent 8f62806e5c
commit 5a311244af
2 changed files with 26 additions and 5 deletions

View File

@ -281,6 +281,7 @@ abstract class LogStream {
{
// Split key and value
$tmpArray = explode(":", $myEntry, 2);
//print_r ( $tmpArray );
// Continue if empty filter!
if ( strlen(trim($tmpArray[FILTER_TMP_VALUE])) == 0 )
@ -643,9 +644,20 @@ abstract class LogStream {
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = $tmpArray[FILTER_TMP_VALUE];
}
// Replace + with spaces
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = str_replace( '+', ' ', $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE]);
// Reverse string prepareation
$searchArray = array(
'/(?<!\+)\+/', // First one replaces all single + into spaces, but unfortunatelly replaces ONE + from a double ++
'/ (?=\+)/', // This is a helper, removes spaces if a + is following
// '/\+\+/', // Not needed, due the rules above, a double + has already become a single +
);
$replaceArray = array(
" ",
"",
// "+",
);
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = preg_replace( $searchArray, $replaceArray, $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] );
// $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = str_replace( '+', ' ', $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE]);
// ---
}

View File

@ -565,7 +565,7 @@ if ( isset($content['Sources'][$currentSourceID]) )
// Set some basic variables first
$content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; // May contain the field value trunscated
$content['syslogmessages'][$counter]['values'][$mycolkey]['rawfieldvalue'] = $logArray[$mycolkey]; // helper variable used for Popups!
$content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue'] = str_replace(' ', '+', $logArray[$mycolkey]); // Convert into filter format for submenus
$content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue'] = PrepareStringForSearch($logArray[$mycolkey]); // Convert into filter format for submenus
// --- Check for reached string character limit
if ( $mycolkey != SYSLOG_MESSAGE )
@ -972,9 +972,18 @@ function HighLightString($highlightArray, $strmsg)
return $strmsg;
}
/*
* Prepare a string for search! spaces will be replaces with a single +
* + will be replaced with a double ++
*/
function PrepareStringForSearch($myString)
{
return str_replace(" ", "+", $myString);
// Create Find & Replace arrays
$searchArray = array("+", " ");
$replaceArray = array("++", "+");
// str_replace(' ', '+', $logArray[$mycolkey]);
return str_replace($searchArray, $replaceArray, $myString);
}
function AddOnClickMenu(&$fieldGridItem, $fieldType, $szSearchFieldName, $szFieldDisplayNameID, $searchOnline = false)