~ubuntu-branches/ubuntu/gutsy/smarty/gutsy-security

« back to all changes in this revision

Viewing changes to libs/plugins/block.textformat.php

  • Committer: Bazaar Package Importer
  • Author(s): Dimitri Fontaine
  • Date: 2005-03-29 11:53:20 UTC
  • mfrom: (0.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050329115320-g3rvndgnn75ogm35
Tags: 2.6.8-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
    }
72
72
 
73
73
    // split into paragraphs
74
 
    $paragraphs = preg_split('![\r\n][\r\n]!',$content);
75
 
    $output = '';
 
74
    $_paragraphs = preg_split('![\r\n][\r\n]!',$content);
 
75
    $_output = '';
76
76
 
77
 
    foreach ($paragraphs as $paragraph) {
78
 
        if ($paragraph == '') {
 
77
    for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
 
78
        if ($_paragraphs[$_x] == '') {
79
79
            continue;
80
80
        }
81
81
        // convert mult. spaces & special chars to single space
82
 
        $paragraph = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'),array(' ',''),$paragraph);
 
82
        $_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]);
83
83
        // indent first line
84
84
        if($indent_first > 0) {
85
 
            $paragraph = str_repeat($indent_char,$indent_first) . $paragraph;
 
85
            $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
86
86
        }
87
87
        // wordwrap sentences
88
 
        $paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
 
88
        $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
89
89
        // indent lines
90
90
        if($indent > 0) {
91
 
            $paragraph = preg_replace('!^!m',str_repeat($indent_char,$indent),$paragraph);
 
91
            $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
92
92
        }
93
 
        $output .= $paragraph . $wrap_char . $wrap_char;
94
 
    }
95
 
 
96
 
    if ($assign) {
97
 
        $smarty->assign($assign,$output);
98
 
    } else {
99
 
        return $output;
100
 
    }
 
93
    }
 
94
    $_output = implode($wrap_char . $wrap_char, $_paragraphs);
 
95
 
 
96
    return $assign ? $smarty->assign($assign, $_output) : $_output;
 
97
 
101
98
}
102
99
 
103
100
/* vim: set expandtab: */