SnapSearch Class Reference
[Utility Classes]

Static class that executes Snap2 searches. More...

Inheritance diagram for SnapSearch:

Inheritance graph
[legend]

List of all members.

Static Public Member Functions

static execute ($req, $mode=self::MODE_METADATA)
 Executes a search request.
static grep ($pattern, $domain= '//', $types=array(), $options=array(), $statuses=array())
 Searches for content using regular expressions.


Detailed Description

Static class that executes Snap2 searches.

To use this class, create a SnapSearchRequest object, fill it with the search parameters and then call SnapSearch::execute() with the object to get the results. This class also supports grepping of content with regular expressions (SnapSearch::grep()).


Member Function Documentation

static SnapSearch::execute ( req,
mode = self::MODE_METADATA 
) [static]

Executes a search request.

Build a SnapSearchRequest object first, and pass it to this method to get the results. You can get the results in several formats based on what you pass in the 2nd argument:

  • MODE_LIST: array of paths for each matching filesystem object, along with some additional information
  • MODE_METADATA: like MODE_LIST, but include the complete file metadata in the result array
  • MODE_ALL: same as MODE_METADATA, but include version content (which would otherwise be excluded)
  • MODE_OBJECTS: return Snap2 objects
  • MODE_ALL_OBJECTS: combines MODE_OBJECTS and MODE_ALL
Parameters:
$req [SnapSearchRequest]: request object that defines the search criteria
$mode [int]: one of the MODE_* constants as described above
Returns:
[mixed]: null on error, otherwise, depends on the value of $mode

static SnapSearch::grep ( pattern,
domain = '//',
types = array(),
options = array(),
statuses = array() 
) [static]

Searches for content using regular expressions.

This method takes a pattern and some options and finds versions that have content that matches the regular expression pattern provided. The $options parameter is an array that may contain zero or more of the following constants:

  • GREP_CASE_INSENSITIVE: do a case-insensitive match (like the '/i' flag on regexes)
  • GREP_MULTILINE: makes '^' and '$' match beginning and end of line instead of beginning and end of string
  • GREP_MATCH_NEWLINE: makes '.' match newline characters (default is not to)
  • GREP_MATCH_ALL: include all matches from a version, not just that the version matched
If GREP_MATCH_ALL is not used, the method returns an array indexed by path for each matchin version. Each element of the array is two-element array, where the first element is the entire line (or set of lines) containing the match and the second element is just the matched portion of the line(s) itself.

If GREP_MATCH_ALL is used, the method returns an array indexed by path for each matching version. The value of each array is a sub-array that contains a list of two-element arrays, where the first element is the entire line (or set of lines) containing the match and the second element is just the portion of the line that matched.

Parameters:
$pattern [string]: regular expression pattern to match
$domain [string]: path to directory or resource under which to search versions for pattern
$types [array]: list of content types that should be searched (see SnapResource)
$options [array]: one of the GREP_* constants as described above
$statuses [array]: list of version statuses that should be searched (see SnapVersion)
Returns:
[array]: null on error, otherwise, arrays as described above


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:03:21 2010 for Common by  doxygen 1.5.6