From 4921fed6c17a54efd4fac0bed4d058463bd9b601 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 7 Jan 2012 01:28:07 +0200 Subject: Improve the smiley, string & text helpers --- system/helpers/smiley_helper.php | 97 ++++++++++++---------------- system/helpers/string_helper.php | 81 +++++++++--------------- system/helpers/text_helper.php | 133 +++++++++++++++++++-------------------- 3 files changed, 134 insertions(+), 177 deletions(-) (limited to 'system') diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 700f4486c..bc265e552 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -1,13 +1,13 @@ - $id) { - foreach ($alias as $name => $id) - { - $m[] = '"'.$name.'" : "'.$id.'"'; - } + $m[] = '"'.$name.'" : "'.$id.'"'; } + } - $m = '{'.implode(',', $m).'}'; + $m = '{'.implode(',', $m).'}'; - $r .= <</*'; - } - else - { - return $r; - } + return ($inline) ? '' : $r; } } @@ -154,12 +145,9 @@ if ( ! function_exists('get_clickable_smileys')) $smileys = $alias; } - if ( ! is_array($smileys)) + if ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())) { - if (FALSE === ($smileys = _get_smiley_array())) - { - return $smileys; - } + return $smileys; } // Add a trailing slash to the file path if needed @@ -178,7 +166,6 @@ if ( ! function_exists('get_clickable_smileys')) } $link[] = "\"".$smileys[$key][3]."\""; - $used[$smileys[$key][0]] = TRUE; } @@ -207,16 +194,13 @@ if ( ! function_exists('parse_smileys')) return $str; } - if ( ! is_array($smileys)) + if ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())) { - if (FALSE === ($smileys = _get_smiley_array())) - { - return $str; - } + return $str; } // Add a trailing slash to the file path if needed - $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url); + $image_url = rtrim($image_url, '/').'/'; foreach ($smileys as $key => $val) { @@ -249,7 +233,7 @@ if ( ! function_exists('_get_smiley_array')) { include(APPPATH.'config/smileys.php'); } - + if (isset($smileys) AND is_array($smileys)) { return $smileys; @@ -288,6 +272,5 @@ EOF; } } - /* End of file smiley_helper.php */ -/* Location: ./system/helpers/smiley_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/smiley_helper.php */ diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index 04d51c2f9..654f721b0 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -1,13 +1,13 @@ -load->helper('security'); - - return do_hash(uniqid(mt_rand(), TRUE), 'sha1'); - break; + case 'basic': return mt_rand(); + case 'alnum': + case 'numeric': + case 'nozero': + case 'alpha': + switch ($type) + { + case 'alpha': $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + break; + case 'alnum': $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + break; + case 'numeric': $pool = '0123456789'; + break; + case 'nozero': $pool = '123456789'; + break; + } + return substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len); + case 'unique': + case 'md5': return md5(uniqid(mt_rand())); + case 'encrypt': + case 'sha1': + $CI =& get_instance(); + $CI->load->helper('security'); + return do_hash(uniqid(mt_rand(), TRUE), 'sha1'); } } } @@ -262,7 +245,6 @@ if ( ! function_exists('random_string')) function increment_string($str, $separator = '_', $first = 1) { preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match); - return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first; } @@ -311,6 +293,5 @@ if ( ! function_exists('repeater')) } } - /* End of file string_helper.php */ -/* Location: ./system/helpers/string_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/string_helper.php */ diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 842a31d75..562270f96 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -1,13 +1,13 @@ -","\"", "'", "-"), - $str); + return str_replace(array('&', '<', '>', '"', ''', '-'), + array('&', '<', '>', '"', "'", '-'), + $str); } return $str; @@ -294,42 +294,38 @@ if ( ! function_exists('highlight_code')) { function highlight_code($str) { - // The highlight string function encodes and highlights - // brackets so we need them to start raw - $str = str_replace(array('<', '>'), array('<', '>'), $str); - - // Replace any existing PHP tags to temporary markers so they don't accidentally - // break the string out of PHP, and thus, thwart the highlighting. - - $str = str_replace(array('', '<%', '%>', '\\', ''), - array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str); + /* The highlight string function encodes and highlights + * brackets so we need them to start raw. + * + * Also replace any existing PHP tags to temporary markers + * so they don't accidentally break the string out of PHP, + * and thus, thwart the highlighting. + */ + $str = str_replace(array('<', '>', '', '<%', '%>', '\\', ''), + array('<', '>', 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), + $str); // The highlight_string function requires that the text be surrounded // by PHP tags, which we will remove later - $str = ''; // tags - // so we'll replace them with tags. - - if (abs(PHP_VERSION) < 5) - { - $str = str_replace(array(''), array(''), $str); - $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str); - } + $str = highlight_string('', TRUE); // Remove our artificially added PHP, and the syntax highlighting that came with it - $str = preg_replace('/<\?php( | )/i', '', $str); - $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1\n\n", $str); - $str = preg_replace('/<\/span>/i', '', $str); + $str = preg_replace(array( + '/<\?php( | )/i', + '/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', + '/<\/span>/i' + ), + array( + '', + "$1\n\n", + '' + ), + $str); // Replace our markers back to PHP tags. - $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), - array('<?', '?>', '<%', '%>', '\\', '</script>'), $str); - - return $str; + return str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), + array('<?', '?>', '<%', '%>', '\\', '</script>'), + $str); } } @@ -414,12 +410,14 @@ if ( ! function_exists('word_wrap')) { function word_wrap($str, $charlim = '76') { - // Se the character limit + // Set the character limit if ( ! is_numeric($charlim)) + { $charlim = 76; + } // Reduce multiple spaces - $str = preg_replace("| +|", " ", $str); + $str = preg_replace('| +|', ' ', $str); // Standardize newlines if (strpos($str, "\r") !== FALSE) @@ -430,22 +428,22 @@ if ( ! function_exists('word_wrap')) // If the current word is surrounded by {unwrap} tags we'll // strip the entire chunk and replace it with a marker. $unwrap = array(); - if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches)) + if (preg_match_all('|(\{unwrap\}.+?\{/unwrap\})|s', $str, $matches)) { - for ($i = 0; $i < count($matches['0']); $i++) + for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { - $unwrap[] = $matches['1'][$i]; - $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str); + $unwrap[] = $matches[1][$i]; + $str = str_replace($matches[1][$i], '{{unwrapped'.$i.'}}', $str); } } // Use PHP's native function to do the initial wordwrap. // We set the cut flag to FALSE so that any individual words that are - // too long get left alone. In the next step we'll deal with them. + // too long get left alone. In the next step we'll deal with them. $str = wordwrap($str, $charlim, "\n", FALSE); // Split the string into individual lines of text and cycle through them - $output = ""; + $output = ''; foreach (explode("\n", $str) as $line) { // Is the line within the allowed character count? @@ -460,7 +458,7 @@ if ( ! function_exists('word_wrap')) while ((strlen($line)) > $charlim) { // If the over-length word is a URL we won't wrap it - if (preg_match("!\[url.+\]|://|wwww.!", $line)) + if (preg_match('!\[url.+\]|://|wwww.!', $line)) { break; } @@ -474,14 +472,12 @@ if ( ! function_exists('word_wrap')) // word into smaller chunks so we'll add it back to our current line if ($temp != '') { - $output .= $temp."\n".$line; + $output .= $temp."\n".$line."\n"; } else { - $output .= $line; + $output .= $line."\n"; } - - $output .= "\n"; } // Put our markers back @@ -489,14 +485,12 @@ if ( ! function_exists('word_wrap')) { foreach ($unwrap as $key => $val) { - $output = str_replace("{{unwrapped".$key."}}", $val, $output); + $output = str_replace('{{unwrapped'.$key.'}}', $val, $output); } } - // Remove the unwrap tags - $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output); - - return $output; + // Remove the unwrap tags and return + return str_replace(array('{unwrap}', '{/unwrap}'), '', $output); } } @@ -527,7 +521,6 @@ if ( ! function_exists('ellipsize')) } $beg = substr($str, 0, floor($max_length * $position)); - $position = ($position > 1) ? 1 : $position; if ($position === 1) @@ -544,4 +537,4 @@ if ( ! function_exists('ellipsize')) } /* End of file text_helper.php */ -/* Location: ./system/helpers/text_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/text_helper.php */ -- cgit v1.2.3-24-g4f1b From fc443553248af8ac0c1cbb635fe9cbb70fdf7b82 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 7 Jan 2012 02:14:55 +0200 Subject: Remove quotes around an integer value --- system/helpers/text_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 562270f96..3a847f29b 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -408,7 +408,7 @@ if ( ! function_exists('convert_accented_characters')) */ if ( ! function_exists('word_wrap')) { - function word_wrap($str, $charlim = '76') + function word_wrap($str, $charlim = 76) { // Set the character limit if ( ! is_numeric($charlim)) -- cgit v1.2.3-24-g4f1b From cb324bd9268fc6b0c93fd22545bd989771d68b04 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 8 Jan 2012 07:06:35 +0200 Subject: Some more misc. stuff --- system/helpers/smiley_helper.php | 2 -- system/helpers/string_helper.php | 17 +++++++++-------- system/helpers/text_helper.php | 8 +++----- 3 files changed, 12 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index bc265e552..03f3ee287 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Smiley Helpers * diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index 654f721b0..fcdb0aa84 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter String Helpers * @@ -153,7 +151,7 @@ if ( ! function_exists('reduce_double_slashes')) { function reduce_double_slashes($str) { - return preg_replace("#(^|[^:])//+#", "\\1/", $str); + return preg_replace('#(^|[^:])//+#', '\\1/', $str); } } @@ -181,7 +179,6 @@ if ( ! function_exists('reduce_multiples')) function reduce_multiples($str, $character = ',', $trim = FALSE) { $str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str); - return ($trim === TRUE) ? trim($str, $character) : $str; } } @@ -211,13 +208,17 @@ if ( ! function_exists('random_string')) case 'alpha': switch ($type) { - case 'alpha': $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + case 'alpha': + $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; break; - case 'alnum': $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + case 'alnum': + $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; break; - case 'numeric': $pool = '0123456789'; + case 'numeric': + $pool = '0123456789'; break; - case 'nozero': $pool = '123456789'; + case 'nozero': + $pool = '123456789'; break; } return substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len); diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 3a847f29b..cef32847d 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Text Helpers * @@ -93,7 +91,7 @@ if ( ! function_exists('character_limiter')) return $str; } - $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); + $str = preg_replace('/\s+/', ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str)); if (strlen($str) <= $n) { @@ -108,7 +106,7 @@ if ( ! function_exists('character_limiter')) if (strlen($out) >= $n) { $out = trim($out); - return (strlen($out) == strlen($str)) ? $out : $out.$end_char; + return (strlen($out) === strlen($str)) ? $out : $out.$end_char; } } } @@ -354,7 +352,7 @@ if ( ! function_exists('highlight_phrase')) if ($phrase != '') { - return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str); + return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open.'\\1'.$tag_close, $str); } return $str; -- cgit v1.2.3-24-g4f1b From 0f2ec5bde259b67f66cc353692d71d8a47f71b01 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 16 Jan 2012 14:02:24 +0200 Subject: convert_accented_characters() to include foreign_chars.php only when needed --- system/helpers/text_helper.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'system') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index cef32847d..8e308b722 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -372,18 +372,23 @@ if ( ! function_exists('convert_accented_characters')) { function convert_accented_characters($str) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); - } - elseif (is_file(APPPATH.'config/foreign_chars.php')) - { - include(APPPATH.'config/foreign_chars.php'); - } + global $foreign_characters; - if ( ! isset($foreign_characters)) + if ( ! isset($foreign_characters) OR ! is_array($foreign_characters)) { - return $str; + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); + } + elseif (is_file(APPPATH.'config/foreign_chars.php')) + { + include(APPPATH.'config/foreign_chars.php'); + } + + if ( ! isset($foreign_characters) OR ! is_array($foreign_chars)) + { + return $str; + } } return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str); -- cgit v1.2.3-24-g4f1b From 09375d71aa933ac6ba3665f7ccc6949840177ade Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Jan 2012 14:57:46 +0200 Subject: Some more cleaning --- system/helpers/smiley_helper.php | 39 ++++++++++++--------------------------- system/helpers/string_helper.php | 32 +++++++++++++++----------------- system/helpers/text_helper.php | 8 ++++---- 3 files changed, 31 insertions(+), 48 deletions(-) (limited to 'system') diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 03f3ee287..d2b8936ae 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it @@ -40,7 +40,7 @@ /** * Smiley Javascript * - * Returns the javascript required for the smiley insertion. Optionally takes + * Returns the javascript required for the smiley insertion. Optionally takes * an array of aliases to loosely couple the smiley array to the view. * * @access public @@ -105,14 +105,11 @@ if ( ! function_exists('smiley_js')) } EOF; } - else + elseif (is_array($alias)) { - if (is_array($alias)) + foreach ($alias as $name => $id) { - foreach ($alias as $name => $id) - { - $r .= 'smiley_map["'.$name.'"] = "'.$id.'";'."\n"; - } + $r .= 'smiley_map["'.$name.'"] = "'.$id."\";\n"; } } @@ -137,13 +134,11 @@ if ( ! function_exists('get_clickable_smileys')) function get_clickable_smileys($image_url, $alias = '', $smileys = NULL) { // For backward compatibility with js_insert_smiley - if (is_array($alias)) { $smileys = $alias; } - - if ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())) + elseif (FALSE === ($smileys = _get_smiley_array())) { return $smileys; } @@ -155,7 +150,7 @@ if ( ! function_exists('get_clickable_smileys')) foreach ($smileys as $key => $val) { // Keep duplicates from being used, which can happen if the - // mapping array contains multiple identical replacements. For example: + // mapping array contains multiple identical replacements. For example: // :-) and :) might be replaced with the same image so both smileys // will be in the array. if (isset($used[$smileys[$key][0]])) @@ -163,7 +158,7 @@ if ( ! function_exists('get_clickable_smileys')) continue; } - $link[] = "\"".$smileys[$key][3]."\""; + $link[] = ''.$smileys[$key][3].''; $used[$smileys[$key][0]] = TRUE; } @@ -187,12 +182,7 @@ if ( ! function_exists('parse_smileys')) { function parse_smileys($str = '', $image_url = '', $smileys = NULL) { - if ($image_url == '') - { - return $str; - } - - if ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())) + if ($image_url == '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array()))) { return $str; } @@ -202,7 +192,7 @@ if ( ! function_exists('parse_smileys')) foreach ($smileys as $key => $val) { - $str = str_replace($key, "\"".$smileys[$key][3]."\"", $str); + $str = str_replace($key, ''.$smileys[$key][3].'', $str); } return $str; @@ -223,7 +213,7 @@ if ( ! function_exists('_get_smiley_array')) { function _get_smiley_array() { - if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) + if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); } @@ -232,12 +222,7 @@ if ( ! function_exists('_get_smiley_array')) include(APPPATH.'config/smileys.php'); } - if (isset($smileys) AND is_array($smileys)) - { - return $smileys; - } - - return FALSE; + return (isset($smileys) && is_array($smileys)) ? $smileys : FALSE; } } diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index fcdb0aa84..d0948800b 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it @@ -75,16 +75,14 @@ if ( ! function_exists('strip_slashes')) { function strip_slashes($str) { - if (is_array($str)) + if ( ! is_array($str)) { - foreach ($str as $key => $val) - { - $str[$key] = strip_slashes($val); - } + return stripslashes($str); } - else + + foreach ($str as $key => $val) { - return stripslashes($str); + $str[$key] = strip_slashes($val); } return $str; @@ -192,7 +190,7 @@ if ( ! function_exists('reduce_multiples')) * * @access public * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1 - * @param integer number of characters + * @param int number of characters * @return string */ if ( ! function_exists('random_string')) @@ -238,10 +236,10 @@ if ( ! function_exists('random_string')) /** * Add's _1 to a string or increment the ending number to allow _2, _3, etc * - * @param string $str required - * @param string $separator What should the duplicate number be appended with - * @param string $first Which number should be used for the first dupe increment - * @return string + * @param string $str required + * @param string $separator What should the duplicate number be appended with + * @param string $first Which number should be used for the first dupe increment + * @return string */ function increment_string($str, $separator = '_', $first = 1) { @@ -254,10 +252,10 @@ function increment_string($str, $separator = '_', $first = 1) /** * Alternator * - * Allows strings to be alternated. See docs... + * Allows strings to be alternated. See docs... * * @access public - * @param string (as many parameters as needed) + * @param string (as many parameters as needed) * @return string */ if ( ! function_exists('alternator')) @@ -283,14 +281,14 @@ if ( ! function_exists('alternator')) * * @access public * @param string - * @param integer number of repeats + * @param int number of repeats * @return string */ if ( ! function_exists('repeater')) { function repeater($data, $num = 1) { - return (($num > 0) ? str_repeat($data, $num) : ''); + return ($num > 0) ? str_repeat($data, $num) : ''; } } diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 8e308b722..2d6da73ac 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it @@ -73,7 +73,7 @@ if ( ! function_exists('word_limiter')) /** * Character Limiter * - * Limits the string based on the character count. Preserves complete words + * Limits the string based on the character count. Preserves complete words * so the character count may not be exactly as specified. * * @access public @@ -376,7 +376,7 @@ if ( ! function_exists('convert_accented_characters')) if ( ! isset($foreign_characters) OR ! is_array($foreign_characters)) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) + if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); } @@ -400,7 +400,7 @@ if ( ! function_exists('convert_accented_characters')) /** * Word Wrap * - * Wraps text at the specified character. Maintains the integrity of words. + * Wraps text at the specified character. Maintains the integrity of words. * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor * will URLs. * -- cgit v1.2.3-24-g4f1b From c5a1f93ef25c99df4035ef7182a6200b91afabab Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:29:02 +0200 Subject: Revert a space in the license agreement :) --- system/helpers/smiley_helper.php | 2 +- system/helpers/string_helper.php | 2 +- system/helpers/text_helper.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index d2b8936ae..cb902114e 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index d0948800b..0d1018f53 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 2d6da73ac..37b5d3178 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it -- cgit v1.2.3-24-g4f1b From 75124a53cf54f2a8c094756f9189be9159957f28 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 13 Mar 2012 12:47:58 +0200 Subject: Some comments altered --- system/helpers/smiley_helper.php | 5 ----- system/helpers/string_helper.php | 20 +++++++------------- system/helpers/text_helper.php | 29 ++++++++++------------------- 3 files changed, 17 insertions(+), 37 deletions(-) (limited to 'system') diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 83fb863df..bc592f74f 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -43,7 +43,6 @@ * Returns the javascript required for the smiley insertion. Optionally takes * an array of aliases to loosely couple the smiley array to the view. * - * @access public * @param mixed alias name or array of alias->field_id pairs * @param string field_id if alias name was passed in * @return array @@ -125,7 +124,6 @@ EOF; * Returns an array of image tag links that can be clicked to be inserted * into a form field. * - * @access public * @param string the URL to the folder containing the smiley images * @return array */ @@ -173,7 +171,6 @@ if ( ! function_exists('get_clickable_smileys')) * * Takes a string as input and swaps any contained smileys for the actual image * - * @access public * @param string the text to be parsed * @param string the URL to the folder containing the smiley images * @return string @@ -206,7 +203,6 @@ if ( ! function_exists('parse_smileys')) * * Fetches the config/smiley.php file * - * @access private * @return mixed */ if ( ! function_exists('_get_smiley_array')) @@ -235,7 +231,6 @@ if ( ! function_exists('_get_smiley_array')) * * DEPRECATED as of version 1.7.2, use smiley_js instead * - * @access public * @param string form name * @param string field name * @return string diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index 6573b9a5d..a53d1b88e 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -48,7 +48,6 @@ * * this/that/theother * - * @access public * @param string * @return string */ @@ -67,7 +66,6 @@ if ( ! function_exists('trim_slashes')) * * Removes slashes contained in a string or in an array * - * @access public * @param mixed string or array * @return mixed string or array */ @@ -96,7 +94,6 @@ if ( ! function_exists('strip_slashes')) * * Removes single and double quotes from a string * - * @access public * @param string * @return string */ @@ -115,7 +112,6 @@ if ( ! function_exists('strip_quotes')) * * Converts single and double quotes to entities * - * @access public * @param string * @return string */ @@ -141,7 +137,6 @@ if ( ! function_exists('quotes_to_entities')) * * http://www.some-site.com/index.php * - * @access public * @param string * @return string */ @@ -166,7 +161,6 @@ if ( ! function_exists('reduce_double_slashes')) * * Fred, Bill, Joe, Jimmy * - * @access public * @param string * @param string the character you wish to reduce * @param bool TRUE/FALSE - whether to trim the character from the beginning/end @@ -188,7 +182,6 @@ if ( ! function_exists('reduce_multiples')) * * Useful for generating passwords or hashes. * - * @access public * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1 * @param int number of characters * @return string @@ -219,7 +212,7 @@ if ( ! function_exists('random_string')) $pool = '123456789'; break; } - return substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len); + return substr(str_shuffle(str_repeat($pool, ceil($len / strlen($pool)))), 0, $len); case 'unique': case 'md5': return md5(uniqid(mt_rand())); case 'encrypt': @@ -241,10 +234,13 @@ if ( ! function_exists('random_string')) * @param string $first Which number should be used for the first dupe increment * @return string */ -function increment_string($str, $separator = '_', $first = 1) +if ( ! function_exists('increment_string')) { - preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match); - return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first; + function increment_string($str, $separator = '_', $first = 1) + { + preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match); + return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first; + } } // ------------------------------------------------------------------------ @@ -254,7 +250,6 @@ function increment_string($str, $separator = '_', $first = 1) * * Allows strings to be alternated. See docs... * - * @access public * @param string (as many parameters as needed) * @return string */ @@ -279,7 +274,6 @@ if ( ! function_exists('alternator')) /** * Repeater function * - * @access public * @param string * @param int number of repeats * @return string diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index bddb112b2..9a56159d9 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -42,9 +42,8 @@ * * Limits a string to X number of words. * - * @access public * @param string - * @param integer + * @param int * @param string the end character. Usually an ellipsis * @return string */ @@ -76,9 +75,8 @@ if ( ! function_exists('word_limiter')) * Limits the string based on the character count. Preserves complete words * so the character count may not be exactly as specified. * - * @access public * @param string - * @param integer + * @param int * @param string the end character. Usually an ellipsis * @return string */ @@ -119,7 +117,6 @@ if ( ! function_exists('character_limiter')) * * Converts High ascii text and MS Word special characters to character entities * - * @access public * @param string * @return string */ @@ -182,7 +179,6 @@ if ( ! function_exists('ascii_to_entities')) * * Converts character entities back to ASCII * - * @access public * @param string * @param bool * @return string @@ -238,7 +234,6 @@ if ( ! function_exists('entities_to_ascii')) * matched words will be converted to #### or to the replacement * word you've submitted. * - * @access public * @param string the text string * @param string the array of censoered words * @param string the optional replacement value @@ -284,7 +279,6 @@ if ( ! function_exists('word_censor')) * * Colorizes code strings * - * @access public * @param string the text string * @return string */ @@ -334,7 +328,6 @@ if ( ! function_exists('highlight_code')) * * Highlights a phrase within a text string * - * @access public * @param string the text string * @param string the phrase you'd like to highlight * @param string the openging tag to precede the phrase with @@ -364,7 +357,6 @@ if ( ! function_exists('highlight_phrase')) /** * Convert Accented Foreign Characters to ASCII * - * @access public * @param string the text string * @return string */ @@ -404,9 +396,8 @@ if ( ! function_exists('convert_accented_characters')) * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor * will URLs. * - * @access public * @param string the text string - * @param integer the number of characters to wrap at + * @param int the number of characters to wrap at * @return string */ if ( ! function_exists('word_wrap')) @@ -467,8 +458,8 @@ if ( ! function_exists('word_wrap')) } // Trim the word down - $temp .= substr($line, 0, $charlim-1); - $line = substr($line, $charlim-1); + $temp .= substr($line, 0, $charlim - 1); + $line = substr($line, $charlim - 1); } // If $temp contains data it means we had to split up an over-length @@ -504,11 +495,11 @@ if ( ! function_exists('word_wrap')) * * This function will strip tags from a string, split it at its max_length and ellipsize * - * @param string string to ellipsize - * @param integer 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 + * @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')) { -- cgit v1.2.3-24-g4f1b From e79a3b134bb5268106d550934808dd9e404ca515 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Mar 2012 15:41:22 +0200 Subject: Remove EOF newlines --- system/helpers/smiley_helper.php | 2 +- system/helpers/string_helper.php | 2 +- system/helpers/text_helper.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index bc592f74f..638100e9c 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -251,4 +251,4 @@ EOF; } /* End of file smiley_helper.php */ -/* Location: ./system/helpers/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 a53d1b88e..e570d5d01 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -287,4 +287,4 @@ if ( ! function_exists('repeater')) } /* End of file string_helper.php */ -/* Location: ./system/helpers/string_helper.php */ +/* Location: ./system/helpers/string_helper.php */ \ No newline at end of file diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 9a56159d9..daf31c3d6 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -531,4 +531,4 @@ if ( ! function_exists('ellipsize')) } /* End of file text_helper.php */ -/* Location: ./system/helpers/text_helper.php */ +/* Location: ./system/helpers/text_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0688ac9ad88a03f1c56cfcd9e3c475b83301344d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 20 Apr 2012 10:25:04 -0400 Subject: Start comment cleanup of libraries --- system/libraries/Cache/Cache.php | 48 ++++++--- system/libraries/Cache/drivers/Cache_apc.php | 2 +- system/libraries/Cache/drivers/Cache_dummy.php | 2 +- system/libraries/Cache/drivers/Cache_file.php | 16 ++- system/libraries/Cache/drivers/Cache_memcached.php | 24 +++-- system/libraries/Cache/drivers/Cache_wincache.php | 2 +- system/libraries/Driver.php | 45 +++++++- system/libraries/Encrypt.php | 35 +++++- system/libraries/Form_validation.php | 83 +++++++++++++- system/libraries/Profiler.php | 44 ++++++-- system/libraries/Typography.php | 36 +++++-- system/libraries/User_agent.php | 120 ++++++++++++++++++--- system/libraries/Xmlrpc.php | 36 +++---- system/libraries/Xmlrpcs.php | 37 ++++++- 14 files changed, 440 insertions(+), 90 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index f98241617..409323def 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -36,16 +36,38 @@ */ class CI_Cache extends CI_Driver_Library { - protected $valid_drivers = array( - 'cache_apc', - 'cache_file', - 'cache_memcached', - 'cache_dummy', - 'cache_wincache' - ); - - protected $_cache_path = NULL; // Path of cache files (if file-based cache) - protected $_adapter = 'dummy'; + /** + * Valid cache drivers + * + * @var array + */ + protected $valid_drivers = array( + 'cache_apc', + 'cache_file', + 'cache_memcached', + 'cache_dummy', + 'cache_wincache' + ); + + /** + * Path of cache files (if file-based cache) + * + * @var string + */ + protected $_cache_path = NULL; + + /** + * Reference to the driver + * + * @var mixe + */ + protected $_adapter = 'dummy'; + + /** + * Fallback driver + * + * @param string + */ protected $_backup_driver; /** @@ -59,9 +81,9 @@ class CI_Cache extends CI_Driver_Library { public function __construct($config = array()) { $default_config = array( - 'adapter', - 'memcached' - ); + 'adapter', + 'memcached' + ); foreach ($default_config as $key) { diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index 59ab67533..c85034f95 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -75,7 +75,7 @@ class CI_Cache_apc extends CI_Driver { * Delete from Cache * * @param mixed unique identifier of the item in the cache - * @param bool true on success/false on failure + * @return bool true on success/false on failure */ public function delete($id) { diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index e8b791c5b..3f2b4b956 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -70,7 +70,7 @@ class CI_Cache_dummy extends CI_Driver { * Delete from Cache * * @param mixed unique identifier of the item in the cache - * @param bool TRUE, simulating success + * @return bool TRUE, simulating success */ public function delete($id) { diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index dd27aa90e..ec4195278 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -36,8 +36,16 @@ */ class CI_Cache_file extends CI_Driver { + /** + * Directory in which to save cache files + * + * @var string + */ protected $_cache_path; + /** + * Initialize file-based cache + */ public function __construct() { $CI =& get_instance(); @@ -86,10 +94,10 @@ class CI_Cache_file extends CI_Driver { public function save($id, $data, $ttl = 60) { $contents = array( - 'time' => time(), - 'ttl' => $ttl, - 'data' => $data - ); + 'time' => time(), + 'ttl' => $ttl, + 'data' => $data + ); if (write_file($this->_cache_path.$id, serialize($contents))) { diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 4cd5f3d6f..813df4b1c 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -36,15 +36,25 @@ */ class CI_Cache_memcached extends CI_Driver { - protected $_memcached; // Holds the memcached object + /** + * Holds the memcached object + * + * @var object + */ + protected $_memcached; + /** + * Memcached configuration + * + * @var array + */ protected $_memcache_conf = array( - 'default' => array( - 'default_host' => '127.0.0.1', - 'default_port' => 11211, - 'default_weight' => 1 - ) - ); + 'default' => array( + 'default_host' => '127.0.0.1', + 'default_port' => 11211, + 'default_weight' => 1 + ) + ); /** * Fetch from cache diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index b32e66a46..74048d564 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -78,7 +78,7 @@ class CI_Cache_wincache extends CI_Driver { * Delete from Cache * * @param mixed unique identifier of the item in the cache - * @param bool true on success/false on failure + * @return bool true on success/false on failure */ public function delete($id) { diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index f409f47d4..b1fff154d 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -39,11 +39,27 @@ */ class CI_Driver_Library { - protected $valid_drivers = array(); + /** + * Array of drivers that are available to use with the driver class + * + * @var array + */ + protected $valid_drivers = array(); + + /** + * Name of the current class - usually the driver class + * + * @var string + */ protected static $lib_name; - // The first time a child is used it won't exist, so we instantiate it - // subsequents calls will go straight to the proper child. + /** + * The first time a child is used it won't exist, so we instantiate it + * subsequents calls will go straight to the proper child. + * + * @param mixed $child + * @return mixed + */ public function __get($child) { if ( ! isset($this->lib_name)) @@ -100,6 +116,8 @@ class CI_Driver_Library { } +// -------------------------------------------------------------------------- + /** * CodeIgniter Driver Class * @@ -114,11 +132,32 @@ class CI_Driver_Library { */ class CI_Driver { + /** + * Instance of the parent class + * + * @var object + */ protected $_parent; + /** + * List of methods in the parent class + * + * @var array + */ protected $_methods = array(); + + /** + * List of properties in the parent class + * + * @var array + */ protected $_properties = array(); + /** + * Array of methods and properties for the parent class(es) + * + * @var array + */ protected static $_reflections = array(); /** diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 54b5bf737..17437c1ca 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -38,12 +38,44 @@ */ class CI_Encrypt { + /** + * Reference to the user's encryption key + * + * @var string + */ public $encryption_key = ''; + + /** + * Type of hash operation + * + * @var string + */ protected $_hash_type = 'sha1'; + + /** + * Flag for the existance of mcrypt + * + * @var bool + */ protected $_mcrypt_exists = FALSE; + + /** + * Current cipher to be used with mcrypt + * + * @var string + */ protected $_mcrypt_cipher; + + /** + * Method for encrypting/decrypting data + * + * @var int + */ protected $_mcrypt_mode; + /** + * Initialize Encryption class + */ public function __construct() { $this->_mcrypt_exists = function_exists('mcrypt_encrypt'); @@ -349,7 +381,8 @@ class CI_Encrypt { * * Function description * - * @param string + * @param string $data + * @param string $key * @return string */ protected function _remove_cipher_noise($data, $key) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 22bc7ddf3..a52cad5ff 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -36,17 +36,81 @@ */ class CI_Form_validation { + /** + * Reference to the CodeIgniter instance + * + * @var object + */ protected $CI; - protected $_field_data = array(); - protected $_config_rules = array(); + + /** + * Validation data for the current form submission + * + * @var array + */ + protected $_field_data = array(); + + /** + * Validation rules for the current form + * + * @var array + */ + protected $_config_rules = array(); + + /** + * Array of validation errors + * + * @var array + */ protected $_error_array = array(); + + /** + * Array of custom error messages + * + * @var array + */ protected $_error_messages = array(); + + /** + * Start tag for error wrapping + * + * @var string + */ protected $_error_prefix = '

'; + + /** + * End tag for error wrapping + * + * @var string + */ protected $_error_suffix = '

'; + + /** + * Custom error message + * + * @var string + */ protected $error_string = ''; + + /** + * Whether the form data has been validated as safe + * + * @var bool + */ protected $_safe_form_data = FALSE; + + /** + * Custom data to validate + * + * @var array + */ protected $validation_data = array(); + /** + * Initialize Form_Validation class + * + * @param array $rules + */ public function __construct($rules = array()) { $this->CI =& get_instance(); @@ -86,8 +150,9 @@ class CI_Form_validation { * This function takes an array of field names and validation * rules as input, validates the info, and stores it * - * @param mixed - * @param string + * @param mixed $field + * @param string $label + * @param mixed $rules * @return object */ public function set_rules($field, $label = '', $rules = '') @@ -241,6 +306,8 @@ class CI_Form_validation { * Gets the error message associated with a particular field * * @param string the field name + * @param string the html start tag + * @param strign the html end tag * @return string */ public function error($field = '', $prefix = '', $suffix = '') @@ -326,6 +393,7 @@ class CI_Form_validation { * * This function does all the work. * + * @param string $group * @return bool */ public function run($group = '') @@ -768,6 +836,7 @@ class CI_Form_validation { * * @param string * @param string + * @param bool * @return string */ public function set_select($field = '', $value = '', $default = FALSE) @@ -803,6 +872,7 @@ class CI_Form_validation { * * @param string * @param string + * @param bool * @return string */ public function set_radio($field = '', $value = '', $default = FALSE) @@ -838,6 +908,7 @@ class CI_Form_validation { * * @param string * @param string + * @param bool * @return string */ public function set_checkbox($field = '', $value = '', $default = FALSE) @@ -1116,6 +1187,7 @@ class CI_Form_validation { * Greater than * * @param string + * @param int * @return bool */ public function greater_than($str, $min) @@ -1129,6 +1201,7 @@ class CI_Form_validation { * Equal to or Greater than * * @param string + * @param int * @return bool */ public function greater_than_equal_to($str, $min) @@ -1142,6 +1215,7 @@ class CI_Form_validation { * Less than * * @param string + * @param int * @return bool */ public function less_than($str, $max) @@ -1155,6 +1229,7 @@ class CI_Form_validation { * Equal to or Less than * * @param string + * @param int * @return bool */ public function less_than_equal_to($str, $max) diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 6320ab50d..1e86f3c61 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -42,23 +42,45 @@ */ class CI_Profiler { + /** + * List of profiler sections available to show + * + * @var array + */ protected $_available_sections = array( - 'benchmarks', - 'get', - 'memory_usage', - 'post', - 'uri_string', - 'controller_info', - 'queries', - 'http_headers', - 'session_data', - 'config' - ); + 'benchmarks', + 'get', + 'memory_usage', + 'post', + 'uri_string', + 'controller_info', + 'queries', + 'http_headers', + 'session_data', + 'config' + ); + /** + * Number of queries to show before making the additional queries togglable + * + * @var int + */ protected $_query_toggle_count = 25; + /** + * Reference to the CodeIgniter singleton + * + * @var object + */ protected $CI; + /** + * Constructor + * + * Initialize Profiler + * + * @param array $config + */ public function __construct($config = array()) { $this->CI =& get_instance(); diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 21bbad038..50bd12486 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -36,22 +36,46 @@ */ class CI_Typography { - // Block level elements that should not be wrapped inside

tags + /** + * Block level elements that should not be wrapped inside

tags + * + * @var string + */ public $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; - // Elements that should not have

and
tags within them. + /** + * Elements that should not have

and
tags within them. + * + * @var string + */ public $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d'; - // Tags we want the parser to completely ignore when splitting the string. + /** + * Tags we want the parser to completely ignore when splitting the string. + * + * @var string + */ public $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'; - // array of block level elements that require inner content to be within another block level element + /** + * array of block level elements that require inner content to be within another block level element + * + * @var array + */ public $inner_block_required = array('blockquote'); - // the last block element parsed + /** + * the last block element parsed + * + * @var string + */ public $last_block_element = ''; - // whether or not to protect quotes within { curly braces } + /** + * whether or not to protect quotes within { curly braces } + * + * @var bool + */ public $protect_braced_quotes = FALSE; /** diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index b8e0d37fb..0ac605fa4 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -38,25 +38,110 @@ */ class CI_User_agent { - public $agent = NULL; + /** + * Current user-agent + * + * @var string + */ + public $agent = NULL; - public $is_browser = FALSE; - public $is_robot = FALSE; - public $is_mobile = FALSE; + /** + * Flag for if the user-agent belongs to a browser + * + * @var bool + */ + public $is_browser = FALSE; + + /** + * Flag for if the user-agent is a robot + * + * @var bool + */ + public $is_robot = FALSE; + + /** + * Flag for if the user-agent is a mobile browser + * + * @var bool + */ + public $is_mobile = FALSE; - public $languages = array(); - public $charsets = array(); + /** + * Languages accepted by the current user agent + * + * @var array + */ + public $languages = array(); + + /** + * Character sets accepted by the current user agent + * + * @var array + */ + public $charsets = array(); - public $platforms = array(); - public $browsers = array(); - public $mobiles = array(); - public $robots = array(); + /** + * List of platforms to compare against current user agent + * + * @var array + */ + public $platforms = array(); + + /** + * List of browsers to compare against current user agent + * + * @var array + */ + public $browsers = array(); + + /** + * List of mobile browsers to compare against current user agent + * + * @var array + */ + public $mobiles = array(); + + /** + * List of robots to compare against current user agent + * + * @var array + */ + public $robots = array(); - public $platform = ''; - public $browser = ''; - public $version = ''; - public $mobile = ''; - public $robot = ''; + /** + * Current user-agent platform + * + * @var string + */ + public $platform = ''; + + /** + * Current user-agent browser + * + * @var string + */ + public $browser = ''; + + /** + * Current user-agent version + * + * @var string + */ + public $version = ''; + + /** + * Current user-agent mobile name + * + * @var string + */ + public $mobile = ''; + + /** + * Current user-agent robot name + * + * @var string + */ + public $robot = ''; /** * Constructor @@ -302,6 +387,7 @@ class CI_User_agent { /** * Is Browser * + * @param string $key * @return bool */ public function is_browser($key = NULL) @@ -326,6 +412,7 @@ class CI_User_agent { /** * Is Robot * + * @param string $key * @return bool */ public function is_robot($key = NULL) @@ -350,6 +437,7 @@ class CI_User_agent { /** * Is Mobile * + * @param string $key * @return bool */ public function is_mobile($key = NULL) @@ -503,6 +591,7 @@ class CI_User_agent { /** * Test for a particular language * + * @param string $lang * @return bool */ public function accept_lang($lang = 'en') @@ -515,6 +604,7 @@ class CI_User_agent { /** * Test for a particular character set * + * @param string $charset * @return bool */ public function accept_charset($charset = 'utf-8') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index fea560c2e..7009deacc 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -104,24 +104,24 @@ class CI_Xmlrpc { ); // Array of Valid Parents for Various XML-RPC elements - $this->valid_parents = array('BOOLEAN' => array('VALUE'), - 'I4' => array('VALUE'), - 'INT' => array('VALUE'), - 'STRING' => array('VALUE'), - 'DOUBLE' => array('VALUE'), - 'DATETIME.ISO8601' => array('VALUE'), - 'BASE64' => array('VALUE'), - 'ARRAY' => array('VALUE'), - 'STRUCT' => array('VALUE'), - 'PARAM' => array('PARAMS'), - 'METHODNAME' => array('METHODCALL'), - 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), - 'MEMBER' => array('STRUCT'), - 'NAME' => array('MEMBER'), - 'DATA' => array('ARRAY'), - 'FAULT' => array('METHODRESPONSE'), - 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') - ); + $this->valid_parents = array('BOOLEAN' => array('VALUE'), + 'I4' => array('VALUE'), + 'INT' => array('VALUE'), + 'STRING' => array('VALUE'), + 'DOUBLE' => array('VALUE'), + 'DATETIME.ISO8601' => array('VALUE'), + 'BASE64' => array('VALUE'), + 'ARRAY' => array('VALUE'), + 'STRUCT' => array('VALUE'), + 'PARAM' => array('PARAMS'), + 'METHODNAME' => array('METHODCALL'), + 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), + 'MEMBER' => array('STRUCT'), + 'NAME' => array('MEMBER'), + 'DATA' => array('ARRAY'), + 'FAULT' => array('METHODRESPONSE'), + 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') + ); // XML-RPC Responses diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 6d270c2ea..f0c5b48e7 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -48,12 +48,39 @@ if ( ! class_exists('CI_Xmlrpc')) */ class CI_Xmlrpcs extends CI_Xmlrpc { - public $methods = array(); //array of methods mapped to function names and signatures - public $debug_msg = ''; // Debug Message - public $system_methods = array(); // XML RPC Server methods - public $controller_obj; - public $object = FALSE; + /** + * array of methods mapped to function names and signatures + * + * @var array + */ + public $methods = array(); + + /** + * Debug Message + * + * @var string + */ + public $debug_msg = ''; + + /** + * XML RPC Server methods + * + * @var array + */ + public $system_methods = array(); + + /** + * Configuration object + * + * @var object + */ + public $object = FALSE; + /** + * Initialize XMLRPC class + * + * @param array $config + */ public function __construct($config = array()) { parent::__construct(); -- cgit v1.2.3-24-g4f1b From fc90a7b66df97db1fa0c792759118119836cb7ed Mon Sep 17 00:00:00 2001 From: Cosmin Atanasiu Date: Mon, 23 Apr 2012 20:56:37 -0700 Subject: Update system/libraries/Javascript.php --- system/libraries/Javascript.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 629a3adfe..21c9e11bd 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -723,7 +723,7 @@ class CI_Javascript { { if (is_object($result)) { - $json_result = $result->result_array(); + $json_result = (array)$result; } elseif (is_array($result)) { -- cgit v1.2.3-24-g4f1b From 3182a76899e75bc99da855d79867ce9fcfdc5592 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 26 Apr 2012 18:09:25 -0400 Subject: Fix Table library docblocks --- system/libraries/Table.php | 52 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 3777d29ff..c5c71d889 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -38,13 +38,60 @@ */ class CI_Table { + /** + * Data for table rows + * + * @var array + */ public $rows = array(); + + /** + * Data for table heading + * + * @var array + */ public $heading = array(); + + /** + * Whether or not to automatically create the table header + * + * @var bool + */ public $auto_heading = TRUE; + + /** + * Table caption + * + * @var string + */ public $caption = NULL; + + /** + * Table layout template + * + * @var array + */ public $template = NULL; + + /** + * Newline setting + * + * @var string + */ public $newline = "\n"; + + /** + * Contents of empty cells + * + * @var string + */ public $empty_cells = ''; + + /** + * Callback for custom table layout + * + * @var function + */ public $function = FALSE; /** @@ -93,7 +140,7 @@ class CI_Table { * @param mixed * @return void */ - public function set_heading() + public function set_heading($args=array()) { $args = func_get_args(); $this->heading = $this->_prep_args($args); @@ -172,7 +219,7 @@ class CI_Table { * @param mixed * @return void */ - public function add_row() + public function add_row($args = array()) { $args = func_get_args(); $this->rows[] = $this->_prep_args($args); @@ -420,6 +467,7 @@ class CI_Table { * Set table data from an array * * @param array + * @param bool * @return void */ protected function _set_from_array($data, $set_heading = TRUE) -- cgit v1.2.3-24-g4f1b From b8e6285feff1b699a94ea56fd9c2067c3a60d3f5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 26 Apr 2012 18:40:54 -0400 Subject: Fix Config.php and partially fix Image_lib.php --- system/core/Config.php | 7 -- system/libraries/Image_lib.php | 223 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 205 insertions(+), 25 deletions(-) (limited to 'system') diff --git a/system/core/Config.php b/system/core/Config.php index 1eab08b82..9cebe6c86 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -66,11 +66,6 @@ class CI_Config { * Constructor * * Sets the $config data from the primary config.php file as a class variable - * - * @param string the config file name - * @param boolean if configuration values should be loaded into their own section - * @param boolean true if errors should just return false, false if an error message should be displayed - * @return boolean if the file was successfully loaded or not */ public function __construct() { @@ -192,7 +187,6 @@ class CI_Config { * * @param string the config item name * @param string the index name - * @param bool * @return string */ public function item($item, $index = '') @@ -211,7 +205,6 @@ class CI_Config { * Fetch a config file item - adds slash after item (if item is not empty) * * @param string the config item name - * @param bool * @return string */ public function slash_item($item) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 1ab8b23e0..e90f325ae 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -36,41 +36,228 @@ */ class CI_Image_lib { - public $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2 + /** + * PHP extension/library to use for image manipulation + * Can be: imagemagick, netpbm, gd, gd2 + * + * @var string + */ + public $image_library = 'gd2'; + + /** + * Path to the graphic library (if applicable) + * + * @var string + */ public $library_path = ''; - public $dynamic_output = FALSE; // Whether to send to browser or write to disk + + /** + * Whether to send to browser or write to disk + * + * @var bool + */ + public $dynamic_output = FALSE; + + /** + * Path to original image + * + * @var string + */ public $source_image = ''; + + /** + * Path to the modified image + * + * @var string + */ public $new_image = ''; + + /** + * Image width + * + * @var int + */ public $width = ''; + + /** + * Image height + * + * @var int + */ public $height = ''; + + /** + * Quality percentage of new image + * + * @var int + */ public $quality = '90'; + + /** + * Whether to create a thumbnail + * + * @var bool + */ public $create_thumb = FALSE; + + /** + * String to add to thumbnail version of image + * + * @var string + */ public $thumb_marker = '_thumb'; - public $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values - public $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension + + /** + * Whether to maintain aspect ratio when resizing or use hard values + * + * @var bool + */ + public $maintain_ratio = TRUE; + + /** + * auto, height, or width. Determines what to use as the master dimension + * + * @var string + */ + public $master_dim = 'auto'; + + /** + * Angle at to rotate image + * + * @var string + */ public $rotation_angle = ''; + + /** + * X Coordinate for manipulation of the current image + * + * @var int + */ public $x_axis = ''; + + /** + * Y Coordinate for manipulation of the current image + * + * @var int + */ public $y_axis = ''; + // -------------------------------------------------------------------------- // Watermark Vars - public $wm_text = ''; // Watermark text if graphic is not used - public $wm_type = 'text'; // Type of watermarking. Options: text/overlay + // -------------------------------------------------------------------------- + + /** + * Watermark text if graphic is not used + * + * @var string + */ + public $wm_text = ''; + + /** + * Type of watermarking. Options: text/overlay + * + * @var string + */ + public $wm_type = 'text'; + + /** + * @var int + */ public $wm_x_transp = 4; + + /** + * @var int + */ public $wm_y_transp = 4; - public $wm_overlay_path = ''; // Watermark image path - public $wm_font_path = ''; // TT font - public $wm_font_size = 17; // Font size (different versions of GD will either use points or pixels) - public $wm_vrt_alignment = 'B'; // Vertical alignment: T M B - public $wm_hor_alignment = 'C'; // Horizontal alignment: L R C - public $wm_padding = 0; // Padding around text - public $wm_hor_offset = 0; // Lets you push text to the right - public $wm_vrt_offset = 0; // Lets you push text down - protected $wm_font_color = '#ffffff'; // Text color - protected $wm_shadow_color = ''; // Dropshadow color - public $wm_shadow_distance = 2; // Dropshadow distance - public $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image + + /** + * Watermark image path + * + * @var string + */ + public $wm_overlay_path = ''; + + /** + * TT font + * + * @var string + */ + public $wm_font_path = ''; + + /** + * Font size (different versions of GD will either use points or pixels) + * + * @var int + */ + public $wm_font_size = 17; + + /** + * Vertical alignment: T M B + * + * @var string + */ + public $wm_vrt_alignment = 'B'; + + /** + * Horizontal alignment: L R C + * + * @var string + */ + public $wm_hor_alignment = 'C'; + + /** + * Padding around text + * + * @var int + */ + public $wm_padding = 0; + + /** + * Lets you push text to the right + * + * @var int + */ + public $wm_hor_offset = 0; + + /** + * Lets you push text down + * + * @var int + */ + public $wm_vrt_offset = 0; + + /** + * Text color + * + * @var string + */ + protected $wm_font_color = '#ffffff'; + + /** + * Dropshadow color + * + * @var string + */ + protected $wm_shadow_color = ''; + + /** + * Dropshadow distance + * + * @var int + */ + public $wm_shadow_distance = 2; + + /** + * Image opacity: 1 - 100 Only works with image + * + * @var int + */ + public $wm_opacity = 50; + // -------------------------------------------------------------------------- // Private Vars + // -------------------------------------------------------------------------- + public $source_folder = ''; public $dest_folder = ''; public $mime_type = ''; -- cgit v1.2.3-24-g4f1b From 03edf58ea6c2a1b74f746a7b27b7305a0d33d3d6 Mon Sep 17 00:00:00 2001 From: ziv Date: Fri, 27 Apr 2012 15:09:04 +0800 Subject: Update system/core/Input.php Fix a cookie get back problem. Cookie $index should start with a prefix. --- system/core/Input.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index fc2a550bc..7594a2e45 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -226,6 +226,7 @@ class CI_Input { */ public function cookie($index = '', $xss_clean = FALSE) { + $index = config_item('cookie_prefix').$index; return $this->_fetch_from_array($_COOKIE, $index, $xss_clean); } -- cgit v1.2.3-24-g4f1b From b82bc3a016ce01dfeb993da5918853625a40af86 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 09:12:58 -0400 Subject: Fix Cache, Image_lib and Log libraries --- system/libraries/Cache/Cache.php | 2 +- system/libraries/Image_lib.php | 96 +++++++++++++++++++++++++++++++++++++++- system/libraries/Log.php | 46 +++++++++++++++++++ 3 files changed, 142 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 409323def..0493d5a6e 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -59,7 +59,7 @@ class CI_Cache extends CI_Driver_Library { /** * Reference to the driver * - * @var mixe + * @var mixed */ protected $_adapter = 'dummy'; diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index e90f325ae..24695049c 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -161,11 +161,15 @@ class CI_Image_lib { public $wm_type = 'text'; /** + * Default transparency for watermark + * * @var int */ public $wm_x_transp = 4; /** + * Default transparency for watermark + * * @var int */ public $wm_y_transp = 4; @@ -258,21 +262,109 @@ class CI_Image_lib { // Private Vars // -------------------------------------------------------------------------- + /** + * Source image folder + * + * @var string + */ public $source_folder = ''; + + /** + * Destination image folder + * + * @var string + */ public $dest_folder = ''; + + /** + * Image mime-type + * + * @var string + */ public $mime_type = ''; + + /** + * Original image width + * + * @var int + */ public $orig_width = ''; + + /** + * Original image height + * + * @var int + */ public $orig_height = ''; + + /** + * Image format + * + * @var string + */ public $image_type = ''; + + /** + * Size of current image + * + * @var string + */ public $size_str = ''; + + /** + * Full path to source image + * + * @var string + */ public $full_src_path = ''; + + /** + * Full path to destination image + * + * @var string + */ public $full_dst_path = ''; + + /** + * Name of function to create image + * + * @var string + */ public $create_fnc = 'imagecreatetruecolor'; + + /** + * Name of function to copy image + * + * @var string + */ public $copy_fnc = 'imagecopyresampled'; + + /** + * Error messages + * + * @var array + */ public $error_msg = array(); + + /** + * Whether to have a drop shadow on watermark + * + * @var bool + */ protected $wm_use_drop_shadow = FALSE; + + /** + * Whether to use truetype fonts + * + * @var bool + */ public $wm_use_truetype = FALSE; + /** + * Initialize Image Library + * + * @param array $props + */ public function __construct($props = array()) { if (count($props) > 0) @@ -991,7 +1083,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the type * of watermarking based on the specified preference. * - * @param string * @return bool */ public function watermark() @@ -1247,6 +1338,7 @@ class CI_Image_lib { * based on the type of image being processed * * @param string + * @param string * @return resource */ public function image_create_gd($path = '', $image_type = '') @@ -1448,6 +1540,7 @@ class CI_Image_lib { * A helper function that gets info about the file * * @param string + * @param bool * @return mixed */ public function get_image_properties($path = '', $return = FALSE) @@ -1639,6 +1732,7 @@ class CI_Image_lib { * Show error messages * * @param string + * @param string * @return string */ public function display_errors($open = '

', $close = '

') diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 66f9ebff9..c10363a2e 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -36,14 +36,60 @@ */ class CI_Log { + /** + * Path to save log files + * + * @var string + */ protected $_log_path; + + /** + * Level of logging + * + * @var int + */ protected $_threshold = 1; + + /** + * Highest level of logging + * + * @var int + */ protected $_threshold_max = 0; + + /** + * Array of threshold levels to log + * + * @var array + */ protected $_threshold_array = array(); + + /** + * Format of timestamp for log files + * + * @var string + */ protected $_date_fmt = 'Y-m-d H:i:s'; + + /** + * Whether or not the logger can write to the log files + * + * @var bool + */ protected $_enabled = TRUE; + + /** + * Predefined logging levels + * + * @var array + */ protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4); + /** + * Initialize Logging class + * + * @return void + */ public function __construct() { $config =& get_config(); -- cgit v1.2.3-24-g4f1b From 86611db279c17cf9b3d6ad8732a1c840cb833148 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 10:06:25 -0400 Subject: Fixed Cart, Migration, Parser and Zip libraries --- system/libraries/Cart.php | 46 +++++++++++++++++++++++++++++++++++++----- system/libraries/Migration.php | 39 +++++++++++++++++++++++++++++++++++ system/libraries/Parser.php | 18 ++++++++++++++++- system/libraries/Zip.php | 40 ++++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index ca7be555e..eee123584 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -36,19 +36,53 @@ */ class CI_Cart { - // These are the regular expression rules that we use to validate the product ID and product name - public $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods - public $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods - public $product_name_safe = TRUE; // only allow safe product names + /** + * These are the regular expression rules that we use to validate the product ID and product name + * alpha-numeric, dashes, underscores, or periods + * + * @var string + */ + public $product_id_rules = '\.a-z0-9_-'; + + /** + * These are the regular expression rules that we use to validate the product ID and product name + * alpha-numeric, dashes, underscores, colons or periods + * + * @var string + */ + public $product_name_rules = '\.\:\-_ a-z0-9'; + + /** + * only allow safe product names + * + * @var bool + */ + public $product_name_safe = TRUE; + // -------------------------------------------------------------------------- // Protected variables. Do not change! + // -------------------------------------------------------------------------- + + /** + * Reference to CodeIgniter instance + * + * @var object + */ protected $CI; + + /** + * Contents of the cart + * + * @var array + */ protected $_cart_contents = array(); /** * Shopping Class Constructor * * The constructor loads the Session class, used to store the shopping cart contents. + * + * @param array */ public function __construct($params = array()) { @@ -245,7 +279,6 @@ class CI_Cart { * product ID and quantity for each item. * * @param array - * @param string * @return bool */ public function update($items = array()) @@ -396,6 +429,7 @@ class CI_Cart { * * Removes an item from the cart * + * @param int * @return bool */ public function remove($rowid) @@ -427,6 +461,7 @@ class CI_Cart { * * Returns the entire cart array * + * @param bool * @return array */ public function contents($newest_first = FALSE) @@ -449,6 +484,7 @@ class CI_Cart { * Returns TRUE if the rowid passed to this function correlates to an item * that has options associated with it. * + * @param mixed * @return bool */ public function has_options($rowid = '') diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index a18fcb9f1..ce4683fc1 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -39,14 +39,53 @@ */ class CI_Migration { + /** + * Whether the library is enabled + * + * @var bool + */ protected $_migration_enabled = FALSE; + + /** + * Path to migration classes + * + * @var string + */ protected $_migration_path = NULL; + + /** + * Current migration version + * + * @var mixed + */ protected $_migration_version = 0; + + /** + * Database table with migration info + * + * @var string + */ protected $_migration_table = 'migrations'; + + /** + * Whether to automatically run migrations + * + * @var bool + */ protected $_migration_auto_latest = FALSE; + /** + * Error message + * + * @var string + */ protected $_error_string = ''; + /** + * Initialize Migration Class + * + * @param array + */ public function __construct($config = array()) { # Only run this constructor on main library load diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index d1b5b764b..c40f339b4 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -36,9 +36,25 @@ */ class CI_Parser { + /** + * Left delimeter character for psuedo vars + * + * @var string + */ public $l_delim = '{'; + + /** + * Right delimeter character for psuedo vars + * + * @var string + */ public $r_delim = '}'; - public $object; + + /** + * Reference to CodeIgniter instance + * + * @var object + */ protected $CI; /** diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 80438546b..86d0787b2 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -42,13 +42,53 @@ */ class CI_Zip { + /** + * Zip data in string form + * + * @var string + */ public $zipdata = ''; + + /** + * Zip data for a directory in string form + * + * @var string + */ public $directory = ''; + + /** + * Number of files/folder in zip file + * + * @var int + */ public $entries = 0; + + /** + * Number of files in zip + * + * @var int + */ public $file_num = 0; + + /** + * relative offset of local header + * + * @var int + */ public $offset = 0; + + /** + * Reference to time at init + * + * @var int + */ public $now; + /** + * Initialize zip compression class + * + * @return void + */ public function __construct() { $this->now = time(); -- cgit v1.2.3-24-g4f1b From 68f098142cb71f6a57f74ce34b5f58616cc1ed2f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 10:38:32 -0400 Subject: Fix calendar and session libraries --- system/libraries/Calendar.php | 92 ++++++++++++++++++++++-------- system/libraries/Session.php | 129 ++++++++++++++++++++++++++++++++++++++++++ system/libraries/Table.php | 2 +- 3 files changed, 199 insertions(+), 24 deletions(-) (limited to 'system') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index b6f145d95..4db754f5e 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -38,14 +38,60 @@ */ class CI_Calendar { + /** + * Reference to CodeIgniter instance + * + * @var object + */ protected $CI; - public $lang; + + /** + * Current local time + * + * @var int + */ public $local_time; + + /** + * Calendar layout template + * + * @var string + */ public $template = ''; + + /** + * Day of the week to start the calendar on + * + * @var string + */ public $start_day = 'sunday'; + + /** + * How to display months + * + * @var string + */ public $month_type = 'long'; + + /** + * How to display names of days + * + * @var string + */ public $day_type = 'abr'; + + /** + * Whether to show next/prev month links + * + * @var bool + */ public $show_next_prev = FALSE; + + /** + * Url base to use for next/prev month links + * + * @var bool + */ public $next_prev_url = ''; /** @@ -403,28 +449,28 @@ class CI_Calendar { public function default_template() { return array ( - 'table_open' => '', - 'heading_row_start' => '', - 'heading_previous_cell' => '', - 'heading_title_cell' => '', - 'heading_next_cell' => '', - 'heading_row_end' => '', - 'week_row_start' => '', - 'week_day_cell' => '', - 'week_row_end' => '', - 'cal_row_start' => '', - 'cal_cell_start' => '', - 'cal_cell_end_today' => '', - 'cal_row_end' => '', - 'table_close' => '
<<{heading}>>
{week_day}
', - 'cal_cell_start_today' => '', - 'cal_cell_content' => '{day}', - 'cal_cell_content_today' => '{day}', - 'cal_cell_no_content' => '{day}', - 'cal_cell_no_content_today' => '{day}', - 'cal_cell_blank' => ' ', - 'cal_cell_end' => '
' - ); + 'table_open' => '', + 'heading_row_start' => '', + 'heading_previous_cell' => '', + 'heading_title_cell' => '', + 'heading_next_cell' => '', + 'heading_row_end' => '', + 'week_row_start' => '', + 'week_day_cell' => '', + 'week_row_end' => '', + 'cal_row_start' => '', + 'cal_cell_start' => '', + 'cal_cell_end_today' => '', + 'cal_row_end' => '', + 'table_close' => '
<<{heading}>>
{week_day}
', + 'cal_cell_start_today' => '', + 'cal_cell_content' => '{day}', + 'cal_cell_content_today' => '{day}', + 'cal_cell_no_content' => '{day}', + 'cal_cell_no_content_today' => '{day}', + 'cal_cell_blank' => ' ', + 'cal_cell_end' => '
' + ); } // -------------------------------------------------------------------- diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 3515764ce..3fa446d84 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -36,26 +36,151 @@ */ class CI_Session { + /** + * Whether to encrypt the session cookie + * + * @var bool + */ public $sess_encrypt_cookie = FALSE; + + /** + * Whether to use to the database for session storage + * + * @var bool + */ public $sess_use_database = FALSE; + + /** + * Name of the database table in which to store sessions + * + * @var string + */ public $sess_table_name = ''; + + /** + * Length of time (in seconds) for sessions to expire + * + * @var int + */ public $sess_expiration = 7200; + + /** + * Whether to kill session on close of browser window + * + * @var bool + */ public $sess_expire_on_close = FALSE; + + /** + * Whether to match session on ip address + * + * @var bool + */ public $sess_match_ip = FALSE; + + /** + * Whether to match session on user-agent + * + * @var bool + */ public $sess_match_useragent = TRUE; + + /** + * Name of session cookie + * + * @var string + */ public $sess_cookie_name = 'ci_session'; + + /** + * Session cookie prefix + * + * @var string + */ public $cookie_prefix = ''; + + /** + * Session cookie path + * + * @var string + */ public $cookie_path = ''; + + /** + * Session cookie domain + * + * @var string + */ public $cookie_domain = ''; + + /** + * Whether to set the cookie only on HTTPS connections + * + * @var bool + */ public $cookie_secure = FALSE; + + /** + * Whether cookie should be allowed only to be sent by the server + * + * @var bool + */ public $cookie_httponly = FALSE; + + /** + * Interval at which to update session + * + * @var int + */ public $sess_time_to_update = 300; + + /** + * Key with which to encrypt the session cookie + * + * @var string + */ public $encryption_key = ''; + + /** + * String to indicate flash data cookies + * + * @var string + */ public $flashdata_key = 'flash'; + + /** + * Function to use to get the current time + * + * @var string + */ public $time_reference = 'time'; + + /** + * Probablity level of garbage collection of old sessions + * + * @var int + */ public $gc_probability = 5; + + /** + * Session data + * + * @var array + */ public $userdata = array(); + + /** + * Reference to CodeIgniter instance + * + * @var object + */ public $CI; + + /** + * Current time + * + * @var int + */ public $now; /** @@ -63,6 +188,8 @@ class CI_Session { * * The constructor runs the session routines automatically * whenever the class is instantiated. + * + * @param array */ public function __construct($params = array()) { @@ -525,6 +652,7 @@ class CI_Session { /** * Delete a session variable from the "userdata" array * + * @param array * @return void */ public function unset_userdata($newdata = array()) @@ -664,6 +792,7 @@ class CI_Session { /** * Write the session cookie * + * @param mixed * @return void */ protected function _set_cookie($cookie_data = NULL) diff --git a/system/libraries/Table.php b/system/libraries/Table.php index c5c71d889..236129531 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -140,7 +140,7 @@ class CI_Table { * @param mixed * @return void */ - public function set_heading($args=array()) + public function set_heading($args = array()) { $args = func_get_args(); $this->heading = $this->_prep_args($args); -- cgit v1.2.3-24-g4f1b From 01b129a42b62fd08cd873f44ded026041b560420 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 11:36:50 -0400 Subject: Fix docblocks A-H --- system/helpers/array_helper.php | 56 ++-- system/helpers/captcha_helper.php | 18 +- system/helpers/cookie_helper.php | 64 ++--- system/helpers/date_helper.php | 244 ++++++++--------- system/helpers/directory_helper.php | 23 +- system/helpers/download_helper.php | 20 +- system/helpers/email_helper.php | 28 +- system/helpers/file_helper.php | 197 +++++++------- system/helpers/form_helper.php | 514 ++++++++++++++++++------------------ system/helpers/html_helper.php | 187 ++++++------- 10 files changed, 680 insertions(+), 671 deletions(-) (limited to 'system') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 6f56d9db9..6a7c8e3c7 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -37,19 +37,19 @@ // ------------------------------------------------------------------------ -/** - * Element - * - * Lets you determine whether an array index is set and whether it has a value. - * If the element is empty it returns FALSE (or whatever you specify as the default value.) - * - * @param string - * @param array - * @param mixed - * @return mixed depends on what the array contains - */ if ( ! function_exists('element')) { + /** + * Element + * + * Lets you determine whether an array index is set and whether it has a value. + * If the element is empty it returns FALSE (or whatever you specify as the default value.) + * + * @param string + * @param array + * @param mixed + * @return mixed depends on what the array contains + */ function element($item, $array, $default = FALSE) { return empty($array[$item]) ? $default : $array[$item]; @@ -58,14 +58,14 @@ if ( ! function_exists('element')) // ------------------------------------------------------------------------ -/** - * Random Element - Takes an array as input and returns a random element - * - * @param array - * @return mixed depends on what the array contains - */ if ( ! function_exists('random_element')) { + /** + * Random Element - Takes an array as input and returns a random element + * + * @param array + * @return mixed depends on what the array contains + */ function random_element($array) { return is_array($array) ? $array[array_rand($array)] : $array; @@ -74,19 +74,19 @@ if ( ! function_exists('random_element')) // -------------------------------------------------------------------- -/** - * Elements - * - * Returns only the array items specified. Will return a default value if - * it is not set. - * - * @param array - * @param array - * @param mixed - * @return mixed depends on what the array contains - */ if ( ! function_exists('elements')) { + /** + * Elements + * + * Returns only the array items specified. Will return a default value if + * it is not set. + * + * @param array + * @param array + * @param mixed + * @return mixed depends on what the array contains + */ function elements($items, $array, $default = FALSE) { $return = array(); diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index bdbc62097..b11670658 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -37,17 +37,17 @@ // ------------------------------------------------------------------------ -/** - * Create CAPTCHA - * - * @param array array of data for the CAPTCHA - * @param string path to create the image in - * @param string URL to the CAPTCHA image folder - * @param string server path to font - * @return string - */ if ( ! function_exists('create_captcha')) { + /** + * Create CAPTCHA + * + * @param array array of data for the CAPTCHA + * @param string path to create the image in + * @param string URL to the CAPTCHA image folder + * @param string server path to font + * @return string + */ function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '') { $defaults = array('word' => '', 'img_path' => '', 'img_url' => '', 'img_width' => '150', 'img_height' => '30', 'font_path' => '', 'expiration' => 7200); diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 06560e723..f396c76b0 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -37,24 +37,24 @@ // ------------------------------------------------------------------------ -/** - * Set cookie - * - * Accepts seven parameters, or you can submit an associative - * array in the first parameter containing all the values. - * - * @param mixed - * @param string the value of the cookie - * @param string the number of seconds until expiration - * @param string the cookie domain. Usually: .yourdomain.com - * @param string the cookie path - * @param string the cookie prefix - * @param bool true makes the cookie secure - * @param bool true makes the cookie accessible via http(s) only (no javascript) - * @return void - */ if ( ! function_exists('set_cookie')) { + /** + * Set cookie + * + * Accepts seven parameters, or you can submit an associative + * array in the first parameter containing all the values. + * + * @param mixed + * @param string the value of the cookie + * @param string the number of seconds until expiration + * @param string the cookie domain. Usually: .yourdomain.com + * @param string the cookie path + * @param string the cookie prefix + * @param bool true makes the cookie secure + * @param bool true makes the cookie accessible via http(s) only (no javascript) + * @return void + */ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE) { // Set the config file options @@ -65,15 +65,15 @@ if ( ! function_exists('set_cookie')) // -------------------------------------------------------------------- -/** - * Fetch an item from the COOKIE array - * - * @param string - * @param bool - * @return mixed - */ if ( ! function_exists('get_cookie')) { + /** + * Fetch an item from the COOKIE array + * + * @param string + * @param bool + * @return mixed + */ function get_cookie($index = '', $xss_clean = FALSE) { $CI =& get_instance(); @@ -84,17 +84,17 @@ if ( ! function_exists('get_cookie')) // -------------------------------------------------------------------- -/** - * Delete a COOKIE - * - * @param mixed - * @param string the cookie domain. Usually: .yourdomain.com - * @param string the cookie path - * @param string the cookie prefix - * @return void - */ if ( ! function_exists('delete_cookie')) { + /** + * Delete a COOKIE + * + * @param mixed + * @param string the cookie domain. Usually: .yourdomain.com + * @param string the cookie path + * @param string the cookie prefix + * @return void + */ function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '') { set_cookie($name, '', '', $domain, $path, $prefix); diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index f1ba364f5..531d1d32f 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -37,15 +37,15 @@ // ------------------------------------------------------------------------ -/** - * Get "now" time - * - * Returns time() or its GMT equivalent based on the config file preference - * - * @return int - */ if ( ! function_exists('now')) { + /** + * Get "now" time + * + * Returns time() or its GMT equivalent based on the config file preference + * + * @return int + */ function now() { $CI =& get_instance(); @@ -70,24 +70,24 @@ if ( ! function_exists('now')) // ------------------------------------------------------------------------ -/** - * Convert MySQL Style Datecodes - * - * This function is identical to PHPs date() function, - * except that it allows date codes to be formatted using - * the MySQL style, where each code letter is preceded - * with a percent sign: %Y %m %d etc... - * - * The benefit of doing dates this way is that you don't - * have to worry about escaping your text letters that - * match the date codes. - * - * @param string - * @param int - * @return int - */ if ( ! function_exists('mdate')) { + /** + * Convert MySQL Style Datecodes + * + * This function is identical to PHPs date() function, + * except that it allows date codes to be formatted using + * the MySQL style, where each code letter is preceded + * with a percent sign: %Y %m %d etc... + * + * The benefit of doing dates this way is that you don't + * have to worry about escaping your text letters that + * match the date codes. + * + * @param string + * @param int + * @return int + */ function mdate($datestr = '', $time = '') { if ($datestr == '') @@ -109,17 +109,17 @@ if ( ! function_exists('mdate')) // ------------------------------------------------------------------------ -/** - * Standard Date - * - * Returns a date formatted according to the submitted standard. - * - * @param string the chosen format - * @param int Unix timestamp - * @return string - */ if ( ! function_exists('standard_date')) { + /** + * Standard Date + * + * Returns a date formatted according to the submitted standard. + * + * @param string the chosen format + * @param int Unix timestamp + * @return string + */ function standard_date($fmt = 'DATE_RFC822', $time = '') { $formats = array( @@ -146,19 +146,19 @@ if ( ! function_exists('standard_date')) // ------------------------------------------------------------------------ -/** - * Timespan - * - * Returns a span of seconds in this format: - * 10 days 14 hours 36 minutes 47 seconds - * - * @param int a number of seconds - * @param int Unix timestamp - * @param int a number of display units - * @return string - */ if ( ! function_exists('timespan')) { + /** + * Timespan + * + * Returns a span of seconds in this format: + * 10 days 14 hours 36 minutes 47 seconds + * + * @param int a number of seconds + * @param int Unix timestamp + * @param int a number of display units + * @return string + */ function timespan($seconds = 1, $time = '', $units = 7) { $CI =& get_instance(); @@ -261,18 +261,18 @@ if ( ! function_exists('timespan')) // ------------------------------------------------------------------------ -/** - * Number of days in a month - * - * Takes a month/year as input and returns the number of days - * for the given month/year. Takes leap years into consideration. - * - * @param int a numeric month - * @param int a numeric year - * @return int - */ if ( ! function_exists('days_in_month')) { + /** + * Number of days in a month + * + * Takes a month/year as input and returns the number of days + * for the given month/year. Takes leap years into consideration. + * + * @param int a numeric month + * @param int a numeric year + * @return int + */ function days_in_month($month = 0, $year = '') { if ($month < 1 OR $month > 12) @@ -300,14 +300,14 @@ if ( ! function_exists('days_in_month')) // ------------------------------------------------------------------------ -/** - * Converts a local Unix timestamp to GMT - * - * @param int Unix timestamp - * @return int - */ if ( ! function_exists('local_to_gmt')) { + /** + * Converts a local Unix timestamp to GMT + * + * @param int Unix timestamp + * @return int + */ function local_to_gmt($time = '') { if ($time == '') @@ -328,20 +328,20 @@ if ( ! function_exists('local_to_gmt')) // ------------------------------------------------------------------------ -/** - * Converts GMT time to a localized value - * - * Takes a Unix timestamp (in GMT) as input, and returns - * at the local value based on the timezone and DST setting - * submitted - * - * @param int Unix timestamp - * @param string timezone - * @param bool whether DST is active - * @return int - */ if ( ! function_exists('gmt_to_local')) { + /** + * Converts GMT time to a localized value + * + * Takes a Unix timestamp (in GMT) as input, and returns + * at the local value based on the timezone and DST setting + * submitted + * + * @param int Unix timestamp + * @param string timezone + * @param bool whether DST is active + * @return int + */ function gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE) { if ($time == '') @@ -362,14 +362,14 @@ if ( ! function_exists('gmt_to_local')) // ------------------------------------------------------------------------ -/** - * Converts a MySQL Timestamp to Unix - * - * @param int Unix timestamp - * @return int - */ if ( ! function_exists('mysql_to_unix')) { + /** + * Converts a MySQL Timestamp to Unix + * + * @param int Unix timestamp + * @return int + */ function mysql_to_unix($time = '') { // We'll remove certain characters for backward compatibility @@ -394,18 +394,18 @@ if ( ! function_exists('mysql_to_unix')) // ------------------------------------------------------------------------ -/** - * Unix to "Human" - * - * Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM - * - * @param int Unix timestamp - * @param bool whether to show seconds - * @param string format: us or euro - * @return string - */ if ( ! function_exists('unix_to_human')) { + /** + * Unix to "Human" + * + * Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM + * + * @param int Unix timestamp + * @param bool whether to show seconds + * @param string format: us or euro + * @return string + */ function unix_to_human($time = '', $seconds = FALSE, $fmt = 'us') { $r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' '; @@ -435,16 +435,16 @@ if ( ! function_exists('unix_to_human')) // ------------------------------------------------------------------------ -/** - * Convert "human" date to GMT - * - * Reverses the above process - * - * @param string format: us or euro - * @return int - */ if ( ! function_exists('human_to_unix')) { + /** + * Convert "human" date to GMT + * + * Reverses the above process + * + * @param string format: us or euro + * @return int + */ function human_to_unix($datestr = '') { if ($datestr == '') @@ -509,16 +509,16 @@ if ( ! function_exists('human_to_unix')) // ------------------------------------------------------------------------ -/** - * Turns many "reasonably-date-like" strings into something - * that is actually useful. This only works for dates after unix epoch. - * - * @param string The terribly formatted date-like string - * @param string Date format to return (same as php date function) - * @return string - */ if ( ! function_exists('nice_date')) { + /** + * Turns many "reasonably-date-like" strings into something + * that is actually useful. This only works for dates after unix epoch. + * + * @param string The terribly formatted date-like string + * @param string Date format to return (same as php date function) + * @return string + */ function nice_date($bad_date = '', $format = FALSE) { if (empty($bad_date)) @@ -575,18 +575,18 @@ if ( ! function_exists('nice_date')) // ------------------------------------------------------------------------ -/** - * Timezone Menu - * - * Generates a drop-down menu of timezones. - * - * @param string timezone - * @param string classname - * @param string menu name - * @return string - */ if ( ! function_exists('timezone_menu')) { + /** + * Timezone Menu + * + * Generates a drop-down menu of timezones. + * + * @param string timezone + * @param string classname + * @param string menu name + * @return string + */ function timezone_menu($default = 'UTC', $class = "", $name = 'timezones') { $CI =& get_instance(); @@ -617,17 +617,17 @@ if ( ! function_exists('timezone_menu')) // ------------------------------------------------------------------------ -/** - * Timezones - * - * Returns an array of timezones. This is a helper function - * for various other ones in this library - * - * @param string timezone - * @return string - */ if ( ! function_exists('timezones')) { + /** + * Timezones + * + * Returns an array of timezones. This is a helper function + * for various other ones in this library + * + * @param string timezone + * @return string + */ function timezones($tz = '') { // Note: Don't change the order of these even though diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php index 4044ace11..bda8fe8bb 100644 --- a/system/helpers/directory_helper.php +++ b/system/helpers/directory_helper.php @@ -37,19 +37,20 @@ // ------------------------------------------------------------------------ -/** - * Create a Directory Map - * - * Reads the specified directory and builds an array - * representation of it. Sub-folders contained with the - * directory will be mapped as well. - * - * @param string path to source - * @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc) - * @return array - */ if ( ! function_exists('directory_map')) { + /** + * Create a Directory Map + * + * Reads the specified directory and builds an array + * representation of it. Sub-folders contained with the + * directory will be mapped as well. + * + * @param string path to source + * @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc) + * @param bool whether to show hidden files + * @return array + */ function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE) { if ($fp = @opendir($source_dir)) diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 8b87f8179..97e6986b0 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -37,18 +37,18 @@ // ------------------------------------------------------------------------ -/** - * Force Download - * - * Generates headers that force a download to happen - * - * @param string filename - * @param mixed the data to be downloaded - * @param bool wether to try and send the actual file MIME type - * @return void - */ if ( ! function_exists('force_download')) { + /** + * Force Download + * + * Generates headers that force a download to happen + * + * @param string filename + * @param mixed the data to be downloaded + * @param bool wether to try and send the actual file MIME type + * @return void + */ function force_download($filename = '', $data = '', $set_mime = FALSE) { if ($filename == '' OR $data == '') diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php index 497625c10..0516e938a 100644 --- a/system/helpers/email_helper.php +++ b/system/helpers/email_helper.php @@ -37,14 +37,14 @@ // ------------------------------------------------------------------------ -/** - * Validate email address - * - * @param string - * @return bool - */ if ( ! function_exists('valid_email')) { + /** + * Validate email address + * + * @param string + * @return bool + */ function valid_email($address) { return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $address); @@ -53,16 +53,16 @@ if ( ! function_exists('valid_email')) // ------------------------------------------------------------------------ -/** - * Send an email - * - * @param string - * @param string - * @param string - * @return bool - */ if ( ! function_exists('send_email')) { + /** + * Send an email + * + * @param string + * @param string + * @param string + * @return bool + */ function send_email($recipient, $subject = 'Test email', $message = 'Hello World') { return mail($recipient, $subject, $message); diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index a5aabecd6..fb4503479 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -37,16 +37,16 @@ // ------------------------------------------------------------------------ -/** - * Read File - * - * Opens the file specfied in the path and returns it as a string. - * - * @param string path to file - * @return string - */ if ( ! function_exists('read_file')) { + /** + * Read File + * + * Opens the file specfied in the path and returns it as a string. + * + * @param string path to file + * @return string + */ function read_file($file) { if ( ! file_exists($file)) @@ -81,18 +81,19 @@ if ( ! function_exists('read_file')) // ------------------------------------------------------------------------ -/** - * Write File - * - * Writes data to the file specified in the path. - * Creates a new file if non-existent. - * - * @param string path to file - * @param string file data - * @return bool - */ if ( ! function_exists('write_file')) { + /** + * Write File + * + * Writes data to the file specified in the path. + * Creates a new file if non-existent. + * + * @param string path to file + * @param string file data + * @param int + * @return bool + */ function write_file($path, $data, $mode = FOPEN_WRITE_CREATE_DESTRUCTIVE) { if ( ! $fp = @fopen($path, $mode)) @@ -111,22 +112,22 @@ if ( ! function_exists('write_file')) // ------------------------------------------------------------------------ -/** - * Delete Files - * - * Deletes all files contained in the supplied directory path. - * Files must be writable or owned by the system in order to be deleted. - * If the second parameter is set to TRUE, any directories contained - * within the supplied base directory will be nuked as well. - * - * @param string path to file - * @param bool whether to delete any directories found in the path - * @param int - * @param bool whether to skip deleting .htaccess and index page files - * @return bool - */ if ( ! function_exists('delete_files')) { + /** + * Delete Files + * + * Deletes all files contained in the supplied directory path. + * Files must be writable or owned by the system in order to be deleted. + * If the second parameter is set to TRUE, any directories contained + * within the supplied base directory will be nuked as well. + * + * @param string path to file + * @param bool whether to delete any directories found in the path + * @param int + * @param bool whether to skip deleting .htaccess and index page files + * @return bool + */ function delete_files($path, $del_dir = FALSE, $level = 0, $htdocs = FALSE) { // Trim the trailing slash @@ -164,19 +165,19 @@ if ( ! function_exists('delete_files')) // ------------------------------------------------------------------------ -/** - * Get Filenames - * - * Reads the specified directory and builds an array containing the filenames. - * Any sub-folders contained within the specified path are read as well. - * - * @param string path to source - * @param bool whether to include the path as part of the filename - * @param bool internal variable to determine recursion status - do not use in calls - * @return array - */ if ( ! function_exists('get_filenames')) { + /** + * Get Filenames + * + * Reads the specified directory and builds an array containing the filenames. + * Any sub-folders contained within the specified path are read as well. + * + * @param string path to source + * @param bool whether to include the path as part of the filename + * @param bool internal variable to determine recursion status - do not use in calls + * @return array + */ function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE) { static $_filedata = array(); @@ -212,21 +213,21 @@ if ( ! function_exists('get_filenames')) // -------------------------------------------------------------------- -/** - * Get Directory File Information - * - * Reads the specified directory and builds an array containing the filenames, - * filesize, dates, and permissions - * - * Any sub-folders contained within the specified path are read as well. - * - * @param string path to source - * @param bool Look only at the top level directory specified? - * @param bool internal variable to determine recursion status - do not use in calls - * @return array - */ if ( ! function_exists('get_dir_file_info')) { + /** + * Get Directory File Information + * + * Reads the specified directory and builds an array containing the filenames, + * filesize, dates, and permissions + * + * Any sub-folders contained within the specified path are read as well. + * + * @param string path to source + * @param bool Look only at the top level directory specified? + * @param bool internal variable to determine recursion status - do not use in calls + * @return array + */ function get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE) { static $_filedata = array(); @@ -265,20 +266,20 @@ if ( ! function_exists('get_dir_file_info')) // -------------------------------------------------------------------- -/** -* Get File Info -* -* Given a file and path, returns the name, path, size, date modified -* Second parameter allows you to explicitly declare what information you want returned -* Options are: name, server_path, size, date, readable, writable, executable, fileperms -* Returns FALSE if the file cannot be found. -* -* @param string path to file -* @param mixed array or comma separated string of information returned -* @return array -*/ if ( ! function_exists('get_file_info')) { + /** + * Get File Info + * + * Given a file and path, returns the name, path, size, date modified + * Second parameter allows you to explicitly declare what information you want returned + * Options are: name, server_path, size, date, readable, writable, executable, fileperms + * Returns FALSE if the file cannot be found. + * + * @param string path to file + * @param mixed array or comma separated string of information returned + * @return array + */ function get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date')) { @@ -330,20 +331,20 @@ if ( ! function_exists('get_file_info')) // -------------------------------------------------------------------- -/** - * Get Mime by Extension - * - * Translates a file extension into a mime type based on config/mimes.php. - * Returns FALSE if it can't determine the type, or open the mime config file - * - * Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience - * It should NOT be trusted, and should certainly NOT be used for security - * - * @param string path to file - * @return mixed - */ if ( ! function_exists('get_mime_by_extension')) { + /** + * Get Mime by Extension + * + * Translates a file extension into a mime type based on config/mimes.php. + * Returns FALSE if it can't determine the type, or open the mime config file + * + * Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience + * It should NOT be trusted, and should certainly NOT be used for security + * + * @param string path to file + * @return mixed + */ function get_mime_by_extension($file) { $extension = strtolower(substr(strrchr($file, '.'), 1)); @@ -386,17 +387,17 @@ if ( ! function_exists('get_mime_by_extension')) // -------------------------------------------------------------------- -/** - * Symbolic Permissions - * - * Takes a numeric value representing a file's permissions and returns - * standard symbolic notation representing that value - * - * @param int - * @return string - */ if ( ! function_exists('symbolic_permissions')) { + /** + * Symbolic Permissions + * + * Takes a numeric value representing a file's permissions and returns + * standard symbolic notation representing that value + * + * @param int + * @return string + */ function symbolic_permissions($perms) { if (($perms & 0xC000) === 0xC000) @@ -453,17 +454,17 @@ if ( ! function_exists('symbolic_permissions')) // -------------------------------------------------------------------- -/** - * Octal Permissions - * - * Takes a numeric value representing a file's permissions and returns - * a three character string representing the file's octal permissions - * - * @param int - * @return string - */ if ( ! function_exists('octal_permissions')) { + /** + * Octal Permissions + * + * Takes a numeric value representing a file's permissions and returns + * a three character string representing the file's octal permissions + * + * @param int + * @return string + */ function octal_permissions($perms) { return substr(sprintf('%o', $perms), -3); diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index e5b487608..b246d72f3 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -36,18 +36,18 @@ // ------------------------------------------------------------------------ -/** - * Form Declaration - * - * Creates the opening portion of the form. - * - * @param string the URI segments of the form destination - * @param array a key/value pair of attributes - * @param array a key/value pair hidden data - * @return string - */ if ( ! function_exists('form_open')) { + /** + * Form Declaration + * + * Creates the opening portion of the form. + * + * @param string the URI segments of the form destination + * @param array a key/value pair of attributes + * @param array a key/value pair hidden data + * @return string + */ function form_open($action = '', $attributes = '', $hidden = array()) { $CI =& get_instance(); @@ -85,18 +85,18 @@ if ( ! function_exists('form_open')) // ------------------------------------------------------------------------ -/** - * Form Declaration - Multipart type - * - * Creates the opening portion of the form, but with "multipart/form-data". - * - * @param string the URI segments of the form destination - * @param array a key/value pair of attributes - * @param array a key/value pair hidden data - * @return string - */ if ( ! function_exists('form_open_multipart')) { + /** + * Form Declaration - Multipart type + * + * Creates the opening portion of the form, but with "multipart/form-data". + * + * @param string the URI segments of the form destination + * @param array a key/value pair of attributes + * @param array a key/value pair hidden data + * @return string + */ function form_open_multipart($action = '', $attributes = array(), $hidden = array()) { if (is_string($attributes)) @@ -114,18 +114,19 @@ if ( ! function_exists('form_open_multipart')) // ------------------------------------------------------------------------ -/** - * Hidden Input Field - * - * Generates hidden fields. You can pass a simple key/value string or - * an associative array with multiple values. - * - * @param mixed - * @param string - * @return string - */ if ( ! function_exists('form_hidden')) { + /** + * Hidden Input Field + * + * Generates hidden fields. You can pass a simple key/value string or + * an associative array with multiple values. + * + * @param mixed + * @param string + * @param bool + * @return string + */ function form_hidden($name, $value = '', $recursing = FALSE) { static $form; @@ -163,16 +164,16 @@ if ( ! function_exists('form_hidden')) // ------------------------------------------------------------------------ -/** - * Text Input Field - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_input')) { + /** + * Text Input Field + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_input($data = '', $value = '', $extra = '') { $defaults = array('type' => 'text', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); @@ -183,18 +184,19 @@ if ( ! function_exists('form_input')) // ------------------------------------------------------------------------ -/** - * Password Field - * - * Identical to the input function but adds the "password" type - * - * @param mixed - * @param string - * @param string - * @return string - */ + if ( ! function_exists('form_password')) { + /** + * Password Field + * + * Identical to the input function but adds the "password" type + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_password($data = '', $value = '', $extra = '') { if ( ! is_array($data)) @@ -209,18 +211,18 @@ if ( ! function_exists('form_password')) // ------------------------------------------------------------------------ -/** - * Upload Field - * - * Identical to the input function but adds the "file" type - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_upload')) { + /** + * Upload Field + * + * Identical to the input function but adds the "file" type + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_upload($data = '', $value = '', $extra = '') { if ( ! is_array($data)) @@ -235,16 +237,16 @@ if ( ! function_exists('form_upload')) // ------------------------------------------------------------------------ -/** - * Textarea field - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_textarea')) { + /** + * Textarea field + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_textarea($data = '', $value = '', $extra = '') { $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'cols' => '40', 'rows' => '10'); @@ -266,17 +268,17 @@ if ( ! function_exists('form_textarea')) // ------------------------------------------------------------------------ -/** - * Multi-select menu - * - * @param string - * @param array - * @param mixed - * @param string - * @return string - */ if ( ! function_exists('form_multiselect')) { + /** + * Multi-select menu + * + * @param string + * @param array + * @param mixed + * @param string + * @return string + */ function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '') { if ( ! strpos($extra, 'multiple')) @@ -290,17 +292,17 @@ if ( ! function_exists('form_multiselect')) // -------------------------------------------------------------------- -/** - * Drop-down Menu - * - * @param string - * @param array - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_dropdown')) { + /** + * Drop-down Menu + * + * @param string + * @param array + * @param string + * @param string + * @return string + */ function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') { // If name is really an array then we'll call the function again using the array @@ -358,17 +360,17 @@ if ( ! function_exists('form_dropdown')) // ------------------------------------------------------------------------ -/** - * Checkbox Field - * - * @param mixed - * @param string - * @param bool - * @param string - * @return string - */ if ( ! function_exists('form_checkbox')) { + /** + * Checkbox Field + * + * @param mixed + * @param string + * @param bool + * @param string + * @return string + */ function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '') { $defaults = array('type' => 'checkbox', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); @@ -402,17 +404,17 @@ if ( ! function_exists('form_checkbox')) // ------------------------------------------------------------------------ -/** - * Radio Button - * - * @param mixed - * @param string - * @param bool - * @param string - * @return string - */ if ( ! function_exists('form_radio')) { + /** + * Radio Button + * + * @param mixed + * @param string + * @param bool + * @param string + * @return string + */ function form_radio($data = '', $value = '', $checked = FALSE, $extra = '') { if ( ! is_array($data)) @@ -427,16 +429,16 @@ if ( ! function_exists('form_radio')) // ------------------------------------------------------------------------ -/** - * Submit Button - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_submit')) { + /** + * Submit Button + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_submit($data = '', $value = '', $extra = '') { $defaults = array('type' => 'submit', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); @@ -446,16 +448,16 @@ if ( ! function_exists('form_submit')) // ------------------------------------------------------------------------ -/** - * Reset Button - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_reset')) { + /** + * Reset Button + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_reset($data = '', $value = '', $extra = '') { $defaults = array('type' => 'reset', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); @@ -465,16 +467,16 @@ if ( ! function_exists('form_reset')) // ------------------------------------------------------------------------ -/** - * Form Button - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_button')) { + /** + * Form Button + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_button($data = '', $content = '', $extra = '') { $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'type' => 'button'); @@ -490,16 +492,16 @@ if ( ! function_exists('form_button')) // ------------------------------------------------------------------------ -/** - * Form Label Tag - * - * @param string The text to appear onscreen - * @param string The id the label applies to - * @param string Additional attributes - * @return string - */ if ( ! function_exists('form_label')) { + /** + * Form Label Tag + * + * @param string The text to appear onscreen + * @param string The id the label applies to + * @param string Additional attributes + * @return string + */ function form_label($label_text = '', $id = '', $attributes = array()) { @@ -523,18 +525,19 @@ if ( ! function_exists('form_label')) } // ------------------------------------------------------------------------ -/** - * Fieldset Tag - * - * Used to produce
text. To close fieldset - * use form_fieldset_close() - * - * @param string The legend text - * @param string Additional attributes - * @return string - */ + if ( ! function_exists('form_fieldset')) { + /** + * Fieldset Tag + * + * Used to produce
text. To close fieldset + * use form_fieldset_close() + * + * @param string The legend text + * @param string Additional attributes + * @return string + */ function form_fieldset($legend_text = '', $attributes = array()) { $fieldset = '\n"; @@ -549,14 +552,14 @@ if ( ! function_exists('form_fieldset')) // ------------------------------------------------------------------------ -/** - * Fieldset Close Tag - * - * @param string - * @return string - */ if ( ! function_exists('form_fieldset_close')) { + /** + * Fieldset Close Tag + * + * @param string + * @return string + */ function form_fieldset_close($extra = '') { return '
'.$extra; @@ -565,14 +568,14 @@ if ( ! function_exists('form_fieldset_close')) // ------------------------------------------------------------------------ -/** - * Form Close Tag - * - * @param string - * @return string - */ if ( ! function_exists('form_close')) { + /** + * Form Close Tag + * + * @param string + * @return string + */ function form_close($extra = '') { return ''.$extra; @@ -581,16 +584,17 @@ if ( ! function_exists('form_close')) // ------------------------------------------------------------------------ -/** - * Form Prep - * - * Formats text so that it can be safely placed in a form field in the event it has HTML tags. - * - * @param string - * @return string - */ if ( ! function_exists('form_prep')) { + /** + * Form Prep + * + * Formats text so that it can be safely placed in a form field in the event it has HTML tags. + * + * @param string + * @param string + * @return string + */ function form_prep($str = '', $field_name = '') { static $prepped_fields = array(); @@ -631,18 +635,19 @@ if ( ! function_exists('form_prep')) // ------------------------------------------------------------------------ -/** - * Form Value - * - * Grabs a value from the POST array for the specified field so you can - * re-populate an input field or textarea. If Form Validation - * is active it retrieves the info from the validation class - * - * @param string - * @return mixed - */ if ( ! function_exists('set_value')) { + /** + * Form Value + * + * Grabs a value from the POST array for the specified field so you can + * re-populate an input field or textarea. If Form Validation + * is active it retrieves the info from the validation class + * + * @param string + * @param string + * @return mixed + */ function set_value($field = '', $default = '') { if (FALSE === ($OBJ =& _get_validation_object())) @@ -661,19 +666,19 @@ if ( ! function_exists('set_value')) // ------------------------------------------------------------------------ -/** - * Set Select - * - * Let's you set the selected value of a menu via data in the POST array. + * If Form Validation is active it retrieves the info from the validation class + * + * @param string + * @param string + * @param bool + * @return string + */ function set_select($field = '', $value = '', $default = FALSE) { $OBJ =& _get_validation_object(); @@ -712,19 +717,19 @@ if ( ! function_exists('set_select')) // ------------------------------------------------------------------------ -/** - * Set Checkbox - * - * Let's you set the selected value of a checkbox via the value in the POST array. - * If Form Validation is active it retrieves the info from the validation class - * - * @param string - * @param string - * @param bool - * @return string - */ if ( ! function_exists('set_checkbox')) { + /** + * Set Checkbox + * + * Let's you set the selected value of a checkbox via the value in the POST array. + * If Form Validation is active it retrieves the info from the validation class + * + * @param string + * @param string + * @param bool + * @return string + */ function set_checkbox($field = '', $value = '', $default = FALSE) { $OBJ =& _get_validation_object(); @@ -763,19 +768,19 @@ if ( ! function_exists('set_checkbox')) // ------------------------------------------------------------------------ -/** - * Set Radio - * - * Let's you set the selected value of a radio field via info in the POST array. - * If Form Validation is active it retrieves the info from the validation class - * - * @param string - * @param string - * @param bool - * @return string - */ if ( ! function_exists('set_radio')) { + /** + * Set Radio + * + * Let's you set the selected value of a radio field via info in the POST array. + * If Form Validation is active it retrieves the info from the validation class + * + * @param string + * @param string + * @param bool + * @return string + */ function set_radio($field = '', $value = '', $default = FALSE) { $OBJ =& _get_validation_object(); @@ -817,19 +822,20 @@ if ( ! function_exists('set_radio')) // ------------------------------------------------------------------------ -/** - * Form Error - * - * Returns the error for a specific form field. This is a helper for the - * form validation class. - * - * @param string - * @param string - * @param string - * @return string - */ + if ( ! function_exists('form_error')) { + /** + * Form Error + * + * Returns the error for a specific form field. This is a helper for the + * form validation class. + * + * @param string + * @param string + * @param string + * @return string + */ function form_error($field = '', $prefix = '', $suffix = '') { if (FALSE === ($OBJ =& _get_validation_object())) @@ -843,18 +849,18 @@ if ( ! function_exists('form_error')) // ------------------------------------------------------------------------ -/** - * Validation Error String - * - * Returns all the errors associated with a form submission. This is a helper - * function for the form validation class. - * - * @param string - * @param string - * @return string - */ if ( ! function_exists('validation_errors')) { + /** + * Validation Error String + * + * Returns all the errors associated with a form submission. This is a helper + * function for the form validation class. + * + * @param string + * @param string + * @return string + */ function validation_errors($prefix = '', $suffix = '') { if (FALSE === ($OBJ =& _get_validation_object())) @@ -868,17 +874,17 @@ if ( ! function_exists('validation_errors')) // ------------------------------------------------------------------------ -/** - * Parse the form attributes - * - * Helper function used by some of the form helpers - * - * @param array - * @param array - * @return string - */ if ( ! function_exists('_parse_form_attributes')) { + /** + * Parse the form attributes + * + * Helper function used by some of the form helpers + * + * @param array + * @param array + * @return string + */ function _parse_form_attributes($attributes, $default) { if (is_array($attributes)) @@ -916,17 +922,17 @@ if ( ! function_exists('_parse_form_attributes')) // ------------------------------------------------------------------------ -/** - * Attributes To String - * - * Helper function used by some of the form helpers - * - * @param mixed - * @param bool - * @return string - */ if ( ! function_exists('_attributes_to_string')) { + /** + * Attributes To String + * + * Helper function used by some of the form helpers + * + * @param mixed + * @param bool + * @return string + */ function _attributes_to_string($attributes, $formtag = FALSE) { if (is_string($attributes) && strlen($attributes) > 0) @@ -975,16 +981,16 @@ if ( ! function_exists('_attributes_to_string')) // ------------------------------------------------------------------------ -/** - * Validation Object - * - * Determines what the form validation class was instantiated as, fetches - * the object and returns it. - * - * @return mixed - */ if ( ! function_exists('_get_validation_object')) { + /** + * Validation Object + * + * Determines what the form validation class was instantiated as, fetches + * the object and returns it. + * + * @return mixed + */ function &_get_validation_object() { $CI =& get_instance(); diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 0417bd253..124f58009 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -37,17 +37,18 @@ // ------------------------------------------------------------------------ -/** - * Heading - * - * Generates an HTML heading tag. - * - * @param string content - * @param int heading level - * @return string - */ if ( ! function_exists('heading')) { + /** + * Heading + * + * Generates an HTML heading tag. + * + * @param string content + * @param int heading level + * @param string + * @return string + */ function heading($data = '', $h = '1', $attributes = '') { return ''.$data.''; @@ -56,17 +57,17 @@ if ( ! function_exists('heading')) // ------------------------------------------------------------------------ -/** - * Unordered List - * - * Generates an HTML unordered list from an single or multi-dimensional array. - * - * @param array - * @param mixed - * @return string - */ if ( ! function_exists('ul')) { + /** + * Unordered List + * + * Generates an HTML unordered list from an single or multi-dimensional array. + * + * @param array + * @param mixed + * @return string + */ function ul($list, $attributes = '') { return _list('ul', $list, $attributes); @@ -75,17 +76,17 @@ if ( ! function_exists('ul')) // ------------------------------------------------------------------------ -/** - * Ordered List - * - * Generates an HTML ordered list from an single or multi-dimensional array. - * - * @param array - * @param mixed - * @return string - */ if ( ! function_exists('ol')) { + /** + * Ordered List + * + * Generates an HTML ordered list from an single or multi-dimensional array. + * + * @param array + * @param mixed + * @return string + */ function ol($list, $attributes = '') { return _list('ol', $list, $attributes); @@ -94,19 +95,19 @@ if ( ! function_exists('ol')) // ------------------------------------------------------------------------ -/** - * Generates the list - * - * Generates an HTML ordered list from an single or multi-dimensional array. - * - * @param string - * @param mixed - * @param mixed - * @param int - * @return string - */ if ( ! function_exists('_list')) { + /** + * Generates the list + * + * Generates an HTML ordered list from an single or multi-dimensional array. + * + * @param string + * @param mixed + * @param mixed + * @param int + * @return string + */ function _list($type = 'ul', $list, $attributes = '', $depth = 0) { // If an array wasn't submitted there's nothing to do... @@ -165,14 +166,14 @@ if ( ! function_exists('_list')) // ------------------------------------------------------------------------ -/** - * Generates HTML BR tags based on number supplied - * - * @param int - * @return string - */ if ( ! function_exists('br')) { + /** + * Generates HTML BR tags based on number supplied + * + * @param int + * @return string + */ function br($num = 1) { return str_repeat('
', $num); @@ -181,17 +182,17 @@ if ( ! function_exists('br')) // ------------------------------------------------------------------------ -/** - * Image - * - * Generates an element - * - * @param mixed - * @param bool - * @return string - */ if ( ! function_exists('img')) { + /** + * Image + * + * Generates an element + * + * @param mixed + * @param bool + * @return string + */ function img($src = '', $index_page = FALSE) { if ( ! is_array($src) ) @@ -234,20 +235,20 @@ if ( ! function_exists('img')) // ------------------------------------------------------------------------ -/** - * Doctype - * - * Generates a page document type declaration - * - * Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame, - * html4-strict, html4-trans, and html4-frame. Values are saved in the - * doctypes config file. - * - * @param string type The doctype to be generated - * @return string - */ if ( ! function_exists('doctype')) { + /** + * Doctype + * + * Generates a page document type declaration + * + * Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame, + * html4-strict, html4-trans, and html4-frame. Values are saved in the + * doctypes config file. + * + * @param string type The doctype to be generated + * @return string + */ function doctype($type = 'xhtml1-strict') { global $_doctypes; @@ -275,21 +276,21 @@ if ( ! function_exists('doctype')) // ------------------------------------------------------------------------ -/** - * Link - * - * Generates link to a CSS file - * - * @param mixed stylesheet hrefs or an array - * @param string rel - * @param string type - * @param string title - * @param string media - * @param bool should index_page be added to the css path - * @return string - */ if ( ! function_exists('link_tag')) { + /** + * Link + * + * Generates link to a CSS file + * + * @param mixed stylesheet hrefs or an array + * @param string rel + * @param string type + * @param string title + * @param string media + * @param bool should index_page be added to the css path + * @return string + */ function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE) { $CI =& get_instance(); @@ -350,17 +351,17 @@ if ( ! function_exists('link_tag')) // ------------------------------------------------------------------------ -/** - * Generates meta tags from an array of key/values - * - * @param array - * @param string - * @param string - * @param string - * @return string - */ if ( ! function_exists('meta')) { + /** + * Generates meta tags from an array of key/values + * + * @param array + * @param string + * @param string + * @param string + * @return string + */ function meta($name = '', $content = '', $type = 'name', $newline = "\n") { // Since we allow the data to be passes as a string, a simple array @@ -392,14 +393,14 @@ if ( ! function_exists('meta')) // ------------------------------------------------------------------------ -/** - * Generates non-breaking space entities based on number supplied - * - * @param int - * @return string - */ if ( ! function_exists('nbs')) { + /** + * Generates non-breaking space entities based on number supplied + * + * @param int + * @return string + */ function nbs($num = 1) { return str_repeat(' ', $num); -- cgit v1.2.3-24-g4f1b From 827b3f0f6fa3fd62f0276908f38d23a4165f0f41 Mon Sep 17 00:00:00 2001 From: Chris Berthe Date: Fri, 27 Apr 2012 23:36:54 -0400 Subject: Important spelling fix to CodeIgniter.php file --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 793c4687e..349f9f2d0 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -153,7 +153,7 @@ * * Note: Order here is rather important as the UTF-8 * class needs to be used very early on, but it cannot - * properly determine if UTf-8 can be supported until + * properly determine if UTF-8 can be supported until * after the Config class is instantiated. * */ -- cgit v1.2.3-24-g4f1b From 193d448eec149b9b26c89a157c9394266a18ffae Mon Sep 17 00:00:00 2001 From: George Petsagourakis Date: Sat, 28 Apr 2012 11:16:18 +0300 Subject: Minor assignment fix. Can not use $array[] for reading. --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 393a1cd75..d0af66de1 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -281,7 +281,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $v = trim($v); $this->_track_aliases($v); - $v = $this->qb_from[] = $this->protect_identifiers($v, TRUE, NULL, FALSE); + $this->qb_from[] = $v = $this->protect_identifiers($v, TRUE, NULL, FALSE); if ($this->qb_caching === TRUE) { -- cgit v1.2.3-24-g4f1b From e57411502933afad6fca682efb437db05998e532 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Mon, 30 Apr 2012 17:57:37 +0200 Subject: Reverted recent commit, cookie_prefix was breaking things. --- system/core/Input.php | 1 - 1 file changed, 1 deletion(-) (limited to 'system') diff --git a/system/core/Input.php b/system/core/Input.php index 7594a2e45..fc2a550bc 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -226,7 +226,6 @@ class CI_Input { */ public function cookie($index = '', $xss_clean = FALSE) { - $index = config_item('cookie_prefix').$index; return $this->_fetch_from_array($_COOKIE, $index, $xss_clean); } -- cgit v1.2.3-24-g4f1b From a5918ebb5354f6e8bea0149fd95fc98412d461eb Mon Sep 17 00:00:00 2001 From: Cosmin Atanasiu Date: Mon, 30 Apr 2012 22:46:20 -0700 Subject: Update system/libraries/Javascript.php --- system/libraries/Javascript.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 21c9e11bd..b56dd9888 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -723,7 +723,14 @@ class CI_Javascript { { if (is_object($result)) { - $json_result = (array)$result; + if (is_callable( array( $result, "result_array" ) )) + { + $json_result = $result->result_array(); + } + else + { + $json_result = (array)$result; + } } elseif (is_array($result)) { -- cgit v1.2.3-24-g4f1b From 0b10a8c71cd8a60281f8dbe872ae4ba0404ac2c3 Mon Sep 17 00:00:00 2001 From: Cosmin Atanasiu Date: Mon, 30 Apr 2012 22:51:17 -0700 Subject: Update system/libraries/Javascript.php --- system/libraries/Javascript.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'system') diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index b56dd9888..008136192 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -723,14 +723,14 @@ class CI_Javascript { { if (is_object($result)) { - if (is_callable( array( $result, "result_array" ) )) - { - $json_result = $result->result_array(); - } - else - { - $json_result = (array)$result; - } + if (is_callable( array( $result, "result_array" ) )) + { + $json_result = $result->result_array(); + } + else + { + $json_result = (array)$result; + } } elseif (is_array($result)) { -- cgit v1.2.3-24-g4f1b From 3259e98b2b775d6dd932e03ae37b08c6e0465898 Mon Sep 17 00:00:00 2001 From: Cosmin Atanasiu Date: Tue, 1 May 2012 20:41:46 -0700 Subject: Update system/libraries/Javascript.php --- system/libraries/Javascript.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'system') diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 008136192..dd2df697c 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -723,14 +723,7 @@ class CI_Javascript { { if (is_object($result)) { - if (is_callable( array( $result, "result_array" ) )) - { - $json_result = $result->result_array(); - } - else - { - $json_result = (array)$result; - } + $json_result = is_callable(array($result, 'result_array')) ? $result->result_array() : (array) $result; } elseif (is_array($result)) { -- cgit v1.2.3-24-g4f1b From 1a3885babb73870ef99af24297c722d8251480a1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 2 May 2012 10:23:12 +0300 Subject: Fix pagination anchor_class with multiple initializations --- system/libraries/Pagination.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 0fe73d69f..3d2911813 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -94,17 +94,16 @@ class CI_Pagination { { foreach ($params as $key => $val) { - if (isset($this->$key)) + if ($key === 'anchor_class') + { + $this->anchor_class = ($val != '') ? 'class="'.$val.'" ' : ''; + } + elseif (isset($this->$key)) { $this->$key = $val; } } } - - if ($this->anchor_class != '') - { - $this->anchor_class = 'class="'.$this->anchor_class.'" '; - } } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 963c96c5507ceb8b5c3de50d0ab959d21dcc8cd1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 2 May 2012 13:09:57 +0300 Subject: Fix a wrong variable name --- system/helpers/text_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index daf31c3d6..c1c0eb947 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -377,7 +377,7 @@ if ( ! function_exists('convert_accented_characters')) include(APPPATH.'config/foreign_chars.php'); } - if ( ! isset($foreign_characters) OR ! is_array($foreign_chars)) + if ( ! isset($foreign_characters) OR ! is_array($foreign_characters)) { return $str; } -- cgit v1.2.3-24-g4f1b