You are here

function ctools_css_store in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/css.inc \ctools_css_store()

Store CSS with a given id and return the filename to use.

This function associates a piece of CSS with an id, and stores the cached filename and the actual CSS for later use with ctools_css_retrieve.

3 calls to ctools_css_store()
CtoolsCssTestCase::testCssStoreFilterRetrieve in tests/css.test
Test that Stored CSS snippets can be retrieved, filtered or otherwise.
CtoolsCssTestCase::testCssStoreOverwrite in tests/css.test
Test that Stored CSS snippets can be correctly overwritten.
ctools_stylizer_build_style in includes/stylizer.inc
Build the files for a stylizer given the proper settings.

File

includes/css.inc, line 68
CSS filtering functions. Contains a disassembler, filter, compressor, and decompressor.

Code

function ctools_css_store($id, $css, $filter = TRUE) {
  $filename = db_query('SELECT filename FROM {ctools_css_cache} WHERE cid = :cid', array(
    ':cid' => $id,
  ))
    ->fetchField();
  if ($filename && file_exists($filename)) {
    file_unmanaged_delete($filename);
  }

  // Remove any previous records.
  db_delete('ctools_css_cache')
    ->condition('cid', $id)
    ->execute();
  $filename = ctools_css_cache($css, $filter);
  db_merge('ctools_css_cache')
    ->key(array(
    'cid' => $id,
  ))
    ->fields(array(
    'filename' => $filename,
    'css' => $css,
    'filter' => intval($filter),
  ))
    ->execute();
  return $filename;
}