method cssLinks documentation in bbn\Cdn\Compiler
Returns a javascript string including css files.
function(array $files, $test = false, $prepend_files = [], $root = '')
{
$code = '';
$num_files = \count($files);
if ($num_files) {
$dirs = [];
$prepended = [];
$unprepended = [];
$dir = null;
foreach ($files as $f) {
if (!is_file($this->fpath . $f)) {
throw new \Exception(X::_("Impossible to find the file %s", $this->fpath . $f));
}
$tmp = X::dirname($f);
if (is_null($dir)) {
$dir = $tmp . '/';
}
elseif (strpos($dir, $tmp) !== 0) {
$old_tmp = null;
while ($tmp = X::dirname($tmp) && ($tmp !== $old_tmp)) {
$old_tmp = $tmp;
if ($tmp === $dir) {
break;
}
}
if ($tmp !== $dir) {
$bits = \bbn\X::split(X::dirname($f), '/');
$new_dir = '';
foreach ($bits as $b) {
if (!empty($b)) {
if (strpos($dir, $new_dir . $b) === 0) {
$new_dir .= $b . '/';
}
else {
$dir = $new_dir ?: '.';
break;
}
}
}
}
}
if (isset($prepend_files[$f])) {
foreach ($prepend_files[$f] as $p) {
if (!in_array($p, $prepended)) {
$prepended[] = $p;
}
}
}
}
if (count($prepended)) {
foreach (array_reverse($prepended) as $p) {
array_unshift($files, $p);
}
}
foreach ($files as $ar) {
$files_json[] = str_replace($dir, '', $ar);
}
$files_json = json_encode($files_json);
$url = $this->furl . '~~~BBN~~~';
$params = [];
// The v parameter is passed between requests (to refresh)
if (!empty($this->cfg['params']['v'])) {
$params['v'] = $this->cfg['params']['v'];
}
// The test parameter also (for minification)
if ($test) {
$params['test'] = 1;
}
$url .= http_build_query($params);
$jsdir = $dir;
$code .= <<getContent($file, false);
if ($this->hasLinks($css)) {
if ($root) {
if (!isset($dirs[$root])) {
$dirs[$root] = [];
}
$dirs[$root][] = substr($file, strlen($root));
}
else {
if (!isset($dirs[X::dirname($file)])) {
$dirs[X::dirname($file)] = [];
}
$dirs[X::dirname($file)][] = X::basename($file);
}
}
else {
if (!isset($dirs['.'])) {
$dirs['.'] = [];
}
$dirs['.'][] = $file;
}
}
if (\count($dirs)) {
foreach ($dirs as $dir => $dfiles) {
if (\count($dfiles)) {
$files_json = json_encode($dfiles);
$url = $this->furl . '~~~BBN~~~';
$params = [];
// The v parameter is passed between requests (to refresh)
if (!empty($this->cfg['params']['v'])) {
$params['v'] = $this->cfg['params']['v'];
}
// The test parameter also (for minification)
if ($test) {
$params['test'] = 1;
}
$url .= http_build_query($params);
$jsdir = $dir === '.' ? '' : $dir . '/';
$code .= <<minify($code, 'js');
}
}
}
return $code;
}
Returns a javascript string including css files. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions