function _css3pie_build_css3pie_css in css3pie 7.2
Same name and namespace in other branches
- 6 css3pie.module \_css3pie_build_css3pie_css()
helper function get all selectors and generates content for css file
Parameters
<type> $css:
Return value
<type> path to new created file
1 call to _css3pie_build_css3pie_css()
- css3pie_preprocess_html in ./
css3pie.module - theme preprocess to add the css file
File
- ./
css3pie.module, line 190 - css3pie.module a very simple Drupal module to implement the css3pie.com javascript to your drupal and make the css selectors configurable over ui. This module creates a real css file on drupal files folder and add them via drupal_add_css.
Code
function _css3pie_build_css3pie_css() {
$cache = cache_get(CSS3PIE_CSS_CACHE_KEY);
if (!empty($cache) && !empty($cache->data)) {
// Try to get that CSS file from ctools.
if ($filename = ctools_css_retrieve($cache->data)) {
return $filename;
}
}
// Otherwise we actually need to compute the ID of the stored CSS.
$output = '';
// invoke hook_css3pie in all modules to get the selectors
$css3pie_selectors = module_invoke_all('css3pie');
if ($css3pie_selectors) {
$show_namespaces_as_comments = variable_get('css3pie_css_comment', TRUE);
$cnt_namespaces = count($css3pie_selectors);
$i = 0;
foreach ($css3pie_selectors as $namespace => $selectors) {
$i++;
if ($show_namespaces_as_comments) {
$output .= '/* ' . $namespace . ' */' . "\n";
}
$output .= implode(', ', $selectors);
if ($i < $cnt_namespaces) {
$output .= ',' . "\n";
}
}
// Check if php wrapper mode is wanted...
if (!variable_get('css3pie_css_use_js_mode')) {
if (!variable_get('css3pie_css_use_php_wrapper', FALSE)) {
$css3library = drupal_get_library('css3pie', 'css3pie_htc');
}
else {
$css3library = drupal_get_library('css3pie', 'css3pie_php');
}
}
// get file from library array because the filename is in the key..
$css3file = '';
foreach ($css3library['js'] as $file => $options) {
$css3file = $file;
}
// @TODO: fix hard key search in array
$output .= "\n" . '{' . "\n" . ' behavior: url(' . base_path() . $css3file . ');' . "\n" . '}';
}
// Hash the CSS that is stored to generate the CTools CSS ID.
$id = md5($output);
cache_set(CSS3PIE_CSS_CACHE_KEY, $id);
// Try to get the file from CTools.
if ($filename = ctools_css_retrieve($id)) {
return $filename;
}
else {
// Otherwise store in the CTools CSS store.
return ctools_css_store($id, $output, FALSE);
}
}