Replaces tokens in the original input with the contents of a file.
The file to be used is controlled by the name of the token which corresponds to the basename of the file to be used together with the optional pre and postfix strings that is possible to set.
By default all HTML entities in the file is replaced by the corresponding HTML entities. This behaviour can be controlled by the "translatehtml" parameter.
Supported parameters are:
prefix string Text to be prefixed to token before using as filename postfix string Text to be prefixed to token before using as filename dir string The directory where the files should be read from translatehtml bool If we should translate all HTML entities in the file.
Example:
author | johan persson, johanp@aditus.nu |
---|---|
version | $Id: 164a2d9eeba3673653086b32e9fa2045168c992c $ |
access | public |
see | \global\ReplaceTokensWithFile |
package | phing.filters |
copyright | 2003 seasonfive. All rights reserved |
__construct(\Reader $in)
The original filter reader is only used for chaining purposes, never for filtering purposes (and indeed it would be useless for filtering purposes, as it has no real data to filter). ChainedReaderHelper uses this placeholder instance to create a chain of real filters.
inherited_from | \BaseFilterReader::__construct() |
---|---|
inherited_from | \BaseParamFilterReader::__construct() |
\Reader
chain(\Reader $reader) : object
object
A Reader object providing the underlying stream. Must not be null
.
object
A new filter based on this configuration, but filtering
the specified readerclose()
inherited_from | \FilterReader::close() |
---|---|
inherited_from | \BaseFilterReader::close() |
inherited_from | \BaseParamFilterReader::close() |
\IOException |
if there is an error closing stream |
---|
eof() : boolean
inherited_from | \BaseFilterReader::eof() |
---|---|
inherited_from | \BaseParamFilterReader::eof() |
boolean
getBeginToken() : string
string
The character used to denote the beginning of a token.getDir()
getEndToken() : \the
\the
character used to denote the beginning of a tokengetInitialized() : boolean
inherited_from | \BaseFilterReader::getInitialized() |
---|---|
inherited_from | \BaseParamFilterReader::getInitialized() |
boolean
whether or not the filter is initializedgetParameters()
inherited_from | \BaseParamFilterReader::getParameters() |
---|
getPostfix()
For example if the token is 01 and the postfix is ".php" then the filename to look for will be "01.php"
getPrefix()
getProject() : object
inherited_from | \BaseFilterReader::getProject() |
---|---|
inherited_from | \BaseParamFilterReader::getProject() |
object
The project this filter is part ofgetResource() : string
that is being read from. This is critical for, e.g., ExpatParser's ability to know the filename that is throwing an ExpatParserException, etc.
inherited_from | \FilterReader::getResource() |
---|---|
inherited_from | \BaseFilterReader::getResource() |
inherited_from | \BaseParamFilterReader::getResource() |
string
getTranslateHTML()
log(string $msg, int $level)
inherited_from | \BaseFilterReader::log() |
---|---|
inherited_from | \BaseParamFilterReader::log() |
string
Message to log.
int
Priority level.
mark()
A subsequent call to reset() will move stream position back to last marker (if supported).
inherited_from | \Reader::mark() |
---|---|
inherited_from | \FilterReader::mark() |
inherited_from | \BaseFilterReader::mark() |
inherited_from | \BaseParamFilterReader::mark() |
markSupported() : boolean
inherited_from | \Reader::markSupported() |
---|---|
inherited_from | \FilterReader::markSupported() |
inherited_from | \BaseFilterReader::markSupported() |
inherited_from | \BaseParamFilterReader::markSupported() |
boolean
read(\off $len) : mixed
If a replacement value is not found for a token, the token is left in the stream.
\off
Offset at which to start storing characters.
\IOException |
If an I/O error occurs |
---|
mixed
filtered stream, -1 on EOF.readLine() : \the
The returned String retains the '\n'.
inherited_from | \BaseFilterReader::readLine() |
---|---|
inherited_from | \BaseParamFilterReader::readLine() |
\IOException |
if the underlying reader throws one during reading |
---|
\the
line read, or null
if the end of the
stream has already been reachedready() : boolean
inherited_from | \Reader::ready() |
---|---|
inherited_from | \FilterReader::ready() |
inherited_from | \BaseFilterReader::ready() |
inherited_from | \BaseParamFilterReader::ready() |
boolean
reset()
inherited_from | \FilterReader::reset() |
---|---|
inherited_from | \BaseFilterReader::reset() |
inherited_from | \BaseParamFilterReader::reset() |
setBeginToken(string $beginToken)
string
the character used to denote the beginning of a token.
setDir(string $dir)
string
setEndToken(string $endToken)
string
the character used to denote the end of a token
setInitialized(boolean $initialized)
inherited_from | \BaseFilterReader::setInitialized() |
---|---|
inherited_from | \BaseParamFilterReader::setInitialized() |
boolean
Whether or not the filter is initialized.
setParameters($parameters)
inherited_from | \BaseParamFilterReader::setParameters() |
---|
setPostfix(string $postfix)
For example if the token is 01 and the postfix is ".php" then the filename to look for will be "01.php"
string
setPrefix(string $prefix)
For example if the token is 01 and the prefix is "example" then the filename to look for will be "example01"
string
setProject(\Project $project)
inherited_from | \BaseFilterReader::setProject() |
---|---|
inherited_from | \BaseParamFilterReader::setProject() |
object
The project this filter is part of. Should not be null
.
setReader(\Reader $in)
inherited_from | \FilterReader::setReader() |
---|---|
inherited_from | \BaseFilterReader::setReader() |
inherited_from | \BaseParamFilterReader::setReader() |
setTranslateHTML($translate)
skip(int $n)
inherited_from | \FilterReader::skip() |
---|---|
inherited_from | \BaseFilterReader::skip() |
inherited_from | \BaseParamFilterReader::skip() |
int
_initialize()
replaceTokenCallback(array $matches) : string
access | private |
---|
array
Array of 1 el containing key to search for.
string
Text with which to replace key or value of key if none is found.$_parameters
inherited_from | \BaseParamFilterReader::$$_parameters |
---|
$in : \Reader
inherited_from | \FilterReader::$$in |
---|---|
inherited_from | \BaseFilterReader::$$in |
inherited_from | \BaseParamFilterReader::$$in |
$initialized
inherited_from | \BaseFilterReader::$$initialized |
---|---|
inherited_from | \BaseParamFilterReader::$$initialized |
$project
inherited_from | \BaseFilterReader::$$project |
---|---|
inherited_from | \BaseParamFilterReader::$$project |
$_beginToken : string
$_dir : string
The default is to look in the current file.
$_endToken : string
$_postfix : string
$_prefix : string
$_tokensources : array
$_translatehtml : boolean
For example all '<' will be translated to < before the content is inserted.
DEFAULT_BEGIN_TOKEN : string
DEFAULT_END_TOKEN : string