Added support for arbitrary attributes in anchor_popup() of the URL helper.
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 002090d..744295f 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 @@
  *

  * @access	public

  * @return	string

- */	

+ */

 if ( ! function_exists('base_url'))

 {

 	function base_url()

@@ -75,7 +75,7 @@
  *

  * @access	public

  * @return	string

- */	

+ */

 if ( ! function_exists('current_url'))

 {

 	function current_url()

@@ -89,11 +89,11 @@
 /**

  * 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 @@
  *

  * @access	public

  * @return	string

- */	

+ */

 if ( ! function_exists('index_page'))

 {

 	function index_page()

@@ -121,7 +121,7 @@
 		return $CI->config->item('index_page');

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -134,13 +134,13 @@
  * @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 @@
 		{

 			$site_url = site_url($uri);

 		}

-	

+

 		if ($title == '')

 		{

 			$title = $site_url;

@@ -163,7 +163,7 @@
 		return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -181,35 +181,41 @@
 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 "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank');\">".$title."</a>";

 		}

-	

+

 		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]);

 		}

 

-		return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\">".$title."</a>";

+		if ($attributes != '')

+		{

+			$attributes = _parse_attributes($attributes);

+		}

+

+		return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -226,18 +232,18 @@
 	function mailto($email, $title = '', $attributes = '')

 	{

 		$title = (string) $title;

-	

+

 		if ($title == "")

 		{

 			$title = $email;

 		}

-	

+

 		$attributes = _parse_attributes($attributes);

-	

+

 		return '<a href="mailto:'.$email.'"'.$attributes.'>'.$title.'</a>';

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -256,17 +262,17 @@
 	function safe_mailto($email, $title = '', $attributes = '')

 	{

 		$title = (string) $title;

-	

+

 		if ($title == "")

 		{

 			$title = $email;

 		}

-					

+

 		for ($i = 0; $i < 16; $i++)

 		{

 			$x[] = substr('<a href="mailto:', $i, 1);

 		}

-	

+

 		for ($i = 0; $i < strlen($email); $i++)

 		{

 			$x[] = "|".ord(substr($email, $i, 1));

@@ -289,21 +295,21 @@
 				}

 			}

 			else

-			{	

+			{

 				for ($i = 0; $i < strlen($attributes); $i++)

 				{

 					$x[] = substr($attributes, $i, 1);

 				}

 			}

-		}	

-	

+		}

+

 		$x[] = '>';

-	

+

 		$temp = array();

 		for ($i = 0; $i < strlen($title); $i++)

 		{

 			$ordinal = ord($title[$i]);

-	

+

 			if ($ordinal < 128)

 			{

 				$x[] = "|".$ordinal;

@@ -314,7 +320,7 @@
 				{

 					$count = ($ordinal < 224) ? 2 : 3;

 				}

-		

+	

 				$temp[] = $ordinal;

 				if (count($temp) == $count)

 				{

@@ -325,12 +331,12 @@
 				}

 			}

 		}

-	

+

 		$x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>';

-	

+

 		$x = array_reverse($x);

 		ob_start();

-	

+

 	?><script type="text/javascript">

 	//<![CDATA[

 	var l=new Array();

@@ -349,7 +355,7 @@
 		return $buffer;

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -371,11 +377,11 @@
 	function auto_link($str, $type = 'both', $popup = FALSE)

 	{

 		if ($type != 'email')

-		{		

+		{

 			if (preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches))

 			{

 				$pop = ($popup == TRUE) ? " target=\"_blank\" " : "";

-		

+	

 				for ($i = 0; $i < sizeof($matches['0']); $i++)

 				{

 					$period = '';

@@ -384,7 +390,7 @@
 						$period = '.';

 						$matches['6'][$i] = substr($matches['6'][$i], 0, -1);

 					}

-			

+		

 					$str = str_replace($matches['0'][$i],

 										$matches['1'][$i].'<a href="http'.

 										$matches['4'][$i].'://'.

@@ -399,7 +405,7 @@
 		}

 

 		if ($type != 'url')

-		{	

+		{

 			if (preg_match_all("/([a-zA-Z0-9_\.\-\+Å]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))

 			{

 				for ($i = 0; $i < sizeof($matches['0']); $i++)

@@ -410,16 +416,16 @@
 						$period = '.';

 						$matches['3'][$i] = substr($matches['3'][$i], 0, -1);

 					}

-			

+		

 					$str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str);

 				}

-		

 			}

 		}

+

 		return $str;

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -439,16 +445,16 @@
 		{

 			return '';

 		}

-	

+

 		if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')

 		{

 			$str = 'http://'.$str;

 		}

-	

+

 		return $str;

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -477,7 +483,7 @@
 			$search		= '-';

 			$replace	= '_';

 		}

-		

+

 		$trans = array(

 						'&\#\d+?;'				=> '',

 						'&\S+?;'				=> '',

@@ -489,16 +495,16 @@
 					  );

 

 		$str = strip_tags($str);

-	

+

 		foreach ($trans as $key => $val)

 		{

 			$str = preg_replace("#".$key."#i", $val, $str);

 		}

-	

+

 		return trim(stripslashes($str));

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -527,7 +533,7 @@
 		exit;

 	}

 }

-	

+

 // ------------------------------------------------------------------------

 

 /**

@@ -561,12 +567,12 @@
 				$att .= ' ' . $key . '="' . $val . '"';

 			}

 		}

-	

+

 		if ($javascript == TRUE AND $att != '')

 		{

 			$att = substr($att, 0, -1);

 		}

-	

+

 		return $att;

 	}

 }