PARSEPHRASE -- break up a search phrase into component parts such as 'exact phrase', AND, OR and NOT

version 1
package wikindx4\core\lists
author Mark Grimshaw

 Methods

PARSEPHRASE

__construct() 

Parse input and create SQL condition

parse(array $input) : mixed

Parameters

$input

array

$input['Word'] is the input string from the search form

Returns

mixedFALSE|string

Create the condition clause and store search highlighting in the session

createCondition(array $input) : string

Parameters

$input

array

Returns

string

extract all fragment elements until end of exact phrase is found

extractExactPhrase(string $fragment, array $fragments, int $searchArrayIndex) 

Parameters

$fragment

string

$fragments

array

Reference to array

$searchArrayIndex

int

check for malformed search strings -- i.e.

malformedString(string $phrase) : boolean

odd no. of " chars

Parameters

$phrase

string

Returns

boolean

Neatly print the elements of the quoteFragments array -- for debugging purposes only

printFragments(array $fragments) 

Parameters

$fragments

array

Remove any NOT words that are listed as AND or OR and any words to be filtered

removeNot_and_FilterWords() 

loop through $fragments sorting into 'exact phrase', AND fragments, NOT fragments and OR fragments

sortFragments(array $fragments) 

Parameters

$fragments

array

split up search string on single spaces

splitSpaces(string $phrase) 

Parameters

$phrase

string

For all AND, OR or NOT fragments, tidy the input so we have something usable

tidyFragment(string $fragment, array $fragments, int $searchArrayIndex, string $type) 

Parameters

$fragment

string

$fragments

array

Reference to array

$searchArrayIndex

int

$type

string

Default is FALSE

Return words governed by AND, OR or NOT

tidySearch(string $phrase) : string

Parameters

$phrase

string

Returns

string

 Properties

 

$NOTfragments 
 

$config 
 

$db 
 

$session 
 

$stringArray 
 

$utf8