function publish_css($user, $chart) { $cdn_files = array(); $static_path = get_static_path($chart); $data = get_chart_content($chart, $user, false, '../'); $all = ''; foreach ($data['stylesheets'] as $css) { $all .= file_get_contents(ROOT_PATH . 'www' . $css) . "\n\n"; } // move @imports to top of file $imports = array(); $body = ""; $lines = explode("\n", $all); foreach ($lines as $line) { if (substr($line, 0, 7) == '@import') { $imports[] = $line; } else { $body .= $line . "\n"; } } $all = implode("\n", $imports) . "\n\n" . $body; $cssmin = new CSSmin(); $minified = $all; //$cssmin->run($all); disabled minification file_put_contents($static_path . "/" . $chart->getID() . '.all.css', $minified); $cdn_files[] = array($static_path . "/" . $chart->getID() . '.all.css', $chart->getCDNPath() . $chart->getID() . '.all.css', 'text/css'); // copy themes assets $theme = $data['theme']; if (isset($theme['assets'])) { foreach ($theme['assets'] as $asset) { $asset_src = '../../www/' . $theme['__static_path'] . '/' . $asset; $asset_tgt = $static_path . "/" . $asset; if (file_exists($asset_src)) { file_put_contents($asset_tgt, file_get_contents($asset_src)); $cdn_files[] = array($asset_src, $chart->getCDNPath() . $asset); } } } // copy visualization assets $vis = $data['visualization']; $assets = DatawrapperVisualization::assets($vis['id'], $chart); foreach ($assets as $asset) { $asset_src = ROOT_PATH . 'www/static/' . $asset; $asset_tgt = $static_path . '/assets/' . $asset; create_missing_directories($asset_tgt); copy($asset_src, $asset_tgt); $cdn_files[] = array($asset_src, $chart->getCDNPath() . 'assets/' . $asset); } return $cdn_files; }