blob: 1a71d18575c1e08e2b66a15db2ab99e6b33a646e [file] [log] [blame]
Derek Allard2067d1a2008-11-13 22:59:24 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Derek Jones7f3719f2010-01-05 13:35:37 +00009 * @copyright Copyright (c) 2008 - 2010, 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{
85 function entity_decode($str, $charset='UTF-8')
86 {
Barry Mienydd671972010-10-04 16:33:58 +020087 $CI =& get_instance();
Derek Jonesa0911472010-03-30 10:33:09 -050088 $CI->load->library('security');
89 return $CI->security->entity_decode($str, $charset);
Derek Allard2067d1a2008-11-13 22:59:24 +000090 }
91}
92
93/* End of file typography_helper.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +000094/* Location: ./system/helpers/typography_helper.php */