From 42597a107d799fa86ebc706bf8cbac4f9471d08c Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Wed, 15 Oct 2008 14:10:44 +0000 Subject: Added support for arbitrary attributes in anchor_popup() of the URL helper. --- system/helpers/url_helper.php | 112 ++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 53 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 002090df1..744295f4c 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -36,7 +36,7 @@ * @access public * @param string * @return string - */ + */ if ( ! function_exists('site_url')) { function site_url($uri = '') @@ -55,7 +55,7 @@ if ( ! function_exists('site_url')) * * @access public * @return string - */ + */ if ( ! function_exists('base_url')) { function base_url() @@ -75,7 +75,7 @@ if ( ! function_exists('base_url')) * * @access public * @return string - */ + */ if ( ! function_exists('current_url')) { function current_url() @@ -89,11 +89,11 @@ if ( ! function_exists('current_url')) /** * URL String * - * Returns the URI segments. + * Returns the URI segments. * * @access public * @return string - */ + */ if ( ! function_exists('uri_string')) { function uri_string() @@ -112,7 +112,7 @@ if ( ! function_exists('uri_string')) * * @access public * @return string - */ + */ if ( ! function_exists('index_page')) { function index_page() @@ -121,7 +121,7 @@ if ( ! function_exists('index_page')) return $CI->config->item('index_page'); } } - + // ------------------------------------------------------------------------ /** @@ -134,13 +134,13 @@ if ( ! function_exists('index_page')) * @param string the link title * @param mixed any attributes * @return string - */ + */ if ( ! function_exists('anchor')) { function anchor($uri = '', $title = '', $attributes = '') { $title = (string) $title; - + if ( ! is_array($uri)) { $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri; @@ -149,7 +149,7 @@ if ( ! function_exists('anchor')) { $site_url = site_url($uri); } - + if ($title == '') { $title = $site_url; @@ -163,7 +163,7 @@ if ( ! function_exists('anchor')) return ''.$title.''; } } - + // ------------------------------------------------------------------------ /** @@ -181,35 +181,41 @@ if ( ! function_exists('anchor')) 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; - + if ($title == '') { $title = $site_url; } - + if ($attributes === FALSE) { return "".$title.""; } - + if ( ! is_array($attributes)) { $attributes = array(); } - + 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]; + unset($attributes[$key]); + } + + if ($attributes != '') + { + $attributes = _parse_attributes($attributes); } - return "".$title.""; + return "".$title.""; } } - + // ------------------------------------------------------------------------ /** @@ -226,18 +232,18 @@ if ( ! function_exists('mailto')) function mailto($email, $title = '', $attributes = '') { $title = (string) $title; - + if ($title == "") { $title = $email; } - + $attributes = _parse_attributes($attributes); - + return ''.$title.''; } } - + // ------------------------------------------------------------------------ /** @@ -256,17 +262,17 @@ if ( ! function_exists('safe_mailto')) function safe_mailto($email, $title = '', $attributes = '') { $title = (string) $title; - + if ($title == "") { $title = $email; } - + for ($i = 0; $i < 16; $i++) { $x[] = substr('