*/ /** * patTemplate modfifier Nl2br * * Formats dates and times according to a format string. * * * See the PHP documentation for number_format() for * more information. */ class patTemplate_Modifier_Nl2br extends patTemplate_Modifier { private $defaults = array( 'mode' => 'html', 'replace' => ' ' ); /** * Modify the value * * @param string value * @return string modified value */ public function modify($value, $params = array()) { $params = array_merge($this->defaults, $params); switch ($params['mode']) { case 'tex': case 'latex': $value = str_replace(array("\r","\n"), array('', "\\newline\n"), $value); break; case 'replace': $value = str_replace(array("\r","\n"), array('', $params['replace']), $value); break; default: $value = nl2br($value); break; } return $value; } }