added asset links and improved html class.

This commit is contained in:
Taylor Otwell
2011-06-16 21:25:24 -05:00
parent 868a33fb9c
commit bf44ce81d7
2 changed files with 47 additions and 24 deletions

View File

@@ -6,9 +6,11 @@ class URL {
* Generate an application URL.
*
* @param string $url
* @param bool $https
* @param bool $asset
* @return string
*/
public static function to($url = '', $https = false)
public static function to($url = '', $https = false, $asset = false)
{
// ----------------------------------------------------
// Return the URL unchanged if it is already formed.
@@ -21,7 +23,17 @@ class URL {
// ----------------------------------------------------
// Get the base URL and index page.
// ----------------------------------------------------
$base = Config::get('application.url').'/'.Config::get('application.index');
$base = Config::get('application.url');
// ----------------------------------------------------
// Assets live in the public directory, so we don't
// want to append the index file to the URL if the
// URL is to an asset.
// ----------------------------------------------------
if ( ! $asset)
{
$base .= '/'.Config::get('application.index');
}
// ----------------------------------------------------
// Does the URL need an HTTPS protocol?
@@ -45,6 +57,18 @@ class URL {
return static::to($url, true);
}
/**
* Generate an application URL to an asset. The index file
* will not be added to the URL.
*
* @param string $url
* @return string
*/
public static function to_asset($url)
{
return static::to($url, false, true);
}
/**
* Generate a URL from a route name.
*