From b75faa1a03a32330e412f0bd0332fb9fa389e914 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 12:03:32 -0400 Subject: Fix rest of the helpers --- system/helpers/inflector_helper.php | 98 ++++++------- system/helpers/language_helper.php | 18 +-- system/helpers/number_helper.php | 13 +- system/helpers/path_helper.php | 14 +- system/helpers/security_helper.php | 63 ++++---- system/helpers/smiley_helper.php | 103 ++++++-------- system/helpers/string_helper.php | 204 +++++++++++++------------- system/helpers/text_helper.php | 194 ++++++++++++------------- system/helpers/typography_helper.php | 47 +++--- system/helpers/url_helper.php | 268 ++++++++++++++++++----------------- system/helpers/xml_helper.php | 14 +- 11 files changed, 509 insertions(+), 527 deletions(-) diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index feeaf57d7..72615671c 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -37,16 +37,16 @@ // -------------------------------------------------------------------- -/** - * Singular - * - * Takes a plural word and makes it singular - * - * @param string - * @return str - */ if ( ! function_exists('singular')) { + /** + * Singular + * + * Takes a plural word and makes it singular + * + * @param string + * @return str + */ function singular($str) { $result = strval($str); @@ -101,17 +101,17 @@ if ( ! function_exists('singular')) // -------------------------------------------------------------------- -/** - * Plural - * - * Takes a singular word and makes it plural - * - * @param string - * @param bool - * @return str - */ if ( ! function_exists('plural')) { + /** + * Plural + * + * Takes a singular word and makes it plural + * + * @param string + * @param bool + * @return str + */ function plural($str, $force = FALSE) { $result = strval($str); @@ -158,16 +158,16 @@ if ( ! function_exists('plural')) // -------------------------------------------------------------------- -/** - * Camelize - * - * Takes multiple words separated by spaces or underscores and camelizes them - * - * @param string - * @return str - */ if ( ! function_exists('camelize')) { + /** + * Camelize + * + * Takes multiple words separated by spaces or underscores and camelizes them + * + * @param string + * @return str + */ function camelize($str) { return strtolower($str[0]).substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1); @@ -176,16 +176,16 @@ if ( ! function_exists('camelize')) // -------------------------------------------------------------------- -/** - * Underscore - * - * Takes multiple words separated by spaces and underscores them - * - * @param string - * @return str - */ if ( ! function_exists('underscore')) { + /** + * Underscore + * + * Takes multiple words separated by spaces and underscores them + * + * @param string + * @return str + */ function underscore($str) { return preg_replace('/[\s]+/', '_', strtolower(trim($str))); @@ -194,31 +194,33 @@ if ( ! function_exists('underscore')) // -------------------------------------------------------------------- -/** - * Humanize - * - * Takes multiple words separated by the separator and changes them to spaces - * - * @param string $str - * @param string $separator - * @return str - */ if ( ! function_exists('humanize')) { + /** + * Humanize + * + * Takes multiple words separated by the separator and changes them to spaces + * + * @param string $str + * @param string $separator + * @return str + */ function humanize($str, $separator = '_') { return ucwords(preg_replace('/['.$separator.']+/', ' ', strtolower(trim($str)))); } } -/** - * Checks if the given word has a plural version. - * - * @param string the word to check - * @return bool if the word is countable - */ +// -------------------------------------------------------------------- + if ( ! function_exists('is_countable')) { + /** + * Checks if the given word has a plural version. + * + * @param string the word to check + * @return bool if the word is countable + */ function is_countable($word) { return ! in_array(strtolower(strval($word)), diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php index b31c97107..34f030716 100644 --- a/system/helpers/language_helper.php +++ b/system/helpers/language_helper.php @@ -37,17 +37,17 @@ // ------------------------------------------------------------------------ -/** - * Lang - * - * Fetches a language variable and optionally outputs a form label - * - * @param string the language line - * @param string the id of the form element - * @return string - */ if ( ! function_exists('lang')) { + /** + * Lang + * + * Fetches a language variable and optionally outputs a form label + * + * @param string the language line + * @param string the id of the form element + * @return string + */ function lang($line, $id = '') { $CI =& get_instance(); diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php index 40da6e7bf..2a906ba1b 100644 --- a/system/helpers/number_helper.php +++ b/system/helpers/number_helper.php @@ -37,14 +37,15 @@ // ------------------------------------------------------------------------ -/** - * Formats a numbers as bytes, based on size, and adds the appropriate suffix - * - * @param mixed // will be cast as int - * @return string - */ if ( ! function_exists('byte_format')) { + /** + * Formats a numbers as bytes, based on size, and adds the appropriate suffix + * + * @param mixed // will be cast as int + * @param int + * @return string + */ function byte_format($num, $precision = 1) { $CI =& get_instance(); diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php index 6ee99072c..13410545c 100644 --- a/system/helpers/path_helper.php +++ b/system/helpers/path_helper.php @@ -37,15 +37,15 @@ // ------------------------------------------------------------------------ -/** - * Set Realpath - * - * @param string - * @param bool checks to see if the path exists - * @return string - */ if ( ! function_exists('set_realpath')) { + /** + * Set Realpath + * + * @param string + * @param bool checks to see if the path exists + * @return string + */ function set_realpath($path, $check_existance = FALSE) { // Security check to make sure the path is NOT a URL. No remote file inclusion! diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index d6f134c9f..6187a4a7a 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -37,15 +37,15 @@ // ------------------------------------------------------------------------ -/** - * XSS Filtering - * - * @param string - * @param bool whether or not the content is an image file - * @return string - */ if ( ! function_exists('xss_clean')) { + /** + * XSS Filtering + * + * @param string + * @param bool whether or not the content is an image file + * @return string + */ function xss_clean($str, $is_image = FALSE) { $CI =& get_instance(); @@ -55,14 +55,14 @@ if ( ! function_exists('xss_clean')) // ------------------------------------------------------------------------ -/** - * Sanitize Filename - * - * @param string - * @return string - */ if ( ! function_exists('sanitize_filename')) { + /** + * Sanitize Filename + * + * @param string + * @return string + */ function sanitize_filename($filename) { $CI =& get_instance(); @@ -72,14 +72,15 @@ if ( ! function_exists('sanitize_filename')) // -------------------------------------------------------------------- -/** - * Hash encode a string - * - * @param string - * @return string - */ if ( ! function_exists('do_hash')) { + /** + * Hash encode a string + * + * @param string + * @param string + * @return string + */ function do_hash($str, $type = 'sha1') { if ( ! in_array(strtolower($type), hash_algos())) @@ -93,14 +94,14 @@ if ( ! function_exists('do_hash')) // ------------------------------------------------------------------------ -/** - * Strip Image Tags - * - * @param string - * @return string - */ if ( ! function_exists('strip_image_tags')) { + /** + * Strip Image Tags + * + * @param string + * @return string + */ function strip_image_tags($str) { return preg_replace(array('##', '##'), '\\1', $str); @@ -109,14 +110,14 @@ if ( ! function_exists('strip_image_tags')) // ------------------------------------------------------------------------ -/** - * Convert PHP tags to entities - * - * @param string - * @return string - */ if ( ! function_exists('encode_php_tags')) { + /** + * Convert PHP tags to entities + * + * @param string + * @return string + */ function encode_php_tags($str) { return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 8dba74e73..6b4daf6d9 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -37,18 +37,19 @@ // ------------------------------------------------------------------------ -/** - * Smiley Javascript - * - * Returns the javascript required for the smiley insertion. Optionally takes - * an array of aliases to loosely couple the smiley array to the view. - * - * @param mixed alias name or array of alias->field_id pairs - * @param string field_id if alias name was passed in - * @return array - */ if ( ! function_exists('smiley_js')) { + /** + * Smiley Javascript + * + * Returns the javascript required for the smiley insertion. Optionally takes + * an array of aliases to loosely couple the smiley array to the view. + * + * @param mixed alias name or array of alias->field_id pairs + * @param string field_id if alias name was passed in + * @param bool + * @return array + */ function smiley_js($alias = '', $field_id = '', $inline = TRUE) { static $do_setup = TRUE; @@ -130,17 +131,20 @@ EOF; // ------------------------------------------------------------------------ -/** - * Get Clickable Smileys - * - * Returns an array of image tag links that can be clicked to be inserted - * into a form field. - * - * @param string the URL to the folder containing the smiley images - * @return array - */ + if ( ! function_exists('get_clickable_smileys')) { + /** + * Get Clickable Smileys + * + * Returns an array of image tag links that can be clicked to be inserted + * into a form field. + * + * @param string the URL to the folder containing the smiley images + * @param array + * @param array + * @return array + */ function get_clickable_smileys($image_url, $alias = '', $smileys = NULL) { // For backward compatibility with js_insert_smiley @@ -184,17 +188,18 @@ if ( ! function_exists('get_clickable_smileys')) // ------------------------------------------------------------------------ -/** - * Parse Smileys - * - * Takes a string as input and swaps any contained smileys for the actual image - * - * @param string the text to be parsed - * @param string the URL to the folder containing the smiley images - * @return string - */ if ( ! function_exists('parse_smileys')) { + /** + * Parse Smileys + * + * Takes a string as input and swaps any contained smileys for the actual image + * + * @param string the text to be parsed + * @param string the URL to the folder containing the smiley images + * @param array + * @return string + */ function parse_smileys($str = '', $image_url = '', $smileys = NULL) { if ($image_url == '') @@ -224,15 +229,15 @@ if ( ! function_exists('parse_smileys')) // ------------------------------------------------------------------------ -/** - * Get Smiley Array - * - * Fetches the config/smiley.php file - * - * @return mixed - */ if ( ! function_exists('_get_smiley_array')) { + /** + * Get Smiley Array + * + * Fetches the config/smiley.php file + * + * @return mixed + */ function _get_smiley_array() { if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) @@ -253,33 +258,5 @@ if ( ! function_exists('_get_smiley_array')) } } -// ------------------------------------------------------------------------ - -/** - * JS Insert Smiley - * - * Generates the javascript function needed to insert smileys into a form field - * - * DEPRECATED as of version 1.7.2, use smiley_js instead - * - * @param string form name - * @param string field name - * @return string - */ -if ( ! function_exists('js_insert_smiley')) -{ - function js_insert_smiley($form_name = '', $form_field = '') - { - return << - function insert_smiley(smiley) - { - document.{$form_name}.{$form_field}.value += " " + smiley; - } - -EOF; - } -} - /* End of file smiley_helper.php */ /* Location: ./system/helpers/smiley_helper.php */ \ No newline at end of file diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index aed35c157..b42799a8e 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -37,22 +37,22 @@ // ------------------------------------------------------------------------ -/** - * Trim Slashes - * - * Removes any leading/trailing slashes from a string: - * - * /this/that/theother/ - * - * becomes: - * - * this/that/theother - * - * @param string - * @return string - */ if ( ! function_exists('trim_slashes')) { + /** + * Trim Slashes + * + * Removes any leading/trailing slashes from a string: + * + * /this/that/theother/ + * + * becomes: + * + * this/that/theother + * + * @param string + * @return string + */ function trim_slashes($str) { return trim($str, '/'); @@ -61,16 +61,16 @@ if ( ! function_exists('trim_slashes')) // ------------------------------------------------------------------------ -/** - * Strip Slashes - * - * Removes slashes contained in a string or in an array - * - * @param mixed string or array - * @return mixed string or array - */ if ( ! function_exists('strip_slashes')) { + /** + * Strip Slashes + * + * Removes slashes contained in a string or in an array + * + * @param mixed string or array + * @return mixed string or array + */ function strip_slashes($str) { if (is_array($str)) @@ -91,16 +91,16 @@ if ( ! function_exists('strip_slashes')) // ------------------------------------------------------------------------ -/** - * Strip Quotes - * - * Removes single and double quotes from a string - * - * @param string - * @return string - */ if ( ! function_exists('strip_quotes')) { + /** + * Strip Quotes + * + * Removes single and double quotes from a string + * + * @param string + * @return string + */ function strip_quotes($str) { return str_replace(array('"', "'"), '', $str); @@ -109,16 +109,16 @@ if ( ! function_exists('strip_quotes')) // ------------------------------------------------------------------------ -/** - * Quotes to Entities - * - * Converts single and double quotes to entities - * - * @param string - * @return string - */ if ( ! function_exists('quotes_to_entities')) { + /** + * Quotes to Entities + * + * Converts single and double quotes to entities + * + * @param string + * @return string + */ function quotes_to_entities($str) { return str_replace(array("\'","\"","'",'"'), array("'",""","'","""), $str); @@ -127,23 +127,23 @@ if ( ! function_exists('quotes_to_entities')) // ------------------------------------------------------------------------ -/** - * Reduce Double Slashes - * - * Converts double slashes in a string to a single slash, - * except those found in http:// - * - * http://www.some-site.com//index.php - * - * becomes: - * - * http://www.some-site.com/index.php - * - * @param string - * @return string - */ if ( ! function_exists('reduce_double_slashes')) { + /** + * Reduce Double Slashes + * + * Converts double slashes in a string to a single slash, + * except those found in http:// + * + * http://www.some-site.com//index.php + * + * becomes: + * + * http://www.some-site.com/index.php + * + * @param string + * @return string + */ function reduce_double_slashes($str) { return preg_replace('#(^|[^:])//+#', '\\1/', $str); @@ -152,24 +152,24 @@ if ( ! function_exists('reduce_double_slashes')) // ------------------------------------------------------------------------ -/** - * Reduce Multiples - * - * Reduces multiple instances of a particular character. Example: - * - * Fred, Bill,, Joe, Jimmy - * - * becomes: - * - * Fred, Bill, Joe, Jimmy - * - * @param string - * @param string the character you wish to reduce - * @param bool TRUE/FALSE - whether to trim the character from the beginning/end - * @return string - */ if ( ! function_exists('reduce_multiples')) { + /** + * Reduce Multiples + * + * Reduces multiple instances of a particular character. Example: + * + * Fred, Bill,, Joe, Jimmy + * + * becomes: + * + * Fred, Bill, Joe, Jimmy + * + * @param string + * @param string the character you wish to reduce + * @param bool TRUE/FALSE - whether to trim the character from the beginning/end + * @return string + */ function reduce_multiples($str, $character = ',', $trim = FALSE) { $str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str); @@ -185,17 +185,17 @@ if ( ! function_exists('reduce_multiples')) // ------------------------------------------------------------------------ -/** - * Create a Random String - * - * Useful for generating passwords or hashes. - * - * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1 - * @param int number of characters - * @return string - */ if ( ! function_exists('random_string')) { + /** + * Create a Random String + * + * Useful for generating passwords or hashes. + * + * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1 + * @param int number of characters + * @return string + */ function random_string($type = 'alnum', $len = 8) { switch($type) @@ -242,16 +242,16 @@ if ( ! function_exists('random_string')) // ------------------------------------------------------------------------ -/** - * Add's _1 to a string or increment the ending number to allow _2, _3, etc - * - * @param string required - * @param string What should the duplicate number be appended with - * @param string Which number should be used for the first dupe increment - * @return string - */ if ( ! function_exists('increment_string')) { + /** + * Add's _1 to a string or increment the ending number to allow _2, _3, etc + * + * @param string required + * @param string What should the duplicate number be appended with + * @param string Which number should be used for the first dupe increment + * @return string + */ function increment_string($str, $separator = '_', $first = 1) { preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match); @@ -262,17 +262,17 @@ if ( ! function_exists('increment_string')) // ------------------------------------------------------------------------ -/** - * Alternator - * - * Allows strings to be alternated. See docs... - * - * @param string (as many parameters as needed) - * @return string - */ if ( ! function_exists('alternator')) { - function alternator() + /** + * Alternator + * + * Allows strings to be alternated. See docs... + * + * @param string (as many parameters as needed) + * @return string + */ + function alternator($args) { static $i; @@ -288,15 +288,15 @@ if ( ! function_exists('alternator')) // ------------------------------------------------------------------------ -/** - * Repeater function - * - * @param string - * @param int number of repeats - * @return string - */ if ( ! function_exists('repeater')) { + /** + * Repeater function + * + * @param string + * @param int number of repeats + * @return string + */ function repeater($data, $num = 1) { return ($num > 0) ? str_repeat($data, $num) : ''; diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index cc501c334..f53b06b93 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -37,18 +37,18 @@ // ------------------------------------------------------------------------ -/** - * Word Limiter - * - * Limits a string to X number of words. - * - * @param string - * @param int - * @param string the end character. Usually an ellipsis - * @return string - */ if ( ! function_exists('word_limiter')) { + /** + * Word Limiter + * + * Limits a string to X number of words. + * + * @param string + * @param int + * @param string the end character. Usually an ellipsis + * @return string + */ function word_limiter($str, $limit = 100, $end_char = '…') { if (trim($str) == '') @@ -69,19 +69,19 @@ if ( ! function_exists('word_limiter')) // ------------------------------------------------------------------------ -/** - * Character Limiter - * - * Limits the string based on the character count. Preserves complete words - * so the character count may not be exactly as specified. - * - * @param string - * @param int - * @param string the end character. Usually an ellipsis - * @return string - */ if ( ! function_exists('character_limiter')) { + /** + * Character Limiter + * + * Limits the string based on the character count. Preserves complete words + * so the character count may not be exactly as specified. + * + * @param string + * @param int + * @param string the end character. Usually an ellipsis + * @return string + */ function character_limiter($str, $n = 500, $end_char = '…') { if (strlen($str) < $n) @@ -112,16 +112,16 @@ if ( ! function_exists('character_limiter')) // ------------------------------------------------------------------------ -/** - * High ASCII to Entities - * - * Converts High ascii text and MS Word special characters to character entities - * - * @param string - * @return string - */ if ( ! function_exists('ascii_to_entities')) { + /** + * High ASCII to Entities + * + * Converts High ascii text and MS Word special characters to character entities + * + * @param string + * @return string + */ function ascii_to_entities($str) { $count = 1; @@ -172,17 +172,17 @@ if ( ! function_exists('ascii_to_entities')) // ------------------------------------------------------------------------ -/** - * Entities to ASCII - * - * Converts character entities back to ASCII - * - * @param string - * @param bool - * @return string - */ if ( ! function_exists('entities_to_ascii')) { + /** + * Entities to ASCII + * + * Converts character entities back to ASCII + * + * @param string + * @param bool + * @return string + */ function entities_to_ascii($str, $all = TRUE) { if (preg_match_all('/\&#(\d+)\;/', $str, $matches)) @@ -227,20 +227,20 @@ if ( ! function_exists('entities_to_ascii')) // ------------------------------------------------------------------------ -/** - * Word Censoring Function - * - * Supply a string and an array of disallowed words and any - * matched words will be converted to #### or to the replacement - * word you've submitted. - * - * @param string the text string - * @param string the array of censoered words - * @param string the optional replacement value - * @return string - */ if ( ! function_exists('word_censor')) { + /** + * Word Censoring Function + * + * Supply a string and an array of disallowed words and any + * matched words will be converted to #### or to the replacement + * word you've submitted. + * + * @param string the text string + * @param string the array of censoered words + * @param string the optional replacement value + * @return string + */ function word_censor($str, $censored, $replacement = '') { if ( ! is_array($censored)) @@ -274,16 +274,16 @@ if ( ! function_exists('word_censor')) // ------------------------------------------------------------------------ -/** - * Code Highlighter - * - * Colorizes code strings - * - * @param string the text string - * @return string - */ if ( ! function_exists('highlight_code')) { + /** + * Code Highlighter + * + * Colorizes code strings + * + * @param string the text string + * @return string + */ function highlight_code($str) { // The highlight string function encodes and highlights @@ -317,19 +317,19 @@ if ( ! function_exists('highlight_code')) // ------------------------------------------------------------------------ -/** - * Phrase Highlighter - * - * Highlights a phrase within a text string - * - * @param string the text string - * @param string the phrase you'd like to highlight - * @param string the openging tag to precede the phrase with - * @param string the closing tag to end the phrase with - * @return string - */ if ( ! function_exists('highlight_phrase')) { + /** + * Phrase Highlighter + * + * Highlights a phrase within a text string + * + * @param string the text string + * @param string the phrase you'd like to highlight + * @param string the openging tag to precede the phrase with + * @param string the closing tag to end the phrase with + * @return string + */ function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '') { if ($str == '') @@ -348,14 +348,14 @@ if ( ! function_exists('highlight_phrase')) // ------------------------------------------------------------------------ -/** - * Convert Accented Foreign Characters to ASCII - * - * @param string the text string - * @return string - */ if ( ! function_exists('convert_accented_characters')) { + /** + * Convert Accented Foreign Characters to ASCII + * + * @param string the text string + * @return string + */ function convert_accented_characters($str) { if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) @@ -378,19 +378,19 @@ if ( ! function_exists('convert_accented_characters')) // ------------------------------------------------------------------------ -/** - * Word Wrap - * - * Wraps text at the specified character. Maintains the integrity of words. - * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor - * will URLs. - * - * @param string the text string - * @param int the number of characters to wrap at - * @return string - */ if ( ! function_exists('word_wrap')) { + /** + * Word Wrap + * + * Wraps text at the specified character. Maintains the integrity of words. + * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor + * will URLs. + * + * @param string the text string + * @param int the number of characters to wrap at + * @return string + */ function word_wrap($str, $charlim = '76') { // Se the character limit @@ -481,19 +481,19 @@ if ( ! function_exists('word_wrap')) // ------------------------------------------------------------------------ -/** - * Ellipsize String - * - * This function will strip tags from a string, split it at its max_length and ellipsize - * - * @param string string to ellipsize - * @param int max length of string - * @param mixed int (1|0) or float, .5, .2, etc for position to split - * @param string ellipsis ; Default '...' - * @return string ellipsized string - */ if ( ! function_exists('ellipsize')) { + /** + * Ellipsize String + * + * This function will strip tags from a string, split it at its max_length and ellipsize + * + * @param string string to ellipsize + * @param int max length of string + * @param mixed int (1|0) or float, .5, .2, etc for position to split + * @param string ellipsis ; Default '...' + * @return string ellipsized string + */ function ellipsize($str, $max_length, $position = 1, $ellipsis = '…') { // Strip tags diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php index 7a3db5d6b..af9d16a89 100644 --- a/system/helpers/typography_helper.php +++ b/system/helpers/typography_helper.php @@ -37,14 +37,14 @@ // ------------------------------------------------------------------------ -/** - * Convert newlines to HTML line breaks except within PRE tags - * - * @param string - * @return string - */ if ( ! function_exists('nl2br_except_pre')) { + /** + * Convert newlines to HTML line breaks except within PRE tags + * + * @param string + * @return string + */ function nl2br_except_pre($str) { $CI =& get_instance(); @@ -55,16 +55,16 @@ if ( ! function_exists('nl2br_except_pre')) // ------------------------------------------------------------------------ -/** - * Auto Typography Wrapper Function - * - * @param string - * @param bool whether to allow javascript event handlers - * @param bool whether to reduce multiple instances of double newlines to two - * @return string - */ if ( ! function_exists('auto_typography')) { + /** + * Auto Typography Wrapper Function + * + * @param string + * @param bool whether to allow javascript event handlers + * @param bool whether to reduce multiple instances of double newlines to two + * @return string + */ function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE) { $CI =& get_instance(); @@ -73,20 +73,19 @@ if ( ! function_exists('auto_typography')) } } - // -------------------------------------------------------------------- -/** - * HTML Entities Decode - * - * This function is a replacement for html_entity_decode() - * - * @param string - * @param string - * @return string - */ if ( ! function_exists('entity_decode')) { + /** + * HTML Entities Decode + * + * This function is a replacement for html_entity_decode() + * + * @param string + * @param string + * @return string + */ function entity_decode($str, $charset = NULL) { global $SEC; diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 5576c2748..fa685645a 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -37,17 +37,17 @@ // ------------------------------------------------------------------------ -/** - * Site URL - * - * Create a local URL based on your basepath. Segments can be passed via the - * first parameter either as a string or an array. - * - * @param string - * @return string - */ if ( ! function_exists('site_url')) { + /** + * Site URL + * + * Create a local URL based on your basepath. Segments can be passed via the + * first parameter either as a string or an array. + * + * @param string + * @return string + */ function site_url($uri = '') { $CI =& get_instance(); @@ -57,18 +57,18 @@ if ( ! function_exists('site_url')) // ------------------------------------------------------------------------ -/** - * Base URL - * - * Create a local URL based on your basepath. - * Segments can be passed in as a string or an array, same as site_url - * or a URL to a file can be passed in, e.g. to an image file. - * - * @param string - * @return string - */ if ( ! function_exists('base_url')) { + /** + * Base URL + * + * Create a local URL based on your basepath. + * Segments can be passed in as a string or an array, same as site_url + * or a URL to a file can be passed in, e.g. to an image file. + * + * @param string + * @return string + */ function base_url($uri = '') { $CI =& get_instance(); @@ -78,16 +78,16 @@ if ( ! function_exists('base_url')) // ------------------------------------------------------------------------ -/** - * Current URL - * - * Returns the full URL (including segments) of the page where this - * function is placed - * - * @return string - */ if ( ! function_exists('current_url')) { + /** + * Current URL + * + * Returns the full URL (including segments) of the page where this + * function is placed + * + * @return string + */ function current_url() { $CI =& get_instance(); @@ -96,15 +96,16 @@ if ( ! function_exists('current_url')) } // ------------------------------------------------------------------------ -/** - * URL String - * - * Returns the URI segments. - * - * @return string - */ + if ( ! function_exists('uri_string')) { + /** + * URL String + * + * Returns the URI segments. + * + * @return string + */ function uri_string() { $CI =& get_instance(); @@ -114,15 +115,15 @@ if ( ! function_exists('uri_string')) // ------------------------------------------------------------------------ -/** - * Index page - * - * Returns the "index_page" from your config file - * - * @return string - */ if ( ! function_exists('index_page')) { + /** + * Index page + * + * Returns the "index_page" from your config file + * + * @return string + */ function index_page() { $CI =& get_instance(); @@ -132,18 +133,18 @@ if ( ! function_exists('index_page')) // ------------------------------------------------------------------------ -/** - * Anchor Link - * - * Creates an anchor based on the local URL. - * - * @param string the URL - * @param string the link title - * @param mixed any attributes - * @return string - */ if ( ! function_exists('anchor')) { + /** + * Anchor Link + * + * Creates an anchor based on the local URL. + * + * @param string the URL + * @param string the link title + * @param mixed any attributes + * @return string + */ function anchor($uri = '', $title = '', $attributes = '') { $title = (string) $title; @@ -173,19 +174,19 @@ if ( ! function_exists('anchor')) // ------------------------------------------------------------------------ -/** - * Anchor Link - Pop-up version - * - * Creates an anchor based on the local URL. The link - * opens a new window based on the attributes specified. - * - * @param string the URL - * @param string the link title - * @param mixed any attributes - * @return string - */ if ( ! function_exists('anchor_popup')) { + /** + * Anchor Link - Pop-up version + * + * Creates an anchor based on the local URL. The link + * opens a new window based on the attributes specified. + * + * @param string the URL + * @param string the link title + * @param mixed any attributes + * @return string + */ function anchor_popup($uri = '', $title = '', $attributes = FALSE) { $title = (string) $title; @@ -223,16 +224,16 @@ if ( ! function_exists('anchor_popup')) // ------------------------------------------------------------------------ -/** - * Mailto Link - * - * @param string the email address - * @param string the link title - * @param mixed any attributes - * @return string - */ if ( ! function_exists('mailto')) { + /** + * Mailto Link + * + * @param string the email address + * @param string the link title + * @param mixed any attributes + * @return string + */ function mailto($email, $title = '', $attributes = '') { $title = (string) $title; @@ -248,18 +249,18 @@ if ( ! function_exists('mailto')) // ------------------------------------------------------------------------ -/** - * Encoded Mailto Link - * - * Create a spam-protected mailto link written in Javascript - * - * @param string the email address - * @param string the link title - * @param mixed any attributes - * @return string - */ if ( ! function_exists('safe_mailto')) { + /** + * Encoded Mailto Link + * + * Create a spam-protected mailto link written in Javascript + * + * @param string the email address + * @param string the link title + * @param mixed any attributes + * @return string + */ function safe_mailto($email, $title = '', $attributes = '') { $title = (string) $title; @@ -357,21 +358,21 @@ if ( ! function_exists('safe_mailto')) // ------------------------------------------------------------------------ -/** - * Auto-linker - * - * Automatically links URL and Email addresses. - * Note: There's a bit of extra code here to deal with - * URLs or emails that end in a period. We'll strip these - * off and add them after the link. - * - * @param string the string - * @param string the type: email, url, or both - * @param bool whether to create pop-up links - * @return string - */ if ( ! function_exists('auto_link')) { + /** + * Auto-linker + * + * Automatically links URL and Email addresses. + * Note: There's a bit of extra code here to deal with + * URLs or emails that end in a period. We'll strip these + * off and add them after the link. + * + * @param string the string + * @param string the type: email, url, or both + * @param bool whether to create pop-up links + * @return string + */ function auto_link($str, $type = 'both', $popup = FALSE) { if ($type !== 'email' && preg_match_all('#(^|\s|\(|\b)((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i', $str, $matches)) @@ -423,16 +424,16 @@ if ( ! function_exists('auto_link')) // ------------------------------------------------------------------------ -/** - * Prep URL - * - * Simply adds the http:// part if no scheme is included - * - * @param string the URL - * @return string - */ if ( ! function_exists('prep_url')) { + /** + * Prep URL + * + * Simply adds the http:// part if no scheme is included + * + * @param string the URL + * @return string + */ function prep_url($str = '') { if ($str === 'http://' OR $str == '') @@ -453,20 +454,20 @@ if ( ! function_exists('prep_url')) // ------------------------------------------------------------------------ -/** - * Create URL Title - * - * Takes a "title" string as input and creates a - * human-friendly URL string with a "separator" string - * as the word separator. - * - * @param string the string - * @param string the separator - * @param bool - * @return string - */ if ( ! function_exists('url_title')) { + /** + * Create URL Title + * + * Takes a "title" string as input and creates a + * human-friendly URL string with a "separator" string + * as the word separator. + * + * @param string the string + * @param string the separator + * @param bool + * @return string + */ function url_title($str, $separator = '-', $lowercase = FALSE) { if ($separator === 'dash') @@ -504,19 +505,20 @@ if ( ! function_exists('url_title')) // ------------------------------------------------------------------------ -/** - * Header Redirect - * - * Header redirect in two flavors - * For very fine grained control over headers, you could use the Output - * Library's set_header() function. - * - * @param string the URL - * @param string the method: location or refresh - * @return string - */ if ( ! function_exists('redirect')) { + /** + * Header Redirect + * + * Header redirect in two flavors + * For very fine grained control over headers, you could use the Output + * Library's set_header() function. + * + * @param string the URL + * @param string the method: location or refresh + * @param int + * @return string + */ function redirect($uri = '', $method = 'auto', $http_response_code = 302) { if ( ! preg_match('#^https?://#i', $uri)) @@ -545,17 +547,17 @@ if ( ! function_exists('redirect')) // ------------------------------------------------------------------------ -/** - * Parse out the attributes - * - * Some of the functions use this - * - * @param array - * @param bool - * @return string - */ if ( ! function_exists('_parse_attributes')) { + /** + * Parse out the attributes + * + * Some of the functions use this + * + * @param array + * @param bool + * @return string + */ function _parse_attributes($attributes, $javascript = FALSE) { if (is_string($attributes)) diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php index 67fd34b97..958c633dd 100644 --- a/system/helpers/xml_helper.php +++ b/system/helpers/xml_helper.php @@ -37,15 +37,15 @@ // ------------------------------------------------------------------------ -/** - * Convert Reserved XML characters to Entities - * - * @param string - * @param bool - * @return string - */ if ( ! function_exists('xml_convert')) { + /** + * Convert Reserved XML characters to Entities + * + * @param string + * @param bool + * @return string + */ function xml_convert($str, $protect_all = FALSE) { $temp = '__TEMP_AMPERSANDS__'; -- cgit v1.2.3-24-g4f1b From 09a1b5e7fb3c930aa9a50e246236227a499b5d28 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Wed, 16 May 2012 22:18:00 +0700 Subject: Reduce decimal points, since there is a micro differencess on runtime and update travis status --- tests/README.md | 2 +- tests/codeigniter/core/Benchmark_test.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/README.md b/tests/README.md index b46f344cb..c8fc608e8 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,6 +1,6 @@ # CodeIgniter Unit Tests # -Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=feature/unit-tests)](http://travis-ci.org/EllisLab/CodeIgniter) +Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=develop)](http://travis-ci.org/EllisLab/CodeIgniter) ### Introduction: diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php index 2790b582e..109b38821 100644 --- a/tests/codeigniter/core/Benchmark_test.php +++ b/tests/codeigniter/core/Benchmark_test.php @@ -29,8 +29,8 @@ class Benchmark_test extends CI_TestCase { $this->benchmark->mark('code_start'); sleep(1); $this->benchmark->mark('code_end'); - - $this->assertEquals('1.00', $this->benchmark->elapsed_time('code_start', 'code_end', 3)); + + $this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 92ebfb65ac044f5c2e6d88fba137253854cf1b94 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 12:49:24 +0300 Subject: Cleanup the core classes --- system/core/Benchmark.php | 6 ++-- system/core/CodeIgniter.php | 2 +- system/core/Common.php | 6 ++-- system/core/Config.php | 27 +++++++++--------- system/core/Controller.php | 7 +++-- system/core/Exceptions.php | 12 ++++---- system/core/Hooks.php | 6 ++-- system/core/Input.php | 31 ++++++++++----------- system/core/Loader.php | 35 +++++++++++------------ system/core/Model.php | 3 ++ system/core/Output.php | 18 ++++++------ system/core/Router.php | 25 ++++++++--------- system/core/Security.php | 18 ++++++------ system/core/URI.php | 67 ++++++++++++++++++++++----------------------- system/core/Utf8.php | 4 ++- 15 files changed, 135 insertions(+), 132 deletions(-) diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index c17e95a19..bb630f40b 100755 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php @@ -25,13 +25,11 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Benchmark Class * * This class enables you to mark points and calculate the time difference - * between them. Memory consumption can also be displayed. + * between them. Memory consumption can also be displayed. * * @package CodeIgniter * @subpackage Libraries @@ -119,4 +117,4 @@ class CI_Benchmark { } /* End of file Benchmark.php */ -/* Location: ./system/core/Benchmark.php */ +/* Location: ./system/core/Benchmark.php */ \ No newline at end of file diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 349f9f2d0..00db6e13a 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -31,7 +31,7 @@ * Loads the base classes and executes the request. * * @package CodeIgniter - * @subpackage codeigniter + * @subpackage CodeIgniter * @category Front-controller * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/ diff --git a/system/core/Common.php b/system/core/Common.php index 78aa6e874..8b897776f 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -31,7 +31,7 @@ * Loads the base classes and executes the request. * * @package CodeIgniter - * @subpackage codeigniter + * @subpackage CodeIgniter * @category Common Functions * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/ @@ -57,7 +57,7 @@ if ( ! function_exists('is_php')) if ( ! isset($_is_php[$version])) { - $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE; + $_is_php[$version] = (version_compare(PHP_VERSION, $version) >= 0); } return $_is_php[$version]; @@ -506,7 +506,7 @@ if ( ! function_exists('_exception_handler')) $_error->show_php_error($severity, $message, $filepath, $line); } - // Should we log the error? No? We're done... + // Should we log the error? No? We're done... if (config_item('log_threshold') == 0) { return; diff --git a/system/core/Config.php b/system/core/Config.php index 9cebe6c86..c07ffa591 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Config Class * @@ -46,14 +44,14 @@ class CI_Config { * @var array */ public $config = array(); - + /** * List of all loaded config files * * @var array */ public $is_loaded = array(); - + /** * List of paths to search when trying to load a config file. * This must be public as it's used by the Loader class. @@ -77,9 +75,9 @@ class CI_Config { { if (isset($_SERVER['HTTP_HOST'])) { - $base_url = ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; - $base_url .= '://'. $_SERVER['HTTP_HOST'] - . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + $base_url = ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https' : 'http'; + $base_url .= '://'.$_SERVER['HTTP_HOST'] + .str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); } else { @@ -96,9 +94,9 @@ class CI_Config { * Load Config File * * @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 loaded correctly + * @param bool if configuration values should be loaded into their own section + * @param bool true if errors should just return false, false if an error message should be displayed + * @return bool if the file was loaded correctly */ public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { @@ -254,8 +252,8 @@ class CI_Config { * Base URL * Returns base_url [. uri_string] * - * @param string $uri - * @return string + * @param string $uri + * @return string */ public function base_url($uri = '') { @@ -267,8 +265,8 @@ class CI_Config { /** * Build URI string for use in Config::site_url() and Config::base_url() * - * @param mixed $uri - * @return string + * @param mixed $uri + * @return string */ protected function _uri_string($uri) { @@ -345,6 +343,7 @@ class CI_Config { } } } + } /* End of file Config.php */ diff --git a/system/core/Controller.php b/system/core/Controller.php index 1f69146d0..491414807 100644 --- a/system/core/Controller.php +++ b/system/core/Controller.php @@ -48,6 +48,8 @@ class CI_Controller { /** * Set up controller properties and methods + * + * @return void */ public function __construct() { @@ -67,14 +69,15 @@ class CI_Controller { } /** - * Return the CI object + * Return the CI object * - * @return object + * @return object */ public static function &get_instance() { return self::$instance; } + } /* End of file Controller.php */ diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 2e9f0c766..965a717ad 100755 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -65,6 +65,8 @@ class CI_Exceptions { /** * Initialize execption class + * + * @return void */ public function __construct() { @@ -87,7 +89,7 @@ class CI_Exceptions { */ public function log_exception($severity, $message, $filepath, $line) { - $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; + $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity; log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE); } @@ -127,14 +129,14 @@ class CI_Exceptions { * @param string the heading * @param string the message * @param string the template name - * @param int the status code + * @param int the status code * @return string */ public function show_error($heading, $message, $template = 'error_general', $status_code = 500) { set_status_header($status_code); - $message = '

