You are here

function csstidy_optimise::subvalue in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg_css_compress/csstidy/class.csstidy_optimise.inc \csstidy_optimise::subvalue()

Optimises a sub-value @access public @version 1.0

File

advagg_css_compress/csstidy/class.csstidy_optimise.inc, line 162

Class

csstidy_optimise
CSS Optimising Class

Code

function subvalue() {
  $replace_colors =& $GLOBALS['csstidy']['replace_colors'];
  $this->sub_value = trim($this->sub_value);
  if ($this->sub_value == '') {

    // caution : '0'
    return;
  }
  $important = '';
  if (csstidy::is_important($this->sub_value)) {
    $important = '!important';
  }
  $this->sub_value = csstidy::gvw_important($this->sub_value);

  // Compress font-weight
  if ($this->property === 'font-weight' && $this->parser
    ->get_cfg('compress_font-weight')) {
    if ($this->sub_value === 'bold') {
      $this->sub_value = '700';
      $this->parser
        ->log('Optimised font-weight: Changed "bold" to "700"', 'Information');
    }
    else {
      if ($this->sub_value === 'normal') {
        $this->sub_value = '400';
        $this->parser
          ->log('Optimised font-weight: Changed "normal" to "400"', 'Information');
      }
    }
  }
  $temp = $this
    ->compress_numbers($this->sub_value);
  if (strcasecmp($temp, $this->sub_value) !== 0) {
    if (strlen($temp) > strlen($this->sub_value)) {
      $this->parser
        ->log('Fixed invalid number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning');
    }
    else {
      $this->parser
        ->log('Optimised number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information');
    }
    $this->sub_value = $temp;
  }
  if ($this->parser
    ->get_cfg('compress_colors')) {
    $temp = $this
      ->cut_color($this->sub_value);
    if ($temp !== $this->sub_value) {
      if (isset($replace_colors[$this->sub_value])) {
        $this->parser
          ->log('Fixed invalid color name: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning');
      }
      else {
        $this->parser
          ->log('Optimised color: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information');
      }
      $this->sub_value = $temp;
    }
  }
  $this->sub_value .= $important;
}