Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: c:/www/apache/doc2//pear/File/SearchReplace.php
PEAR 2000/12/03 -

File_SearchReplace

File_SearchReplace

Warning: documentation is missing.

 

private class File_SearchReplace


 

Public Method Summary

void

File_SearchReplace(string $find, string $replace, array $files, [ string $directories, integer $include_subdir, array $ignore_lines ])

Sets up the object
int

getNumOccurences()

Accessor to return the number of occurences found.
string

getLastError()

Accessor for retrieving last error.
void

setFind(string $find)

Accessor for setting find variable.
void

setReplace(string $replace)

Accessor for setting replace variable.
void

setFiles(array $files)

Accessor for setting files variable.
void

setDirectories(array $directories)

Accessor for setting directories variable.
void

setIncludeSubdir(int $include_subdir)

Accessor for setting include_subdir variable.
void

setIgnoreLines(array $ignore_lines)

Accessor for setting ignore_lines variable.
void

setSearchFunction(string $search_function)

Function to determine which search function is used.
void

doSearch()

This starts the search/replace off. Call this to do the search.

Private Method Summary

array

search(string $filename)

Default ("normal") search routine.
array

quickSearch(string $filename)

Quick search routine.
array

pregSearch(string $filename)

Preg search routine.
array

eregSearch(string $filename)

Ereg search routine.
void

writeout(string $filename, string $contents)

Function to writeout the file contents.
void

doFiles(string $ser_func)

Function called by doSearch() to go through any files that need searching.
void

doDirectories(string $ser_func)

Function called by doSearch() to go through any directories that need searching.

Private Field Summary

unknown

$find

unknown

$replace

unknown

$files

unknown

$directories

unknown

$include_subdir

unknown

$ignore_lines

unknown

$ignore_sep

unknown

$occurences

unknown

$search_function

unknown

$last_error

Public Method Details

File_SearchReplace

public void File_SearchReplace( string $find, string $replace, array $files, [ string $directories, integer $include_subdir, array $ignore_lines ] )

  Sets up the object

Parameter
string $find
The string/regex to find.
string $replace
The string/regex to replace $find with.
array $files
The file(s) to perform this operation on.
string $directories = >>''<<
(optional) The directories to perform this operation on.
integer $include_subdir = >>1<<
If performing on directories, whether to traverse subdirectories.
array $ignore_lines = >>array()<<
Ignore lines beginning with any of the strings in this array. This
feature only works with the "normal" search.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

getNumOccurences

public int getNumOccurences( )

  Accessor to return the number of occurences found.

Returns int

Number of occurences found.

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

getLastError

public string getLastError( )

  Accessor for retrieving last error.

Returns string

The last error that occurred, if any.

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

setFind

public void setFind( string $find )

  Accessor for setting find variable.

Parameter
string $find
The string/regex to find.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

setReplace

public void setReplace( string $replace )

  Accessor for setting replace variable.

Parameter
string $replace
The string/regex to replace the find string/regex with.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

setFiles

public void setFiles( array $files )

  Accessor for setting files variable.

Parameter
array $files
The file(s) to perform this operation on.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

setDirectories

public void setDirectories( array $directories )

  Accessor for setting directories variable.

Parameter
array $directories
The directories to perform this operation on.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

setIncludeSubdir

public void setIncludeSubdir( int $include_subdir )

  Accessor for setting include_subdir variable.

Parameter
int $include_subdir
Whether to traverse subdirectories or not.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

setIgnoreLines

public void setIgnoreLines( array $ignore_lines )

  Accessor for setting ignore_lines variable.

Parameter
array $ignore_lines
Ignore lines beginning with any of the strings in this array. This
feature only works with the "normal" search.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

setSearchFunction

public void setSearchFunction( string $search_function )

  Function to determine which search function is used.

Parameter
string $search_function
search function that should be used. Can be any one of:
normal - Default search. Goes line by line. Ignore lines feature only works with this type.
quick - Uses str_replace for straight replacement throughout file. Quickest of the lot.
preg - Uses preg_replace(), so any regex valid with this function is valid here.
ereg - Uses ereg_replace(), so any regex valid with this function is valid here.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

doSearch

public void doSearch( )

  This starts the search/replace off. Call this to do the search.
First do whatever files are specified, and/or if directories are specified,do those too.

Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

Private Method Details

search

private array search( string $filename )

  Default ("normal") search routine.

Parameter
string $filename
The filename to search and replace upon.
Returns array

Will return an array containing the new file contents and the number of occurences.
Will return FALSE if there are no occurences.

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

quickSearch

private array quickSearch( string $filename )

  Quick search routine.

Parameter
string $filename
The filename to search and replace upon.
Returns array

Will return an array containing the new file contents and the number of occurences.
Will return FALSE if there are no occurences.

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

pregSearch

private array pregSearch( string $filename )

  Preg search routine.

Parameter
string $filename
The filename to search and replace upon.
Returns array

Will return an array containing the new file contents and the number of occurences.
Will return FALSE if there are no occurences.

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

eregSearch

private array eregSearch( string $filename )

  Ereg search routine.

Parameter
string $filename
The filename to search and replace upon.
Returns array

Will return an array containing the new file contents and the number of occurences.
Will return FALSE if there are no occurences.

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

writeout

private void writeout( string $filename, string $contents )

  Function to writeout the file contents.

Parameter
string $filename
The filename of the file to write.
string $contents
The contents to write to the file.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

doFiles

private void doFiles( string $ser_func )

  Function called by doSearch() to go through any files that need searching.

Parameter
string $ser_func
The search function to use.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

doDirectories

private void doDirectories( string $ser_func )

  Function called by doSearch() to go through any directories that need searching.

Parameter
string $ser_func
The search function to use.
Returns void

Author(s) Richard Heyes <richard.heyes@heyes-computing.net>

Private Field Details

$find

private unknown $find

>><<



$replace

private unknown $replace

>><<



$files

private unknown $files

>><<



$directories

private unknown $directories

>><<



$include_subdir

private unknown $include_subdir

>><<



$ignore_lines

private unknown $ignore_lines

>><<



$ignore_sep

private unknown $ignore_sep

>><<



$occurences

private unknown $occurences

>><<



$search_function

private unknown $search_function

>><<



$last_error

private unknown $last_error

>><<




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta