summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/array_helper.php47
-rw-r--r--system/helpers/captcha_helper.php152
-rw-r--r--system/helpers/cookie_helper.php32
-rw-r--r--system/helpers/date_helper.php116
-rw-r--r--system/helpers/directory_helper.php18
-rw-r--r--system/helpers/download_helper.php93
-rw-r--r--system/helpers/email_helper.php12
-rw-r--r--system/helpers/file_helper.php29
-rw-r--r--system/helpers/form_helper.php141
-rw-r--r--system/helpers/html_helper.php68
-rw-r--r--system/helpers/inflector_helper.php161
-rw-r--r--system/helpers/language_helper.php9
-rw-r--r--system/helpers/number_helper.php7
-rw-r--r--system/helpers/path_helper.php23
-rw-r--r--system/helpers/security_helper.php20
-rw-r--r--system/helpers/smiley_helper.php22
-rw-r--r--system/helpers/string_helper.php53
-rw-r--r--system/helpers/text_helper.php57
-rw-r--r--system/helpers/typography_helper.php10
-rw-r--r--system/helpers/url_helper.php75
-rw-r--r--system/helpers/xml_helper.php16
21 files changed, 489 insertions, 672 deletions
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
index c46c4d103..6f56d9db9 100644
--- a/system/helpers/array_helper.php
+++ b/system/helpers/array_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Array Helpers
*
@@ -45,7 +43,6 @@
* Lets you determine whether an array index is set and whether it has a value.
* If the element is empty it returns FALSE (or whatever you specify as the default value.)
*
- * @access public
* @param string
* @param array
* @param mixed
@@ -55,12 +52,7 @@ if ( ! function_exists('element'))
{
function element($item, $array, $default = FALSE)
{
- if ( ! isset($array[$item]) OR $array[$item] == "")
- {
- return $default;
- }
-
- return $array[$item];
+ return empty($array[$item]) ? $default : $array[$item];
}
}
@@ -69,7 +61,6 @@ if ( ! function_exists('element'))
/**
* Random Element - Takes an array as input and returns a random element
*
- * @access public
* @param array
* @return mixed depends on what the array contains
*/
@@ -77,12 +68,7 @@ if ( ! function_exists('random_element'))
{
function random_element($array)
{
- if ( ! is_array($array))
- {
- return $array;
- }
-
- return $array[array_rand($array)];
+ return is_array($array) ? $array[array_rand($array)] : $array;
}
}
@@ -91,10 +77,9 @@ if ( ! function_exists('random_element'))
/**
* Elements
*
- * Returns only the array items specified. Will return a default value if
+ * Returns only the array items specified. Will return a default value if
* it is not set.
*
- * @access public
* @param array
* @param array
* @param mixed
@@ -105,22 +90,12 @@ if ( ! function_exists('elements'))
function elements($items, $array, $default = FALSE)
{
$return = array();
-
- if ( ! is_array($items))
- {
- $items = array($items);
- }
-
+
+ is_array($items) OR $items = array($items);
+
foreach ($items as $item)
{
- if (isset($array[$item]))
- {
- $return[$item] = $array[$item];
- }
- else
- {
- $return[$item] = $default;
- }
+ $return[$item] = isset($array[$item]) ? $array[$item] : $default;
}
return $return;
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 668b034d4..bdbc62097 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter CAPTCHA Helper
*
@@ -42,7 +40,6 @@
/**
* Create CAPTCHA
*
- * @access public
* @param array array of data for the CAPTCHA
* @param string path to create the image in
* @param string URL to the CAPTCHA image folder
@@ -57,35 +54,19 @@ if ( ! function_exists('create_captcha'))
foreach ($defaults as $key => $val)
{
- if ( ! is_array($data))
+ if ( ! is_array($data) && empty($$key))
{
- if ( ! isset($$key) OR $$key == '')
- {
- $$key = $val;
- }
+ $$key = $val;
}
else
{
- $$key = ( ! isset($data[$key])) ? $val : $data[$key];
+ $$key = isset($data[$key]) ? $data[$key] : $val;
}
}
- if ($img_path == '' OR $img_url == '')
- {
- return FALSE;
- }
-
- if ( ! @is_dir($img_path))
- {
- return FALSE;
- }
-
- if ( ! is_writable($img_path))
- {
- return FALSE;
- }
-
- if ( ! extension_loaded('gd'))
+ if ($img_path == '' OR $img_url == ''
+ OR ! @is_dir($img_path) OR ! is_writeable($img_path)
+ OR ! extension_loaded('gd'))
{
return FALSE;
}
@@ -94,21 +75,15 @@ if ( ! function_exists('create_captcha'))
// Remove old images
// -----------------------------------
- list($usec, $sec) = explode(" ", microtime());
- $now = ((float)$usec + (float)$sec);
+ $now = microtime(TRUE);
$current_dir = @opendir($img_path);
-
while ($filename = @readdir($current_dir))
{
- if ($filename != "." and $filename != ".." and $filename != "index.html")
+ if ($filename !== '.' && $filename !== '..' && $filename !== 'index.html'
+ && (str_replace('.jpg', '', $filename) + $expiration) < $now)
{
- $name = str_replace(".jpg", "", $filename);
-
- if (($name + $expiration) < $now)
- {
- @unlink($img_path.$filename);
- }
+ @unlink($img_path.$filename);
}
}
@@ -118,141 +93,114 @@ if ( ! function_exists('create_captcha'))
// Do we have a "word" yet?
// -----------------------------------
- if ($word == '')
- {
+ if ($word == '')
+ {
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-
- $str = '';
- for ($i = 0; $i < 8; $i++)
+ $word = '';
+ for ($i = 0, $mt_rand_max = strlen($pool) - 1; $i < 8; $i++)
{
- $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
+ $word .= $pool[mt_rand(0, $mt_rand_max)];
}
-
- $word = $str;
- }
+ }
// -----------------------------------
// Determine angle and position
// -----------------------------------
-
$length = strlen($word);
$angle = ($length >= 6) ? rand(-($length-6), ($length-6)) : 0;
$x_axis = rand(6, (360/$length)-16);
- $y_axis = ($angle >= 0 ) ? rand($img_height, $img_width) : rand(6, $img_height);
+ $y_axis = ($angle >= 0) ? rand($img_height, $img_width) : rand(6, $img_height);
- // -----------------------------------
// Create image
- // -----------------------------------
-
// PHP.net recommends imagecreatetruecolor(), but it isn't always available
- if (function_exists('imagecreatetruecolor'))
- {
- $im = imagecreatetruecolor($img_width, $img_height);
- }
- else
- {
- $im = imagecreate($img_width, $img_height);
- }
+ $im = function_exists('imagecreatetruecolor')
+ ? imagecreatetruecolor($img_width, $img_height)
+ : imagecreate($img_width, $img_height);
// -----------------------------------
// Assign colors
// -----------------------------------
-
- $bg_color = imagecolorallocate ($im, 255, 255, 255);
- $border_color = imagecolorallocate ($im, 153, 102, 102);
- $text_color = imagecolorallocate ($im, 204, 153, 153);
- $grid_color = imagecolorallocate($im, 255, 182, 182);
+ $bg_color = imagecolorallocate($im, 255, 255, 255);
+ $border_color = imagecolorallocate($im, 153, 102, 102);
+ $text_color = imagecolorallocate($im, 204, 153, 153);
+ $grid_color = imagecolorallocate($im, 255, 182, 182);
$shadow_color = imagecolorallocate($im, 255, 240, 240);
- // -----------------------------------
// Create the rectangle
- // -----------------------------------
-
ImageFilledRectangle($im, 0, 0, $img_width, $img_height, $bg_color);
// -----------------------------------
// Create the spiral pattern
// -----------------------------------
-
$theta = 1;
$thetac = 7;
$radius = 16;
$circles = 20;
$points = 32;
- for ($i = 0; $i < ($circles * $points) - 1; $i++)
+ for ($i = 0, $cp = ($circles * $points) - 1; $i < $cp; $i++)
{
- $theta = $theta + $thetac;
- $rad = $radius * ($i / $points );
+ $theta += $thetac;
+ $rad = $radius * ($i / $points);
$x = ($rad * cos($theta)) + $x_axis;
$y = ($rad * sin($theta)) + $y_axis;
- $theta = $theta + $thetac;
+ $theta += $thetac;
$rad1 = $radius * (($i + 1) / $points);
$x1 = ($rad1 * cos($theta)) + $x_axis;
- $y1 = ($rad1 * sin($theta )) + $y_axis;
+ $y1 = ($rad1 * sin($theta)) + $y_axis;
imageline($im, $x, $y, $x1, $y1, $grid_color);
- $theta = $theta - $thetac;
+ $theta -= $thetac;
}
// -----------------------------------
// Write the text
// -----------------------------------
- $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE;
-
- if ($use_font == FALSE)
+ $use_font = ($font_path != '' && file_exists($font_path) && function_exists('imagettftext'));
+ if ($use_font === FALSE)
{
$font_size = 5;
- $x = rand(0, $img_width/($length/3));
+ $x = rand(0, $img_width / ($length / 3));
$y = 0;
}
else
{
- $font_size = 16;
- $x = rand(0, $img_width/($length/1.5));
- $y = $font_size+2;
+ $font_size = 16;
+ $x = rand(0, $img_width / ($length / 1.5));
+ $y = $font_size + 2;
}
- for ($i = 0; $i < strlen($word); $i++)
+ for ($i = 0; $i < $length; $i++)
{
- if ($use_font == FALSE)
+ if ($use_font === FALSE)
{
- $y = rand(0 , $img_height/2);
- imagestring($im, $font_size, $x, $y, substr($word, $i, 1), $text_color);
- $x += ($font_size*2);
+ $y = rand(0 , $img_height / 2);
+ imagestring($im, $font_size, $x, $y, $word[$i], $text_color);
+ $x += ($font_size * 2);
}
else
{
- $y = rand($img_height/2, $img_height-3);
- imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, substr($word, $i, 1));
+ $y = rand($img_height / 2, $img_height - 3);
+ imagettftext($im, $font_size, $angle, $x, $y, $text_color, $font_path, $word[$i]);
$x += $font_size;
}
}
- // -----------------------------------
- // Create the border
- // -----------------------------------
-
- imagerectangle($im, 0, 0, $img_width-1, $img_height-1, $border_color);
+ // Create the border
+ imagerectangle($im, 0, 0, $img_width - 1, $img_height - 1, $border_color);
// -----------------------------------
// Generate the image
// -----------------------------------
-
$img_name = $now.'.jpg';
-
ImageJPEG($im, $img_path.$img_name);
-
- $img = "<img src=\"$img_url$img_name\" width=\"$img_width\" height=\"$img_height\" style=\"border:0;\" alt=\" \" />";
-
+ $img = '<img src="'.$img_url.$img_name.'" style="width: '.$img_width.'; height: '.$img_height .'; border: 0;" alt=" " />';
ImageDestroy($im);
return array('word' => $word, 'time' => $now, 'image' => $img);
}
}
-// ------------------------------------------------------------------------
-
/* End of file captcha_helper.php */
/* Location: ./system/helpers/captcha_helper.php */ \ No newline at end of file
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index 7b439c47f..06560e723 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Cookie Helpers
*
@@ -42,25 +40,26 @@
/**
* Set cookie
*
- * Accepts six parameter, or you can submit an associative
+ * Accepts seven parameters, or you can submit an associative
* array in the first parameter containing all the values.
*
- * @access public
* @param mixed
* @param string the value of the cookie
* @param string the number of seconds until expiration
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
+ * @param bool true makes the cookie secure
+ * @param bool true makes the cookie accessible via http(s) only (no javascript)
* @return void
*/
if ( ! function_exists('set_cookie'))
{
- function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
+ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
{
// Set the config file options
$CI =& get_instance();
- $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
+ $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly);
}
}
@@ -69,7 +68,6 @@ if ( ! function_exists('set_cookie'))
/**
* Fetch an item from the COOKIE array
*
- * @access public
* @param string
* @param bool
* @return mixed
@@ -79,14 +77,7 @@ if ( ! function_exists('get_cookie'))
function get_cookie($index = '', $xss_clean = FALSE)
{
$CI =& get_instance();
-
- $prefix = '';
-
- if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
- {
- $prefix = config_item('cookie_prefix');
- }
-
+ $prefix = isset($_COOKIE[$index]) ? '' : config_item('cookie_prefix');
return $CI->input->cookie($prefix.$index, $xss_clean);
}
}
@@ -97,7 +88,7 @@ if ( ! function_exists('get_cookie'))
* Delete a COOKIE
*
* @param mixed
- * @param string the cookie domain. Usually: .yourdomain.com
+ * @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
* @return void
@@ -110,6 +101,5 @@ if ( ! function_exists('delete_cookie'))
}
}
-
/* End of file cookie_helper.php */
/* Location: ./system/helpers/cookie_helper.php */ \ No newline at end of file
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 9e58d8630..f1ba364f5 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -1,8 +1,8 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Date Helpers
*
@@ -44,8 +42,7 @@
*
* Returns time() or its GMT equivalent based on the config file preference
*
- * @access public
- * @return integer
+ * @return int
*/
if ( ! function_exists('now'))
{
@@ -85,10 +82,9 @@ if ( ! function_exists('now'))
* have to worry about escaping your text letters that
* match the date codes.
*
- * @access public
* @param string
- * @param integer
- * @return integer
+ * @param int
+ * @return int
*/
if ( ! function_exists('mdate'))
{
@@ -118,9 +114,8 @@ if ( ! function_exists('mdate'))
*
* Returns a date formatted according to the submitted standard.
*
- * @access public
* @param string the chosen format
- * @param integer Unix timestamp
+ * @param int Unix timestamp
* @return string
*/
if ( ! function_exists('standard_date'))
@@ -128,15 +123,16 @@ if ( ! function_exists('standard_date'))
function standard_date($fmt = 'DATE_RFC822', $time = '')
{
$formats = array(
- 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q',
+ 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%O',
'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC',
- 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q',
+ 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O',
'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O',
'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC',
'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O',
'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O',
+ 'DATE_RFC2822' => '%D, %d %M %Y %H:%i:%s %O',
'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O',
- 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q'
+ 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%O'
);
if ( ! isset($formats[$fmt]))
@@ -156,14 +152,14 @@ if ( ! function_exists('standard_date'))
* Returns a span of seconds in this format:
* 10 days 14 hours 36 minutes 47 seconds
*
- * @access public
- * @param integer a number of seconds
- * @param integer Unix timestamp
- * @return integer
+ * @param int a number of seconds
+ * @param int Unix timestamp
+ * @param int a number of display units
+ * @return string
*/
if ( ! function_exists('timespan'))
{
- function timespan($seconds = 1, $time = '')
+ function timespan($seconds = 1, $time = '', $units = 7)
{
$CI =& get_instance();
$CI->lang->load('date');
@@ -178,24 +174,29 @@ if ( ! function_exists('timespan'))
$time = time();
}
+ if ( ! is_numeric($units))
+ {
+ $units = 7;
+ }
+
$seconds = ($time <= $seconds) ? 1 : $time - $seconds;
- $str = '';
+ $str = array();
$years = floor($seconds / 31557600);
if ($years > 0)
{
- $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', ';
+ $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year'));
}
$seconds -= $years * 31557600;
$months = floor($seconds / 2629743);
- if ($years > 0 OR $months > 0)
+ if (count($str) < $units && ($years > 0 OR $months > 0))
{
if ($months > 0)
{
- $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', ';
+ $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month'));
}
$seconds -= $months * 2629743;
@@ -203,11 +204,11 @@ if ( ! function_exists('timespan'))
$weeks = floor($seconds / 604800);
- if ($years > 0 OR $months > 0 OR $weeks > 0)
+ if (count($str) < $units && ($years > 0 OR $months > 0 OR $weeks > 0))
{
if ($weeks > 0)
{
- $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', ';
+ $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week'));
}
$seconds -= $weeks * 604800;
@@ -215,11 +216,11 @@ if ( ! function_exists('timespan'))
$days = floor($seconds / 86400);
- if ($months > 0 OR $weeks > 0 OR $days > 0)
+ if (count($str) < $units && ($months > 0 OR $weeks > 0 OR $days > 0))
{
if ($days > 0)
{
- $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', ';
+ $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day'));
}
$seconds -= $days * 86400;
@@ -227,11 +228,11 @@ if ( ! function_exists('timespan'))
$hours = floor($seconds / 3600);
- if ($days > 0 OR $hours > 0)
+ if (count($str) < $units && ($days > 0 OR $hours > 0))
{
if ($hours > 0)
{
- $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', ';
+ $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour'));
}
$seconds -= $hours * 3600;
@@ -239,22 +240,22 @@ if ( ! function_exists('timespan'))
$minutes = floor($seconds / 60);
- if ($days > 0 OR $hours > 0 OR $minutes > 0)
+ if (count($str) < $units && ($days > 0 OR $hours > 0 OR $minutes > 0))
{
if ($minutes > 0)
{
- $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', ';
+ $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute'));
}
$seconds -= $minutes * 60;
}
- if ($str == '')
+ if (count($str) === 0)
{
- $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', ';
+ $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second'));
}
- return substr(trim($str), 0, -1);
+ return implode(', ', $str);
}
}
@@ -266,10 +267,9 @@ if ( ! function_exists('timespan'))
* Takes a month/year as input and returns the number of days
* for the given month/year. Takes leap years into consideration.
*
- * @access public
- * @param integer a numeric month
- * @param integer a numeric year
- * @return integer
+ * @param int a numeric month
+ * @param int a numeric year
+ * @return int
*/
if ( ! function_exists('days_in_month'))
{
@@ -287,7 +287,7 @@ if ( ! function_exists('days_in_month'))
if ($month == 2)
{
- if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
+ if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0))
{
return 29;
}
@@ -303,9 +303,8 @@ if ( ! function_exists('days_in_month'))
/**
* Converts a local Unix timestamp to GMT
*
- * @access public
- * @param integer Unix timestamp
- * @return integer
+ * @param int Unix timestamp
+ * @return int
*/
if ( ! function_exists('local_to_gmt'))
{
@@ -336,11 +335,10 @@ if ( ! function_exists('local_to_gmt'))
* at the local value based on the timezone and DST setting
* submitted
*
- * @access public
- * @param integer Unix timestamp
+ * @param int Unix timestamp
* @param string timezone
* @param bool whether DST is active
- * @return integer
+ * @return int
*/
if ( ! function_exists('gmt_to_local'))
{
@@ -367,9 +365,8 @@ if ( ! function_exists('gmt_to_local'))
/**
* Converts a MySQL Timestamp to Unix
*
- * @access public
- * @param integer Unix timestamp
- * @return integer
+ * @param int Unix timestamp
+ * @return int
*/
if ( ! function_exists('mysql_to_unix'))
{
@@ -402,8 +399,7 @@ if ( ! function_exists('mysql_to_unix'))
*
* Formats Unix timestamp to the following prototype: 2006-08-21 11:35 PM
*
- * @access public
- * @param integer Unix timestamp
+ * @param int Unix timestamp
* @param bool whether to show seconds
* @param string format: us or euro
* @return string
@@ -444,9 +440,8 @@ if ( ! function_exists('unix_to_human'))
*
* Reverses the above process
*
- * @access public
* @param string format: us or euro
- * @return integer
+ * @return int
*/
if ( ! function_exists('human_to_unix'))
{
@@ -492,12 +487,12 @@ if ( ! function_exists('human_to_unix'))
{
$ampm = strtolower($split['2']);
- if (substr($ampm, 0, 1) == 'p' AND $hour < 12)
+ if (substr($ampm, 0, 1) === 'p' && $hour < 12)
{
$hour = $hour + 12;
}
- if (substr($ampm, 0, 1) == 'a' AND $hour == 12)
+ if (substr($ampm, 0, 1) === 'a' && $hour == 12)
{
$hour = '00';
}
@@ -518,10 +513,9 @@ if ( ! function_exists('human_to_unix'))
* Turns many "reasonably-date-like" strings into something
* that is actually useful. This only works for dates after unix epoch.
*
- * @access public
- * @param string The terribly formatted date-like string
- * @param string Date format to return (same as php date function)
- * @return string
+ * @param string The terribly formatted date-like string
+ * @param string Date format to return (same as php date function)
+ * @return string
*/
if ( ! function_exists('nice_date'))
{
@@ -586,7 +580,6 @@ if ( ! function_exists('nice_date'))
*
* Generates a drop-down menu of timezones.
*
- * @access public
* @param string timezone
* @param string classname
* @param string menu name
@@ -627,10 +620,9 @@ if ( ! function_exists('timezone_menu'))
/**
* Timezones
*
- * Returns an array of timezones. This is a helper function
+ * Returns an array of timezones. This is a helper function
* for various other ones in this library
*
- * @access public
* @param string timezone
* @return string
*/
@@ -691,7 +683,7 @@ if ( ! function_exists('timezones'))
$tz = ($tz == 'GMT') ? 'UTC' : $tz;
- return ( ! isset($zones[$tz])) ? 0 : $zones[$tz];
+ return isset($zones[$tz]) ? $zones[$tz] : 0;
}
}
diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php
index be65b388d..4044ace11 100644
--- a/system/helpers/directory_helper.php
+++ b/system/helpers/directory_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Directory Helpers
*
@@ -43,12 +41,11 @@
* Create a Directory Map
*
* Reads the specified directory and builds an array
- * representation of it. Sub-folders contained with the
+ * representation of it. Sub-folders contained with the
* directory will be mapped as well.
*
- * @access public
* @param string path to source
- * @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
+ * @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
* @return array
*/
if ( ! function_exists('directory_map'))
@@ -64,7 +61,7 @@ if ( ! function_exists('directory_map'))
while (FALSE !== ($file = readdir($fp)))
{
// Remove '.', '..', and hidden files [optional]
- if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] == '.'))
+ if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] === '.'))
{
continue;
}
@@ -87,6 +84,5 @@ if ( ! function_exists('directory_map'))
}
}
-
/* End of file directory_helper.php */
/* Location: ./system/helpers/directory_helper.php */ \ No newline at end of file
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 4a1a79cc3..8b87f8179 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Download Helpers
*
@@ -44,76 +42,89 @@
*
* Generates headers that force a download to happen
*
- * @access public
* @param string filename
* @param mixed the data to be downloaded
+ * @param bool wether to try and send the actual file MIME type
* @return void
*/
if ( ! function_exists('force_download'))
{
- function force_download($filename = '', $data = '')
+ function force_download($filename = '', $data = '', $set_mime = FALSE)
{
if ($filename == '' OR $data == '')
{
return FALSE;
}
- // Try to determine if the filename includes a file extension.
- // We need it in order to set the MIME type
- if (FALSE === strpos($filename, '.'))
- {
- return FALSE;
- }
+ // Set the default MIME type to send
+ $mime = 'application/octet-stream';
- // Grab the file extension
$x = explode('.', $filename);
$extension = end($x);
- // Load the mime types
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
- }
- elseif (is_file(APPPATH.'config/mimes.php'))
+ if ($set_mime === TRUE)
{
- include(APPPATH.'config/mimes.php');
- }
+ if (count($x) === 1 OR $extension === '')
+ {
+ /* If we're going to detect the MIME type,
+ * we'll need a file extension.
+ */
+ return FALSE;
+ }
- // Set a default mime if we can't find it
- if ( ! isset($mimes[$extension]))
- {
- $mime = 'application/octet-stream';
+ // Load the mime types
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
+ }
+ elseif (is_file(APPPATH.'config/mimes.php'))
+ {
+ include(APPPATH.'config/mimes.php');
+ }
+
+ // Only change the default MIME if we can find one
+ if (isset($mimes[$extension]))
+ {
+ $mime = is_array($mimes[$extension]) ? $mimes[$extension][0] : $mimes[$extension];
+ }
}
- else
+
+ /* It was reported that browsers on Android 2.1 (and possibly older as well)
+ * need to have the filename extension upper-cased in order to be able to
+ * download it.
+ *
+ * Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/
+ */
+ if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[01])/', $_SERVER['HTTP_USER_AGENT']))
{
- $mime = (is_array($mimes[$extension])) ? $mimes[$extension][0] : $mimes[$extension];
+ $x[count($x) - 1] = strtoupper($extension);
+ $filename = implode('.', $x);
}
+
+ // Clean output buffer
+ ob_clean();
// Generate the server headers
- if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") !== FALSE)
+ header('Content-Type: '.$mime);
+ header('Content-Disposition: attachment; filename="'.$filename.'"');
+ header('Expires: 0');
+ header('Content-Transfer-Encoding: binary');
+ header('Content-Length: '.strlen($data));
+
+ // Internet Explorer-specific headers
+ if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
{
- header('Content-Type: "'.$mime.'"');
- header('Content-Disposition: attachment; filename="'.$filename.'"');
- header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header("Content-Transfer-Encoding: binary");
header('Pragma: public');
- header("Content-Length: ".strlen($data));
}
else
{
- header('Content-Type: "'.$mime.'"');
- header('Content-Disposition: attachment; filename="'.$filename.'"');
- header("Content-Transfer-Encoding: binary");
- header('Expires: 0');
header('Pragma: no-cache');
- header("Content-Length: ".strlen($data));
}
exit($data);
}
}
-
/* End of file download_helper.php */
/* Location: ./system/helpers/download_helper.php */ \ No newline at end of file
diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php
index f184031a9..497625c10 100644
--- a/system/helpers/email_helper.php
+++ b/system/helpers/email_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Email Helpers
*
@@ -42,7 +40,7 @@
/**
* Validate email address
*
- * @access public
+ * @param string
* @return bool
*/
if ( ! function_exists('valid_email'))
@@ -58,7 +56,9 @@ if ( ! function_exists('valid_email'))
/**
* Send an email
*
- * @access public
+ * @param string
+ * @param string
+ * @param string
* @return bool
*/
if ( ! function_exists('send_email'))
@@ -70,4 +70,4 @@ if ( ! function_exists('send_email'))
}
/* End of file email_helper.php */
-/* Location: ./system/helpers/email_helper.php */
+/* Location: ./system/helpers/email_helper.php */ \ No newline at end of file
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 2d4b10e37..a5aabecd6 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter File Helpers
*
@@ -44,7 +42,6 @@
*
* Opens the file specfied in the path and returns it as a string.
*
- * @access public
* @param string path to file
* @return string
*/
@@ -90,7 +87,6 @@ if ( ! function_exists('read_file'))
* Writes data to the file specified in the path.
* Creates a new file if non-existent.
*
- * @access public
* @param string path to file
* @param string file data
* @return bool
@@ -123,14 +119,15 @@ if ( ! function_exists('write_file'))
* If the second parameter is set to TRUE, any directories contained
* within the supplied base directory will be nuked as well.
*
- * @access public
* @param string path to file
* @param bool whether to delete any directories found in the path
+ * @param int
+ * @param bool whether to skip deleting .htaccess and index page files
* @return bool
*/
if ( ! function_exists('delete_files'))
{
- function delete_files($path, $del_dir = FALSE, $level = 0)
+ function delete_files($path, $del_dir = FALSE, $level = 0, $htdocs = FALSE)
{
// Trim the trailing slash
$path = rtrim($path, DIRECTORY_SEPARATOR);
@@ -142,21 +139,21 @@ if ( ! function_exists('delete_files'))
while (FALSE !== ($filename = @readdir($current_dir)))
{
- if ($filename !== '.' and $filename !== '..')
+ if ($filename !== '.' && $filename !== '..')
{
if (is_dir($path.DIRECTORY_SEPARATOR.$filename) && $filename[0] !== '.')
{
- delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
+ delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1, $htdocs);
}
- else
+ elseif ($htdocs === TRUE && ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename))
{
- unlink($path.DIRECTORY_SEPARATOR.$filename);
+ @unlink($path.DIRECTORY_SEPARATOR.$filename);
}
}
}
@closedir($current_dir);
- if ($del_dir == TRUE AND $level > 0)
+ if ($del_dir == TRUE && $level > 0)
{
return @rmdir($path);
}
@@ -173,7 +170,6 @@ if ( ! function_exists('delete_files'))
* Reads the specified directory and builds an array containing the filenames.
* Any sub-folders contained within the specified path are read as well.
*
- * @access public
* @param string path to source
* @param bool whether to include the path as part of the filename
* @param bool internal variable to determine recursion status - do not use in calls
@@ -224,7 +220,6 @@ if ( ! function_exists('get_filenames'))
*
* Any sub-folders contained within the specified path are read as well.
*
- * @access public
* @param string path to source
* @param bool Look only at the top level directory specified?
* @param bool internal variable to determine recursion status - do not use in calls
@@ -278,7 +273,6 @@ if ( ! function_exists('get_dir_file_info'))
* Options are: name, server_path, size, date, readable, writable, executable, fileperms
* Returns FALSE if the file cannot be found.
*
-* @access public
* @param string path to file
* @param mixed array or comma separated string of information returned
* @return array
@@ -345,7 +339,6 @@ if ( ! function_exists('get_file_info'))
* Note: this is NOT an accurate way of determining file mime types, and is here strictly as a convenience
* It should NOT be trusted, and should certainly NOT be used for security
*
- * @access public
* @param string path to file
* @return mixed
*/
@@ -399,7 +392,6 @@ if ( ! function_exists('get_mime_by_extension'))
* Takes a numeric value representing a file's permissions and returns
* standard symbolic notation representing that value
*
- * @access public
* @param int
* @return string
*/
@@ -467,7 +459,6 @@ if ( ! function_exists('symbolic_permissions'))
* Takes a numeric value representing a file's permissions and returns
* a three character string representing the file's octal permissions
*
- * @access public
* @param int
* @return string
*/
@@ -480,4 +471,4 @@ if ( ! function_exists('octal_permissions'))
}
/* End of file file_helper.php */
-/* Location: ./system/helpers/file_helper.php */
+/* Location: ./system/helpers/file_helper.php */ \ No newline at end of file
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index bed2cb297..e5b487608 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -22,11 +22,8 @@
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 1.0
- * @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Form Helpers
*
@@ -44,7 +41,6 @@
*
* Creates the opening portion of the form.
*
- * @access public
* @param string the URI segments of the form destination
* @param array a key/value pair of attributes
* @param array a key/value pair hidden data
@@ -73,14 +69,14 @@ if ( ! function_exists('form_open'))
$form = '<form action="'.$action.'"'._attributes_to_string($attributes, TRUE).">\n";
// Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
- if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"')))
+ if ($CI->config->item('csrf_protection') === TRUE && ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"')))
{
$hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
}
- if (is_array($hidden) AND count($hidden) > 0)
+ if (is_array($hidden) && count($hidden) > 0)
{
- $form .= sprintf("<div style=\"display:none\">%s</div>", form_hidden($hidden));
+ $form .= sprintf('<div style="display:none;">%s</div>', form_hidden($hidden));
}
return $form;
@@ -94,7 +90,6 @@ if ( ! function_exists('form_open'))
*
* Creates the opening portion of the form, but with "multipart/form-data".
*
- * @access public
* @param string the URI segments of the form destination
* @param array a key/value pair of attributes
* @param array a key/value pair hidden data
@@ -122,10 +117,9 @@ if ( ! function_exists('form_open_multipart'))
/**
* Hidden Input Field
*
- * Generates hidden fields. You can pass a simple key/value string or an associative
- * array with multiple values.
+ * Generates hidden fields. You can pass a simple key/value string or
+ * an associative array with multiple values.
*
- * @access public
* @param mixed
* @param string
* @return string
@@ -158,7 +152,7 @@ if ( ! function_exists('form_hidden'))
{
foreach ($value as $k => $v)
{
- $k = (is_int($k)) ? '' : $k;
+ $k = is_int($k) ? '' : $k;
form_hidden($name.'['.$k.']', $v, TRUE);
}
}
@@ -172,7 +166,6 @@ if ( ! function_exists('form_hidden'))
/**
* Text Input Field
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -182,7 +175,7 @@ if ( ! function_exists('form_input'))
{
function form_input($data = '', $value = '', $extra = '')
{
- $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+ $defaults = array('type' => 'text', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
@@ -195,7 +188,6 @@ if ( ! function_exists('form_input'))
*
* Identical to the input function but adds the "password" type
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -222,7 +214,6 @@ if ( ! function_exists('form_password'))
*
* Identical to the input function but adds the "file" type
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -247,7 +238,6 @@ if ( ! function_exists('form_upload'))
/**
* Textarea field
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -257,7 +247,7 @@ if ( ! function_exists('form_textarea'))
{
function form_textarea($data = '', $value = '', $extra = '')
{
- $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '40', 'rows' => '10');
+ $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'cols' => '40', 'rows' => '10');
if ( ! is_array($data) OR ! isset($data['value']))
{
@@ -269,7 +259,7 @@ if ( ! function_exists('form_textarea'))
unset($data['value']); // textareas don't use the value attribute
}
- $name = (is_array($data)) ? $data['name'] : $data;
+ $name = is_array($data) ? $data['name'] : $data;
return '<textarea '._parse_form_attributes($data, $defaults).$extra.'>'.form_prep($val, $name)."</textarea>\n";
}
}
@@ -279,12 +269,11 @@ if ( ! function_exists('form_textarea'))
/**
* Multi-select menu
*
- * @access public
* @param string
* @param array
* @param mixed
* @param string
- * @return type
+ * @return string
*/
if ( ! function_exists('form_multiselect'))
{
@@ -304,7 +293,6 @@ if ( ! function_exists('form_multiselect'))
/**
* Drop-down Menu
*
- * @access public
* @param string
* @param array
* @param string
@@ -315,6 +303,16 @@ if ( ! function_exists('form_dropdown'))
{
function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
{
+ // If name is really an array then we'll call the function again using the array
+ if (is_array($name) && isset($name['name']))
+ {
+ isset($name['options']) OR $name['options'] = array();
+ isset($name['selected']) OR $name['selected'] = array();
+ isset($name['extra']) OR $name['extra'] = array();
+
+ return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']);
+ }
+
if ( ! is_array($selected))
{
$selected = array($selected);
@@ -342,11 +340,11 @@ if ( ! function_exists('form_dropdown'))
foreach ($val as $optgroup_key => $optgroup_val)
{
- $sel = (in_array($optgroup_key, $selected)) ? ' selected="selected"' : '';
+ $sel = in_array($optgroup_key, $selected) ? ' selected="selected"' : '';
$form .= '<option value="'.$optgroup_key.'"'.$sel.'>'.(string) $optgroup_val."</option>\n";
}
- $form .= '</optgroup>'."\n";
+ $form .= "</optgroup>\n";
}
else
{
@@ -354,9 +352,7 @@ if ( ! function_exists('form_dropdown'))
}
}
- $form .= "</select>\n";
-
- return $form;
+ return $form."</select>\n";
}
}
@@ -365,7 +361,6 @@ if ( ! function_exists('form_dropdown'))
/**
* Checkbox Field
*
- * @access public
* @param mixed
* @param string
* @param bool
@@ -376,9 +371,9 @@ if ( ! function_exists('form_checkbox'))
{
function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
{
- $defaults = array('type' => 'checkbox', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+ $defaults = array('type' => 'checkbox', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
- if (is_array($data) AND array_key_exists('checked', $data))
+ if (is_array($data) && array_key_exists('checked', $data))
{
$checked = $data['checked'];
@@ -410,7 +405,6 @@ if ( ! function_exists('form_checkbox'))
/**
* Radio Button
*
- * @access public
* @param mixed
* @param string
* @param bool
@@ -436,7 +430,6 @@ if ( ! function_exists('form_radio'))
/**
* Submit Button
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -446,7 +439,7 @@ if ( ! function_exists('form_submit'))
{
function form_submit($data = '', $value = '', $extra = '')
{
- $defaults = array('type' => 'submit', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+ $defaults = array('type' => 'submit', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
@@ -456,7 +449,6 @@ if ( ! function_exists('form_submit'))
/**
* Reset Button
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -466,7 +458,7 @@ if ( ! function_exists('form_reset'))
{
function form_reset($data = '', $value = '', $extra = '')
{
- $defaults = array('type' => 'reset', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);
+ $defaults = array('type' => 'reset', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
}
}
@@ -476,7 +468,6 @@ if ( ! function_exists('form_reset'))
/**
* Form Button
*
- * @access public
* @param mixed
* @param string
* @param string
@@ -486,8 +477,8 @@ if ( ! function_exists('form_button'))
{
function form_button($data = '', $content = '', $extra = '')
{
- $defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'type' => 'button');
- if ( is_array($data) AND isset($data['content']))
+ $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'type' => 'button');
+ if (is_array($data) && isset($data['content']))
{
$content = $data['content'];
unset($data['content']); // content is not an attribute
@@ -502,7 +493,6 @@ if ( ! function_exists('form_button'))
/**
* Form Label Tag
*
- * @access public
* @param string The text to appear onscreen
* @param string The id the label applies to
* @param string Additional attributes
@@ -517,10 +507,10 @@ if ( ! function_exists('form_label'))
if ($id != '')
{
- $label .= " for=\"$id\"";
+ $label .= ' for="'.$id.'"';
}
- if (is_array($attributes) AND count($attributes) > 0)
+ if (is_array($attributes) && count($attributes) > 0)
{
foreach ($attributes as $key => $val)
{
@@ -528,7 +518,7 @@ if ( ! function_exists('form_label'))
}
}
- return $label .= ">$label_text</label>";
+ return $label.'>'.$label_text.'</label>';
}
}
@@ -539,7 +529,6 @@ if ( ! function_exists('form_label'))
* Used to produce <fieldset><legend>text</legend>. To close fieldset
* use form_fieldset_close()
*
- * @access public
* @param string The legend text
* @param string Additional attributes
* @return string
@@ -551,7 +540,7 @@ if ( ! function_exists('form_fieldset'))
$fieldset = '<fieldset'._attributes_to_string($attributes, FALSE).">\n";
if ($legend_text != '')
{
- $fieldset .= "<legend>$legend_text</legend>\n";
+ return $fieldset.'<legend>'.$legend_text."</legend>\n";
}
return $fieldset;
@@ -563,7 +552,6 @@ if ( ! function_exists('form_fieldset'))
/**
* Fieldset Close Tag
*
- * @access public
* @param string
* @return string
*/
@@ -571,7 +559,7 @@ if ( ! function_exists('form_fieldset_close'))
{
function form_fieldset_close($extra = '')
{
- return "</fieldset>".$extra;
+ return '</fieldset>'.$extra;
}
}
@@ -580,7 +568,6 @@ if ( ! function_exists('form_fieldset_close'))
/**
* Form Close Tag
*
- * @access public
* @param string
* @return string
*/
@@ -588,7 +575,7 @@ if ( ! function_exists('form_close'))
{
function form_close($extra = '')
{
- return "</form>".$extra;
+ return '</form>'.$extra;
}
}
@@ -599,7 +586,6 @@ if ( ! function_exists('form_close'))
*
* Formats text so that it can be safely placed in a form field in the event it has HTML tags.
*
- * @access public
* @param string
* @return string
*/
@@ -649,10 +635,9 @@ if ( ! function_exists('form_prep'))
* Form Value
*
* Grabs a value from the POST array for the specified field so you can
- * re-populate an input field or textarea. If Form Validation
+ * re-populate an input field or textarea. If Form Validation
* is active it retrieves the info from the validation class
*
- * @access public
* @param string
* @return mixed
*/
@@ -682,7 +667,6 @@ if ( ! function_exists('set_value'))
* Let's you set the selected value of a <select> menu via data in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
- * @access public
* @param string
* @param string
* @param bool
@@ -698,7 +682,7 @@ if ( ! function_exists('set_select'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0 AND $default == TRUE)
+ if (count($_POST) === 0 && $default == TRUE)
{
return ' selected="selected"';
}
@@ -714,12 +698,9 @@ if ( ! function_exists('set_select'))
return '';
}
}
- else
+ elseif (($field == '' OR $value == '') OR ($field != $value))
{
- if (($field == '' OR $value == '') OR ($field != $value))
- {
- return '';
- }
+ return '';
}
return ' selected="selected"';
@@ -737,7 +718,6 @@ if ( ! function_exists('set_select'))
* Let's you set the selected value of a checkbox via the value in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
- * @access public
* @param string
* @param string
* @param bool
@@ -753,7 +733,7 @@ if ( ! function_exists('set_checkbox'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0 AND $default == TRUE)
+ if (count($_POST) === 0 && $default == TRUE)
{
return ' checked="checked"';
}
@@ -769,12 +749,9 @@ if ( ! function_exists('set_checkbox'))
return '';
}
}
- else
+ elseif (($field == '' OR $value == '') OR ($field != $value))
{
- if (($field == '' OR $value == '') OR ($field != $value))
- {
- return '';
- }
+ return '';
}
return ' checked="checked"';
@@ -792,7 +769,6 @@ if ( ! function_exists('set_checkbox'))
* Let's you set the selected value of a radio field via info in the POST array.
* If Form Validation is active it retrieves the info from the validation class
*
- * @access public
* @param string
* @param string
* @param bool
@@ -808,7 +784,7 @@ if ( ! function_exists('set_radio'))
{
if ( ! isset($_POST[$field]))
{
- if (count($_POST) === 0 AND $default == TRUE)
+ if (count($_POST) === 0 && $default == TRUE)
{
return ' checked="checked"';
}
@@ -844,10 +820,9 @@ if ( ! function_exists('set_radio'))
/**
* Form Error
*
- * Returns the error for a specific form field. This is a helper for the
+ * Returns the error for a specific form field. This is a helper for the
* form validation class.
*
- * @access public
* @param string
* @param string
* @param string
@@ -871,10 +846,9 @@ if ( ! function_exists('form_error'))
/**
* Validation Error String
*
- * Returns all the errors associated with a form submission. This is a helper
+ * Returns all the errors associated with a form submission. This is a helper
* function for the form validation class.
*
- * @access public
* @param string
* @param string
* @return string
@@ -899,7 +873,6 @@ if ( ! function_exists('validation_errors'))
*
* Helper function used by some of the form helpers
*
- * @access private
* @param array
* @param array
* @return string
@@ -934,7 +907,7 @@ if ( ! function_exists('_parse_form_attributes'))
$val = form_prep($val, $default['name']);
}
- $att .= $key . '="' . $val . '" ';
+ $att .= $key.'="'.$val.'" ';
}
return $att;
@@ -948,7 +921,6 @@ if ( ! function_exists('_parse_form_attributes'))
*
* Helper function used by some of the form helpers
*
- * @access private
* @param mixed
* @param bool
* @return string
@@ -957,14 +929,14 @@ if ( ! function_exists('_attributes_to_string'))
{
function _attributes_to_string($attributes, $formtag = FALSE)
{
- if (is_string($attributes) AND strlen($attributes) > 0)
+ if (is_string($attributes) && strlen($attributes) > 0)
{
- if ($formtag == TRUE AND strpos($attributes, 'method=') === FALSE)
+ if ($formtag == TRUE && strpos($attributes, 'method=') === FALSE)
{
$attributes .= ' method="post"';
}
- if ($formtag == TRUE AND strpos($attributes, 'accept-charset=') === FALSE)
+ if ($formtag == TRUE && strpos($attributes, 'accept-charset=') === FALSE)
{
$attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"';
}
@@ -972,21 +944,21 @@ if ( ! function_exists('_attributes_to_string'))
return ' '.$attributes;
}
- if (is_object($attributes) AND count($attributes) > 0)
+ if (is_object($attributes) && count($attributes) > 0)
{
- $attributes = (array)$attributes;
+ $attributes = (array) $attributes;
}
- if (is_array($attributes) AND ($formtag === TRUE OR count($attributes) > 0))
+ if (is_array($attributes) && ($formtag === TRUE OR count($attributes) > 0))
{
$atts = '';
- if ( ! isset($attributes['method']) AND $formtag === TRUE)
+ if ( ! isset($attributes['method']) && $formtag === TRUE)
{
$atts .= ' method="post"';
}
- if ( ! isset($attributes['accept-charset']) AND $formtag === TRUE)
+ if ( ! isset($attributes['accept-charset']) && $formtag === TRUE)
{
$atts .= ' accept-charset="'.strtolower(config_item('charset')).'"';
}
@@ -1009,7 +981,6 @@ if ( ! function_exists('_attributes_to_string'))
* Determines what the form validation class was instantiated as, fetches
* the object and returns it.
*
- * @access private
* @return mixed
*/
if ( ! function_exists('_get_validation_object'))
@@ -1036,4 +1007,4 @@ if ( ! function_exists('_get_validation_object'))
}
/* End of file form_helper.php */
-/* Location: ./system/helpers/form_helper.php */
+/* Location: ./system/helpers/form_helper.php */ \ No newline at end of file
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 72970d9ca..0417bd253 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter HTML Helpers
*
@@ -42,12 +40,10 @@
/**
* Heading
*
- * Generates an HTML heading tag. First param is the data.
- * Second param is the size of the heading tag.
+ * Generates an HTML heading tag.
*
- * @access public
- * @param string
- * @param integer
+ * @param string content
+ * @param int heading level
* @return string
*/
if ( ! function_exists('heading'))
@@ -65,7 +61,6 @@ if ( ! function_exists('heading'))
*
* Generates an HTML unordered list from an single or multi-dimensional array.
*
- * @access public
* @param array
* @param mixed
* @return string
@@ -85,7 +80,6 @@ if ( ! function_exists('ul'))
*
* Generates an HTML ordered list from an single or multi-dimensional array.
*
- * @access public
* @param array
* @param mixed
* @return string
@@ -105,11 +99,10 @@ if ( ! function_exists('ol'))
*
* Generates an HTML ordered list from an single or multi-dimensional array.
*
- * @access private
* @param string
* @param mixed
* @param mixed
- * @param integer
+ * @param int
* @return string
*/
if ( ! function_exists('_list'))
@@ -131,13 +124,13 @@ if ( ! function_exists('_list'))
$atts = '';
foreach ($attributes as $key => $val)
{
- $atts .= ' ' . $key . '="' . $val . '"';
+ $atts .= ' '.$key.'="'.$val.'"';
}
$attributes = $atts;
}
- elseif (is_string($attributes) AND strlen($attributes) > 0)
+ elseif (is_string($attributes) && strlen($attributes) > 0)
{
- $attributes = ' '. $attributes;
+ $attributes = ' '.$attributes;
}
// Write the opening list tag
@@ -175,8 +168,7 @@ if ( ! function_exists('_list'))
/**
* Generates HTML BR tags based on number supplied
*
- * @access public
- * @param integer
+ * @param int
* @return string
*/
if ( ! function_exists('br'))
@@ -194,8 +186,8 @@ if ( ! function_exists('br'))
*
* Generates an <img /> element
*
- * @access public
* @param mixed
+ * @param bool
* @return string
*/
if ( ! function_exists('img'))
@@ -217,7 +209,7 @@ if ( ! function_exists('img'))
foreach ($src as $k => $v)
{
- if ($k === 'src' AND strpos($v, '://') === FALSE)
+ if ($k === 'src' && strpos($v, '://') === FALSE)
{
$CI =& get_instance();
@@ -232,7 +224,7 @@ if ( ! function_exists('img'))
}
else
{
- $img .= " $k=\"$v\"";
+ $img .= ' '.$k.'="'.$v.'"';
}
}
@@ -248,10 +240,9 @@ if ( ! function_exists('img'))
* Generates a page document type declaration
*
* Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame,
- * html4-strict, html4-trans, and html4-frame. Values are saved in the
+ * html4-strict, html4-trans, and html4-frame. Values are saved in the
* doctypes config file.
*
- * @access public
* @param string type The doctype to be generated
* @return string
*/
@@ -263,7 +254,7 @@ if ( ! function_exists('doctype'))
if ( ! is_array($_doctypes))
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
}
@@ -278,7 +269,7 @@ if ( ! function_exists('doctype'))
}
}
- return (isset($_doctypes[$type])) ? $_doctypes[$type] : FALSE;
+ return isset($_doctypes[$type]) ? $_doctypes[$type] : FALSE;
}
}
@@ -289,13 +280,12 @@ if ( ! function_exists('doctype'))
*
* Generates link to a CSS file
*
- * @access public
* @param mixed stylesheet hrefs or an array
* @param string rel
* @param string type
* @param string title
* @param string media
- * @param boolean should index_page be added to the css path
+ * @param bool should index_page be added to the css path
* @return string
*/
if ( ! function_exists('link_tag'))
@@ -309,7 +299,7 @@ if ( ! function_exists('link_tag'))
{
foreach ($href as $k => $v)
{
- if ($k === 'href' AND strpos($v, '://') === FALSE)
+ if ($k === 'href' && strpos($v, '://') === FALSE)
{
if ($index_page === TRUE)
{
@@ -322,11 +312,9 @@ if ( ! function_exists('link_tag'))
}
else
{
- $link .= "$k=\"$v\" ";
+ $link .= $k.'="'.$v.'" ';
}
}
-
- $link .= '/>';
}
else
{
@@ -354,11 +342,9 @@ if ( ! function_exists('link_tag'))
{
$link .= 'title="'.$title.'" ';
}
-
- $link .= '/>';
}
- return $link."\n";
+ return $link."/>\n";
}
}
@@ -367,8 +353,10 @@ if ( ! function_exists('link_tag'))
/**
* Generates meta tags from an array of key/values
*
- * @access public
* @param array
+ * @param string
+ * @param string
+ * @param string
* @return string
*/
if ( ! function_exists('meta'))
@@ -381,13 +369,10 @@ if ( ! function_exists('meta'))
{
$name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
}
- else
+ elseif (isset($name['name']))
{
// Turn single array into multidimensional
- if (isset($name['name']))
- {
- $name = array($name);
- }
+ $name = array($name);
}
$str = '';
@@ -410,8 +395,7 @@ if ( ! function_exists('meta'))
/**
* Generates non-breaking space entities based on number supplied
*
- * @access public
- * @param integer
+ * @param int
* @return string
*/
if ( ! function_exists('nbs'))
@@ -423,4 +407,4 @@ if ( ! function_exists('nbs'))
}
/* End of file html_helper.php */
-/* Location: ./system/helpers/html_helper.php */
+/* Location: ./system/helpers/html_helper.php */ \ No newline at end of file
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 0bd1e112f..feeaf57d7 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Inflector Helpers
*
@@ -34,10 +32,9 @@
* @subpackage Helpers
* @category Helpers
* @author EllisLab Dev Team
- * @link http://codeigniter.com/user_guide/helpers/directory_helper.html
+ * @link http://codeigniter.com/user_guide/helpers/inflector_helper.html
*/
-
// --------------------------------------------------------------------
/**
@@ -45,7 +42,6 @@
*
* Takes a plural word and makes it singular
*
- * @access public
* @param string
* @return str
*/
@@ -55,37 +51,51 @@ if ( ! function_exists('singular'))
{
$result = strval($str);
+ if ( ! is_countable($result))
+ {
+ return $result;
+ }
+
$singular_rules = array(
- '/(matr)ices$/' => '\1ix',
- '/(vert|ind)ices$/' => '\1ex',
- '/^(ox)en/' => '\1',
- '/(alias)es$/' => '\1',
- '/([octop|vir])i$/' => '\1us',
- '/(cris|ax|test)es$/' => '\1is',
- '/(shoe)s$/' => '\1',
- '/(o)es$/' => '\1',
- '/(bus|campus)es$/' => '\1',
- '/([m|l])ice$/' => '\1ouse',
- '/(x|ch|ss|sh)es$/' => '\1',
- '/(m)ovies$/' => '\1\2ovie',
- '/(s)eries$/' => '\1\2eries',
- '/([^aeiouy]|qu)ies$/' => '\1y',
- '/([lr])ves$/' => '\1f',
- '/(tive)s$/' => '\1',
- '/(hive)s$/' => '\1',
- '/([^f])ves$/' => '\1fe',
- '/(^analy)ses$/' => '\1sis',
+ '/(matr)ices$/' => '\1ix',
+ '/(vert|ind)ices$/' => '\1ex',
+ '/^(ox)en/' => '\1',
+ '/(alias)es$/' => '\1',
+ '/([octop|vir])i$/' => '\1us',
+ '/(cris|ax|test)es$/' => '\1is',
+ '/(shoe)s$/' => '\1',
+ '/(o)es$/' => '\1',
+ '/(bus|campus)es$/' => '\1',
+ '/([m|l])ice$/' => '\1ouse',
+ '/(x|ch|ss|sh)es$/' => '\1',
+ '/(m)ovies$/' => '\1\2ovie',
+ '/(s)eries$/' => '\1\2eries',
+ '/([^aeiouy]|qu)ies$/' => '\1y',
+ '/([lr])ves$/' => '\1f',
+ '/(tive)s$/' => '\1',
+ '/(hive)s$/' => '\1',
+ '/([^f])ves$/' => '\1fe',
+ '/(^analy)ses$/' => '\1sis',
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/' => '\1\2sis',
- '/([ti])a$/' => '\1um',
- '/(p)eople$/' => '\1\2erson',
- '/(m)en$/' => '\1an',
- '/(s)tatuses$/' => '\1\2tatus',
- '/(c)hildren$/' => '\1\2hild',
- '/(n)ews$/' => '\1\2ews',
- '/([^u])s$/' => '\1',
+ '/([ti])a$/' => '\1um',
+ '/(p)eople$/' => '\1\2erson',
+ '/(m)en$/' => '\1an',
+ '/(s)tatuses$/' => '\1\2tatus',
+ '/(c)hildren$/' => '\1\2hild',
+ '/(n)ews$/' => '\1\2ews',
+ '/([^us])s$/' => '\1',
);
- return preg_replace(array_keys($singular_values), $singular_values, $result);
+ foreach ($singular_rules as $rule => $replacement)
+ {
+ if (preg_match($rule, $result))
+ {
+ $result = preg_replace($rule, $replacement, $result);
+ break;
+ }
+ }
+
+ return $result;
}
}
@@ -96,7 +106,6 @@ if ( ! function_exists('singular'))
*
* Takes a singular word and makes it plural
*
- * @access public
* @param string
* @param bool
* @return str
@@ -107,29 +116,43 @@ if ( ! function_exists('plural'))
{
$result = strval($str);
+ if ( ! is_countable($result))
+ {
+ return $result;
+ }
+
$plural_rules = array(
- '/^(ox)$/' => '\1\2en', // ox
- '/([m|l])ouse$/' => '\1ice', // mouse, louse
- '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
- '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
- '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
- '/(hive)$/' => '\1s', // archive, hive
- '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
- '/sis$/' => 'ses', // basis, diagnosis
- '/([ti])um$/' => '\1a', // datum, medium
- '/(p)erson$/' => '\1eople', // person, salesperson
- '/(m)an$/' => '\1en', // man, woman, spokesman
- '/(c)hild$/' => '\1hildren', // child
- '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
- '/(bu|campu)s$/' => '\1\2ses', // bus, campus
- '/(alias|status|virus)/' => '\1es', // alias
- '/(octop)us$/' => '\1i', // octopus
- '/(ax|cris|test)is$/' => '\1es', // axis, crisis
- '/s$/' => 's', // no change (compatibility)
- '/$/' => 's',
+ '/^(ox)$/' => '\1\2en', // ox
+ '/([m|l])ouse$/' => '\1ice', // mouse, louse
+ '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
+ '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
+ '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
+ '/(hive)$/' => '\1s', // archive, hive
+ '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
+ '/sis$/' => 'ses', // basis, diagnosis
+ '/([ti])um$/' => '\1a', // datum, medium
+ '/(p)erson$/' => '\1eople', // person, salesperson
+ '/(m)an$/' => '\1en', // man, woman, spokesman
+ '/(c)hild$/' => '\1hildren', // child
+ '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
+ '/(bu|campu)s$/' => '\1\2ses', // bus, campus
+ '/(alias|status|virus)$/' => '\1es', // alias
+ '/(octop)us$/' => '\1i', // octopus
+ '/(ax|cris|test)is$/' => '\1es', // axis, crisis
+ '/s$/' => 's', // no change (compatibility)
+ '/$/' => 's',
);
- return preg_replace(array_keys($plural_rules), $plural_rules, $result);
+ foreach ($plural_rules as $rule => $replacement)
+ {
+ if (preg_match($rule, $result))
+ {
+ $result = preg_replace($rule, $replacement, $result);
+ break;
+ }
+ }
+
+ return $result;
}
}
@@ -140,7 +163,6 @@ if ( ! function_exists('plural'))
*
* Takes multiple words separated by spaces or underscores and camelizes them
*
- * @access public
* @param string
* @return str
*/
@@ -148,7 +170,7 @@ if ( ! function_exists('camelize'))
{
function camelize($str)
{
- return substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
+ return strtolower($str[0]).substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
}
}
@@ -159,7 +181,6 @@ if ( ! function_exists('camelize'))
*
* Takes multiple words separated by spaces and underscores them
*
- * @access public
* @param string
* @return str
*/
@@ -178,9 +199,8 @@ if ( ! function_exists('underscore'))
*
* Takes multiple words separated by the separator and changes them to spaces
*
- * @access public
- * @param string $str
- * @param string $separator
+ * @param string $str
+ * @param string $separator
* @return str
*/
if ( ! function_exists('humanize'))
@@ -191,5 +211,24 @@ if ( ! function_exists('humanize'))
}
}
+/**
+ * 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'))
+{
+ function is_countable($word)
+ {
+ return ! in_array(strtolower(strval($word)),
+ array(
+ 'equipment', 'information', 'rice', 'money',
+ 'species', 'series', 'fish', 'meta'
+ )
+ );
+ }
+}
+
/* End of file inflector_helper.php */
-/* Location: ./system/helpers/inflector_helper.php */
+/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index a83580a97..b31c97107 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Language Helpers
*
@@ -44,7 +42,6 @@
*
* Fetches a language variable and optionally outputs a form label
*
- * @access public
* @param string the language line
* @param string the id of the form element
* @return string
@@ -58,7 +55,7 @@ if ( ! function_exists('lang'))
if ($id != '')
{
- $line = '<label for="'.$id.'">'.$line."</label>";
+ $line = '<label for="'.$id.'">'.$line.'</label>';
}
return $line;
@@ -66,4 +63,4 @@ if ( ! function_exists('lang'))
}
/* End of file language_helper.php */
-/* Location: ./system/helpers/language_helper.php */
+/* Location: ./system/helpers/language_helper.php */ \ No newline at end of file
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
index 331b468c6..40da6e7bf 100644
--- a/system/helpers/number_helper.php
+++ b/system/helpers/number_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Number Helpers
*
@@ -42,7 +40,6 @@
/**
* Formats a numbers as bytes, based on size, and adds the appropriate suffix
*
- * @access public
* @param mixed // will be cast as int
* @return string
*/
@@ -84,4 +81,4 @@ if ( ! function_exists('byte_format'))
}
/* End of file number_helper.php */
-/* Location: ./system/helpers/number_helper.php */
+/* Location: ./system/helpers/number_helper.php */ \ No newline at end of file
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index cd87a73eb..6ee99072c 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Path Helpers
*
@@ -42,7 +40,6 @@
/**
* Set Realpath
*
- * @access public
* @param string
* @param bool checks to see if the path exists
* @return string
@@ -51,30 +48,26 @@ if ( ! function_exists('set_realpath'))
{
function set_realpath($path, $check_existance = FALSE)
{
- // Security check to make sure the path is NOT a URL. No remote file inclusion!
- if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $path))
+ // Security check to make sure the path is NOT a URL. No remote file inclusion!
+ if (preg_match('#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i', $path))
{
show_error('The path you submitted must be a local server path, not a URL');
}
// Resolve the path
- if (function_exists('realpath') AND @realpath($path) !== FALSE)
+ if (function_exists('realpath') && @realpath($path) !== FALSE)
{
$path = realpath($path);
}
-
- // Add a trailing slash
- $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
-
- // Make sure the path exists
- if ($check_existance == TRUE && ! is_dir($path))
+ elseif ($check_existance && ! is_dir($path) && ! is_file($path))
{
show_error('Not a valid path: '.$path);
}
- return $path;
+ // Add a trailing slash, if this is a directory
+ return is_dir($path) ? rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $path;
}
}
/* End of file path_helper.php */
-/* Location: ./system/helpers/path_helper.php */
+/* Location: ./system/helpers/path_helper.php */ \ No newline at end of file
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 99fda561a..d6f134c9f 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Security Helpers
*
@@ -42,7 +40,6 @@
/**
* XSS Filtering
*
- * @access public
* @param string
* @param bool whether or not the content is an image file
* @return string
@@ -61,7 +58,6 @@ if ( ! function_exists('xss_clean'))
/**
* Sanitize Filename
*
- * @access public
* @param string
* @return string
*/
@@ -79,7 +75,6 @@ if ( ! function_exists('sanitize_filename'))
/**
* Hash encode a string
*
- * @access public
* @param string
* @return string
*/
@@ -87,7 +82,12 @@ if ( ! function_exists('do_hash'))
{
function do_hash($str, $type = 'sha1')
{
- return ($type === 'sha1') ? sha1($str) : md5($str);
+ if ( ! in_array(strtolower($type), hash_algos()))
+ {
+ $type = 'md5';
+ }
+
+ return hash($type, $str);
}
}
@@ -96,7 +96,6 @@ if ( ! function_exists('do_hash'))
/**
* Strip Image Tags
*
- * @access public
* @param string
* @return string
*/
@@ -104,7 +103,7 @@ if ( ! function_exists('strip_image_tags'))
{
function strip_image_tags($str)
{
- return preg_replace(array("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "#<img\s+.*?src\s*=\s*(.+?).*?\>#"), "\\1", $str);
+ return preg_replace(array('#<img\s+.*?src\s*=\s*["\'](.+?)["\'].*?\>#', '#<img\s+.*?src\s*=\s*(.+?).*?\>#'), '\\1', $str);
}
}
@@ -113,7 +112,6 @@ if ( ! function_exists('strip_image_tags'))
/**
* Convert PHP tags to entities
*
- * @access public
* @param string
* @return string
*/
@@ -126,4 +124,4 @@ if ( ! function_exists('encode_php_tags'))
}
/* End of file security_helper.php */
-/* Location: ./system/helpers/security_helper.php */
+/* Location: ./system/helpers/security_helper.php */ \ No newline at end of file
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 700f4486c..8dba74e73 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Smiley Helpers
*
@@ -45,7 +43,6 @@
* Returns the javascript required for the smiley insertion. Optionally takes
* an array of aliases to loosely couple the smiley array to the view.
*
- * @access public
* @param mixed alias name or array of alias->field_id pairs
* @param string field_id if alias name was passed in
* @return array
@@ -139,7 +136,6 @@ EOF;
* Returns an array of image tag links that can be clicked to be inserted
* into a form field.
*
- * @access public
* @param string the URL to the folder containing the smiley images
* @return array
*/
@@ -193,7 +189,6 @@ if ( ! function_exists('get_clickable_smileys'))
*
* Takes a string as input and swaps any contained smileys for the actual image
*
- * @access public
* @param string the text to be parsed
* @param string the URL to the folder containing the smiley images
* @return string
@@ -234,14 +229,13 @@ if ( ! function_exists('parse_smileys'))
*
* Fetches the config/smiley.php file
*
- * @access private
* @return mixed
*/
if ( ! function_exists('_get_smiley_array'))
{
function _get_smiley_array()
{
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
+ if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
}
@@ -249,8 +243,8 @@ if ( ! function_exists('_get_smiley_array'))
{
include(APPPATH.'config/smileys.php');
}
-
- if (isset($smileys) AND is_array($smileys))
+
+ if (isset($smileys) && is_array($smileys))
{
return $smileys;
}
@@ -268,7 +262,6 @@ if ( ! function_exists('_get_smiley_array'))
*
* DEPRECATED as of version 1.7.2, use smiley_js instead
*
- * @access public
* @param string form name
* @param string field name
* @return string
@@ -288,6 +281,5 @@ 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 04d51c2f9..aed35c157 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter String Helpers
*
@@ -50,7 +48,6 @@
*
* this/that/theother
*
- * @access public
* @param string
* @return string
*/
@@ -69,7 +66,6 @@ if ( ! function_exists('trim_slashes'))
*
* Removes slashes contained in a string or in an array
*
- * @access public
* @param mixed string or array
* @return mixed string or array
*/
@@ -100,7 +96,6 @@ if ( ! function_exists('strip_slashes'))
*
* Removes single and double quotes from a string
*
- * @access public
* @param string
* @return string
*/
@@ -119,7 +114,6 @@ if ( ! function_exists('strip_quotes'))
*
* Converts single and double quotes to entities
*
- * @access public
* @param string
* @return string
*/
@@ -145,7 +139,6 @@ if ( ! function_exists('quotes_to_entities'))
*
* http://www.some-site.com/index.php
*
- * @access public
* @param string
* @return string
*/
@@ -153,7 +146,7 @@ if ( ! function_exists('reduce_double_slashes'))
{
function reduce_double_slashes($str)
{
- return preg_replace("#(^|[^:])//+#", "\\1/", $str);
+ return preg_replace('#(^|[^:])//+#', '\\1/', $str);
}
}
@@ -170,7 +163,6 @@ if ( ! function_exists('reduce_double_slashes'))
*
* Fred, Bill, Joe, Jimmy
*
- * @access public
* @param string
* @param string the character you wish to reduce
* @param bool TRUE/FALSE - whether to trim the character from the beginning/end
@@ -184,7 +176,7 @@ if ( ! function_exists('reduce_multiples'))
if ($trim === TRUE)
{
- $str = trim($str, $character);
+ return trim($str, $character);
}
return $str;
@@ -198,9 +190,8 @@ if ( ! function_exists('reduce_multiples'))
*
* Useful for generating passwords or hashes.
*
- * @access public
* @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
- * @param integer number of characters
+ * @param int number of characters
* @return string
*/
if ( ! function_exists('random_string'))
@@ -227,9 +218,9 @@ if ( ! function_exists('random_string'))
case 'nozero' : $pool = '123456789';
break;
}
-
+
$str = substr(str_shuffle(str_repeat($pool, ceil($len/strlen($pool)))),0,$len);
-
+
return $str;
break;
case 'unique' :
@@ -254,16 +245,19 @@ if ( ! function_exists('random_string'))
/**
* Add's _1 to a string or increment the ending number to allow _2, _3, etc
*
- * @param string $str required
- * @param string $separator What should the duplicate number be appended with
- * @param string $first Which number should be used for the first dupe increment
- * @return string
+ * @param string 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)
+if ( ! function_exists('increment_string'))
{
- preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
+ function increment_string($str, $separator = '_', $first = 1)
+ {
+ preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
- return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+ return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+ }
}
// ------------------------------------------------------------------------
@@ -271,9 +265,8 @@ function increment_string($str, $separator = '_', $first = 1)
/**
* Alternator
*
- * Allows strings to be alternated. See docs...
+ * Allows strings to be alternated. See docs...
*
- * @access public
* @param string (as many parameters as needed)
* @return string
*/
@@ -298,19 +291,17 @@ if ( ! function_exists('alternator'))
/**
* Repeater function
*
- * @access public
* @param string
- * @param integer number of repeats
+ * @param int number of repeats
* @return string
*/
if ( ! function_exists('repeater'))
{
function repeater($data, $num = 1)
{
- return (($num > 0) ? str_repeat($data, $num) : '');
+ return ($num > 0) ? str_repeat($data, $num) : '';
}
}
-
/* End of file string_helper.php */
/* Location: ./system/helpers/string_helper.php */ \ No newline at end of file
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 842a31d75..cc501c334 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Text Helpers
*
@@ -44,9 +42,8 @@
*
* Limits a string to X number of words.
*
- * @access public
* @param string
- * @param integer
+ * @param int
* @param string the end character. Usually an ellipsis
* @return string
*/
@@ -78,9 +75,8 @@ if ( ! function_exists('word_limiter'))
* Limits the string based on the character count. Preserves complete words
* so the character count may not be exactly as specified.
*
- * @access public
* @param string
- * @param integer
+ * @param int
* @param string the end character. Usually an ellipsis
* @return string
*/
@@ -121,7 +117,6 @@ if ( ! function_exists('character_limiter'))
*
* Converts High ascii text and MS Word special characters to character entities
*
- * @access public
* @param string
* @return string
*/
@@ -182,7 +177,6 @@ if ( ! function_exists('ascii_to_entities'))
*
* Converts character entities back to ASCII
*
- * @access public
* @param string
* @param bool
* @return string
@@ -240,7 +234,6 @@ if ( ! function_exists('entities_to_ascii'))
* matched words will be converted to #### or to the replacement
* word you've submitted.
*
- * @access public
* @param string the text string
* @param string the array of censoered words
* @param string the optional replacement value
@@ -286,7 +279,6 @@ if ( ! function_exists('word_censor'))
*
* Colorizes code strings
*
- * @access public
* @param string the text string
* @return string
*/
@@ -300,9 +292,9 @@ if ( ! function_exists('highlight_code'))
// Replace any existing PHP tags to temporary markers so they don't accidentally
// break the string out of PHP, and thus, thwart the highlighting.
-
$str = str_replace(array('<?', '?>', '<%', '%>', '\\', '</script>'),
- array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str);
+ array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ $str);
// The highlight_string function requires that the text be surrounded
// by PHP tags, which we will remove later
@@ -311,25 +303,15 @@ if ( ! function_exists('highlight_code'))
// All the magic happens here, baby!
$str = highlight_string($str, TRUE);
- // Prior to PHP 5, the highligh function used icky <font> tags
- // so we'll replace them with <span> tags.
-
- if (abs(PHP_VERSION) < 5)
- {
- $str = str_replace(array('<font ', '</font>'), array('<span ', '</span>'), $str);
- $str = preg_replace('#color="(.*?)"#', 'style="color: \\1"', $str);
- }
-
// Remove our artificially added PHP, and the syntax highlighting that came with it
$str = preg_replace('/<span style="color: #([A-Z0-9]+)">&lt;\?php(&nbsp;| )/i', '<span style="color: #$1">', $str);
$str = preg_replace('/(<span style="color: #[A-Z0-9]+">.*?)\?&gt;<\/span>\n<\/span>\n<\/code>/is', "$1</span>\n</span>\n</code>", $str);
$str = preg_replace('/<span style="color: #[A-Z0-9]+"\><\/span>/i', '', $str);
// Replace our markers back to PHP tags.
- $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
- array('&lt;?', '?&gt;', '&lt;%', '%&gt;', '\\', '&lt;/script&gt;'), $str);
-
- return $str;
+ return str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ array('&lt;?', '?&gt;', '&lt;%', '%&gt;', '\\', '&lt;/script&gt;'),
+ $str);
}
}
@@ -340,7 +322,6 @@ if ( ! function_exists('highlight_code'))
*
* Highlights a phrase within a text string
*
- * @access public
* @param string the text string
* @param string the phrase you'd like to highlight
* @param string the openging tag to precede the phrase with
@@ -370,7 +351,6 @@ if ( ! function_exists('highlight_phrase'))
/**
* Convert Accented Foreign Characters to ASCII
*
- * @access public
* @param string the text string
* @return string
*/
@@ -378,7 +358,7 @@ if ( ! function_exists('convert_accented_characters'))
{
function convert_accented_characters($str)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
}
@@ -405,9 +385,8 @@ if ( ! function_exists('convert_accented_characters'))
* Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
* will URLs.
*
- * @access public
* @param string the text string
- * @param integer the number of characters to wrap at
+ * @param int the number of characters to wrap at
* @return string
*/
if ( ! function_exists('word_wrap'))
@@ -507,11 +486,11 @@ if ( ! function_exists('word_wrap'))
*
* This function will strip tags from a string, split it at its max_length and ellipsize
*
- * @param string string to ellipsize
- * @param integer max length of string
- * @param mixed int (1|0) or float, .5, .2, etc for position to split
- * @param string ellipsis ; Default '...'
- * @return string ellipsized string
+ * @param string string to ellipsize
+ * @param int max length of string
+ * @param mixed int (1|0) or float, .5, .2, etc for position to split
+ * @param string ellipsis ; Default '...'
+ * @return string ellipsized string
*/
if ( ! function_exists('ellipsize'))
{
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index c49348e6a..7a3db5d6b 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Typography Helpers
*
@@ -42,7 +40,6 @@
/**
* Convert newlines to HTML line breaks except within PRE tags
*
- * @access public
* @param string
* @return string
*/
@@ -61,8 +58,6 @@ if ( ! function_exists('nl2br_except_pre'))
/**
* Auto Typography Wrapper Function
*
- *
- * @access public
* @param string
* @param bool whether to allow javascript event handlers
* @param bool whether to reduce multiple instances of double newlines to two
@@ -86,7 +81,6 @@ if ( ! function_exists('auto_typography'))
*
* This function is a replacement for html_entity_decode()
*
- * @access public
* @param string
* @param string
* @return string
@@ -101,4 +95,4 @@ if ( ! function_exists('entity_decode'))
}
/* End of file typography_helper.php */
-/* Location: ./system/helpers/typography_helper.php */
+/* Location: ./system/helpers/typography_helper.php */ \ No newline at end of file
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 2cbcd9dbf..5576c2748 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter URL Helpers
*
@@ -45,7 +43,6 @@
* Create a local URL based on your basepath. Segments can be passed via the
* first parameter either as a string or an array.
*
- * @access public
* @param string
* @return string
*/
@@ -67,8 +64,7 @@ if ( ! function_exists('site_url'))
* 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.
*
- * @access public
- * @param string
+ * @param string
* @return string
*/
if ( ! function_exists('base_url'))
@@ -88,7 +84,6 @@ if ( ! function_exists('base_url'))
* Returns the full URL (including segments) of the page where this
* function is placed
*
- * @access public
* @return string
*/
if ( ! function_exists('current_url'))
@@ -106,7 +101,6 @@ if ( ! function_exists('current_url'))
*
* Returns the URI segments.
*
- * @access public
* @return string
*/
if ( ! function_exists('uri_string'))
@@ -125,7 +119,6 @@ if ( ! function_exists('uri_string'))
*
* Returns the "index_page" from your config file
*
- * @access public
* @return string
*/
if ( ! function_exists('index_page'))
@@ -144,7 +137,6 @@ if ( ! function_exists('index_page'))
*
* Creates an anchor based on the local URL.
*
- * @access public
* @param string the URL
* @param string the link title
* @param mixed any attributes
@@ -158,7 +150,7 @@ if ( ! function_exists('anchor'))
if ( ! is_array($uri))
{
- $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
+ $site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri);
}
else
{
@@ -187,7 +179,6 @@ if ( ! function_exists('anchor'))
* Creates an anchor based on the local URL. The link
* opens a new window based on the attributes specified.
*
- * @access public
* @param string the URL
* @param string the link title
* @param mixed any attributes
@@ -198,7 +189,7 @@ if ( ! function_exists('anchor_popup'))
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
$title = (string) $title;
- $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
+ $site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri);
if ($title == '')
{
@@ -207,7 +198,7 @@ if ( ! function_exists('anchor_popup'))
if ($attributes === FALSE)
{
- return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";
+ return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title.'</a>';
}
if ( ! is_array($attributes))
@@ -217,7 +208,7 @@ if ( ! function_exists('anchor_popup'))
foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
{
- $atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
+ $atts[$key] = isset($attributes[$key]) ? $attributes[$key] : $val;
unset($attributes[$key]);
}
@@ -226,7 +217,7 @@ if ( ! function_exists('anchor_popup'))
$attributes = _parse_attributes($attributes);
}
- return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
+ return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"".$attributes.'>'.$title.'</a>';
}
}
@@ -235,7 +226,6 @@ if ( ! function_exists('anchor_popup'))
/**
* Mailto Link
*
- * @access public
* @param string the email address
* @param string the link title
* @param mixed any attributes
@@ -263,7 +253,6 @@ if ( ! function_exists('mailto'))
*
* Create a spam-protected mailto link written in Javascript
*
- * @access public
* @param string the email address
* @param string the link title
* @param mixed any attributes
@@ -373,10 +362,9 @@ if ( ! function_exists('safe_mailto'))
*
* 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
+ * URLs or emails that end in a period. We'll strip these
* off and add them after the link.
*
- * @access public
* @param string the string
* @param string the type: email, url, or both
* @param bool whether to create pop-up links
@@ -440,7 +428,6 @@ if ( ! function_exists('auto_link'))
*
* Simply adds the http:// part if no scheme is included
*
- * @access public
* @param string the URL
* @return string
*/
@@ -470,39 +457,35 @@ if ( ! function_exists('prep_url'))
* Create URL Title
*
* Takes a "title" string as input and creates a
- * human-friendly URL string with either a dash
- * or an underscore as the word separator.
+ * human-friendly URL string with a "separator" string
+ * as the word separator.
*
- * @access public
* @param string the string
- * @param string the separator: dash, or underscore
+ * @param string the separator
+ * @param bool
* @return string
*/
if ( ! function_exists('url_title'))
{
- function url_title($str, $separator = 'dash', $lowercase = FALSE)
+ function url_title($str, $separator = '-', $lowercase = FALSE)
{
if ($separator === 'dash')
{
- $search = '_';
- $replace = '-';
+ $separator = '-';
}
- else
+ elseif ($separator === 'underscore')
{
- $search = '-';
- $replace = '_';
+ $separator = '_';
}
+ $q_separator = preg_quote($separator);
+
$trans = array(
- '&\#\d+?;' => '',
- '&\S+?;' => '',
- '\s+' => $replace,
- '[^a-z0-9\-\._]' => '',
- $replace.'+' => $replace,
- $replace.'$' => $replace,
- '^'.$replace => $replace,
- '\.+$' => ''
- );
+ '&.+?;' => '',
+ '[^a-z0-9 _-]' => '',
+ '\s+' => $separator,
+ '('.$q_separator.')+' => $separator
+ );
$str = strip_tags($str);
foreach ($trans as $key => $val)
@@ -515,7 +498,7 @@ if ( ! function_exists('url_title'))
$str = strtolower($str);
}
- return trim(trim(stripslashes($str)), $replace);
+ return trim(trim($str, $separator));
}
}
@@ -528,7 +511,6 @@ if ( ! function_exists('url_title'))
* For very fine grained control over headers, you could use the Output
* Library's set_header() function.
*
- * @access public
* @param string the URL
* @param string the method: location or refresh
* @return string
@@ -568,7 +550,6 @@ if ( ! function_exists('redirect'))
*
* Some of the functions use this
*
- * @access private
* @param array
* @param bool
* @return string
@@ -587,15 +568,15 @@ if ( ! function_exists('_parse_attributes'))
{
if ($javascript == TRUE)
{
- $att .= $key . '=' . $val . ',';
+ $att .= $key.'='.$val.',';
}
else
{
- $att .= ' ' . $key . '="' . $val . '"';
+ $att .= ' '.$key.'="'.$val.'"';
}
}
- if ($javascript == TRUE AND $att != '')
+ if ($javascript == TRUE && $att != '')
{
return substr($att, 0, -1);
}
@@ -605,4 +586,4 @@ if ( ! function_exists('_parse_attributes'))
}
/* End of file url_helper.php */
-/* Location: ./system/helpers/url_helper.php */
+/* Location: ./system/helpers/url_helper.php */ \ No newline at end of file
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 5242193ac..67fd34b97 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter XML Helpers
*
@@ -42,8 +40,8 @@
/**
* Convert Reserved XML characters to Entities
*
- * @access public
* @param string
+ * @param bool
* @return string
*/
if ( ! function_exists('xml_convert'))
@@ -54,11 +52,11 @@ if ( ! function_exists('xml_convert'))
// Replace entities to temporary markers so that
// ampersands won't get messed up
- $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
+ $str = preg_replace('/&#(\d+);/', $temp.'\\1;', $str);
if ($protect_all == TRUE)
{
- $str = preg_replace('/&(\w+);/', "$temp\\1;", $str);
+ $str = preg_replace('/&(\w+);/', $temp.'\\1;', $str);
}
$str = str_replace(array('&', '<', '>', '"', "'", '-'),
@@ -66,11 +64,11 @@ if ( ! function_exists('xml_convert'))
$str);
// Decode the temp markers back to entities
- $str = preg_replace('/$temp(\d+);/', '&#\\1;', $str);
+ $str = preg_replace('/'.$temp.'(\d+);/', '&#\\1;', $str);
if ($protect_all == TRUE)
{
- return preg_replace("/$temp(\w+);/", '&\\1;', $str);
+ return preg_replace('/'.$temp.'(\w+);/', '&\\1;', $str);
}
return $str;
@@ -78,4 +76,4 @@ if ( ! function_exists('xml_convert'))
}
/* End of file xml_helper.php */
-/* Location: ./system/helpers/xml_helper.php */
+/* Location: ./system/helpers/xml_helper.php */ \ No newline at end of file