function parse_asset($matches) { $id = ''; $passthrough = array(); $if = false; if ($matches[1] === 'settings') { global $final_path; $file = 'settings.css.lens'; if ($final_path === 'lightbox.lens') { if (!file_exists(Koken::$template_path . '/css/lightbox-settings.css.lens')) { return ''; } $file = 'lightbox-' . $file; } $path = Koken::$location['root_folder'] . '/' . (Koken::$draft ? 'preview.php?/' : (Koken::$rewrite ? '' : 'index.php?/')) . $file . (Koken::$preview ? '&preview=' . Koken::$preview : ''); $info = array('extension' => 'css'); $id = ' id="koken_settings_css_link"'; } else { preg_match_all('/([a-z_]+)="([^"]+)"/', $matches[1], $params); foreach ($params[1] as $i => $name) { $value = $params[2][$i]; if ($name === 'file') { $file = $value; } else { if ($name === 'common') { $common = $value; } else { if ($name === 'if') { $if = str_replace('settings.', '', $value); } else { $passthrough[] = "{$name}=\"{$value}\""; } } } } $info = pathinfo($file); if (strpos($file, 'http') === 0) { $path = $file; } else { if (isset($common) && $common) { $path = '/app/site/themes/common/' . $info['extension'] . '/' . $file; $buster = KOKEN_VERSION; if (!file_exists(Koken::$root_path . $path)) { return ''; } $path = Koken::$location['real_root_folder'] . $path . '?' . $buster; } else { $path = Koken::get_path($file, true); if (!$path) { return ''; } $buster = Koken::$site['theme']['version']; } } } if (count($passthrough)) { $parameters = ' ' . join(' ', $passthrough); } else { $parameters = ''; } if ($if && !Koken::$settings[$if]) { return ''; } if (!isset($info['extension'])) { $info['extension'] = strpos($path, 'css') === false ? 'js' : 'css'; } if ($info['extension'] == 'css' || $info['extension'] == 'less') { return "<link{$id} rel=\"stylesheet\" type=\"text/{$info['extension']}\" href=\"{$path}\"{$parameters} />"; } else { if ($info['extension'] == 'js') { return "<script src=\"{$path}\"{$parameters}></script>"; } else { if (in_array($info['extension'], array('jpeg', 'jpg', 'gif', 'png'))) { return "<img src=\"{$path}\"{$parameters} />"; } else { if ($info['extension'] === 'svg') { return "<embed src=\"{$path}\" type=\"image/svg+xml\"{$parameters} />"; } } } } }