Skip to content

Commit

Permalink
Updating HTML helper for 3.1 URL::base() changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiall committed Jan 15, 2011
1 parent 465527d commit 7bd187b
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions classes/kohana/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,17 @@ public static function entities($value, $double_encode = TRUE)
*
* echo HTML::anchor('/user/profile', 'My Profile');
*
* @param string URL or URI string
* @param string link text
* @param array HTML anchor attributes
* @param mixed text based protocol, or request object to use for protocol
* @param string URL or URI string
* @param string link text
* @param array HTML anchor attributes
* @param mixed protocol to pass to URL::base()
* @param boolean include the index page
* @return string
* @uses URL::base
* @uses URL::site
* @uses HTML::attributes
*/
public static function anchor($uri, $title = NULL, array $attributes = NULL, $protocol = NULL)
public static function anchor($uri, $title = NULL, array $attributes = NULL, $protocol = NULL, $index = FALSE)
{
if ($title === NULL)
{
Expand All @@ -108,7 +109,7 @@ public static function anchor($uri, $title = NULL, array $attributes = NULL, $pr
if ($uri === '')
{
// Only use the base URL
$uri = URL::base(FALSE, $protocol);
$uri = URL::base($protocol, $index);
}
else
{
Expand Down Expand Up @@ -142,12 +143,13 @@ public static function anchor($uri, $title = NULL, array $attributes = NULL, $pr
* @param string name of file to link to
* @param string link text
* @param array HTML anchor attributes
* @param string non-default protocol, eg: ftp
* @param mixed protocol to pass to URL::base()
* @param boolean include the index page
* @return string
* @uses URL::base
* @uses HTML::attributes
*/
public static function file_anchor($file, $title = NULL, array $attributes = NULL, $protocol = NULL)
public static function file_anchor($file, $title = NULL, array $attributes = NULL, $protocol = NULL, $index = FALSE)
{
if ($title === NULL)
{
Expand All @@ -156,7 +158,7 @@ public static function file_anchor($file, $title = NULL, array $attributes = NUL
}

// Add the file link to the attributes
$attributes['href'] = URL::base(FALSE, $protocol).$file;
$attributes['href'] = URL::base($protocol, $index).$file;

return '<a'.HTML::attributes($attributes).'>'.$title.'</a>';
}
Expand Down Expand Up @@ -247,19 +249,20 @@ public static function mailto($email, $title = NULL, array $attributes = NULL)
*
* echo HTML::style('media/css/screen.css');
*
* @param string file name
* @param array default attributes
* @param string file name
* @param array default attributes
* @param mixed protocol to pass to URL::base()
* @param boolean include the index page
* @return string
* @uses URL::base
* @uses HTML::attributes
*/
public static function style($file, array $attributes = NULL, $index = FALSE)
public static function style($file, array $attributes = NULL, $protocol = NULL, $index = FALSE)
{
if (strpos($file, '://') === FALSE)
{
// Add the base URL
$file = URL::base($index).$file;
$file = URL::base($protocol, $index).$file;
}

// Set the stylesheet link
Expand All @@ -281,17 +284,18 @@ public static function style($file, array $attributes = NULL, $index = FALSE)
*
* @param string file name
* @param array default attributes
* @param mixed protocol to pass to URL::base()
* @param boolean include the index page
* @return string
* @uses URL::base
* @uses HTML::attributes
*/
public static function script($file, array $attributes = NULL, $index = FALSE)
public static function script($file, array $attributes = NULL, $protocol = NULL, $index = FALSE)
{
if (strpos($file, '://') === FALSE)
{
// Add the base URL
$file = URL::base($index).$file;
$file = URL::base($protocol, $index).$file;
}

// Set the script link
Expand All @@ -310,16 +314,18 @@ public static function script($file, array $attributes = NULL, $index = FALSE)
*
* @param string file name
* @param array default attributes
* @param mixed protocol to pass to URL::base()
* @param boolean include the index page
* @return string
* @uses URL::base
* @uses HTML::attributes
*/
public static function image($file, array $attributes = NULL, $index = FALSE)
public static function image($file, array $attributes = NULL, $protocol = NULL, $index = FALSE)
{
if (strpos($file, '://') === FALSE)
{
// Add the base URL
$file = URL::base($index).$file;
$file = URL::base($protocol, $index).$file;
}

// Add the image link
Expand Down

0 comments on commit 7bd187b

Please sign in to comment.