Fixing content type ordering when content_type is not defined.
[akelos.git] / lib / AkActionView / helpers / mail_helper.php
blobf485f3dafb133c25520594748d3bc9e5ad77c225
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4 // +----------------------------------------------------------------------+
5 // | Akelos Framework - http://www.akelos.org |
6 // +----------------------------------------------------------------------+
7 // | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez |
8 // | Released under the GNU Lesser General Public License, see LICENSE.txt|
9 // +----------------------------------------------------------------------+
11 /**
12 * @package AkelosFramework
13 * @subpackage Helpers
14 * @author Bermi Ferrer <bermi a.t akelos c.om>
15 * @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
19 require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'helpers'.DS.'text_helper.php');
21 class MailHelper
23 function setController(&$controller)
25 $this->_controller =& $controller;
28 /**
29 * Uses TextHelper::format to take the text and format it, indented two spaces for
30 * each line, and wrapped at 72 columns.
32 function block_format($text)
34 $formatted = '';
35 $paragraphs = split("(\n|\r){2,}",$text);
36 foreach ((array)$paragraphs as $paragraph){
37 $formatted .= TextHelper::format($paragraph, array('columns' => 72, 'first_indent' => 2, 'body_indent' => 2));
39 // Make list points stand on their own line
40 return preg_replace("/[ ]*([*]+) ([^*]*)/"," $1 $2\n", preg_replace("/[ ]*([#]+) ([^#]*)/"," $1 $2\n",$formatted));