imars world - Think about it: nobody will do it for you
Go to site navigation

FText

edited on March 23rd, 2009

Text processing utilities. The class wrapper is mostly to help keep your namespace clean.

Summary

Introduction

Legal

Copyright (C) 2008 Stephane Lavergne http://www.imars.com/

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Functions

msgWrap

function msgWrap($body, $width = 76)

Perform word-wrap on a text message. Takes care of quote indentations.

Usually called from msgFormat(), but useful when saving messages coming from forms as well. (Messages coming from an e-mail gateway should be stored as-is in your database and formatted for displaying only, to avoid data loss if any reformatting were to have a bug.)

Parameters

$body
String containing the possibly multiline text.
$width
Number of columns to use. (Optional.)

Note

Formerly named “wrap_message()” in rtphp.

Returns

The reformatted text string.

msgFormat

function msgFormat($body, $width = 76, $html_markup = false, $html_quotes = false)

Reformat text/plain messages for user-friendly display. A lot of cleaning up is performed:

Parameters

$body
Raw body to process.
$width
Rewrapping number of columns, useful in text output. (Optional.)
$html_markup
Set true to request XHTML formatting. (Optional.)
$html_quotes
Set true to request BLOCKQUOTE for quotes. (Optional.)

Note

Formerly named “prettify()” in rtphp.

Returns

Reformatted content.

msgAbstract

function msgAbstract($body, $max = 500)

Extract most relevant start of a message body. If you've used Gmail before, you've seen the usefulness of this kind of logic for displaying alongside message subjects in lists. This is more intelligent than Gmail (as of 2008/03/26) and skips quotes and quote introductions. Often, message threads can be read just with one-line abstracts this way, saving a lot of time to the user.

Parameters

$body
The raw message body to extract an abstract from.
$max
Maximum number of characters. (Optional.)

Returns

The abstract string.

Post a comment:


(not displayed, optional)

(optional)

Don't write in these two boxes:

(URLs will become hyperlinks, please omit "http://".)

Navigation:

© 2009 Stéphane Lavergne   Site powered by FernCMS   Valid: XHTML 1.1 CSS