public function removeCSS($css_uri, $css_media_type = 'all') { if (!is_array($css_uri)) { $css_uri = array($css_uri); } foreach ($css_uri as $css_file => $media) { if (is_string($css_file) && strlen($css_file) > 1) { $css_path = Media::getCSSPath($css_file, $media); } else { $css_path = Media::getCSSPath($media, $css_media_type); } if ($css_path && isset($this->css_files[key($css_path)]) && $this->css_files[key($css_path)] == reset($css_path)) { unset($this->css_files[key($css_path)]); } } }
/** * Add a new stylesheet in page header. * * @param mixed $css_uri Path to css file, or list of css files like this : array(array(uri => media_type), ...) * @param string $css_media_type * @return true */ public function addCSS($css_uri, $css_media_type = 'all') { if (is_array($css_uri)) { foreach ($css_uri as $css_file => $media) { if (is_string($css_file) && strlen($css_file) > 1) { $css_path = Media::getCSSPath($css_file, $media); if ($css_path && !in_array($css_path, $this->css_files)) { $this->css_files = array_merge($this->css_files, $css_path); } } else { $css_path = Media::getCSSPath($media, $css_media_type); if ($css_path && !in_array($css_path, $this->css_files)) { $this->css_files = array_merge($this->css_files, $css_path); } } } } else { if (is_string($css_uri) && strlen($css_uri) > 1) { $css_path = Media::getCSSPath($css_uri, $css_media_type); if ($css_path) { $this->css_files = array_merge($this->css_files, $css_path); } } } }
/** * return jquery plugin css path if exist. * * @param mixed $name * @return string|boolean */ public static function getJqueryPluginCSSPath($name, $folder = null) { if ($folder === null) { $folder = _PS_JS_DIR_ . 'jquery/plugins/'; } //set default folder $file = 'jquery.' . $name . '.css'; $url_data = parse_url($folder); $file_uri = _PS_ROOT_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']); $file_uri_host_mode = _PS_CORE_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']); if (@file_exists($file_uri . $file) || defined('_PS_HOST_MODE_') && @file_exists($file_uri_host_mode . $file)) { return Media::getCSSPath($folder . $file); } elseif (@file_exists($file_uri . $name . '/' . $file) || defined('_PS_HOST_MODE_') && @file_exists($file_uri_host_mode . $name . '/' . $file)) { return Media::getCSSPath($folder . $name . '/' . $file); } else { return false; } }
/** * return jquery plugin css path if exist. * * @param mixed $name * @return void */ public static function getJqueryPluginCSSPath($name) { $folder = _PS_JS_DIR_ . 'jquery/plugins/'; $file = 'jquery.' . $name . '.css'; $url_data = parse_url($folder); $file_uri = _PS_ROOT_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']); if (@filemtime($file_uri . $file)) { return Media::getCSSPath($folder . $file); } elseif (@filemtime($file_uri . $name . '/' . $file)) { return Media::getCSSPath($folder . $name . '/' . $file); } else { return false; } }