diff --git a/system/html.php b/system/html.php index f92a0e6a..89968130 100644 --- a/system/html.php +++ b/system/html.php @@ -76,6 +76,34 @@ class HTML { return static::link($url, $title, $attributes, false, true); } + /** + * Generate an HTML link to a route. + * + * @param string $name + * @param string $title + * @param array $parameters + * @param array $attributes + * @return string + */ + public static function link_to_route($name, $title, $parameters = array(), $attributes = array(), $https = false) + { + return static::link(URL::to_route($name, $parameters, $https), $title, $attributes); + } + + /** + * Generate an HTTPS HTML link to a route. + * + * @param string $name + * @param string $title + * @param array $parameters + * @param array $attributes + * @return string + */ + public static function link_to_secure_route($name, $title, $parameters = array(), $attributes = array()) + { + return static::link_to_route($name, $title, $parameters, $attributes, true); + } + /** * Generate an HTML mailto link. * @@ -250,4 +278,28 @@ class HTML { return $safe; } + /** + * Magic Method for handling dynamic static methods. + */ + public static function __callStatic($method, $parameters) + { + // ------------------------------------------------------- + // Handle the dynamic creation of links to secure routes. + // ------------------------------------------------------- + if (strpos($method, 'link_to_secure_') === 0) + { + array_unshift($parameters, substr($method, 15)); + 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) + { + array_unshift($parameters, substr($method, 8)); + return forward_static_call_array('HTML::link_to_route', $parameters); + } + } + } \ No newline at end of file