Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'support/4.x' of github.com:netzmacht/contao-theme-plus …
Browse files Browse the repository at this point in the history
…into support/4.x
  • Loading branch information
dmolineus committed Nov 24, 2016
2 parents 8ebfb34 + cd738c4 commit 31349fd
Showing 1 changed file with 58 additions and 3 deletions.
61 changes: 58 additions & 3 deletions src/Bit3/Contao/ThemePlus/ThemePlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ class ThemePlus
*/
private static $instance = null;

/**
* @var array
*/
private $contaoCssFiles = array();

/**
* @var array
*/
private $contaoUserCssFiles = array();

/**
* @var array
*/
private $contaoJavascriptFiles = array();

/**
* Get the singleton instance.
Expand Down Expand Up @@ -950,7 +964,18 @@ protected function parseStylesheets(\LayoutModel $layout, array &$sr)
$GLOBALS['TL_FRAMEWORK_CSS'] = array();

// Add the internal style sheets
if (is_array($GLOBALS['TL_CSS']) && !empty($GLOBALS['TL_CSS'])) {
if (!empty($this->contaoCssFiles) && is_array($this->contaoCssFiles)) {
$this->addAssetsToCollectionFromArray(
$this->contaoCssFiles,
'css',
true,
$collection,
$stylesheets,
$defaultFilters
);
}

if (!empty($GLOBALS['TL_CSS']) && is_array($GLOBALS['TL_CSS'])) {
$this->addAssetsToCollectionFromArray(
$GLOBALS['TL_CSS'],
'css',
Expand All @@ -959,11 +984,24 @@ protected function parseStylesheets(\LayoutModel $layout, array &$sr)
$stylesheets,
$defaultFilters
);

$this->contaoCssFiles = array_merge($this->contaoCssFiles, $GLOBALS['TL_CSS']);
}
$GLOBALS['TL_CSS'] = array();

// Add the user style sheets
if (is_array($GLOBALS['TL_USER_CSS']) && !empty($GLOBALS['TL_USER_CSS'])) {
if (!empty($this->contaoUserCssFiles)) {
$this->addAssetsToCollectionFromArray(
$this->contaoUserCssFiles,
'css',
true,
$collection,
$stylesheets,
$defaultFilters
);
}

if (!empty($GLOBALS['TL_USER_CSS']) && is_array($GLOBALS['TL_USER_CSS'])) {
$this->addAssetsToCollectionFromArray(
array_unique($GLOBALS['TL_USER_CSS']),
'css',
Expand All @@ -972,6 +1010,8 @@ protected function parseStylesheets(\LayoutModel $layout, array &$sr)
$stylesheets,
$defaultFilters
);

$this->contaoUserCssFiles = array_merge($this->contaoUserCssFiles, $GLOBALS['TL_USER_CSS']);
}
$GLOBALS['TL_USER_CSS'] = array();

Expand Down Expand Up @@ -1140,7 +1180,19 @@ protected function parseJavaScripts(\LayoutModel $layout, array &$sr)
$collection = new AssetCollection(array(), array(), TL_ROOT);

// Add the internal scripts
if (is_array($GLOBALS['TL_JAVASCRIPT']) && !empty($GLOBALS['TL_JAVASCRIPT'])) {
if (!empty($this->contaoJavascriptFiles) && is_array($this->contaoJavascriptFiles)) {
$this->addAssetsToCollectionFromArray(
$this->contaoJavascriptFiles,
'js',
false,
$collection,
$javascripts,
$defaultFilters,
$layout->theme_plus_default_javascript_position
);
}

if (!empty($GLOBALS['TL_JAVASCRIPT']) && is_array($GLOBALS['TL_JAVASCRIPT'])) {
$this->addAssetsToCollectionFromArray(
$GLOBALS['TL_JAVASCRIPT'],
'js',
Expand All @@ -1150,7 +1202,10 @@ protected function parseJavaScripts(\LayoutModel $layout, array &$sr)
$defaultFilters,
$layout->theme_plus_default_javascript_position
);

$this->contaoJavascriptFiles = array_merge($this->contaoJavascriptFiles, $GLOBALS['TL_JAVASCRIPT']);
}

$GLOBALS['TL_JAVASCRIPT'] = array();

// Add layout files
Expand Down

0 comments on commit 31349fd

Please sign in to comment.