Class: IOFilter
- Package: saf.CGI
- Author: John Luxford <lux@simian.ca>
- Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
- License: http://www.sitellite.org/index/license Simian Open Software License
- Version: 1.0, 2002-08-10, $Id: IOFilter.php,v 1.3 2007/10/06 00:06:30 lux Exp $
- Access: public
IOFilter provides the skeleton for creating filters on incoming
or outgoing data, including the automatic sending of relevant HTTP
headers. Its purpose is to be extended through subclassing to create
custom filters (ie. an XSLT filter).
Usage Example
<?php
class XsltFilter extends IOFilter {
var $xsltDoc = '';
function transform ($content) {
if (empty ($this->xsltDoc)) {
$this->error = 'No $xsltDoc property specified!';
return false;
}
global $loader;
$loader->import ('saf.XML.XSLT');
$xslt = new XSLT ();
if ($res = $xslt->process ($this->xsltDoc, $content)) {
$xslt->free ();
return $res;
} else {
$this->error = $xslt->error ();
$xslt->free ();
return false;
}
}
}
$xslf = new XsltFilter ('xslt', 'text/html');
$xslf->xsltDoc = 'inc/xslt/xml2html.xslt';
if ($new_data = $xslf->transform ($original_data)) {
$xslf->sendHeaders ();
echo $new_data;
} else {
echo $xslf->error;
}
?>
Properties
$param = array ()
- Access: public
Contains a list of the names of all the cookie variables
available to the current script.
$files = array ()
- Access: public
Contains a list of the names of all the file upload variables
passed to the current script through the POST method.
$error
- Access: public
Contains an error message that may have been created during
the execution of a transform() call.
$name
- Access: public
A name for this filter.
$contentType
- Access: public
The content type of the data, which if provided will be
sent as an HTTP Content-Type header by sendHeaders().
$extraHeaders
- Access: public
A list of extra HTTP headers to send by sendHeaders().
Methods
IOFilter ($name, $contentType = false)
- Access: public
Constructor method.
addHeader ($header)
- Access: public
Adds a header to $extraHeaders.
transform ($content)
- Access: public
- Return: string
Transforms the content provided into a new format. This
method is left blank for subclasses to fill in.
sendHeaders ()
- Access: public
Sends any HTTP headers specified, including the
Content-Type header if $contentType is specified.
