From 756f01cc734ba7603f7e24bce8102bb360e6f56d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Fri, 22 Jun 2012 00:45:31 +0000 Subject: - Improve help search updates while typing, adding basic display for no results found and showing the table of contents if the field is cleared - Permit help searches for the operator "%" as a standalone string - Update localisable strings --- Source/SPCustomQuery.m | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Source') diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 0bb182dd..e62c6c44 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -2791,7 +2791,12 @@ */ - (void)showHelpFor:(NSString *)searchString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp { - if(![searchString length]) return; + + // If there's no search string, show nothing if called by autohelp, and the index otherwise + if (![searchString length]) { + if (autoHelp) return; + searchString = SP_HELP_TOC_SEARCH_STRING; + } NSString *helpString = [self getHTMLformattedMySQLHelpFor:searchString calledByAutoHelp:autoHelp]; @@ -3044,6 +3049,9 @@ if(![searchString length]) return @""; + // Don't escape % when being used as a wildcard, but escape it when it's being used by itself. + if ([searchString isEqualToString:@"%"]) searchString = @"\\%"; + NSRange aRange; SPMySQLResult *theResult = nil; NSDictionary *tableDetails; @@ -3071,8 +3079,8 @@ theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"HELP '%@%%'", [searchString stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]]; // really nothing found? - if(![theResult numberOfRows]) - return @""; + if (![theResult numberOfRows]) + return [NSString stringWithFormat:@"%@", NSLocalizedString(@"No results found.", @"No results found for a help search")]; } // Ensure rows are returned as strings to prevent data problems with older 4.1 servers @@ -3128,8 +3136,6 @@ } } else { // list all found topics - NSUInteger r = (NSUInteger)[theResult numberOfRows]; - if (r) [theResult seekToRow:0]; // check if HELP 'contents' is called if(![searchString isEqualToString:SP_HELP_TOC_SEARCH_STRING]) -- cgit v1.2.3