phpDocumentor pivotx
modules
[ class tree: pivotx ] [ index: pivotx ] [ all elements ]

Procedural File: module_search.php

Source Location: /modules/module_search.php

Page Details

Contains the functions we use to search entries and pages, and indexing entries and pages for flat file database.

Todo:  Support Asian languages word-splitting.
Functions
addToSearchIndex  [line 165]

void addToSearchIndex( $arr, [ $type = 'e']  )

Parses the entry/page, strips punctuation and stop/non-words, lower cases and adds to the global master index array.

Parameters:
   $arr: 
   $type: 

API Tags:
Uses:  filterWords() - The function that strips the stop/non-words


[ Top ]
cmp_weights  [line 334]

integer cmp_weights( assoc.array &$a, assoc.array &$b  )

Compare weights of search results

Parameters:
assoc.array   &$a:  search result a
assoc.array   &$b:  search result b

API Tags:
Return:  -1,0,+1 depending on comparison


[ Top ]
createSearchIndex  [line 73]

boolean createSearchIndex( int $start, int $stop, int $time  )

Indexes entries and pages in the PivotX database and returns true if there are more entries to index.

Parameters:
int   $start:  Code for first entry to index
int   $stop:  Code for last entry to index
int   $time:  Indexing time.


[ Top ]
filterWords  [line 251]

array filterWords( array $arr  )

Strips stop/non-words from an array of words.

Parameters:
array   $arr:  Words to be filtered.

API Tags:
Usedby:  addToSearchIndex() - The function that strips the stop/non-words


[ Top ]
getWord  [line 804]

boolean getWord( string $word  )

Search for a given word. It branches depending on the selected database model

Parameters:
string   $word:  Word to search for.

API Tags:
Return:  false if not found, else true.


[ Top ]
getWordFlat  [line 824]

boolean getWordFlat( string $word  )

Checks if a word is part of the search index and if so sets the global variable $matches_entries to the matching entry codes and the global variable $matches_pages to the matching page codes.

Parameters:
string   $word:  Word to search for.

API Tags:
Return:  False if not found, else true.


[ Top ]
getWordSql  [line 894]

boolean getWordSql( string $word  )

Checks if a word is part of the search index and if so sets the global variable $matches_entries to the matching entry codes and the global variable $matches_pages to the matching page codes.

If this function returns no results when they are expected, keep in mind that:

  • Words called stopwords are ignored, you can specify your own stopwords, but default words include the, have, some - see default stopwords list.
  • If a word is present in more than 50% of the rows it will have a weight of zero. This has advantages on large datasets, but can make testing difficult on small ones.
http://www.petefreitag.com/item/477.cfm

Parameters:
string   $word:  Word to search for.

API Tags:
Return:  false if not found, else true.


[ Top ]
loadSearchIndex  [line 782]

void loadSearchIndex( array $words  )

Loads (the needed part of) the search index for the given array of words.

Parameters:
array   $words: 


[ Top ]
removeFromSearchIndex  [line 210]

void removeFromSearchIndex( $item, [ $type = 'e']  )

For a given entry/page, removes the related key from the content of the index.

The global master index array contains the altered content (keys).

Parameters:
   $item: 
   $type: 


[ Top ]
searchEntries  [line 695]

array searchEntries( string $str  )

Searches the index and returns the matching entries in an array.

Used in the entries screen/overview search.

Parameters:
string   $str:  Text/words to search for


[ Top ]
searchIndex  [line 433]

string searchIndex( array $str_a, [string $only = ''], [string $weblog = ''], [string $category = ''], &$searchresults  )

Searches the index for words.

Parameters:
array   $str_a:  Contains the display text (index 0) and the search text (index 1).
string   $only:  Selects if you want to search "entries" or "pages".
string   $weblog:  Selects if you want to search inside a specific weblog.
string   $category:  Selects if you want to search inside a specific category.
   &$searchresults: 

API Tags:
Return:  The search results as a list (in HTML code).
Usedby:  searchResult()


[ Top ]
searchIndexKey  [line 43]

string searchIndexKey( string $str  )

Calculates a search index key (used for file names). Only used be flat file database.

Parameters:
string   $str: 


[ Top ]
searchResult  [line 982]

string searchResult( &$searchresults  )

Returns the search form and (possibly) the search results.

Parameters:
   &$searchresults: 

API Tags:
Uses:  searchIndex()


[ Top ]
updateSearchIndex  [line 149]

void updateSearchIndex( array $item, [string $type = 'e']  )

Updates the search index for a single entry or page.

Parameters:
array   $item:  The entry or page to get indexed/updated.
string   $type:  Tells if we are indexing an entry or a page.


[ Top ]
weighSearchResult  [line 384]

integer weighSearchResult( assoc.array &$result, assoc.array $params  )

Default callback for weighing a search result

Parameters:
assoc.array   &$result:  a single result
assoc.array   $params:  an array containts: complete=complete-search-text, words=array-of-search-words

API Tags:
Return:  the weight


[ Top ]
weighText  [line 353]

integer weighText( string $subject, string $complete, array $words, integer $max  )

Weight a text part relative to some other part

Parameters:
string   $subject:  the subject to search in
string   $complete:  the complete search term (lowercased)
array   $words:  all the individuele search terms (lowercased)
integer   $max:  maximum number of points to return

API Tags:
Return:  the weight


[ Top ]
writeSearchIndex  [line 281]

void writeSearchIndex( [boolean $silent = false], [ $loadindex = true]  )

Write the index to file (using the global variable $master_index.

Parameters:
boolean   $silent: 
   $loadindex: 


[ Top ]


Documentation generated on Tue, 05 Sep 2017 01:06:09 +0200 by phpDocumentor 1.4.3