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

This commit is contained in:
Rémi Gaillard
2013-11-13 15:31:29 +01:00
parent f7e1229e16
commit 2fe12b965b
2 changed files with 22 additions and 25 deletions
+19 -22
View File
@@ -233,29 +233,26 @@ abstract class ControllerCore
* @param string $css_media_type
* @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))
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)
if (!is_array($css_uri))
$css_uri = array($css_uri);
foreach ($css_uri as $css_file => $media)
{
$css_path = Media::getCSSPath($css_uri, $css_media_type);
if ($css_path)
$this->css_files = array_merge($this->css_files, $css_path);
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 && !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));
}
}
}
@@ -370,4 +367,4 @@ abstract class ControllerCore
Tools::restoreCacheSettings();
return $res;
}
}
}