blob: 0bb0938a413c0698a19cd600b1132a002b2d41a6 [file] [log] [blame]
Derek Jones4b9c6292011-07-01 17:40:48 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Greg Aker0711dc82011-01-05 10:49:40 -06009 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
Derek Allard2067d1a2008-11-13 22:59:24 +000010 * @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 Mienydd671972010-10-04 16:33:58 +020036 */
Derek Allard2067d1a2008-11-13 22:59:24 +000037if ( ! function_exists('nl2br_except_pre'))
38{
39 function nl2br_except_pre($str)
40 {
41 $CI =& get_instance();
Barry Mienydd671972010-10-04 16:33:58 +020042
Derek Allard2067d1a2008-11-13 22:59:24 +000043 $CI->load->library('typography');
Barry Mienydd671972010-10-04 16:33:58 +020044
Derek Allard2067d1a2008-11-13 22:59:24 +000045 return $CI->typography->nl2br_except_pre($str);
46 }
47}
Barry Mienydd671972010-10-04 16:33:58 +020048
Derek Allard2067d1a2008-11-13 22:59:24 +000049// ------------------------------------------------------------------------
50
51/**
52 * Auto Typography Wrapper Function
53 *
54 *
55 * @access public
56 * @param string
Derek Jones2b7de062010-03-05 10:31:08 -060057 * @param bool whether to allow javascript event handlers
Derek Allard2067d1a2008-11-13 22:59:24 +000058 * @param bool whether to reduce multiple instances of double newlines to two
59 * @return string
60 */
61if ( ! function_exists('auto_typography'))
62{
Derek Jones2b7de062010-03-05 10:31:08 -060063 function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +000064 {
Barry Mienydd671972010-10-04 16:33:58 +020065 $CI =& get_instance();
Derek Allard2067d1a2008-11-13 22:59:24 +000066 $CI->load->library('typography');
Derek Jones2b7de062010-03-05 10:31:08 -060067 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 Jones2b7de062010-03-05 10:31:08 -060079 * @access public
80 * @param string
81 * @return string
82 */
83if ( ! function_exists('entity_decode'))
84{
freewil8cc0cfe2011-08-27 21:53:00 -040085 function entity_decode($str, $charset = NULL)
Derek Jones2b7de062010-03-05 10:31:08 -060086 {
Pascal Kriete6984aaf2011-04-05 14:58:04 -040087 global $SEC;
freewil8cc0cfe2011-08-27 21:53:00 -040088
89 if (empty($charset)) $charset = config_item('charset');
90
Pascal Kriete6984aaf2011-04-05 14:58:04 -040091 return $SEC->entity_decode($str, $charset);
Derek Allard2067d1a2008-11-13 22:59:24 +000092 }
93}
94
95/* End of file typography_helper.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +000096/* Location: ./system/helpers/typography_helper.php */