diff options
author | Derek Jones <derek.jones@ellislab.com> | 2008-01-28 22:00:20 +0100 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2008-01-28 22:00:20 +0100 |
commit | 269b942a2bf7b022795e591d9b0ad04526ee7e09 (patch) | |
tree | f465bb5a700d4cc5d72ca6e55e251640a46b869b /system/helpers/cookie_helper.php | |
parent | a25530f6594c7ba45b3faa9537fda9f807069759 (diff) |
added ability to "extend" helpers
* modified Loader to check for prefixed helpers in application/helpers folder
* surrounded provided helper functions with if (! function_exists('foo')) conditionals so the user's helper functions take precedent.
Diffstat (limited to 'system/helpers/cookie_helper.php')
-rw-r--r-- | system/helpers/cookie_helper.php | 86 |
1 files changed, 47 insertions, 39 deletions
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php index 2a4a963dd..102057f8c 100644 --- a/system/helpers/cookie_helper.php +++ b/system/helpers/cookie_helper.php @@ -42,52 +42,55 @@ * @param string the cookie prefix
* @return void
*/
-function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
+if (! function_exists('set_cookie'))
{
- if (is_array($name))
- {
- foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
- {
- if (isset($name[$item]))
+ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
+ {
+ if (is_array($name))
+ {
+ foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
{
- $$item = $name[$item];
+ if (isset($name[$item]))
+ {
+ $$item = $name[$item];
+ }
}
}
- }
- // Set the config file options
- $CI =& get_instance();
+ // Set the config file options
+ $CI =& get_instance();
- if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
- {
- $prefix = $CI->config->item('cookie_prefix');
- }
- if ($domain == '' AND $CI->config->item('cookie_domain') != '')
- {
- $domain = $CI->config->item('cookie_domain');
- }
- if ($path == '/' AND $CI->config->item('cookie_path') != '/')
- {
- $path = $CI->config->item('cookie_path');
- }
+ if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
+ {
+ $prefix = $CI->config->item('cookie_prefix');
+ }
+ if ($domain == '' AND $CI->config->item('cookie_domain') != '')
+ {
+ $domain = $CI->config->item('cookie_domain');
+ }
+ if ($path == '/' AND $CI->config->item('cookie_path') != '/')
+ {
+ $path = $CI->config->item('cookie_path');
+ }
- if ( ! is_numeric($expire))
- {
- $expire = time() - 86500;
- }
- else
- {
- if ($expire > 0)
+ if ( ! is_numeric($expire))
{
- $expire = time() + $expire;
+ $expire = time() - 86500;
}
else
{
- $expire = 0;
+ if ($expire > 0)
+ {
+ $expire = time() + $expire;
+ }
+ else
+ {
+ $expire = 0;
+ }
}
- }
- setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
+ setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
+ }
}
// --------------------------------------------------------------------
@@ -100,10 +103,13 @@ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = * @param bool
* @return mixed
*/
-function get_cookie($index = '', $xss_clean = FALSE)
+if (! function_exists('get_cookie'))
{
- $CI =& get_instance();
- return $CI->input->cookie($index, $xss_clean);
+ function get_cookie($index = '', $xss_clean = FALSE)
+ {
+ $CI =& get_instance();
+ return $CI->input->cookie($index, $xss_clean);
+ }
}
// --------------------------------------------------------------------
@@ -117,10 +123,12 @@ function get_cookie($index = '', $xss_clean = FALSE) * @param string the cookie prefix
* @return void
*/
-function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
+if (! function_exists('delete_cookie'))
{
- set_cookie($name, '', '', $domain, $path, $prefix);
+ function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
+ {
+ set_cookie($name, '', '', $domain, $path, $prefix);
+ }
}
-
?>
\ No newline at end of file |