Refactoring the html class.
This commit is contained in:
parent
d1934b731e
commit
5862faf2c4
|
@ -34,12 +34,11 @@ public static function script($url, $attributes = array())
|
||||||
*/
|
*/
|
||||||
public static function style($url, $attributes = array())
|
public static function style($url, $attributes = array())
|
||||||
{
|
{
|
||||||
if ( ! array_key_exists('media', $attributes))
|
if ( ! array_key_exists('media', $attributes)) $attributes['media'] = 'all';
|
||||||
{
|
|
||||||
$attributes['media'] = 'all';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<link href="'.static::entities(URL::to_asset($url)).'" rel="stylesheet" type="text/css"'.static::attributes($attributes).'>'.PHP_EOL;
|
$attributes = $attributes + array('rel' => 'stylesheet', 'type' => 'text/css');
|
||||||
|
|
||||||
|
return '<link href="'.static::entities(URL::to_asset($url)).'"'.static::attributes($attributes).'>'.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,10 +147,7 @@ public static function mailto($email, $title = null, $attributes = array())
|
||||||
{
|
{
|
||||||
$email = static::email($email);
|
$email = static::email($email);
|
||||||
|
|
||||||
if (is_null($title))
|
if (is_null($title)) $title = $email;
|
||||||
{
|
|
||||||
$title = $email;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<a href="mailto:'.$email.'"'.static::attributes($attributes).'>'.static::entities($title).'</a>';
|
return '<a href="mailto:'.$email.'"'.static::attributes($attributes).'>'.static::entities($title).'</a>';
|
||||||
}
|
}
|
||||||
|
@ -240,10 +236,7 @@ public static function attributes($attributes)
|
||||||
{
|
{
|
||||||
// Assume numeric-keyed attributes to have the same key and value.
|
// Assume numeric-keyed attributes to have the same key and value.
|
||||||
// Example: required="required", autofocus="autofocus", etc.
|
// Example: required="required", autofocus="autofocus", etc.
|
||||||
if (is_numeric($key))
|
if (is_numeric($key)) $key = $value;
|
||||||
{
|
|
||||||
$key = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! is_null($value))
|
if ( ! is_null($value))
|
||||||
{
|
{
|
||||||
|
@ -292,17 +285,17 @@ public static function obfuscate($value)
|
||||||
*/
|
*/
|
||||||
public static function __callStatic($method, $parameters)
|
public static function __callStatic($method, $parameters)
|
||||||
{
|
{
|
||||||
// Handle the dynamic creation of links to secure routes.
|
|
||||||
if (strpos($method, 'link_to_secure_') === 0)
|
if (strpos($method, 'link_to_secure_') === 0)
|
||||||
{
|
{
|
||||||
array_unshift($parameters, substr($method, 15));
|
array_unshift($parameters, substr($method, 15));
|
||||||
|
|
||||||
return forward_static_call_array('HTML::link_to_secure_route', $parameters);
|
return forward_static_call_array('HTML::link_to_secure_route', $parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the dynamic creation of links to routes.
|
|
||||||
if (strpos($method, 'link_to_') === 0)
|
if (strpos($method, 'link_to_') === 0)
|
||||||
{
|
{
|
||||||
array_unshift($parameters, substr($method, 8));
|
array_unshift($parameters, substr($method, 8));
|
||||||
|
|
||||||
return forward_static_call_array('HTML::link_to_route', $parameters);
|
return forward_static_call_array('HTML::link_to_route', $parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue