/** * Constructor. * * Load the assets config file, and inserts the base * css and js into our array for later use. This ensures * that these files will be processed first, in the order * the user is expecting, prior to and later-added files. * * @access public * @return void */ public function __construct() { $this->ci =& get_instance(); $this->ci->config->load('assets'); $this->ci->config->load('assets_js'); $this->ci->config->load('assets_css'); $this->styles_default = $this->ci->config->item('assets_css_default'); $this->external_scripts_default = $this->ci->config->item('assets_js_default'); $this->assets_css_group = $this->ci->config->item('assets_css_group'); $this->assets_js_group = $this->ci->config->item('assets_js_group'); // Setup our host $this->host = $this->ci->config->item('asset_host'); $this->host = empty($this->host) ? base_url() : $this->host; $this->combine = $this->ci->config->item('combine_on_' . devmode()); }
/** * _external_js function. * * This private method does the actual work of generating the * links to the js files. It is called by the js() method. * * @access private * @param mixed $js. (default: null) * @return void */ private function _external_js($js = null) { if (!is_array($js)) { return; } $path = $this->ci->config->item('asset_folder') . $this->ci->config->item('js_folder') . '/'; // If development mode, then render individual links, // else create a link to the combine.php file. if ($this->ci->config->item('combine_on_' . devmode()) === false) { foreach ($js as $script) { echo '<script type="text/javascript" src="' . $this->host . $path . $script . '.js" ></script>' . "\n"; } } else { // For test and production modes $files = implode('.js,', $js); $files = $files . '.js'; echo '<script type="text/javascript" href="/combine.php?type=javascript&files=' . $files . '" />'; } }