blob: ce628115af49b2f3f74039d5b9ad226df0cb4e6f [file] [log] [blame]
Derek Jones0b59f272008-05-13 04:22:33 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allardd2df9bc2007-04-15 17:41:17 +00002/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
Derek Allard3d879d52008-01-18 19:41:32 +00008 * @author ExpressionEngine Dev Team
Derek Allardd2df9bc2007-04-15 17:41:17 +00009 * @copyright Copyright (c) 2006, EllisLab, Inc.
Derek Jones7a9193a2008-01-21 18:39:20 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
Derek Allardd2df9bc2007-04-15 17:41:17 +000012 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * CodeIgniter Typography Helpers
20 *
21 * @package CodeIgniter
22 * @subpackage Helpers
23 * @category Helpers
Derek Allard3d879d52008-01-18 19:41:32 +000024 * @author ExpressionEngine Dev Team
Derek Jones7a9193a2008-01-21 18:39:20 +000025 * @link http://codeigniter.com/user_guide/helpers/typography_helper.html
Derek Allardd2df9bc2007-04-15 17:41:17 +000026 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * Convert newlines to HTML line breaks except within PRE tags
32 *
33 * @access public
34 * @param string
35 * @return string
36 */
Derek Jones0b59f272008-05-13 04:22:33 +000037if ( ! function_exists('nl2br_except_pre'))
Derek Allardd2df9bc2007-04-15 17:41:17 +000038{
Derek Jones269b9422008-01-28 21:00:20 +000039 function nl2br_except_pre($str)
Derek Allardd2df9bc2007-04-15 17:41:17 +000040 {
Derek Jones269b9422008-01-28 21:00:20 +000041 $ex = explode("pre>",$str);
42 $ct = count($ex);
Derek Allardd2df9bc2007-04-15 17:41:17 +000043
Derek Jones269b9422008-01-28 21:00:20 +000044 $newstr = "";
45 for ($i = 0; $i < $ct; $i++)
46 {
47 if (($i % 2) == 0)
48 {
49 $newstr .= nl2br($ex[$i]);
50 }
51 else
52 {
53 $newstr .= $ex[$i];
54 }
55
56 if ($ct - 1 != $i)
57 $newstr .= "pre>";
58 }
59
60 return $newstr;
61 }
Derek Allardd2df9bc2007-04-15 17:41:17 +000062}
63
64// ------------------------------------------------------------------------
65
66/**
67 * Auto Typography Wrapper Function
68 *
69 *
70 * @access public
71 * @param string
72 * @return string
73 */
Derek Jones0b59f272008-05-13 04:22:33 +000074if ( ! function_exists('auto_typography'))
Derek Allardd2df9bc2007-04-15 17:41:17 +000075{
Derek Jones269b9422008-01-28 21:00:20 +000076 function auto_typography($str)
77 {
Rick Ellis037a5bc2008-09-10 22:58:21 +000078 $CI =& get_instance();
79
80 $CI->load->library('typography');
81
82 return $CI->typography->convert($str);
Derek Jones269b9422008-01-28 21:00:20 +000083 }
Derek Allardd2df9bc2007-04-15 17:41:17 +000084}
Derek Jones0b59f272008-05-13 04:22:33 +000085
86/* End of file typography_helper.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +000087/* Location: ./system/helpers/typography_helper.php */