PHP Class FileTextSearch

Usage: It is very easy to use, just look at the example below. To only search for a pattern into the text file, do not define any replacement key. Example: $path = '/path/to/search'; create a class instance $obj = new FileTextSearch(); set the extensions to search files within $obj = setExtensions(array('xml','xsl'); add an extension whenever you need $obj = addExtension('css'); set the pattern to search for $obj = setSearchKey('pattern'); set the replace key if you want to replace matches with it $obj = setReplacementKey('replace'); finally run the search $obj = findReplace($path);
Datei anzeigen Open project: sourcefabric/newscoop Class Usage Examples

Public Properties

Property Type Description
$m_caseSensitive
$m_fileExtensions
$m_findAllExtensions
$m_isReplaceEnabled
$m_replacementKey
$m_searchKey
$m_totalFound

Public Methods

Method Description
addExtension ( string $p_extension ) Add a valid search extension.
filePutContents ( string $p_file, mixed $p_data ) : mixed Puts data (after replacement) to given file.
findExtension ( string $p_file ) : mixed Finds the extension for the given file.
findReplace ( string $p_path ) searchDirFiles() wrapper function.
matchedExtension ( string $p_file ) : boolean Checks if a file extension is one the extensions we are going to search.
searchDirFiles ( string $p_path ) : array Runs recursively all into the path.
searchFileData ( string $p_file ) Searches file data and replaces with given pattern.
setExtensions ( array $p_extensions = [] ) Sets extensions to search for.
setReplacementKey ( string $p_replacementKey ) Sets the replacement to replace pattern with.
setSearchKey ( string $p_searchKey, integer $p_caseSensitive ) Sets the pattern and case sensitivity.

Method Details

addExtension() public method

Add a valid search extension.
public addExtension ( string $p_extension )
$p_extension string

filePutContents() public method

Puts data (after replacement) to given file.
public filePutContents ( string $p_file, mixed $p_data ) : mixed
$p_file string
$p_data mixed
return mixed

findExtension() public method

Finds the extension for the given file.
public findExtension ( string $p_file ) : mixed
$p_file string
return mixed the extension on success or NULL on failure

findReplace() public method

searchDirFiles() wrapper function.
public findReplace ( string $p_path )
$p_path string

matchedExtension() public method

Checks if a file extension is one the extensions we are going to search.
public matchedExtension ( string $p_file ) : boolean
$p_file string
return boolean true on success or false on failure

searchDirFiles() public method

Runs recursively all into the path.
public searchDirFiles ( string $p_path ) : array
$p_path string
return array

searchFileData() public method

Searches file data and replaces with given pattern.
public searchFileData ( string $p_file )
$p_file string

setExtensions() public method

Sets extensions to search for.
public setExtensions ( array $p_extensions = [] )
$p_extensions array

setReplacementKey() public method

Sets the replacement to replace pattern with.
public setReplacementKey ( string $p_replacementKey )
$p_replacementKey string

setSearchKey() public method

Sets the pattern and case sensitivity.
public setSearchKey ( string $p_searchKey, integer $p_caseSensitive )
$p_searchKey string
$p_caseSensitive integer

Property Details

$m_caseSensitive public_oe property

public $m_caseSensitive

$m_fileExtensions public_oe property

public $m_fileExtensions

$m_findAllExtensions public_oe property

public $m_findAllExtensions

$m_isReplaceEnabled public_oe property

public $m_isReplaceEnabled

$m_replacementKey public_oe property

public $m_replacementKey

$m_searchKey public_oe property

public $m_searchKey

$m_totalFound public_oe property

public $m_totalFound