Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Greg Aker | 741de1c | 2010-11-10 14:52:57 -0600 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.1.6 or newer |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 6 | * |
| 7 | * @package CodeIgniter |
| 8 | * @author ExpressionEngine Dev Team |
Greg Aker | 0711dc8 | 2011-01-05 10:49:40 -0600 | [diff] [blame] | 9 | * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 10 | * @license http://codeigniter.com/user_guide/license.html |
| 11 | * @link http://codeigniter.com |
| 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 |
| 24 | * @author ExpressionEngine Dev Team |
| 25 | * @link http://codeigniter.com/user_guide/helpers/typography_helper.html |
| 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 |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 36 | */ |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 37 | if ( ! function_exists('nl2br_except_pre')) |
| 38 | { |
| 39 | function nl2br_except_pre($str) |
| 40 | { |
| 41 | $CI =& get_instance(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 42 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 43 | $CI->load->library('typography'); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 44 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 45 | return $CI->typography->nl2br_except_pre($str); |
| 46 | } |
| 47 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 48 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 49 | // ------------------------------------------------------------------------ |
| 50 | |
| 51 | /** |
| 52 | * Auto Typography Wrapper Function |
| 53 | * |
| 54 | * |
| 55 | * @access public |
| 56 | * @param string |
Derek Jones | 2b7de06 | 2010-03-05 10:31:08 -0600 | [diff] [blame] | 57 | * @param bool whether to allow javascript event handlers |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 58 | * @param bool whether to reduce multiple instances of double newlines to two |
| 59 | * @return string |
| 60 | */ |
| 61 | if ( ! function_exists('auto_typography')) |
| 62 | { |
Derek Jones | 2b7de06 | 2010-03-05 10:31:08 -0600 | [diff] [blame] | 63 | function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 64 | { |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 65 | $CI =& get_instance(); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 66 | $CI->load->library('typography'); |
Derek Jones | 2b7de06 | 2010-03-05 10:31:08 -0600 | [diff] [blame] | 67 | return $CI->typography->auto_typography($str, $strip_js_event_handlers, $reduce_linebreaks); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | |
| 72 | // -------------------------------------------------------------------- |
| 73 | |
| 74 | /** |
| 75 | * HTML Entities Decode |
| 76 | * |
| 77 | * This function is a replacement for html_entity_decode() |
| 78 | * |
Derek Jones | 2b7de06 | 2010-03-05 10:31:08 -0600 | [diff] [blame] | 79 | * @access public |
| 80 | * @param string |
| 81 | * @return string |
| 82 | */ |
| 83 | if ( ! function_exists('entity_decode')) |
| 84 | { |
freewil | 8cc0cfe | 2011-08-27 21:53:00 -0400 | [diff] [blame^] | 85 | function entity_decode($str, $charset = NULL) |
Derek Jones | 2b7de06 | 2010-03-05 10:31:08 -0600 | [diff] [blame] | 86 | { |
Pascal Kriete | 6984aaf | 2011-04-05 14:58:04 -0400 | [diff] [blame] | 87 | global $SEC; |
freewil | 8cc0cfe | 2011-08-27 21:53:00 -0400 | [diff] [blame^] | 88 | |
| 89 | if (empty($charset)) $charset = config_item('charset'); |
| 90 | |
Pascal Kriete | 6984aaf | 2011-04-05 14:58:04 -0400 | [diff] [blame] | 91 | return $SEC->entity_decode($str, $charset); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 92 | } |
| 93 | } |
| 94 | |
| 95 | /* End of file typography_helper.php */ |
Derek Jones | a3ffbbb | 2008-05-11 18:18:29 +0000 | [diff] [blame] | 96 | /* Location: ./system/helpers/typography_helper.php */ |