'.implode('

', ( ! is_array($message)) ? array($message) : $message).'

'; + $message = '

'.implode('

', is_array($message) ? $message : array($message)).'

'; if (ob_get_level() > $this->ob_level + 1) { @@ -160,7 +162,7 @@ class CI_Exceptions { */ public function show_php_error($severity, $message, $filepath, $line) { - $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; + $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity; $filepath = str_replace('\\', '/', $filepath); // For safety reasons we do not show the full file path @@ -175,7 +177,7 @@ class CI_Exceptions { ob_end_flush(); } ob_start(); - include(APPPATH.'errors/'.'error_php.php'); + include(APPPATH.'errors/error_php.php'); $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; diff --git a/system/core/Hooks.php b/system/core/Hooks.php index b42ecbe20..5bbb0009a 100755 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -44,14 +44,14 @@ class CI_Hooks { * @var bool */ public $enabled = FALSE; - + /** * List of all hooks set in config/hooks.php * * @var array */ public $hooks = array(); - + /** * Determines wether hook is in progress, used to prevent infinte loops * @@ -152,7 +152,7 @@ class CI_Hooks { // If the script being called happens to have the same // hook call within it a loop can happen - if ($this->in_progress == TRUE) + if ($this->in_progress === TRUE) { return; } diff --git a/system/core/Input.php b/system/core/Input.php index fc2a550bc..e916ac66d 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -44,28 +44,28 @@ class CI_Input { * @var string */ public $ip_address = FALSE; - + /** * user agent (web browser) being used by the current user * * @var string */ public $user_agent = FALSE; - + /** * If FALSE, then $_GET will be set to an empty array * * @var bool */ protected $_allow_get_array = TRUE; - + /** * If TRUE, then newlines are standardized * * @var bool */ protected $_standardize_newlines = TRUE; - + /** * Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered * Set automatically based on config setting @@ -73,7 +73,7 @@ class CI_Input { * @var bool */ protected $_enable_xss = FALSE; - + /** * Enables a CSRF cookie token to be set. * Set automatically based on config setting @@ -81,7 +81,7 @@ class CI_Input { * @var bool */ protected $_enable_csrf = FALSE; - + /** * List of all HTTP request headers * @@ -94,6 +94,8 @@ class CI_Input { * * Sets whether to globally enable the XSS processing * and whether to allow the $_GET array + * + * @return void */ public function __construct() { @@ -438,15 +440,7 @@ class CI_Input { // This is effectively the same as register_globals = off foreach (array($_GET, $_POST, $_COOKIE) as $global) { - if ( ! is_array($global)) - { - if ( ! in_array($global, $protected)) - { - global $$global; - $$global = NULL; - } - } - else + if (is_array($global)) { foreach ($global as $key => $val) { @@ -457,6 +451,11 @@ class CI_Input { } } } + elseif ( ! in_array($global, $protected)) + { + global $$global; + $$global = NULL; + } } // Is $_GET data allowed? If not we'll set the $_GET to an empty array @@ -605,7 +604,7 @@ class CI_Input { * In Apache, you can simply call apache_request_headers(), however for * people running other webservers the function is undefined. * - * @param bool XSS cleaning + * @param bool XSS cleaning * @return array */ public function request_headers($xss_clean = FALSE) diff --git a/system/core/Loader.php b/system/core/Loader.php index bf7f6cb02..3eb09e6ab 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -32,8 +32,8 @@ * * @package CodeIgniter * @subpackage Libraries - * @author EllisLab Dev Team * @category Loader + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/loader.html */ class CI_Loader { @@ -45,77 +45,77 @@ class CI_Loader { * @var int */ protected $_ci_ob_level; - + /** * List of paths to load views from * * @var array */ protected $_ci_view_paths = array(); - + /** * List of paths to load libraries from * * @var array */ protected $_ci_library_paths = array(); - + /** * List of paths to load models from * * @var array */ protected $_ci_model_paths = array(); - + /** * List of paths to load helpers from * * @var array */ protected $_ci_helper_paths = array(); - + /** * List of loaded base classes * * @var array */ protected $_base_classes = array(); // Set by the controller class - + /** * List of cached variables * * @var array */ protected $_ci_cached_vars = array(); - + /** * List of loaded classes * * @var array */ protected $_ci_classes = array(); - + /** * List of loaded files * * @var array */ protected $_ci_loaded_files = array(); - + /** * List of loaded models * * @var array */ protected $_ci_models = array(); - + /** * List of loaded helpers * * @var array */ protected $_ci_helpers = array(); - + /** * List of class name mappings * @@ -130,6 +130,8 @@ class CI_Loader { * Constructor * * Sets the path to the view files and gets the initial output buffering level + * + * @return void */ public function __construct() { @@ -178,12 +180,7 @@ class CI_Loader { */ public function is_loaded($class) { - if (isset($this->_ci_classes[$class])) - { - return $this->_ci_classes[$class]; - } - - return FALSE; + return isset($this->_ci_classes[$class]) ? $this->_ci_classes[$class] : FALSE; } // -------------------------------------------------------------------- @@ -1263,4 +1260,4 @@ class CI_Loader { } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ +/* Location: ./system/core/Loader.php */ \ No newline at end of file diff --git a/system/core/Model.php b/system/core/Model.php index 7c9971970..9bc9f879f 100755 --- a/system/core/Model.php +++ b/system/core/Model.php @@ -38,6 +38,8 @@ class CI_Model { /** * Initialize CI_Model Class + * + * @return void */ public function __construct() { @@ -57,6 +59,7 @@ class CI_Model { $CI =& get_instance(); return $CI->$key; } + } /* End of file Model.php */ diff --git a/system/core/Output.php b/system/core/Output.php index 513c657a6..c8feb4e67 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -44,49 +44,49 @@ class CI_Output { * @var string */ public $final_output; - + /** * Cache expiration time * * @var int */ public $cache_expiration = 0; - + /** * List of server headers * * @var array */ public $headers = array(); - + /** * List of mime types * * @var array */ public $mime_types = array(); - + /** * Determines wether profiler is enabled * * @var book */ public $enable_profiler = FALSE; - + /** * Determines if output compression is enabled * * @var bool */ protected $_zlib_oc = FALSE; - + /** * List of profiler sections * * @var array */ protected $_profiler_sections = array(); - + /** * Whether or not to parse variables like {elapsed_time} and {memory_usage} * @@ -96,6 +96,8 @@ class CI_Output { /** * Set up Output class + * + * @return void */ public function __construct() { @@ -177,7 +179,7 @@ class CI_Output { * * Lets you set a server header which will be outputted with the final display. * - * Note: If a file is cached, headers will not be sent. We need to figure out + * Note: If a file is cached, headers will not be sent. We need to figure out * how to permit header data to be saved with the cache data... * * @param string diff --git a/system/core/Router.php b/system/core/Router.php index 9314052fe..5ea13797b 100755 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -32,8 +32,8 @@ * * @package CodeIgniter * @subpackage Libraries - * @author EllisLab Dev Team * @category Libraries + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/general/routing.html */ class CI_Router { @@ -44,42 +44,42 @@ class CI_Router { * @var object */ public $config; - + /** * List of routes * * @var array */ public $routes = array(); - + /** * List of error routes * * @var array */ public $error_routes = array(); - + /** * Current class name * * @var string */ - public $class = ''; - + public $class = ''; + /** * Current method name * * @var string */ public $method = 'index'; - + /** * Sub-directory that contains the requested controller class * * @var string */ public $directory = ''; - + /** * Default controller (and method if specific) * @@ -91,6 +91,8 @@ class CI_Router { * Constructor * * Runs the route mapping function. + * + * @return void */ public function __construct() { @@ -433,12 +435,7 @@ class CI_Router { */ public function fetch_method() { - if ($this->method == $this->fetch_class()) - { - return 'index'; - } - - return $this->method; + return ($this->method == $this->fetch_class()) ? 'index' : $this->method; } // -------------------------------------------------------------------- diff --git a/system/core/Security.php b/system/core/Security.php index c82b69ff9..81b6602ae 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -102,9 +102,11 @@ class CI_Security { 'Redirect\s+302', "([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?" ); - + /** * Initialize security class + * + * @return void */ public function __construct() { @@ -201,11 +203,11 @@ class CI_Security { } setcookie( - $this->_csrf_cookie_name, - $this->_csrf_hash, - $expire, - config_item('cookie_path'), - config_item('cookie_domain'), + $this->_csrf_cookie_name, + $this->_csrf_hash, + $expire, + config_item('cookie_path'), + config_item('cookie_domain'), $secure_cookie, config_item('cookie_httponly') ); @@ -626,7 +628,7 @@ class CI_Security { // replace illegal attribute strings that are inside an html tag if (count($attribs) > 0) { - $str = preg_replace("/<(\/?[^><]+?)([^A-Za-z<>\-])(.*?)(".implode('|', $attribs).")(.*?)([\s><])([><]*)/i", '<$1 $3$5$6$7', $str, -1, $count); + $str = preg_replace('/<(\/?[^><]+?)([^A-Za-z<>\-])(.*?)('.implode('|', $attribs).')(.*?)([\s><])([><]*)/i', '<$1 $3$5$6$7', $str, -1, $count); } } while ($count); @@ -844,4 +846,4 @@ class CI_Security { } /* End of file Security.php */ -/* Location: ./system/core/Security.php */ +/* Location: ./system/core/Security.php */ \ No newline at end of file diff --git a/system/core/URI.php b/system/core/URI.php index cf82c5838..e66cb6dc5 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -22,6 +22,7 @@ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 + * @filesource */ /** @@ -43,21 +44,21 @@ class CI_URI { * @var array */ public $keyval = array(); - + /** * Current uri string * * @var string */ public $uri_string; - + /** * List of uri segments * * @var array */ public $segments = array(); - + /** * Re-indexed list of uri segments * Starts at 1 instead of 0 @@ -72,6 +73,8 @@ class CI_URI { * Simply globalizes the $RTR object. The front * loads the Router class early on so it's not available * normally as other classes are. + * + * @return void */ public function __construct() { @@ -148,7 +151,7 @@ class CI_URI { return; } - $path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri); + $path = isset($_SERVER[$uri]) ? $_SERVER[$uri] : @getenv($uri); $this->_set_uri_string($path); } @@ -181,7 +184,7 @@ class CI_URI { */ protected function _detect_uri() { - if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME'])) + if ( ! isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])) { return ''; } @@ -227,20 +230,19 @@ class CI_URI { } // -------------------------------------------------------------------- - + /** * Is cli Request? * * Duplicate of function from the Input class to test to see if a request was made from the command line * - * @return boolean + * @return bool */ protected function _is_cli_request() { - return (php_sapi_name() == 'cli') OR defined('STDIN'); + return (php_sapi_name() === 'cli') OR defined('STDIN'); } - // -------------------------------------------------------------------- /** @@ -253,7 +255,7 @@ class CI_URI { protected function _parse_cli_args() { $args = array_slice($_SERVER['argv'], 1); - return $args ? '/' . implode('/', $args) : ''; + return $args ? '/'.implode('/', $args) : ''; } // -------------------------------------------------------------------- @@ -327,7 +329,7 @@ class CI_URI { } // -------------------------------------------------------------------- - + /** * Re-index Segments * @@ -355,13 +357,13 @@ class CI_URI { * * This function returns the URI segment based on the number provided. * - * @param integer + * @param int * @param bool * @return string */ public function segment($n, $no_result = FALSE) { - return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n]; + return isset($this->segments[$n]) ? $this->segments[$n] : $no_result; } // -------------------------------------------------------------------- @@ -370,16 +372,16 @@ class CI_URI { * Fetch a URI "routed" Segment * * This function returns the re-routed URI segment (assuming routing rules are used) - * based on the number provided. If there is no routing this function returns the + * based on the number provided. If there is no routing this function returns the * same result as $this->segment() * - * @param integer + * @param int * @param bool * @return string */ public function rsegment($n, $no_result = FALSE) { - return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n]; + return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result; } // -------------------------------------------------------------------- @@ -400,7 +402,7 @@ class CI_URI { * gender => male * ) * - * @param integer the starting segment number + * @param int the starting segment number * @param array an array of default values * @return array */ @@ -408,13 +410,13 @@ class CI_URI { { return $this->_uri_to_assoc($n, $default, 'segment'); } - + // -------------------------------------------------------------------- - + /** * Identical to above only it uses the re-routed segment array * - * @param integer the starting segment number + * @param int the starting segment number * @param array an array of default values * @return array */ @@ -428,7 +430,7 @@ class CI_URI { /** * Generate a key value pair from the URI string or Re-routed URI string * - * @param integer the starting segment number + * @param int the starting segment number * @param array an array of default values * @param string which array we should use * @return array @@ -458,12 +460,9 @@ class CI_URI { if ($this->$total_segments() < $n) { - if (count($default) === 0) - { - return array(); - } - - return array_fill_keys($default, FALSE); + return (count($default) === 0) + ? array() + : array_fill_keys($default, FALSE); } $segments = array_slice($this->$segment_array(), ($n - 1)); @@ -512,7 +511,7 @@ class CI_URI { public function assoc_to_uri($array) { $temp = array(); - foreach ((array)$array as $key => $val) + foreach ( (array) $array as $key => $val) { $temp[] = $key; $temp[] = $val; @@ -526,7 +525,7 @@ class CI_URI { /** * Fetch a URI Segment and add a trailing slash * - * @param integer + * @param int * @param string * @return string */ @@ -540,7 +539,7 @@ class CI_URI { /** * Fetch a URI Segment and add a trailing slash * - * @param integer + * @param int * @param string * @return string */ @@ -554,7 +553,7 @@ class CI_URI { /** * Fetch a URI Segment and add a trailing slash - helper function * - * @param integer + * @param int * @param string * @param string * @return string @@ -604,7 +603,7 @@ class CI_URI { /** * Total number of segments * - * @return integer + * @return int */ public function total_segments() { @@ -616,7 +615,7 @@ class CI_URI { /** * Total number of routed segments * - * @return integer + * @return int */ public function total_rsegments() { @@ -651,4 +650,4 @@ class CI_URI { } /* End of file URI.php */ -/* Location: ./system/core/URI.php */ +/* Location: ./system/core/URI.php */ \ No newline at end of file diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 122020aea..a6faa84ec 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -42,6 +42,8 @@ class CI_Utf8 { * Constructor * * Determines if UTF-8 support is to be enabled + * + * @return void */ public function __construct() { @@ -124,7 +126,7 @@ class CI_Utf8 { * Attempts to convert a string to UTF-8 * * @param string - * @param string - input encoding + * @param string input encoding * @return string */ public function convert_to_utf8($str, $encoding) -- cgit v1.2.3-24-g4f1b From 5645479c622eb36cf9869797896dc0921568c4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:32:19 +0300 Subject: Clean up the libraries --- system/libraries/Cache/Cache.php | 4 +- system/libraries/Cache/drivers/Cache_file.php | 2 + system/libraries/Cache/drivers/Cache_memcached.php | 4 +- system/libraries/Calendar.php | 41 ++-- system/libraries/Cart.php | 31 +-- system/libraries/Driver.php | 8 +- system/libraries/Email.php | 206 ++++++++--------- system/libraries/Encrypt.php | 12 +- system/libraries/Form_validation.php | 60 +++-- system/libraries/Ftp.php | 2 - system/libraries/Image_lib.php | 252 +++++++++++---------- system/libraries/Log.php | 18 +- system/libraries/Migration.php | 13 +- system/libraries/Pagination.php | 1 + system/libraries/Parser.php | 26 +-- system/libraries/Profiler.php | 1 + system/libraries/Session.php | 1 + system/libraries/Table.php | 16 +- system/libraries/Typography.php | 4 +- system/libraries/Unit_test.php | 4 +- system/libraries/Upload.php | 4 +- system/libraries/Xmlrpcs.php | 9 +- system/libraries/Zip.php | 12 +- system/libraries/javascript/Jquery.php | 66 +++--- 24 files changed, 383 insertions(+), 414 deletions(-) diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 0493d5a6e..ba732ee8e 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -55,14 +55,14 @@ class CI_Cache extends CI_Driver_Library { * @var string */ protected $_cache_path = NULL; - + /** * Reference to the driver * * @var mixed */ protected $_adapter = 'dummy'; - + /** * Fallback driver * diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index ec4195278..f0eb8bdf7 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -45,6 +45,8 @@ class CI_Cache_file extends CI_Driver { /** * Initialize file-based cache + * + * @return void */ public function __construct() { diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 813df4b1c..1df149c2d 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -77,7 +77,7 @@ class CI_Cache_memcached extends CI_Driver { * @param string unique identifier * @param mixed data being cached * @param int time to live - * @return bool true on success, false on failure + * @return bool true on success, false on failure */ public function save($id, $data, $ttl = 60) { @@ -99,7 +99,7 @@ class CI_Cache_memcached extends CI_Driver { * Delete from Cache * * @param mixed key to be deleted. - * @return bool true on success, false on failure + * @return bool true on success, false on failure */ public function delete($id) { diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 4db754f5e..92f372b20 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -44,55 +44,55 @@ class CI_Calendar { * @var object */ protected $CI; - + /** * 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; - + public $show_next_prev = FALSE; + /** * Url base to use for next/prev month links * * @var bool */ - public $next_prev_url = ''; + public $next_prev_url = ''; /** * Constructor @@ -187,7 +187,7 @@ class CI_Calendar { // Set the starting day of the week $start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6); - $start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day]; + $start_day = isset($start_days[$this->start_day]) ? $start_days[$this->start_day] : 0; // Set the starting day number $local_date = mktime(12, 0, 0, $month, 1, $year); @@ -290,9 +290,7 @@ class CI_Calendar { $out .= "\n".$this->temp['cal_row_end']."\n"; } - $out .= "\n".$this->temp['table_close']; - - return $out; + return $out .= "\n".$this->temp['table_close']; } // -------------------------------------------------------------------- @@ -317,14 +315,9 @@ class CI_Calendar { $month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december'); } - $month = $month_names[$month]; - - if ($this->CI->lang->line($month) === FALSE) - { - return ucfirst(substr($month, 4)); - } - - return $this->CI->lang->line($month); + return ($this->CI->lang->line($month_names[$month]) === FALSE) + ? ucfirst(substr($month_names[$month], 4)) + : $this->CI->lang->line($month_names[$month]); } // -------------------------------------------------------------------- @@ -345,11 +338,11 @@ class CI_Calendar { $this->day_type = $day_type; } - if ($this->day_type == 'long') + if ($this->day_type === 'long') { $day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); } - elseif ($this->day_type == 'short') + elseif ($this->day_type === 'short') { $day_names = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'); } @@ -448,7 +441,7 @@ class CI_Calendar { */ public function default_template() { - return array ( + return array( 'table_open' => '', 'heading_row_start' => '', 'heading_previous_cell' => '', diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index eee123584..b73ed5128 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -39,11 +39,11 @@ class CI_Cart { /** * 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 @@ -51,7 +51,7 @@ class CI_Cart { * @var string */ public $product_name_rules = '\.\:\-_ a-z0-9'; - + /** * only allow safe product names * @@ -62,14 +62,14 @@ class CI_Cart { // -------------------------------------------------------------------------- // Protected variables. Do not change! // -------------------------------------------------------------------------- - + /** * Reference to CodeIgniter instance * * @var object */ protected $CI; - + /** * Contents of the cart * @@ -83,6 +83,7 @@ class CI_Cart { * The constructor loads the Session class, used to store the shopping cart contents. * * @param array + * @return void */ public function __construct($params = array()) { @@ -180,7 +181,7 @@ class CI_Cart { // -------------------------------------------------------------------- // Does the $items array contain an id, quantity, price, and name? These are required - if ( ! isset($items['id']) OR ! isset($items['qty']) OR ! isset($items['price']) OR ! isset($items['name'])) + if ( ! isset($items['id'], $items['qty'], $items['price'], $items['name'])) { log_message('error', 'The cart array must contain a product ID, quantity, price, and name.'); return FALSE; @@ -341,7 +342,7 @@ class CI_Cart { protected function _update($items = array()) { // Without these array indexes there is nothing we can do - if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']])) + if ( ! isset($items['qty'], $items['rowid'], $this->_cart_contents[$items['rowid']])) { return FALSE; } @@ -383,7 +384,7 @@ class CI_Cart { foreach ($this->_cart_contents as $key => $val) { // We make sure the array contains the proper indexes - if ( ! is_array($val) OR ! isset($val['price']) OR ! isset($val['qty'])) + if ( ! is_array($val) OR ! isset($val['price'], $val['qty'])) { continue; } @@ -393,7 +394,7 @@ class CI_Cart { $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']); } - // Is our cart empty? If so we delete it from the session + // Is our cart empty? If so we delete it from the session if (count($this->_cart_contents) <= 2) { $this->CI->session->unset_userdata('cart_contents'); @@ -489,7 +490,7 @@ class CI_Cart { */ public function has_options($rowid = '') { - return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0) ? TRUE : FALSE; + return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0); } // -------------------------------------------------------------------- @@ -519,15 +520,7 @@ class CI_Cart { */ public function format_number($n = '') { - if ($n == '') - { - return ''; - } - - // Remove anything that isn't a number or decimal point. - $n = (float) $n; - - return number_format($n, 2, '.', ','); + return ($n == '') ? '' : number_format( (float) $n, 2, '.', ','); } // -------------------------------------------------------------------- diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index b1fff154d..c79698c7b 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -45,7 +45,7 @@ class CI_Driver_Library { * @var array */ protected $valid_drivers = array(); - + /** * Name of the current class - usually the driver class * @@ -57,8 +57,8 @@ class CI_Driver_Library { * 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 + * @param mixed $child + * @return mixed */ public function __get($child) { @@ -145,7 +145,7 @@ class CI_Driver { * @var array */ protected $_methods = array(); - + /** * List of properties in the parent class * diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 103c3cb25..56d60c802 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -93,6 +93,8 @@ class CI_Email { * Constructor - Sets Email Preferences * * The constructor can be passed an array of config values + * + * @return void */ public function __construct($config = array()) { @@ -303,8 +305,7 @@ class CI_Email { */ public function cc($cc) { - $cc = $this->_str_to_array($cc); - $cc = $this->clean_email($cc); + $cc = $this->clean_email($this->_str_to_array($cc)); if ($this->validate) { @@ -338,8 +339,7 @@ class CI_Email { $this->bcc_batch_size = $limit; } - $bcc = $this->_str_to_array($bcc); - $bcc = $this->clean_email($bcc); + $bcc = $this->clean_email($this->_str_to_array($bcc)); if ($this->validate) { @@ -441,15 +441,11 @@ class CI_Email { { if ( ! is_array($email)) { - if (strpos($email, ',') !== FALSE) - { - $email = preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY); - } - else - { - $email = (array) trim($email); - } + return (strpos($email, ',') !== FALSE) + ? preg_split('/[\s,]/', $email, -1, PREG_SPLIT_NO_EMPTY) + : (array) trim($email); } + return $email; } @@ -477,7 +473,7 @@ class CI_Email { */ public function set_mailtype($type = 'text') { - $this->mailtype = ($type == 'html') ? 'html' : 'text'; + $this->mailtype = ($type === 'html') ? 'html' : 'text'; return $this; } @@ -574,7 +570,7 @@ class CI_Email { protected function _get_message_id() { $from = str_replace(array('>', '<'), '', $this->_headers['Return-Path']); - return '<'.uniqid('').strstr($from, '@').'>'; + return '<'.uniqid('').strstr($from, '@').'>'; } // -------------------------------------------------------------------- @@ -631,13 +627,9 @@ class CI_Email { */ protected function _get_content_type() { - if ($this->mailtype === 'html' && count($this->_attach_name) === 0) - { - return 'html'; - } - elseif ($this->mailtype === 'html' && count($this->_attach_name) > 0) + if ($this->mailtype === 'html') { - return 'html-attach'; + return (count($this->_attach_name) == 0) ? 'html' : 'html-attach'; } elseif ($this->mailtype === 'text' && count($this->_attach_name) > 0) { @@ -731,7 +723,7 @@ class CI_Email { { if ( ! is_array($email)) { - return (preg_match('/\<(.*)\>/', $email, $match)) ? $match[1] : $email; + return preg_match('/\<(.*)\>/', $email, $match) ? $match[1] : $email; } $clean_email = array(); @@ -763,7 +755,7 @@ class CI_Email { return $this->word_wrap($this->alt_message, '76'); } - $body = (preg_match('/\(.*)\<\/body\>/si', $this->_body, $match)) ? $match[1] : $this->_body; + $body = preg_match('/\(.*)\<\/body\>/si', $this->_body, $match) ? $match[1] : $this->_body; $body = str_replace("\t", '', preg_replace('# '.$msg."\n"; + $message .= $level.' '.($level === 'INFO' ? ' -' : '-').' '.date($this->_date_fmt).' --> '.$msg."\n"; flock($fp, LOCK_EX); fwrite($fp, $message); diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index ce4683fc1..0a88e6926 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -45,28 +45,28 @@ class CI_Migration { * @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 * @@ -85,6 +85,7 @@ class CI_Migration { * Initialize Migration Class * * @param array + * @return void */ public function __construct($config = array()) { @@ -96,7 +97,7 @@ class CI_Migration { foreach ($config as $key => $val) { - $this->{'_' . $key} = $val; + $this->{'_'.$key} = $val; } log_message('debug', 'Migrations class initialized'); @@ -340,7 +341,6 @@ class CI_Migration { } sort($files); - return $files; } @@ -384,6 +384,7 @@ class CI_Migration { { return get_instance()->$var; } + } /* End of file Migration.php */ diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 3d2911813..58f86fa17 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -73,6 +73,7 @@ class CI_Pagination { * Constructor * * @param array initialization parameters + * @return void */ public function __construct($params = array()) { diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index c40f339b4..a0b60ed97 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -42,14 +42,14 @@ class CI_Parser { * @var string */ public $l_delim = '{'; - + /** * Right delimeter character for psuedo vars * * @var string */ public $r_delim = '}'; - + /** * Reference to CodeIgniter instance * @@ -116,14 +116,9 @@ class CI_Parser { foreach ($data as $key => $val) { - if (is_array($val)) - { - $template = $this->_parse_pair($key, $val, $template); - } - else - { - $template = $this->_parse_single($key, (string)$val, $template); - } + $template = is_array($val) + ? $this->_parse_pair($key, $val, $template) + : $template = $this->_parse_single($key, (string) $val, $template); } if ($return == FALSE) @@ -189,14 +184,9 @@ class CI_Parser { $temp = $match[1]; foreach ($row as $key => $val) { - if ( ! is_array($val)) - { - $temp = $this->_parse_single($key, $val, $temp); - } - else - { - $temp = $this->_parse_pair($key, $val, $temp); - } + $temp = is_array($val) + ? $this->_parse_pair($key, $val, $temp) + : $this->_parse_single($key, $val, $temp); } $str .= $temp; diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 1e86f3c61..e219d20f2 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -527,6 +527,7 @@ class CI_Profiler { return $output.''; } + } /* End of file Profiler.php */ diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 3195f0a91..783109a60 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -190,6 +190,7 @@ class CI_Session { * whenever the class is instantiated. * * @param array + * @return void */ public function __construct($params = array()) { diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 236129531..f844d6435 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -44,49 +44,49 @@ class CI_Table { * @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 + * 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 * diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 50bd12486..6aaa993ae 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -38,7 +38,7 @@ class CI_Typography { /** * 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'; @@ -52,7 +52,7 @@ class CI_Typography { /** * 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'; diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 0f6e2dfdd..6ec2dcd5d 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -350,11 +350,11 @@ class CI_Unit_test { */ function is_true($test) { - return (is_bool($test) && $test === TRUE); + return ($test === TRUE); } function is_false($test) { - return (is_bool($test) && $test === FALSE); + return ($test === FALSE); } /* End of file Unit_test.php */ diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 24d4bd4d0..271c6d21f 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1036,7 +1036,7 @@ class CI_Upload { */ if (DIRECTORY_SEPARATOR !== '\\') { - $cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1'; + $cmd = 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1'; if (function_exists('exec')) { @@ -1103,4 +1103,4 @@ class CI_Upload { } /* End of file Upload.php */ -/* Location: ./system/libraries/Upload.php */ +/* Location: ./system/libraries/Upload.php */ \ No newline at end of file diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index f0c5b48e7..1853906ea 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -54,21 +54,21 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @var array */ public $methods = array(); - + /** * Debug Message * * @var string */ public $debug_msg = ''; - + /** * XML RPC Server methods * * @var array */ public $system_methods = array(); - + /** * Configuration object * @@ -79,7 +79,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc /** * Initialize XMLRPC class * - * @param array $config + * @param array $config + * @return void */ public function __construct($config = array()) { diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 86d0787b2..e0dc637ad 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -48,35 +48,35 @@ class CI_Zip { * @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 * @@ -87,7 +87,7 @@ class CI_Zip { /** * Initialize zip compression class * - * @return void + * @return void */ public function __construct() { diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index f30d7c639..3c9ae1867 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Jquery Class * @@ -57,7 +55,7 @@ class CI_Jquery extends CI_Javascript { $this->script(); } - log_message('debug', "Jquery Class Initialized"); + log_message('debug', 'Jquery Class Initialized'); } // -------------------------------------------------------------------- @@ -115,7 +113,7 @@ class CI_Jquery extends CI_Javascript { if ($ret_false) { - $js[] = "return false;"; + $js[] = 'return false;'; } return $this->_add_event($element, $js, 'click'); @@ -183,7 +181,7 @@ class CI_Jquery extends CI_Javascript { */ protected function _hover($element = 'this', $over, $out) { - $event = "\n\t$(" . $this->_prep_element($element) . ").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n"; + $event = "\n\t$(".$this->_prep_element($element).").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n"; $this->jquery_code_for_compile[] = $event; @@ -322,7 +320,7 @@ class CI_Jquery extends CI_Javascript { foreach ($array_js as $js) { - $this->jquery_code_for_compile[] = "\t$js\n"; + $this->jquery_code_for_compile[] = "\t".$js."\n"; } } @@ -389,7 +387,7 @@ class CI_Jquery extends CI_Javascript { protected function _addClass($element = 'this', $class='') { $element = $this->_prep_element($element); - return "$({$element}).addClass(\"$class\");"; + return '$('.$element.').addClass("'.$class.'");'; } // -------------------------------------------------------------------- @@ -411,9 +409,9 @@ class CI_Jquery extends CI_Javascript { $animations = "\t\t\t"; - foreach ($params as $param=>$value) + foreach ($params as $param => $value) { - $animations .= $param.': \''.$value.'\', '; + $animations .= $param.": '".$value."', "; } $animations = substr($animations, 0, -2); // remove the last ", " @@ -428,7 +426,7 @@ class CI_Jquery extends CI_Javascript { $extra = ', '.$extra; } - return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; + return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.');'; } // -------------------------------------------------------------------- @@ -478,7 +476,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).fadeOut({$speed}{$callback});"; + return '$('.$element.').fadeOut('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -519,7 +517,7 @@ class CI_Jquery extends CI_Javascript { protected function _removeClass($element = 'this', $class='') { $element = $this->_prep_element($element); - return "$({$element}).removeClass(\"$class\");"; + return '$('.$element.').removeClass("'.$class.'");'; } // -------------------------------------------------------------------- @@ -544,7 +542,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).slideUp({$speed}{$callback});"; + return '$('.$element.').slideUp('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -569,7 +567,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).slideDown({$speed}{$callback});"; + return '$('.$element.').slideDown('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -594,7 +592,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).slideToggle({$speed}{$callback});"; + return '$('.$element.').slideToggle('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -610,7 +608,7 @@ class CI_Jquery extends CI_Javascript { protected function _toggle($element = 'this') { $element = $this->_prep_element($element); - return "$({$element}).toggle();"; + return '$('.$element.').toggle();'; } // -------------------------------------------------------------------- @@ -626,7 +624,7 @@ class CI_Jquery extends CI_Javascript { protected function _toggleClass($element = 'this', $class='') { $element = $this->_prep_element($element); - return "$({$element}).toggleClass(\"$class\");"; + return '$('.$element.').toggleClass("'.$class.'");'; } // -------------------------------------------------------------------- @@ -651,7 +649,7 @@ class CI_Jquery extends CI_Javascript { $callback = ", function(){\n{$callback}\n}"; } - return "$({$element}).show({$speed}{$callback});"; + return '$('.$element.').show('.$speed.$callback.');'; } // -------------------------------------------------------------------- @@ -676,22 +674,22 @@ class CI_Jquery extends CI_Javascript { // ajaxStart and ajaxStop are better choices here... but this is a stop gap if ($this->CI->config->item('javascript_ajax_img') == '') { - $loading_notifier = "Loading..."; + $loading_notifier = 'Loading...'; } else { - $loading_notifier = 'CI->config->slash_item('base_url').$this->CI->config->item('javascript_ajax_img').'\' alt=\'Loading\' />'; + $loading_notifier = 'Loading'; } - $updater = "$($container).empty();\n" // anything that was in... get it out - . "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image + $updater = '$('.$container.").empty();\n" // anything that was in... get it out + ."\t\t$(".$container.').prepend("'.$loading_notifier."\");\n"; // to replace with an image $request_options = ''; if ($options != '') { $request_options .= ', {' - . (is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'") - . '}'; + .(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'") + .'}'; } return $updater."\t\t$($container).load('$controller'$request_options);"; @@ -746,7 +744,7 @@ class CI_Jquery extends CI_Javascript { $corner_style = '"'.$corner_style.'"'; } - return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");"; + return '$('.$this->_prep_element($element).').corner('.$corner_style.');'; } // -------------------------------------------------------------------- @@ -821,16 +819,16 @@ class CI_Jquery extends CI_Javascript { $sort_options = array(); foreach ($options as $k=>$v) { - $sort_options[] = "\n\t\t".$k.': '.$v.""; + $sort_options[] = "\n\t\t".$k.': '.$v; } - $sort_options = implode(",", $sort_options); + $sort_options = implode(',', $sort_options); } else { $sort_options = ''; } - return "$(" . $this->_prep_element($element) . ").sortable({".$sort_options."\n\t});"; + return '$('.$this->_prep_element($element).').sortable({'.$sort_options."\n\t});"; } // -------------------------------------------------------------------- @@ -844,7 +842,7 @@ class CI_Jquery extends CI_Javascript { */ public function tablesorter($table = '', $options = '') { - $this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n"; + $this->jquery_code_for_compile[] = "\t$(".$this->_prep_element($table).').tablesorter('.$options.");\n"; } // -------------------------------------------------------------------- @@ -869,7 +867,7 @@ class CI_Jquery extends CI_Javascript { } - $event = "\n\t$(" . $this->_prep_element($element) . ").{$event}(function(){\n\t\t{$js}\n\t});\n"; + $event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n"; $this->jquery_code_for_compile[] = $event; return $event; } @@ -898,8 +896,8 @@ class CI_Jquery extends CI_Javascript { // Inline references $script = '$(document).ready(function() {'."\n" - . implode('', $this->jquery_code_for_compile) - . '});'; + .implode('', $this->jquery_code_for_compile) + .'});'; $output = ($script_tags === FALSE) ? $script : $this->inline($script); @@ -998,7 +996,7 @@ class CI_Jquery extends CI_Javascript { { return '"'.$speed.'"'; } - elseif (preg_match("/[^0-9]/", $speed)) + elseif (preg_match('/[^0-9]/', $speed)) { return ''; } @@ -1009,4 +1007,4 @@ class CI_Jquery extends CI_Javascript { } /* End of file Jquery.php */ -/* Location: ./system/libraries/Jquery.php */ +/* Location: ./system/libraries/Jquery.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From ae31eb5e75d914fc3ab622a7ac5c23eb1e6d9f9a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:54:15 +0300 Subject: Clean up the helpers --- system/helpers/date_helper.php | 65 ++++++++++++++++++------------------- system/helpers/download_helper.php | 2 +- system/helpers/form_helper.php | 1 - system/helpers/html_helper.php | 8 ++--- system/helpers/inflector_helper.php | 2 +- system/helpers/url_helper.php | 4 +-- 6 files changed, 39 insertions(+), 43 deletions(-) diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 531d1d32f..5f0427f7d 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -100,7 +100,7 @@ if ( ! function_exists('mdate')) $datestr = str_replace( '%\\', '', - preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr) + preg_replace('/([a-z]+?){1}/i', '\\\\\\1', $datestr) ); return date($datestr, $time); @@ -316,12 +316,12 @@ if ( ! function_exists('local_to_gmt')) } return mktime( - gmdate("H", $time), - gmdate("i", $time), - gmdate("s", $time), - gmdate("m", $time), - gmdate("d", $time), - gmdate("Y", $time) + gmdate('H', $time), + gmdate('i', $time), + gmdate('s', $time), + gmdate('m', $time), + gmdate('d', $time), + gmdate('Y', $time) ); } } @@ -452,8 +452,7 @@ if ( ! function_exists('human_to_unix')) return FALSE; } - $datestr = trim($datestr); - $datestr = preg_replace("/\040+/", ' ', $datestr); + $datestr = preg_replace('/\040+/', ' ', trim($datestr)); if ( ! preg_match('/^[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', $datestr)) { @@ -462,20 +461,20 @@ if ( ! function_exists('human_to_unix')) $split = explode(' ', $datestr); - $ex = explode("-", $split['0']); + $ex = explode('-', $split['0']); - $year = (strlen($ex['0']) == 2) ? '20'.$ex['0'] : $ex['0']; - $month = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1']; - $day = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2']; + $year = (strlen($ex[0]) === 2) ? '20'.$ex[0] : $ex[0]; + $month = (strlen($ex[1]) === 1) ? '0'.$ex[1] : $ex[1]; + $day = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2]; - $ex = explode(":", $split['1']); + $ex = explode(':', $split['1']); - $hour = (strlen($ex['0']) == 1) ? '0'.$ex['0'] : $ex['0']; - $min = (strlen($ex['1']) == 1) ? '0'.$ex['1'] : $ex['1']; + $hour = (strlen($ex[0]) === 1) ? '0'.$ex[0] : $ex[0]; + $min = (strlen($ex[1]) === 1) ? '0'.$ex[1] : $ex[1]; - if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex['2'])) + if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex[2])) { - $sec = (strlen($ex['2']) == 1) ? '0'.$ex['2'] : $ex['2']; + $sec = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2]; } else { @@ -485,11 +484,11 @@ if ( ! function_exists('human_to_unix')) if (isset($split['2'])) { - $ampm = strtolower($split['2']); + $ampm = strtolower($split[2]); if (substr($ampm, 0, 1) === 'p' && $hour < 12) { - $hour = $hour + 12; + $hour += 12; } if (substr($ampm, 0, 1) === 'a' && $hour == 12) @@ -497,7 +496,7 @@ if ( ! function_exists('human_to_unix')) $hour = '00'; } - if (strlen($hour) == 1) + if (strlen($hour) === 1) { $hour = '0'.$hour; } @@ -529,7 +528,7 @@ if ( ! function_exists('nice_date')) // Date like: YYYYMM if (preg_match('/^\d{6}$/', $bad_date)) { - if (in_array(substr($bad_date, 0, 2),array('19', '20'))) + if (in_array(substr($bad_date, 0, 2), array('19', '20'))) { $year = substr($bad_date, 0, 4); $month = substr($bad_date, 4, 2); @@ -540,24 +539,24 @@ if ( ! function_exists('nice_date')) $year = substr($bad_date, 2, 4); } - return date($format, strtotime($year . '-' . $month . '-01')); + return date($format, strtotime($year.'-'.$month.'-01')); } // Date Like: YYYYMMDD - if (preg_match('/^\d{8}$/',$bad_date)) + if (preg_match('/^\d{8}$/', $bad_date)) { $month = substr($bad_date, 0, 2); $day = substr($bad_date, 2, 2); $year = substr($bad_date, 4, 4); - return date($format, strtotime($month . '/01/' . $year)); + return date($format, strtotime($month.'/01/'.$year)); } // Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between) - if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/',$bad_date)) + if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/', $bad_date)) { list($m, $d, $y) = explode('-', $bad_date); - return date($format, strtotime("{$y}-{$m}-{$d}")); + return date($format, strtotime($y.'-'.$m.'-'.$d)); } // Any other kind of string, when converted into UNIX time, @@ -565,7 +564,7 @@ if ( ! function_exists('nice_date')) // return "Invalid Date". if (date('U', strtotime($bad_date)) == '0') { - return "Invalid Date"; + return 'Invalid Date'; } // It's probably a valid-ish date format already @@ -587,7 +586,7 @@ if ( ! function_exists('timezone_menu')) * @param string menu name * @return string */ - function timezone_menu($default = 'UTC', $class = "", $name = 'timezones') + function timezone_menu($default = 'UTC', $class = '', $name = 'timezones') { $CI =& get_instance(); $CI->lang->load('date'); @@ -605,13 +604,11 @@ if ( ! function_exists('timezone_menu')) foreach (timezones() as $key => $val) { - $selected = ($default == $key) ? " selected='selected'" : ''; - $menu .= "\n"; + $selected = ($default == $key) ? ' selected="selected"' : ''; + $menu .= '\n"; } - $menu .= ""; - - return $menu; + return $menu.''; } } diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 97e6986b0..470b61ede 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -100,7 +100,7 @@ if ( ! function_exists('force_download')) $x[count($x) - 1] = strtoupper($extension); $filename = implode('.', $x); } - + // Clean output buffer ob_clean(); diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index b246d72f3..eca6c5f1e 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -184,7 +184,6 @@ if ( ! function_exists('form_input')) // ------------------------------------------------------------------------ - if ( ! function_exists('form_password')) { /** diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 124f58009..92a6db477 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -379,10 +379,10 @@ if ( ! function_exists('meta')) $str = ''; foreach ($name as $meta) { - $type = ( ! isset($meta['type']) OR $meta['type'] == 'name') ? 'name' : 'http-equiv'; - $name = ( ! isset($meta['name'])) ? '' : $meta['name']; - $content = ( ! isset($meta['content'])) ? '' : $meta['content']; - $newline = ( ! isset($meta['newline'])) ? "\n" : $meta['newline']; + $type = ( ! isset($meta['type']) OR $meta['type'] === 'name') ? 'name' : 'http-equiv'; + $name = isset($meta['name']) ? $meta['name'] : ''; + $content = isset($meta['content']) ? $meta['content'] : ''; + $newline = isset($meta['newline']) ? $meta['newline'] : "\n"; $str .= ''.$newline; } diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index feeaf57d7..2a9466305 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -201,7 +201,7 @@ if ( ! function_exists('underscore')) * * @param string $str * @param string $separator - * @return str + * @return string */ if ( ! function_exists('humanize')) { diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 5576c2748..cf6df4ef5 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -198,7 +198,7 @@ if ( ! function_exists('anchor_popup')) if ($attributes === FALSE) { - return "".$title.''; + return '".$title.''; } if ( ! is_array($attributes)) @@ -217,7 +217,7 @@ if ( ! function_exists('anchor_popup')) $attributes = _parse_attributes($attributes); } - return "'.$title.''; + return ''.$title.''; } } -- cgit v1.2.3-24-g4f1b From 16642c71403f4463dfe6e83c13a0e3120474cd1d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 08:20:16 -0400 Subject: Update inflector docblocks, add changelog entry --- system/helpers/inflector_helper.php | 10 +++++----- user_guide_src/source/changelog.rst | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 72615671c..647d840e4 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -45,7 +45,7 @@ if ( ! function_exists('singular')) * Takes a plural word and makes it singular * * @param string - * @return str + * @return string */ function singular($str) { @@ -110,7 +110,7 @@ if ( ! function_exists('plural')) * * @param string * @param bool - * @return str + * @return string */ function plural($str, $force = FALSE) { @@ -166,7 +166,7 @@ if ( ! function_exists('camelize')) * Takes multiple words separated by spaces or underscores and camelizes them * * @param string - * @return str + * @return string */ function camelize($str) { @@ -184,7 +184,7 @@ if ( ! function_exists('underscore')) * Takes multiple words separated by spaces and underscores them * * @param string - * @return str + * @return string */ function underscore($str) { @@ -203,7 +203,7 @@ if ( ! function_exists('humanize')) * * @param string $str * @param string $separator - * @return str + * @return string */ function humanize($str, $separator = '_') { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d33a6a635..0066af9ad 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -52,6 +52,7 @@ Release Date: Not Released - set_realpath() can now also handle file paths as opposed to just directories. - do_hash() now uses PHP's native hash() function, supporting more algorithms. - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html. + - Removed deprecated helper function ``js_insert_smiley`` from smiley helper. - Database -- cgit v1.2.3-24-g4f1b From f0eb2f133bf43be7ffa1bf71babf4ed28852e71b Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 08:32:11 -0400 Subject: Suggested changes --- system/helpers/number_helper.php | 2 +- system/helpers/smiley_helper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php index 2a906ba1b..e49f2f7a0 100644 --- a/system/helpers/number_helper.php +++ b/system/helpers/number_helper.php @@ -42,7 +42,7 @@ if ( ! function_exists('byte_format')) /** * Formats a numbers as bytes, based on size, and adds the appropriate suffix * - * @param mixed // will be cast as int + * @param mixed will be cast as int * @param int * @return string */ diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 4320dd392..5e6de08af 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -130,7 +130,7 @@ if ( ! function_exists('get_clickable_smileys')) * * @param string the URL to the folder containing the smiley images * @param array - * @param array + * @param array * @return array */ function get_clickable_smileys($image_url, $alias = '', $smileys = NULL) -- cgit v1.2.3-24-g4f1b From 98fde46fb938694feb1f36e590c4cfa5c97c3261 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 17 May 2012 08:33:05 -0400 Subject: Add parens to changelog entry --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 0066af9ad..7fc5ee5a0 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -52,7 +52,7 @@ Release Date: Not Released - set_realpath() can now also handle file paths as opposed to just directories. - do_hash() now uses PHP's native hash() function, supporting more algorithms. - Added an optional paramater to ``delete_files()`` to enable it to skip deleting files such as .htaccess and index.html. - - Removed deprecated helper function ``js_insert_smiley`` from smiley helper. + - Removed deprecated helper function ``js_insert_smiley()`` from smiley helper. - Database -- cgit v1.2.3-24-g4f1b

<<