From efed3b6eafb1e24fcf0476313d9100a4ab2b6aeb Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 21 Sep 2011 23:03:58 -0500 Subject: [PATCH] added comments to html class. --- laravel/html.php | 51 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/laravel/html.php b/laravel/html.php index 1007a335..5a8aa7bc 100644 --- a/laravel/html.php +++ b/laravel/html.php @@ -16,7 +16,15 @@ public static function entities($value) } /** - * Generate a JavaScript reference. + * Generate a link to a JavaScript file. + * + * + * // Generate a link to a JavaScript file + * echo HTML::script('js/jquery.js'); + * + * // Generate a link to a JavaScript file and add some attributes + * echo HTML::script('js/jquery.js', array('defer')); + * * * @param string $url * @param array $attributes @@ -30,10 +38,18 @@ public static function script($url, $attributes = array()) } /** - * Generate a CSS reference. + * Generate a link to a CSS file. * * If no media type is selected, "all" will be used. * + * + * // Generate a link to a CSS file + * echo HTML::style('css/common.css'); + * + * // Generate a link to a CSS file and add some attributes + * echo HTML::style('css/common.css', array('media' => 'print')); + * + * * @param string $url * @param array $attributes * @return string @@ -62,6 +78,14 @@ public static function span($value, $attributes = array()) /** * Generate a HTML link. * + * + * // Generate a link to a location within the application + * echo HTML::link('user/profile', 'User Profile'); + * + * // Generate a link to a location outside of the application + * echo HTML::link('http://google.com', 'Google'); + * + * * @param string $url * @param string $title * @param array $attributes @@ -122,6 +146,14 @@ public static function link_to_secure_asset($url, $title, $attributes = array()) * * An array of parameters may be specified to fill in URI segment wildcards. * + * + * // Generate a link to the "profile" named route + * echo HTML::link_to_route('profile', 'Profile'); + * + * // Generate a link to the "profile" route and add some parameters + * echo HTML::link_to_route('profile', 'Profile', array('taylor')); + * + * * @param string $name * @param string $title * @param array $parameters @@ -248,7 +280,7 @@ public static function attributes($attributes) { $html = array(); - foreach ($attributes as $key => $value) + foreach ((array) $attributes as $key => $value) { // Assume numeric-keyed attributes to have the same key and value. // Example: required="required", autofocus="autofocus", etc. @@ -269,7 +301,7 @@ public static function attributes($attributes) * @param string $value * @return string */ - public static function obfuscate($value) + protected static function obfuscate($value) { $safe = ''; @@ -300,6 +332,17 @@ public static function obfuscate($value) * Magic Method for handling dynamic static methods. * * This method primarily handles dynamic calls to create links to named routes. + * + * + * // Generate a link to the "profile" named route + * echo HTML::link_to_profile('Profile'); + * + * // Generate a link to the "profile" route and add some parameters + * echo HTML::link_to_profile('Profile', array('taylor')); + * + * // Generate a link to the "profile" named route using HTTPS + * echo HTML::link_to_secure_profile('Profile'); + * */ public static function __callStatic($method, $parameters) {