Improve asset library

This commit is contained in:
Eike Foken
2011-09-04 23:43:32 +02:00
parent 43cf335ffc
commit 5ea117aeb8
4 changed files with 194 additions and 117 deletions

View File

@@ -16,10 +16,9 @@
*/
function asset_url($type, $filename) {
$CI = &get_instance();
$CI->load->config('assets');
$CI->load->library('assets');
return $CI->config->item('base_url') . $CI->config->item('assets_folder')
. $type . '/' . $filename;
return $CI->assets->url($type, $filename);
}
/**
@@ -27,14 +26,46 @@ function asset_url($type, $filename) {
*
* @param string $type
* @param string $filename
* @param array $attributes
* @param mixed $attributes
* @return string
*/
function asset($type, $filename, $attributes = array()) {
function asset($type, $filename, $attributes = '') {
$CI = &get_instance();
$CI->load->library('asset');
$CI->load->library('assets');
return $CI->asset->load($type, $filename, $attributes);
return $CI->assets->load($type, $filename, $attributes);
}
/**
* Inserts CSS assets.
*
* @param string $filename
* @param mixed $attributes
* @return string
*/
function css_asset($filename, $attributes = '') {
return asset('css', $filename, $attributes);
}
/**
* Inserts image assets.
*
* @param string $filename
* @param mixed $attributes
* @return string
*/
function image_asset($filename, $attributes = '') {
return asset('image', $filename, $attributes);
}
/**
* Inserts javascript assets.
*
* @param string $filename
* @return string
*/
function js_asset($filename) {
return asset('js', $filename);
}
/* End of file asset_helper.php */