Source for file Converter.class.php
Documentation is available at Converter.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* This class is responsible for loading the appropriate Converter object. The name
* given must be a Gumbo_Interface_Converter, otherwise the returned value will be
* the Blank Converter. The Blank Converter simply returns the data given. If the
* name given is not a class, the Factory will attempt to search for a Gumbo_Converter_*
* class. Since the Factory will always return a Converter object, the information
* $data = $fact->factory ("Array", ... )->convert ($data_array, "composite");
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
gumbo_load ("Converter_Blank");
* Returns an instantiated object (accept Constructor arguments)
* @param string|int$name name of Class or key string
* @param mixed $args additional arguments
* @return Gumbo_Interface_Converter
* @throws Gumbo_Exception
* @uses Gumbo_Converter_Blank
public function factory ($name=
null, $args=
null) {
// prepend Gumbo_Converter_ to the name if class not found
if ($key ==
0) { continue; }
$e->setFunction (__METHOD__
);
* Converts new line characters into HTML line breaks
* @uses Gumbo_Converter_Factory
public static function nl2br ($txt) {
return $fact->factory ("NewLineBreak")->convert ($txt, "br");
* Converts HTML line breaks into new line characters
* @param string $eol End of Line characters (default PHP_EOL)
public static function br2nl ($txt, $eol=
PHP_EOL) {
return $fact->factory ("NewLineBreak", $eol)->convert ($txt, "nl");
* Converts the characters into HTML entities, including single-double quotes
* @param int $quote_style ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES
* @param string $charset character set
public static function htmlencode ($txt, $quote_style=
ENT_QUOTES, $charset=
null) {
return $fact->factory ("Html", $quote_style, $charset)->convert ($txt, "encode");
* Converts the HTML entities, including single-double quotes, into a characters
* @param int $quote_style ENT_COMPAT, ENT_QUOTES, ENT_NOQUOTES
* @param string $charset character set
public static function htmldecode ($txt, $quote_style=
ENT_QUOTES, $charset=
null) {
return $fact->factory ("Html", $quote_style, $charset)->convert ($txt, "decode");
* Adds slashes to the string
return $fact->factory ("Slashes")->convert ($txt, "add");
* Strips slashes to the string
return $fact->factory ("Slashes")->convert ($txt, "strip");