function __construct() { self::$ci =& get_instance(); if (function_exists('base_url')) { self::$ci->load->helper('url'); } self::$base_path = base_url('/assets/'); }
/** * Setup paths */ private static function _paths() { // Start benchmark if (self::$_enable_benchmark) { self::$_ci->benchmark->mark("Assets::paths()_start"); } // Set the assets base path self::$base_path = reduce_double_slashes(realpath(self::$assets_dir)); // Now set the assets base URL if (!self::$base_url) { self::$base_url = reduce_double_slashes(config_item('base_url') . '/' . self::$assets_dir); } else { self::$base_url = self::$base_url . self::$assets_dir; } // Auto protocol if (stripos(self::$base_url, '//') === 0) { $slash = '/'; } else { $slash = ''; } // And finally the paths and URL's to the css and js assets self::$js_path = reduce_double_slashes(self::$base_path . '/' . self::$js_dir); self::$js_url = $slash . reduce_double_slashes(self::$base_url . '/' . self::$js_dir); self::$css_path = reduce_double_slashes(self::$base_path . '/' . self::$css_dir); self::$css_url = $slash . reduce_double_slashes(self::$base_url . '/' . self::$css_dir); self::$img_path = reduce_double_slashes(self::$base_path . '/' . self::$img_dir); self::$img_url = $slash . reduce_double_slashes(self::$base_url . '/' . self::$img_dir); self::$cache_path = reduce_double_slashes(self::$base_path . '/' . self::$cache_dir); self::$cache_url = $slash . reduce_double_slashes(self::$base_url . '/' . self::$cache_dir); if (!self::$freeze) { // Check if all directories exist if (!is_dir(self::$js_path)) { if (!@mkdir(self::$js_path, 0755)) { exit('Error with JS directory.'); } } if (!is_dir(self::$css_path)) { if (!@mkdir(self::$css_path, 0755)) { exit('Error with CSS directory.'); } } if (!is_dir(self::$cache_path)) { if (!@mkdir(self::$cache_path, 0777)) { exit('Error with CACHE directory.'); } } // Try to make the cache direcory writable if (is_dir(self::$cache_path) and !is_really_writable(self::$cache_path)) { @chmod(self::$cache_path, 0777); } // If it's still not writable throw error if (!is_dir(self::$cache_path) or !is_really_writable(self::$cache_path)) { exit('Error with CACHE directory.'); } } // End benchmark if (self::$_enable_benchmark) { self::$_ci->benchmark->mark("Assets::paths()_end"); } }
/** * Setup paths * @return [type] [description] */ private static function _paths() { // Set the assets base path self::$base_path = reduce_double_slashes(realpath(self::$assets_dir)); // Now set the assets base URL self::$base_url = reduce_double_slashes(config_item('base_url') . '/' . self::$assets_dir); // And finally the paths and URL's to the css and js assets self::$js_path = reduce_double_slashes(self::$base_path . '/' . self::$js_dir); self::$js_url = reduce_double_slashes(self::$base_url . '/' . self::$js_dir); self::$css_path = reduce_double_slashes(self::$base_path . '/' . self::$css_dir); self::$css_url = reduce_double_slashes(self::$base_url . '/' . self::$css_dir); self::$img_path = reduce_double_slashes(self::$base_path . '/' . self::$img_dir); self::$img_url = reduce_double_slashes(self::$base_url . '/' . self::$img_dir); self::$cache_path = reduce_double_slashes(self::$base_path . '/' . self::$cache_dir); self::$cache_url = reduce_double_slashes(self::$base_url . '/' . self::$cache_dir); // Check if all directories exist if (!is_dir(self::$js_path)) { if (!@mkdir(self::$js_path, 0755)) { exit('Error with JS directory.'); } } if (!is_dir(self::$css_path)) { if (!@mkdir(self::$css_path, 0755)) { exit('Error with CSS directory.'); } } if (!is_dir(self::$cache_path)) { if (!@mkdir(self::$cache_path, 0777)) { exit('Error with CACHE directory.'); } } // Try to make the cache direcory writable if (is_dir(self::$cache_path) and !is_really_writable(self::$cache_path)) { @chmod(self::$cache_path, 0777); } // If it's still not writable throw error if (!is_dir(self::$cache_path) or !is_really_writable(self::$cache_path)) { exit('Error with CACHE directory.'); } }