Derek Jones | 0b59f27 | 2008-05-13 04:22:33 +0000 | [diff] [blame] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 2 | /**
|
| 3 | * CodeIgniter
|
| 4 | *
|
| 5 | * An open source application development framework for PHP 4.3.2 or newer
|
| 6 | *
|
| 7 | * @package CodeIgniter
|
Derek Allard | 3d879d5 | 2008-01-18 19:41:32 +0000 | [diff] [blame] | 8 | * @author ExpressionEngine Dev Team
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 9 | * @copyright Copyright (c) 2006, EllisLab, Inc.
|
Derek Jones | 7a9193a | 2008-01-21 18:39:20 +0000 | [diff] [blame] | 10 | * @license http://codeigniter.com/user_guide/license.html
|
| 11 | * @link http://codeigniter.com
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 12 | * @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 Allard | 3d879d5 | 2008-01-18 19:41:32 +0000 | [diff] [blame] | 24 | * @author ExpressionEngine Dev Team
|
Derek Jones | 7a9193a | 2008-01-21 18:39:20 +0000 | [diff] [blame] | 25 | * @link http://codeigniter.com/user_guide/helpers/typography_helper.html
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 26 | */
|
| 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 Jones | 0b59f27 | 2008-05-13 04:22:33 +0000 | [diff] [blame] | 37 | if ( ! function_exists('nl2br_except_pre'))
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 38 | {
|
Derek Jones | 269b942 | 2008-01-28 21:00:20 +0000 | [diff] [blame] | 39 | function nl2br_except_pre($str)
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 40 | {
|
Derek Jones | 269b942 | 2008-01-28 21:00:20 +0000 | [diff] [blame] | 41 | $ex = explode("pre>",$str);
|
| 42 | $ct = count($ex);
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 43 |
|
Derek Jones | 269b942 | 2008-01-28 21:00:20 +0000 | [diff] [blame] | 44 | $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 Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 62 | }
|
| 63 |
|
| 64 | // ------------------------------------------------------------------------
|
| 65 |
|
| 66 | /**
|
| 67 | * Auto Typography Wrapper Function
|
| 68 | *
|
| 69 | *
|
| 70 | * @access public
|
| 71 | * @param string
|
| 72 | * @return string
|
| 73 | */
|
Derek Jones | 0b59f27 | 2008-05-13 04:22:33 +0000 | [diff] [blame] | 74 | if ( ! function_exists('auto_typography'))
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 75 | {
|
Derek Jones | 269b942 | 2008-01-28 21:00:20 +0000 | [diff] [blame] | 76 | function auto_typography($str)
|
| 77 | {
|
Rick Ellis | 037a5bc | 2008-09-10 22:58:21 +0000 | [diff] [blame^] | 78 | $CI =& get_instance();
|
| 79 |
|
| 80 | $CI->load->library('typography');
|
| 81 |
|
| 82 | return $CI->typography->convert($str);
|
Derek Jones | 269b942 | 2008-01-28 21:00:20 +0000 | [diff] [blame] | 83 | }
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 84 | }
|
Derek Jones | 0b59f27 | 2008-05-13 04:22:33 +0000 | [diff] [blame] | 85 |
|
| 86 | /* End of file typography_helper.php */
|
Derek Jones | a3ffbbb | 2008-05-11 18:18:29 +0000 | [diff] [blame] | 87 | /* Location: ./system/helpers/typography_helper.php */ |