Source for file block.textformat.php
Documentation is available at block.textformat.php
* Smarty {textformat}{/textformat} block plugin
* Type: block function<br>
* Purpose: format text a certain way with preset styles
* or custom wrap/indent settings<br>
* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
* Params: style: string (email)
* wrap_char string ("\n")
* indent_char: string (" ")
* wrap_boundary: boolean (true)
* @param string contents of the block
* @param Smarty clever simulation of a method
* @return string string $content re-formatted
$paragraphs = preg_split('![\r\n][\r\n]!',$content);
foreach($paragraphs as $paragraph) {
// convert mult. spaces & special chars to single space
$paragraph = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'),array(' ',''),$paragraph);
$paragraph = str_repeat($indent_char,$indent_first) . $paragraph;
$paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
$output .= $paragraph . $wrap_char . $wrap_char;
$smarty->assign($assign,$output);
/* vim: set expandtab: */
|