You are here

function sweaver_drush_json_to_css in Sweaver 6

Same name and namespace in other branches
  1. 7 drush/sweaver.drush.inc \sweaver_drush_json_to_css()

Convert the properties which are collected by the editor.

They are saved in the database as a JSON object but all properties do not have their pre- and/or suffix on them.

Parameters

$css: A collection of properties and values configured by the editor.

Return value

$new_css CSS with pre- and suffixes.

1 call to sweaver_drush_json_to_css()
sweaver_drush_edit_style in drush/sweaver.drush.inc
Edit a style.

File

drush/sweaver.drush.inc, line 375
Sweaver Drush functions.

Code

function sweaver_drush_json_to_css($css) {
  ctools_include('css');
  $new_css = clone $css;
  $sweaver_properties = sweaver_object_load(NULL, 'property');
  foreach ($css as $selector => $properties) {
    foreach ($properties as $property => $value) {
      if (isset($sweaver_properties[$property])) {

        // Get the property.
        $sp = $sweaver_properties[$property];

        // Add prefixes and suffixes, but skip special cases.
        if ($property == 'background-color' && $value == 'transparent' || $property == 'background-image' && $value == 'none') {
          continue;
        }
        $new_value = $sp->property_prefix . $value . $sp->property_suffix;
        $new_css->{$selector}->{$property} = $new_value;
      }
    }
  }
  return ctools_css_assemble($new_css);
}