summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-05-17 14:43:09 +0200
committerAndrey Andreev <narf@bofh.bg>2012-05-17 14:43:09 +0200
commite30b3f7afafa2c016cf78cc8bb8a457c2dbcda8c (patch)
tree805c7d92c46d9f669a6eacda3cc7d36faab22116
parentae31eb5e75d914fc3ab622a7ac5c23eb1e6d9f9a (diff)
parent98fde46fb938694feb1f36e590c4cfa5c97c3261 (diff)
Merge pull request #1300 from timw4mail/patch
Fix rest of the helpers
-rw-r--r--system/helpers/inflector_helper.php98
-rw-r--r--system/helpers/language_helper.php18
-rw-r--r--system/helpers/number_helper.php13
-rw-r--r--system/helpers/path_helper.php14
-rw-r--r--system/helpers/security_helper.php63
-rw-r--r--system/helpers/smiley_helper.php103
-rw-r--r--system/helpers/string_helper.php204
-rw-r--r--system/helpers/text_helper.php172
-rw-r--r--system/helpers/typography_helper.php47
-rw-r--r--system/helpers/url_helper.php268
-rw-r--r--system/helpers/xml_helper.php14
-rw-r--r--user_guide_src/source/changelog.rst1
12 files changed, 499 insertions, 516 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 2a9466305..647d840e4 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -37,16 +37,16 @@
// --------------------------------------------------------------------
-/**
- * Singular
- *
- * Takes a plural word and makes it singular
- *
- * @param string
- * @return str
- */
if ( ! function_exists('singular'))
{
+ /**
+ * Singular
+ *
+ * Takes a plural word and makes it singular
+ *
+ * @param string
+ * @return string
+ */
function singular($str)
{
$result = strval($str);
@@ -101,17 +101,17 @@ if ( ! function_exists('singular'))
// --------------------------------------------------------------------
-/**
- * Plural
- *
- * Takes a singular word and makes it plural
- *
- * @param string
- * @param bool
- * @return str
- */
if ( ! function_exists('plural'))
{
+ /**
+ * Plural
+ *
+ * Takes a singular word and makes it plural
+ *
+ * @param string
+ * @param bool
+ * @return string
+ */
function plural($str, $force = FALSE)
{
$result = strval($str);
@@ -158,16 +158,16 @@ if ( ! function_exists('plural'))
// --------------------------------------------------------------------
-/**
- * Camelize
- *
- * Takes multiple words separated by spaces or underscores and camelizes them
- *
- * @param string
- * @return str
- */
if ( ! function_exists('camelize'))
{
+ /**
+ * Camelize
+ *
+ * Takes multiple words separated by spaces or underscores and camelizes them
+ *
+ * @param string
+ * @return string
+ */
function camelize($str)
{
return strtolower($str[0]).substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
@@ -176,16 +176,16 @@ if ( ! function_exists('camelize'))
// --------------------------------------------------------------------
-/**
- * Underscore
- *
- * Takes multiple words separated by spaces and underscores them
- *
- * @param string
- * @return str
- */
if ( ! function_exists('underscore'))
{
+ /**
+ * Underscore
+ *
+ * Takes multiple words separated by spaces and underscores them
+ *
+ * @param string
+ * @return string
+ */
function underscore($str)
{
return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
@@ -194,31 +194,33 @@ if ( ! function_exists('underscore'))
// --------------------------------------------------------------------
-/**
- * Humanize
- *
- * Takes multiple words separated by the separator and changes them to spaces
- *
- * @param string $str
- * @param string $separator
- * @return string
- */
if ( ! function_exists('humanize'))
{
+ /**
+ * Humanize
+ *
+ * Takes multiple words separated by the separator and changes them to spaces
+ *
+ * @param string $str
+ * @param string $separator
+ * @return string
+ */
function humanize($str, $separator = '_')
{
return ucwords(preg_replace('/['.$separator.']+/', ' ', strtolower(trim($str))));
}
}
-/**
- * Checks if the given word has a plural version.
- *
- * @param string the word to check
- * @return bool if the word is countable
- */
+// --------------------------------------------------------------------
+
if ( ! function_exists('is_countable'))
{
+ /**
+ * Checks if the given word has a plural version.
+ *
+ * @param string the word to check
+ * @return bool if the word is countable
+ */
function is_countable($word)
{
return ! in_array(strtolower(strval($word)),
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index b31c97107..34f030716 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -37,17 +37,17 @@
// ------------------------------------------------------------------------
-/**
- * Lang
- *
- * Fetches a language variable and optionally outputs a form label
- *
- * @param string the language line
- * @param string the id of the form element
- * @return string
- */
if ( ! function_exists('lang'))
{
+ /**
+ * Lang
+ *
+ * Fetches a language variable and optionally outputs a form label
+ *
+ * @param string the language line
+ * @param string the id of the form element
+ * @return string
+ */
function lang($line, $id = '')
{
$CI =& get_instance();
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
index 40da6e7bf..e49f2f7a0 100644
--- a/system/helpers/number_helper.php
+++ b/system/helpers/number_helper.php
@@ -37,14 +37,15 @@
// ------------------------------------------------------------------------
-/**
- * Formats a numbers as bytes, based on size, and adds the appropriate suffix
- *
- * @param mixed // will be cast as int
- * @return string
- */
if ( ! function_exists('byte_format'))
{
+ /**
+ * Formats a numbers as bytes, based on size, and adds the appropriate suffix
+ *
+ * @param mixed will be cast as int
+ * @param int
+ * @return string
+ */
function byte_format($num, $precision = 1)
{
$CI =& get_instance();
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index 6ee99072c..13410545c 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -37,15 +37,15 @@
// ------------------------------------------------------------------------
-/**
- * Set Realpath
- *
- * @param string
- * @param bool checks to see if the path exists
- * @return string
- */
if ( ! function_exists('set_realpath'))
{
+ /**
+ * Set Realpath
+ *
+ * @param string
+ * @param bool checks to see if the path exists
+ * @return string
+ */
function set_realpath($path, $check_existance = FALSE)
{
// Security check to make sure the path is NOT a URL. No remote file inclusion!
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index d6f134c9f..6187a4a7a 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -37,15 +37,15 @@
// ------------------------------------------------------------------------
-/**
- * XSS Filtering
- *
- * @param string
- * @param bool whether or not the content is an image file
- * @return string
- */
if ( ! function_exists('xss_clean'))
{
+ /**
+ * XSS Filtering
+ *
+ * @param string
+ * @param bool whether or not the content is an image file
+ * @return string
+ */
function xss_clean($str, $is_image = FALSE)
{
$CI =& get_instance();
@@ -55,14 +55,14 @@ if ( ! function_exists('xss_clean'))
// ------------------------------------------------------------------------
-/**
- * Sanitize Filename
- *
- * @param string
- * @return string
- */
if ( ! function_exists('sanitize_filename'))
{
+ /**
+ * Sanitize Filename
+ *
+ * @param string
+ * @return string
+ */
function sanitize_filename($filename)
{
$CI =& get_instance();
@@ -72,14 +72,15 @@ if ( ! function_exists('sanitize_filename'))
// --------------------------------------------------------------------
-/**
- * Hash encode a string
- *
- * @param string
- * @return string
- */
if ( ! function_exists('do_hash'))
{
+ /**
+ * Hash encode a string
+ *
+ * @param string
+ * @param string
+ * @return string
+ */
function do_hash($str, $type = 'sha1')
{
if ( ! in_array(strtolower($type), hash_algos()))
@@ -93,14 +94,14 @@ if ( ! function_exists('do_hash'))
// ------------------------------------------------------------------------
-/**
- * Strip Image Tags
- *
- * @param string
- * @return string
- */
if ( ! function_exists('strip_image_tags'))
{
+ /**
+ * Strip Image Tags
+ *
+ * @param string
+ * @return string
+ */
function strip_image_tags($str)
{
return preg_replace(array('#<img\s+.*?src\s*=\s*["\'](.+?)["\'].*?\>#', '#<img\s+.*?src\s*=\s*(.+?).*?\>#'), '\\1', $str);
@@ -109,14 +110,14 @@ if ( ! function_exists('strip_image_tags'))
// ------------------------------------------------------------------------
-/**
- * Convert PHP tags to entities
- *
- * @param string
- * @return string
- */
if ( ! function_exists('encode_php_tags'))
{
+ /**
+ * Convert PHP tags to entities
+ *
+ * @param string
+ * @return string
+ */
function encode_php_tags($str)
{
return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 638100e9c..5e6de08af 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -37,18 +37,19 @@
// ------------------------------------------------------------------------
-/**
- * Smiley Javascript
- *
- * Returns the javascript required for the smiley insertion. Optionally takes
- * an array of aliases to loosely couple the smiley array to the view.
- *
- * @param mixed alias name or array of alias->field_id pairs
- * @param string field_id if alias name was passed in
- * @return array
- */
if ( ! function_exists('smiley_js'))
{
+ /**
+ * Smiley Javascript
+ *
+ * Returns the javascript required for the smiley insertion. Optionally takes
+ * an array of aliases to loosely couple the smiley array to the view.
+ *
+ * @param mixed alias name or array of alias->field_id pairs
+ * @param string field_id if alias name was passed in
+ * @param bool
+ * @return array
+ */
function smiley_js($alias = '', $field_id = '', $inline = TRUE)
{
static $do_setup = TRUE;
@@ -118,17 +119,20 @@ EOF;
// ------------------------------------------------------------------------
-/**
- * Get Clickable Smileys
- *
- * Returns an array of image tag links that can be clicked to be inserted
- * into a form field.
- *
- * @param string the URL to the folder containing the smiley images
- * @return array
- */
+
if ( ! function_exists('get_clickable_smileys'))
{
+ /**
+ * Get Clickable Smileys
+ *
+ * Returns an array of image tag links that can be clicked to be inserted
+ * into a form field.
+ *
+ * @param string the URL to the folder containing the smiley images
+ * @param array
+ * @param array
+ * @return array
+ */
function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
{
// For backward compatibility with js_insert_smiley
@@ -166,17 +170,18 @@ if ( ! function_exists('get_clickable_smileys'))
// ------------------------------------------------------------------------
-/**
- * Parse Smileys
- *
- * Takes a string as input and swaps any contained smileys for the actual image
- *
- * @param string the text to be parsed
- * @param string the URL to the folder containing the smiley images
- * @return string
- */
if ( ! function_exists('parse_smileys'))
{
+ /**
+ * Parse Smileys
+ *
+ * Takes a string as input and swaps any contained smileys for the actual image
+ *
+ * @param string the text to be parsed
+ * @param string the URL to the folder containing the smiley images
+ * @param array
+ * @return string
+ */
function parse_smileys($str = '', $image_url = '', $smileys = NULL)
{
if ($image_url == '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())))
@@ -198,15 +203,15 @@ if ( ! function_exists('parse_smileys'))
// ------------------------------------------------------------------------
-/**
- * Get Smiley Array
- *
- * Fetches the config/smiley.php file
- *
- * @return mixed
- */
if ( ! function_exists('_get_smiley_array'))
{
+ /**
+ * Get Smiley Array
+ *
+ * Fetches the config/smiley.php file
+ *
+ * @return mixed
+ */
function _get_smiley_array()
{
if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
@@ -222,33 +227,5 @@ if ( ! function_exists('_get_smiley_array'))
}
}
-// ------------------------------------------------------------------------
-
-/**
- * JS Insert Smiley
- *
- * Generates the javascript function needed to insert smileys into a form field
- *
- * DEPRECATED as of version 1.7.2, use smiley_js instead
- *
- * @param string form name
- * @param string field name
- * @return string
- */
-if ( ! function_exists('js_insert_smiley'))
-{
- function js_insert_smiley($form_name = '', $form_field = '')
- {
- return <<<EOF
-<script type="text/javascript">
- function insert_smiley(smiley)
- {
- document.{$form_name}.{$form_field}.value += " " + smiley;
- }
-</script>
-EOF;
- }
-}
-
/* End of file smiley_helper.php */
/* Location: ./system/helpers/smiley_helper.php */ \ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index a6a6b485d..0c47d440a 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -37,22 +37,22 @@
// ------------------------------------------------------------------------
-/**
- * Trim Slashes
- *
- * Removes any leading/trailing slashes from a string:
- *
- * /this/that/theother/
- *
- * becomes:
- *
- * this/that/theother
- *
- * @param string
- * @return string
- */
if ( ! function_exists('trim_slashes'))
{
+ /**
+ * Trim Slashes
+ *
+ * Removes any leading/trailing slashes from a string:
+ *
+ * /this/that/theother/
+ *
+ * becomes:
+ *
+ * this/that/theother
+ *
+ * @param string
+ * @return string
+ */
function trim_slashes($str)
{
return trim($str, '/');
@@ -61,16 +61,16 @@ if ( ! function_exists('trim_slashes'))
// ------------------------------------------------------------------------
-/**
- * Strip Slashes
- *
- * Removes slashes contained in a string or in an array
- *
- * @param mixed string or array
- * @return mixed string or array
- */
if ( ! function_exists('strip_slashes'))
{
+ /**
+ * Strip Slashes
+ *
+ * Removes slashes contained in a string or in an array
+ *
+ * @param mixed string or array
+ * @return mixed string or array
+ */
function strip_slashes($str)
{
if ( ! is_array($str))
@@ -89,16 +89,16 @@ if ( ! function_exists('strip_slashes'))
// ------------------------------------------------------------------------
-/**
- * Strip Quotes
- *
- * Removes single and double quotes from a string
- *
- * @param string
- * @return string
- */
if ( ! function_exists('strip_quotes'))
{
+ /**
+ * Strip Quotes
+ *
+ * Removes single and double quotes from a string
+ *
+ * @param string
+ * @return string
+ */
function strip_quotes($str)
{
return str_replace(array('"', "'"), '', $str);
@@ -107,16 +107,16 @@ if ( ! function_exists('strip_quotes'))
// ------------------------------------------------------------------------
-/**
- * Quotes to Entities
- *
- * Converts single and double quotes to entities
- *
- * @param string
- * @return string
- */
if ( ! function_exists('quotes_to_entities'))
{
+ /**
+ * Quotes to Entities
+ *
+ * Converts single and double quotes to entities
+ *
+ * @param string
+ * @return string
+ */
function quotes_to_entities($str)
{
return str_replace(array("\'","\"","'",'"'), array("&#39;","&quot;","&#39;","&quot;"), $str);
@@ -125,23 +125,23 @@ if ( ! function_exists('quotes_to_entities'))
// ------------------------------------------------------------------------
-/**
- * Reduce Double Slashes
- *
- * Converts double slashes in a string to a single slash,
- * except those found in http://
- *
- * http://www.some-site.com//index.php
- *
- * becomes:
- *
- * http://www.some-site.com/index.php
- *
- * @param string
- * @return string
- */
if ( ! function_exists('reduce_double_slashes'))
{
+ /**
+ * Reduce Double Slashes
+ *
+ * Converts double slashes in a string to a single slash,
+ * except those found in http://
+ *
+ * http://www.some-site.com//index.php
+ *
+ * becomes:
+ *
+ * http://www.some-site.com/index.php
+ *
+ * @param string
+ * @return string
+ */
function reduce_double_slashes($str)
{
return preg_replace('#(^|[^:])//+#', '\\1/', $str);
@@ -150,24 +150,24 @@ if ( ! function_exists('reduce_double_slashes'))
// ------------------------------------------------------------------------
-/**
- * Reduce Multiples
- *
- * Reduces multiple instances of a particular character. Example:
- *
- * Fred, Bill,, Joe, Jimmy
- *
- * becomes:
- *
- * Fred, Bill, Joe, Jimmy
- *
- * @param string
- * @param string the character you wish to reduce
- * @param bool TRUE/FALSE - whether to trim the character from the beginning/end
- * @return string
- */
if ( ! function_exists('reduce_multiples'))
{
+ /**
+ * Reduce Multiples
+ *
+ * Reduces multiple instances of a particular character. Example:
+ *
+ * Fred, Bill,, Joe, Jimmy
+ *
+ * becomes:
+ *
+ * Fred, Bill, Joe, Jimmy
+ *
+ * @param string
+ * @param string the character you wish to reduce
+ * @param bool TRUE/FALSE - whether to trim the character from the beginning/end
+ * @return string
+ */
function reduce_multiples($str, $character = ',', $trim = FALSE)
{
$str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
@@ -177,17 +177,17 @@ if ( ! function_exists('reduce_multiples'))
// ------------------------------------------------------------------------
-/**
- * Create a Random String
- *
- * Useful for generating passwords or hashes.
- *
- * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
- * @param int number of characters
- * @return string
- */
if ( ! function_exists('random_string'))
{
+ /**
+ * Create a Random String
+ *
+ * Useful for generating passwords or hashes.
+ *
+ * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
+ * @param int number of characters
+ * @return string
+ */
function random_string($type = 'alnum', $len = 8)
{
switch ($type)
@@ -226,16 +226,16 @@ if ( ! function_exists('random_string'))
// ------------------------------------------------------------------------
-/**
- * Add's _1 to a string or increment the ending number to allow _2, _3, etc
- *
- * @param string required
- * @param string What should the duplicate number be appended with
- * @param string Which number should be used for the first dupe increment
- * @return string
- */
if ( ! function_exists('increment_string'))
{
+ /**
+ * Add's _1 to a string or increment the ending number to allow _2, _3, etc
+ *
+ * @param string required
+ * @param string What should the duplicate number be appended with
+ * @param string Which number should be used for the first dupe increment
+ * @return string
+ */
function increment_string($str, $separator = '_', $first = 1)
{
preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
@@ -245,17 +245,17 @@ if ( ! function_exists('increment_string'))
// ------------------------------------------------------------------------
-/**
- * Alternator
- *
- * Allows strings to be alternated. See docs...
- *
- * @param string (as many parameters as needed)
- * @return string
- */
if ( ! function_exists('alternator'))
{
- function alternator()
+ /**
+ * Alternator
+ *
+ * Allows strings to be alternated. See docs...
+ *
+ * @param string (as many parameters as needed)
+ * @return string
+ */
+ function alternator($args)
{
static $i;
@@ -271,15 +271,15 @@ if ( ! function_exists('alternator'))
// ------------------------------------------------------------------------
-/**
- * Repeater function
- *
- * @param string
- * @param int number of repeats
- * @return string
- */
if ( ! function_exists('repeater'))
{
+ /**
+ * Repeater function
+ *
+ * @param string
+ * @param int number of repeats
+ * @return string
+ */
function repeater($data, $num = 1)
{
return ($num > 0) ? str_repeat($data, $num) : '';
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index c1c0eb947..e4451ae81 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -37,18 +37,18 @@
// ------------------------------------------------------------------------
-/**
- * Word Limiter
- *
- * Limits a string to X number of words.
- *
- * @param string
- * @param int
- * @param string the end character. Usually an ellipsis
- * @return string
- */
if ( ! function_exists('word_limiter'))
{
+ /**
+ * Word Limiter
+ *
+ * Limits a string to X number of words.
+ *
+ * @param string
+ * @param int
+ * @param string the end character. Usually an ellipsis
+ * @return string
+ */
function word_limiter($str, $limit = 100, $end_char = '&#8230;')
{
if (trim($str) == '')
@@ -69,19 +69,19 @@ if ( ! function_exists('word_limiter'))
// ------------------------------------------------------------------------
-/**
- * Character Limiter
- *
- * Limits the string based on the character count. Preserves complete words
- * so the character count may not be exactly as specified.
- *
- * @param string
- * @param int
- * @param string the end character. Usually an ellipsis
- * @return string
- */
if ( ! function_exists('character_limiter'))
{
+ /**
+ * Character Limiter
+ *
+ * Limits the string based on the character count. Preserves complete words
+ * so the character count may not be exactly as specified.
+ *
+ * @param string
+ * @param int
+ * @param string the end character. Usually an ellipsis
+ * @return string
+ */
function character_limiter($str, $n = 500, $end_char = '&#8230;')
{
if (strlen($str) < $n)
@@ -112,16 +112,16 @@ if ( ! function_exists('character_limiter'))
// ------------------------------------------------------------------------
-/**
- * High ASCII to Entities
- *
- * Converts High ascii text and MS Word special characters to character entities
- *
- * @param string
- * @return string
- */
if ( ! function_exists('ascii_to_entities'))
{
+ /**
+ * High ASCII to Entities
+ *
+ * Converts High ascii text and MS Word special characters to character entities
+ *
+ * @param string
+ * @return string
+ */
function ascii_to_entities($str)
{
$count = 1;
@@ -174,17 +174,17 @@ if ( ! function_exists('ascii_to_entities'))
// ------------------------------------------------------------------------
-/**
- * Entities to ASCII
- *
- * Converts character entities back to ASCII
- *
- * @param string
- * @param bool
- * @return string
- */
if ( ! function_exists('entities_to_ascii'))
{
+ /**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @param string
+ * @param bool
+ * @return string
+ */
function entities_to_ascii($str, $all = TRUE)
{
if (preg_match_all('/\&#(\d+)\;/', $str, $matches))
@@ -227,20 +227,20 @@ if ( ! function_exists('entities_to_ascii'))
// ------------------------------------------------------------------------
-/**
- * Word Censoring Function
- *
- * Supply a string and an array of disallowed words and any
- * matched words will be converted to #### or to the replacement
- * word you've submitted.
- *
- * @param string the text string
- * @param string the array of censoered words
- * @param string the optional replacement value
- * @return string
- */
if ( ! function_exists('word_censor'))
{
+ /**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @param string the text string
+ * @param string the array of censoered words
+ * @param string the optional replacement value
+ * @return string
+ */
function word_censor($str, $censored, $replacement = '')
{
if ( ! is_array($censored))
@@ -274,16 +274,16 @@ if ( ! function_exists('word_censor'))
// ------------------------------------------------------------------------
-/**
- * Code Highlighter
- *
- * Colorizes code strings
- *
- * @param string the text string
- * @return string
- */
if ( ! function_exists('highlight_code'))
{
+ /**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @param string the text string
+ * @return string
+ */
function highlight_code($str)
{
/* The highlight string function encodes and highlights
@@ -323,19 +323,19 @@ if ( ! function_exists('highlight_code'))
// ------------------------------------------------------------------------
-/**
- * Phrase Highlighter
- *
- * Highlights a phrase within a text string
- *
- * @param string the text string
- * @param string the phrase you'd like to highlight
- * @param string the openging tag to precede the phrase with
- * @param string the closing tag to end the phrase with
- * @return string
- */
if ( ! function_exists('highlight_phrase'))
{
+ /**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @param string the text string
+ * @param string the phrase you'd like to highlight
+ * @param string the openging tag to precede the phrase with
+ * @param string the closing tag to end the phrase with
+ * @return string
+ */
function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
{
if ($str == '')
@@ -354,14 +354,14 @@ if ( ! function_exists('highlight_phrase'))
// ------------------------------------------------------------------------
-/**
- * Convert Accented Foreign Characters to ASCII
- *
- * @param string the text string
- * @return string
- */
if ( ! function_exists('convert_accented_characters'))
{
+ /**
+ * Convert Accented Foreign Characters to ASCII
+ *
+ * @param string the text string
+ * @return string
+ */
function convert_accented_characters($str)
{
global $foreign_characters;
@@ -490,19 +490,19 @@ if ( ! function_exists('word_wrap'))
// ------------------------------------------------------------------------
-/**
- * Ellipsize String
- *
- * This function will strip tags from a string, split it at its max_length and ellipsize
- *
- * @param string string to ellipsize
- * @param int max length of string
- * @param mixed int (1|0) or float, .5, .2, etc for position to split
- * @param string ellipsis ; Default '...'
- * @return string ellipsized string
- */
if ( ! function_exists('ellipsize'))
{
+ /**
+ * Ellipsize String
+ *
+ * This function will strip tags from a string, split it at its max_length and ellipsize
+ *
+ * @param string string to ellipsize
+ * @param int max length of string
+ * @param mixed int (1|0) or float, .5, .2, etc for position to split
+ * @param string ellipsis ; Default '...'
+ * @return string ellipsized string
+ */
function ellipsize($str, $max_length, $position = 1, $ellipsis = '&hellip;')
{
// Strip tags
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 7a3db5d6b..af9d16a89 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -37,14 +37,14 @@
// ------------------------------------------------------------------------
-/**
- * Convert newlines to HTML line breaks except within PRE tags
- *
- * @param string
- * @return string
- */
if ( ! function_exists('nl2br_except_pre'))
{
+ /**
+ * Convert newlines to HTML line breaks except within PRE tags
+ *
+ * @param string
+ * @return string
+ */
function nl2br_except_pre($str)
{
$CI =& get_instance();
@@ -55,16 +55,16 @@ if ( ! function_exists('nl2br_except_pre'))
// ------------------------------------------------------------------------
-/**
- * Auto Typography Wrapper Function
- *
- * @param string
- * @param bool whether to allow javascript event handlers
- * @param bool whether to reduce multiple instances of double newlines to two
- * @return string
- */
if ( ! function_exists('auto_typography'))
{
+ /**
+ * Auto Typography Wrapper Function
+ *
+ * @param string
+ * @param bool whether to allow javascript event handlers
+ * @param bool whether to reduce multiple instances of double newlines to two
+ * @return string
+ */
function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE)
{
$CI =& get_instance();
@@ -73,20 +73,19 @@ if ( ! function_exists('auto_typography'))
}
}
-
// --------------------------------------------------------------------
-/**
- * HTML Entities Decode
- *
- * This function is a replacement for html_entity_decode()
- *
- * @param string
- * @param string
- * @return string
- */
if ( ! function_exists('entity_decode'))
{
+ /**
+ * HTML Entities Decode
+ *
+ * This function is a replacement for html_entity_decode()
+ *
+ * @param string
+ * @param string
+ * @return string
+ */
function entity_decode($str, $charset = NULL)
{
global $SEC;
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index cf6df4ef5..0e933c18e 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -37,17 +37,17 @@
// ------------------------------------------------------------------------
-/**
- * Site URL
- *
- * Create a local URL based on your basepath. Segments can be passed via the
- * first parameter either as a string or an array.
- *
- * @param string
- * @return string
- */
if ( ! function_exists('site_url'))
{
+ /**
+ * Site URL
+ *
+ * Create a local URL based on your basepath. Segments can be passed via the
+ * first parameter either as a string or an array.
+ *
+ * @param string
+ * @return string
+ */
function site_url($uri = '')
{
$CI =& get_instance();
@@ -57,18 +57,18 @@ if ( ! function_exists('site_url'))
// ------------------------------------------------------------------------
-/**
- * Base URL
- *
- * Create a local URL based on your basepath.
- * Segments can be passed in as a string or an array, same as site_url
- * or a URL to a file can be passed in, e.g. to an image file.
- *
- * @param string
- * @return string
- */
if ( ! function_exists('base_url'))
{
+ /**
+ * Base URL
+ *
+ * Create a local URL based on your basepath.
+ * Segments can be passed in as a string or an array, same as site_url
+ * or a URL to a file can be passed in, e.g. to an image file.
+ *
+ * @param string
+ * @return string
+ */
function base_url($uri = '')
{
$CI =& get_instance();
@@ -78,16 +78,16 @@ if ( ! function_exists('base_url'))
// ------------------------------------------------------------------------
-/**
- * Current URL
- *
- * Returns the full URL (including segments) of the page where this
- * function is placed
- *
- * @return string
- */
if ( ! function_exists('current_url'))
{
+ /**
+ * Current URL
+ *
+ * Returns the full URL (including segments) of the page where this
+ * function is placed
+ *
+ * @return string
+ */
function current_url()
{
$CI =& get_instance();
@@ -96,15 +96,16 @@ if ( ! function_exists('current_url'))
}
// ------------------------------------------------------------------------
-/**
- * URL String
- *
- * Returns the URI segments.
- *
- * @return string
- */
+
if ( ! function_exists('uri_string'))
{
+ /**
+ * URL String
+ *
+ * Returns the URI segments.
+ *
+ * @return string
+ */
function uri_string()
{
$CI =& get_instance();
@@ -114,15 +115,15 @@ if ( ! function_exists('uri_string'))
// ------------------------------------------------------------------------
-/**
- * Index page
- *
- * Returns the "index_page" from your config file
- *
- * @return string
- */
if ( ! function_exists('index_page'))
{
+ /**
+ * Index page
+ *
+ * Returns the "index_page" from your config file
+ *
+ * @return string
+ */
function index_page()
{
$CI =& get_instance();
@@ -132,18 +133,18 @@ if ( ! function_exists('index_page'))
// ------------------------------------------------------------------------
-/**
- * Anchor Link
- *
- * Creates an anchor based on the local URL.
- *
- * @param string the URL
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('anchor'))
{
+ /**
+ * Anchor Link
+ *
+ * Creates an anchor based on the local URL.
+ *
+ * @param string the URL
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function anchor($uri = '', $title = '', $attributes = '')
{
$title = (string) $title;
@@ -173,19 +174,19 @@ if ( ! function_exists('anchor'))
// ------------------------------------------------------------------------
-/**
- * Anchor Link - Pop-up version
- *
- * Creates an anchor based on the local URL. The link
- * opens a new window based on the attributes specified.
- *
- * @param string the URL
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('anchor_popup'))
{
+ /**
+ * Anchor Link - Pop-up version
+ *
+ * Creates an anchor based on the local URL. The link
+ * opens a new window based on the attributes specified.
+ *
+ * @param string the URL
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
$title = (string) $title;
@@ -223,16 +224,16 @@ if ( ! function_exists('anchor_popup'))
// ------------------------------------------------------------------------
-/**
- * Mailto Link
- *
- * @param string the email address
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('mailto'))
{
+ /**
+ * Mailto Link
+ *
+ * @param string the email address
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function mailto($email, $title = '', $attributes = '')
{
$title = (string) $title;
@@ -248,18 +249,18 @@ if ( ! function_exists('mailto'))
// ------------------------------------------------------------------------
-/**
- * Encoded Mailto Link
- *
- * Create a spam-protected mailto link written in Javascript
- *
- * @param string the email address
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('safe_mailto'))
{
+ /**
+ * Encoded Mailto Link
+ *
+ * Create a spam-protected mailto link written in Javascript
+ *
+ * @param string the email address
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function safe_mailto($email, $title = '', $attributes = '')
{
$title = (string) $title;
@@ -357,21 +358,21 @@ if ( ! function_exists('safe_mailto'))
// ------------------------------------------------------------------------
-/**
- * Auto-linker
- *
- * Automatically links URL and Email addresses.
- * Note: There's a bit of extra code here to deal with
- * URLs or emails that end in a period. We'll strip these
- * off and add them after the link.
- *
- * @param string the string
- * @param string the type: email, url, or both
- * @param bool whether to create pop-up links
- * @return string
- */
if ( ! function_exists('auto_link'))
{
+ /**
+ * Auto-linker
+ *
+ * Automatically links URL and Email addresses.
+ * Note: There's a bit of extra code here to deal with
+ * URLs or emails that end in a period. We'll strip these
+ * off and add them after the link.
+ *
+ * @param string the string
+ * @param string the type: email, url, or both
+ * @param bool whether to create pop-up links
+ * @return string
+ */
function auto_link($str, $type = 'both', $popup = FALSE)
{
if ($type !== 'email' && preg_match_all('#(^|\s|\(|\b)((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i', $str, $matches))
@@ -423,16 +424,16 @@ if ( ! function_exists('auto_link'))
// ------------------------------------------------------------------------
-/**
- * Prep URL
- *
- * Simply adds the http:// part if no scheme is included
- *
- * @param string the URL
- * @return string
- */
if ( ! function_exists('prep_url'))
{
+ /**
+ * Prep URL
+ *
+ * Simply adds the http:// part if no scheme is included
+ *
+ * @param string the URL
+ * @return string
+ */
function prep_url($str = '')
{
if ($str === 'http://' OR $str == '')
@@ -453,20 +454,20 @@ if ( ! function_exists('prep_url'))
// ------------------------------------------------------------------------
-/**
- * Create URL Title
- *
- * Takes a "title" string as input and creates a
- * human-friendly URL string with a "separator" string
- * as the word separator.
- *
- * @param string the string
- * @param string the separator
- * @param bool
- * @return string
- */
if ( ! function_exists('url_title'))
{
+ /**
+ * Create URL Title
+ *
+ * Takes a "title" string as input and creates a
+ * human-friendly URL string with a "separator" string
+ * as the word separator.
+ *
+ * @param string the string
+ * @param string the separator
+ * @param bool
+ * @return string
+ */
function url_title($str, $separator = '-', $lowercase = FALSE)
{
if ($separator === 'dash')
@@ -504,19 +505,20 @@ if ( ! function_exists('url_title'))
// ------------------------------------------------------------------------
-/**
- * Header Redirect
- *
- * Header redirect in two flavors
- * For very fine grained control over headers, you could use the Output
- * Library's set_header() function.
- *
- * @param string the URL
- * @param string the method: location or refresh
- * @return string
- */
if ( ! function_exists('redirect'))
{
+ /**
+ * Header Redirect
+ *
+ * Header redirect in two flavors
+ * For very fine grained control over headers, you could use the Output
+ * Library's set_header() function.
+ *
+ * @param string the URL
+ * @param string the method: location or refresh
+ * @param int
+ * @return string
+ */
function redirect($uri = '', $method = 'auto', $http_response_code = 302)
{
if ( ! preg_match('#^https?://#i', $uri))
@@ -545,17 +547,17 @@ if ( ! function_exists('redirect'))
// ------------------------------------------------------------------------
-/**
- * Parse out the attributes
- *
- * Some of the functions use this
- *
- * @param array
- * @param bool
- * @return string
- */
if ( ! function_exists('_parse_attributes'))
{
+ /**
+ * Parse out the attributes
+ *
+ * Some of the functions use this
+ *
+ * @param array
+ * @param bool
+ * @return string
+ */
function _parse_attributes($attributes, $javascript = FALSE)
{
if (is_string($attributes))
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 67fd34b97..958c633dd 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -37,15 +37,15 @@
// ------------------------------------------------------------------------
-/**
- * Convert Reserved XML characters to Entities
- *
- * @param string
- * @param bool
- * @return string
- */
if ( ! function_exists('xml_convert'))
{
+ /**
+ * Convert Reserved XML characters to Entities
+ *
+ * @param string
+ * @param bool
+ * @return string
+ */
function xml_convert($str, $protect_all = FALSE)
{
$temp = '__TEMP_AMPERSANDS__';
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index d33a6a635..7fc5ee5a0 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -52,6 +52,7 @@ Release Date: Not Released
- set_realpath() can now also handle file paths as opposed to just directories.
- do_hash() now uses PHP's native hash() function, supporting more algorithms.
- Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html.
+ - Removed deprecated helper function ``js_insert_smiley()`` from smiley helper.
- Database