[-] Core: add possibility to choose the position of your css files

This commit is contained in:
Rémi Gaillard committed 2013-11-13 15:31:29 +01:00
1 parent f7e1229e16
commit 2fe12b965b
2 files changed
+20 -23

No files matched your search

+2 -2
View File
@@ -1940,8 +1940,8 @@ class AdminControllerCore extends Controller
{ {
$admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_); $admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_);
$admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath); $admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath);
$this->addCSS(__PS_BASE_URI__.$admin_webpath.'/themes/'.$this->bo_theme.'/css/backward-admin-bootstrap-reset.css', 'all'); $this->addCSS(__PS_BASE_URI__.$admin_webpath.'/themes/'.$this->bo_theme.'/css/backward-admin-bootstrap-reset.css', 'all', 1);
$this->addCSS(__PS_BASE_URI__.$admin_webpath.'/themes/'.$this->bo_theme.'/css/backward-admin-old.css', 'all'); $this->addCSS(__PS_BASE_URI__.$admin_webpath.'/themes/'.$this->bo_theme.'/css/backward-admin-old.css', 'all', 1);
} }
public function setMedia() public function setMedia()
+18 -21
View File
@@ -233,29 +233,26 @@ abstract class ControllerCore
* @param string $css_media_type * @param string $css_media_type
* @return true * @return true
*/ */
public function addCSS($css_uri, $css_media_type = 'all') public function addCSS($css_uri, $css_media_type = 'all', $offset = null)
{ {
if (is_array($css_uri)) if (!is_array($css_uri))
foreach ($css_uri as $css_file => $media) $css_uri = array($css_uri);
{
if (is_string($css_file) && strlen($css_file) > 1) foreach ($css_uri as $css_file => $media)
{
$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 (is_string($css_file) && strlen($css_file) > 1)
if ($css_path) $css_path = Media::getCSSPath($css_file, $media);
$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))
{
$size = count($this->css_files);
if ($offset === null || $offset > $size || $offset < 0 || !is_numeric($offset))
$offset = $size;
$this->css_files = array_merge(array_slice($this->css_files, 0, $offset), $css_path, array_slice($this->css_files, $offset));
}
} }
} }