Upgrade to CodeIgniter 2.0.3

This commit is contained in:
Eike Foken
2011-09-13 19:15:50 +02:00
parent 8dd1099e04
commit a8c2551be2
53 changed files with 1949 additions and 578 deletions

View File

@@ -58,13 +58,13 @@ if ( ! function_exists('force_download'))
$extension = end($x);
// Load the mime types
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
elseif (is_file(APPPATH.'config/mimes'.EXT))
elseif (is_file(APPPATH.'config/mimes.php'))
{
include(APPPATH.'config/mimes'.EXT);
include(APPPATH.'config/mimes.php');
}
// Set a default mime if we can't find it

View File

@@ -352,13 +352,13 @@ if ( ! function_exists('get_mime_by_extension'))
if ( ! is_array($mimes))
{
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
elseif (is_file(APPPATH.'config/mimes'.EXT))
elseif (is_file(APPPATH.'config/mimes.php'))
{
include(APPPATH.'config/mimes'.EXT);
include(APPPATH.'config/mimes.php');
}
if ( ! is_array($mimes))

View File

@@ -72,7 +72,7 @@ if ( ! function_exists('form_open'))
if (is_array($hidden) AND count($hidden) > 0)
{
$form .= sprintf("\n<div class=\"hidden\">%s</div>", form_hidden($hidden));
$form .= sprintf("<div style=\"display:none\">%s</div>", form_hidden($hidden));
}
return $form;
@@ -1032,25 +1032,23 @@ if ( ! function_exists('_get_validation_object'))
{
$CI =& get_instance();
// We set this as a variable since we're returning by reference
// We set this as a variable since we're returning by reference.
$return = FALSE;
if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation']))
if (FALSE !== ($object = $CI->load->is_loaded('form_validation')))
{
return $return;
if ( ! isset($CI->$object) OR ! is_object($CI->$object))
{
return $return;
}
return $CI->$object;
}
$object = $CI->load->_ci_classes['form_validation'];
if ( ! isset($CI->$object) OR ! is_object($CI->$object))
{
return $return;
}
return $CI->$object;
return $return;
}
}
/* End of file form_helper.php */
/* Location: ./system/helpers/form_helper.php */
/* Location: ./system/helpers/form_helper.php */

View File

@@ -40,9 +40,10 @@
*/
if ( ! function_exists('heading'))
{
function heading($data = '', $h = '1')
function heading($data = '', $h = '1', $attributes = '')
{
return "<h".$h.">".$data."</h".$h.">";
$attributes = ($attributes != '') ? ' '.$attributes : $attributes;
return "<h".$h.$attributes.">".$data."</h".$h.">";
}
}
@@ -123,6 +124,10 @@ if ( ! function_exists('_list'))
}
$attributes = $atts;
}
elseif (is_string($attributes) AND strlen($attributes) > 0)
{
$attributes = ' '. $attributes;
}
// Write the opening list tag
$out .= "<".$type.$attributes.">\n";
@@ -258,13 +263,13 @@ if ( ! function_exists('doctype'))
if ( ! is_array($_doctypes))
{
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT))
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT);
include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php');
}
elseif (is_file(APPPATH.'config/doctypes'.EXT))
elseif (is_file(APPPATH.'config/doctypes.php'))
{
include(APPPATH.'config/doctypes'.EXT);
include(APPPATH.'config/doctypes.php');
}
if ( ! is_array($_doctypes))

View File

@@ -41,30 +41,48 @@ if ( ! function_exists('singular'))
{
function singular($str)
{
$str = trim($str);
$end = substr($str, -3);
$str = preg_replace('/(.*)?([s|c]h)es/i','$1$2',$str);
if (strtolower($end) == 'ies')
{
$str = substr($str, 0, strlen($str)-3).(preg_match('/[a-z]/',$end) ? 'y' : 'Y');
}
elseif (strtolower($end) == 'ses')
{
$str = substr($str, 0, strlen($str)-2);
}
else
{
$end = strtolower(substr($str, -1));
$result = strval($str);
if ($end == 's')
$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',
'/((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',
);
foreach ($singular_rules as $rule => $replacement)
{
if (preg_match($rule, $result))
{
$str = substr($str, 0, strlen($str)-1);
$result = preg_replace($rule, $replacement, $result);
break;
}
}
return $str;
return $result;
}
}
@@ -83,40 +101,41 @@ if ( ! function_exists('singular'))
if ( ! function_exists('plural'))
{
function plural($str, $force = FALSE)
{
$str = trim($str);
$end = substr($str, -1);
{
$result = strval($str);
$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',
);
if (preg_match('/y/i',$end))
foreach ($plural_rules as $rule => $replacement)
{
// Y preceded by vowel => regular plural
$vowels = array('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U');
$str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies';
}
elseif (preg_match('/h/i',$end))
{
if(preg_match('/^[c|s]h$/i',substr($str, -2)))
if (preg_match($rule, $result))
{
$str .= 'es';
$result = preg_replace($rule, $replacement, $result);
break;
}
else
{
$str .= 's';
}
}
elseif (preg_match('/s/i',$end))
{
if ($force == TRUE)
{
$str .= 'es';
}
}
else
{
$str .= 's';
}
return $str;
return $result;
}
}

View File

@@ -229,13 +229,13 @@ if ( ! function_exists('_get_smiley_array'))
{
function _get_smiley_array()
{
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT))
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT);
include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
}
elseif (file_exists(APPPATH.'config/smileys'.EXT))
elseif (file_exists(APPPATH.'config/smileys.php'))
{
include(APPPATH.'config/smileys'.EXT);
include(APPPATH.'config/smileys.php');
}
if (isset($smileys) AND is_array($smileys))

View File

@@ -366,13 +366,13 @@ if ( ! function_exists('convert_accented_characters'))
{
function convert_accented_characters($str)
{
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT))
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT);
include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
}
elseif (is_file(APPPATH.'config/foreign_chars'.EXT))
elseif (is_file(APPPATH.'config/foreign_chars.php'))
{
include(APPPATH.'config/foreign_chars'.EXT);
include(APPPATH.'config/foreign_chars.php');
}
if ( ! isset($foreign_characters))

View File

@@ -50,18 +50,21 @@ if ( ! function_exists('site_url'))
/**
* Base URL
*
* Returns the "base_url" item from your config file
*
* Create a local URL based on your basepath.
* Segments can be passed in as a string or an array, same as site_url
* or a URL to a file can be passed in, e.g. to an image file.
*
* @access public
* @param string
* @return string
*/
if ( ! function_exists('base_url'))
{
function base_url()
function base_url($uri = '')
{
$CI =& get_instance();
return $CI->config->slash_item('base_url');
return $CI->config->base_url($uri);
}
}