Fuel-textfilter is a project mainly written in PHP, it's free.
Text output filters for the FuelPHP framework.
The Text-Filter package was created as a way to easily alter Response output before it was sent to the user. Since then it has made more sense to not limit it to that specific use. This package is simply a collection of filters meant to process and alter a text string.
This package follows standard installation rules, which can be found within the [FuelPHP Documentation for Packages] (http://fuelphp.com/docs/general/packages.html)
To install via the oil package command, first ninjarite's github to the package config.
// fuel/app/config/package.php
return array(
'sources' => array(
'github.com/fuel-packages',
'github.com/ninjarite', // ADD THIS LINE
),
),
Then run the following command from your shell while in your applications' base directory
oil package install textfilter
To run just one single filter, simply do the following. You will find the list of filters included with this package below. And for more configuration options on each filter, see the filters' corresponding config file.
$string = "string to parse";
$config = array('config' => 'options');
$output = new Filter('filtername', $config);
$string = "String to parse";
// Process all filters at once.
$output = FilterSet::factory('group', array('acronym', 'censor', 'stripper')->process_all($string);
// Process one filter from the set.
$output = FilterSet::factory('group', array('acronym', 'censor', 'stripper')->process('stripper', $string);
If you only plan on having one Filter Set instance you can simply call FilterSet::factory() with no attributes.
$filterset = FilterSet::factory('mygroup');
$filterset->append('stripper'); // Add the filter to the end of the filters array
$filterset->prepend('acronym'); // Add the filter to the beginning of the array.
Sometimes you may wish to organize the filters you would like to run in a certain order... For instance, if a certain filter processes your HTML and replaces it with entities, then you will need to run the HTML replacement filters before it...
$filterset = FilterSet::factory('mygroup', array('stripper', 'acronym');
$output = $filterset->process_all("My input string");
// This will clear all loaded filters and
// leave you with an empty filterset.
FilterSet::instance('mygroup')->reset();