function _mailsystem_indent_mail_line in Mail System 7.3
Same name and namespace in other branches
- 8.2 html_to_text.inc \_mailsystem_indent_mail_line()
- 6.2 html_to_text.inc \_mailsystem_indent_mail_line()
- 7.2 html_to_text.inc \_mailsystem_indent_mail_line()
Helper function for array_walk in drupal_wrap_mail().
If $values['pad'] is non-empty, $values['indent'] will be added at the start of each line, and $values['pad'] at the end, repeating the last character of $values['pad'] until the line length equals $values['max'].
If $values['pad'] is empty, $values['indent'] will be added at the start of the first line, and $values['clean'] at the start of subsequent lines.
If $values['stuff'] is true, then an extra space character will be added at the start of any line beginning with a space, a '>', or the word 'From'.
See also
http://www.ietf.org/rfc/rfc3676.txt
1 string reference to '_mailsystem_indent_mail_line'
- mailsystem_wrap_mail in ./
html_to_text.inc - Perform format=flowed soft wrapping for mail (RFC 3676).
File
- ./
html_to_text.inc, line 721 - Copy of drupal_html_to_text improvements from issue #299138.
Code
function _mailsystem_indent_mail_line(&$line, $key, $values) {
if ($line == '') {
return;
}
if ($values['pad']) {
$line = $values['indent'] . $line;
$count = $values['max'] - drupal_strlen($line) - drupal_strlen($values['pad']);
if ($count >= 0) {
$line .= $values['pad'] . str_repeat($values['pad_repeat'], $count);
}
}
else {
$line = $values[$key === 0 ? 'indent' : 'clean'] . $line;
}
if ($values['stuff']) {
// chr(160) is the non-breaking space character.
$line = preg_replace('/^(' . chr(160) . '| |>|From)/', ' $1', $line);
}
}