1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-22 06:03:27 +02:00

Ability to use theme.xml to define library dependencies.

This commit is contained in:
Lóna Lore
2017-03-02 20:55:31 +01:00
parent aa36466220
commit 53a7fb2fc9
8 changed files with 175 additions and 35 deletions

View File

@@ -1877,13 +1877,63 @@ class e_library_manager
$coreLib = $coreLibs[$library['machine_name']];
$library['files'] = $coreLib['files'];
$library['variants'] = $coreLib['variants'];
// Admin UI uses its own CSS.
unset($library['files']['css']);
unset($library['variants']['dev']['files']['css']);
break;
}
}
$excluded = $this->getExcludedLibraries();
if(empty($excluded))
{
return;
}
// Make sure we have the name without cdn prefix.
$basename = str_replace('cdn.', '', $library['machine_name']);
// If this library (or the CDN version of this library) is excluded
// by the theme is currently used.
if (in_array($basename, $excluded) || in_array('cdn.' . $basename, $excluded))
{
unset($library['files']['css']);
if (!empty($library['variants']))
{
foreach($library['variants'] as &$variant)
{
if(!empty($variant['files']['css']))
{
unset($variant['files']['css']);
}
}
}
}
}
/**
* Get excluded libraries.
*
* @return array
*/
public function getExcludedLibraries()
{
// This static cache is re-used by preLoad() to save memory.
static $excludedLibraries;
if(!isset($excludedLibraries))
{
$excludedLibraries = array();
$exclude = e107::getTheme('current', true)->cssAttribute('auto', 'exclude');
if($exclude)
{
// Split string into array and remove whitespaces.
$excludedLibraries = array_map('trim', explode(',', $exclude));
}
}
return $excludedLibraries;
}
}