Merge pull request #945 from cviebrock/html-link

Allow second param of HTML::link* methods to be null
This commit is contained in:
Dayle Rees 2012-07-31 08:39:24 -07:00
commit 01f8323420
1 changed files with 9 additions and 7 deletions

View File

@ -137,10 +137,12 @@ public static function span($value, $attributes = array())
* @param bool $https * @param bool $https
* @return string * @return string
*/ */
public static function link($url, $title, $attributes = array(), $https = null) public static function link($url, $title = null, $attributes = array(), $https = null)
{ {
$url = URL::to($url, $https); $url = URL::to($url, $https);
if (is_null($title)) $title = $url;
return '<a href="'.$url.'"'.static::attributes($attributes).'>'.static::entities($title).'</a>'; return '<a href="'.$url.'"'.static::attributes($attributes).'>'.static::entities($title).'</a>';
} }
@ -152,7 +154,7 @@ public static function link($url, $title, $attributes = array(), $https = null)
* @param array $attributes * @param array $attributes
* @return string * @return string
*/ */
public static function link_to_secure($url, $title, $attributes = array()) public static function link_to_secure($url, $title = null, $attributes = array())
{ {
return static::link($url, $title, $attributes, true); return static::link($url, $title, $attributes, true);
} }
@ -168,7 +170,7 @@ public static function link_to_secure($url, $title, $attributes = array())
* @param bool $https * @param bool $https
* @return string * @return string
*/ */
public static function link_to_asset($url, $title, $attributes = array(), $https = null) public static function link_to_asset($url, $title = null, $attributes = array(), $https = null)
{ {
$url = URL::to_asset($url, $https); $url = URL::to_asset($url, $https);
@ -183,7 +185,7 @@ public static function link_to_asset($url, $title, $attributes = array(), $https
* @param array $attributes * @param array $attributes
* @return string * @return string
*/ */
public static function link_to_secure_asset($url, $title, $attributes = array()) public static function link_to_secure_asset($url, $title = null, $attributes = array())
{ {
return static::link_to_asset($url, $title, $attributes, true); return static::link_to_asset($url, $title, $attributes, true);
} }
@ -207,7 +209,7 @@ public static function link_to_secure_asset($url, $title, $attributes = array())
* @param array $attributes * @param array $attributes
* @return string * @return string
*/ */
public static function link_to_route($name, $title, $parameters = array(), $attributes = array()) public static function link_to_route($name, $title = null, $parameters = array(), $attributes = array())
{ {
return static::link(URL::to_route($name, $parameters), $title, $attributes); return static::link(URL::to_route($name, $parameters), $title, $attributes);
} }
@ -231,7 +233,7 @@ public static function link_to_route($name, $title, $parameters = array(), $attr
* @param array $attributes * @param array $attributes
* @return string * @return string
*/ */
public static function link_to_action($action, $title, $parameters = array(), $attributes = array()) public static function link_to_action($action, $title = null, $parameters = array(), $attributes = array())
{ {
return static::link(URL::to_action($action, $parameters), $title, $attributes); return static::link(URL::to_action($action, $parameters), $title, $attributes);
} }
@ -418,7 +420,7 @@ public static function __callStatic($method, $parameters)
{ {
return call_user_func_array(static::$macros[$method], $parameters); return call_user_func_array(static::$macros[$method], $parameters);
} }
throw new \Exception("Method [$method] does not exist."); throw new \Exception("Method [$method] does not exist.");
} }