summaryrefslogtreecommitdiffstats
path: root/system/helpers/url_helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers/url_helper.php')
-rw-r--r--system/helpers/url_helper.php112
1 files changed, 59 insertions, 53 deletions
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 '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -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 "<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]);
+ }
+
+ if ($attributes != '')
+ {
+ $attributes = _parse_attributes($attributes);
}
- return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\">".$title."</a>";
+ return "<a href='javascript:void(0);' onclick=\"window.open('".$site_url."', '_blank', '"._parse_attributes($atts, TRUE)."');\"$attributes>".$title."</a>";
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -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 '<a href="mailto:'.$email.'"'.$attributes.'>'.$title.'</a>';
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -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('<a href="mailto:', $i, 1);
}
-
+
for ($i = 0; $i < strlen($email); $i++)
{
$x[] = "|".ord(substr($email, $i, 1));
@@ -289,21 +295,21 @@ if ( ! function_exists('safe_mailto'))
}
}
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 @@ if ( ! function_exists('safe_mailto'))
{
$count = ($ordinal < 224) ? 2 : 3;
}
-
+
$temp[] = $ordinal;
if (count($temp) == $count)
{
@@ -325,12 +331,12 @@ if ( ! function_exists('safe_mailto'))
}
}
}
-
+
$x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>';
-
+
$x = array_reverse($x);
ob_start();
-
+
?><script type="text/javascript">
//<![CDATA[
var l=new Array();
@@ -349,7 +355,7 @@ if ( ! function_exists('safe_mailto'))
return $buffer;
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -371,11 +377,11 @@ if ( ! function_exists('auto_link'))
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 @@ if ( ! function_exists('auto_link'))
$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 ( ! function_exists('auto_link'))
}
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 @@ if ( ! function_exists('auto_link'))
$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 @@ if ( ! function_exists('prep_url'))
{
return '';
}
-
+
if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
{
$str = 'http://'.$str;
}
-
+
return $str;
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -477,7 +483,7 @@ if ( ! function_exists('url_title'))
$search = '-';
$replace = '_';
}
-
+
$trans = array(
'&\#\d+?;' => '',
'&\S+?;' => '',
@@ -489,16 +495,16 @@ if ( ! function_exists('url_title'))
);
$str = strip_tags($str);
-
+
foreach ($trans as $key => $val)
{
$str = preg_replace("#".$key."#i", $val, $str);
}
-
+
return trim(stripslashes($str));
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -527,7 +533,7 @@ if ( ! function_exists('redirect'))
exit;
}
}
-
+
// ------------------------------------------------------------------------
/**
@@ -561,12 +567,12 @@ if ( ! function_exists('_parse_attributes'))
$att .= ' ' . $key . '="' . $val . '"';
}
}
-
+
if ($javascript == TRUE AND $att != '')
{
$att = substr($att, 0, -1);
}
-
+
return $att;
}
}