You are here

private function ParseMaster::_replacement in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 8.4 advagg_js_minify/jspacker.inc \ParseMaster::_replacement()
  2. 8.2 advagg_js_minify/jspacker.inc \ParseMaster::_replacement()
  3. 8.3 advagg_js_minify/jspacker.inc \ParseMaster::_replacement()
  4. 7.2 advagg_js_compress/jspacker.inc \ParseMaster::_replacement()
  5. 7 advagg_js_compress/jspacker.inc \ParseMaster::_replacement()

File

advagg_js_compress/jspacker.inc, line 659

Class

ParseMaster

Code

private function _replacement($arguments) {
  if (empty($arguments)) {
    return '';
  }
  $i = 1;
  $j = 0;

  // loop through the patterns
  while (isset($this->_patterns[$j])) {
    $pattern = $this->_patterns[$j++];

    // do we have a result?
    if (isset($arguments[$i]) && $arguments[$i] != '') {
      $replacement = $pattern[self::REPLACEMENT];
      if (is_array($replacement) && isset($replacement['fn'])) {
        if (isset($replacement['data'])) {
          $this->buffer = $replacement['data'];
        }
        return call_user_func(array(
          &$this,
          $replacement['fn'],
        ), $arguments, $i);
      }
      elseif (is_int($replacement)) {
        return $arguments[$replacement + $i];
      }
      $delete = $this->escapeChar == '' || strpos($arguments[$i], $this->escapeChar) === false ? '' : "\1" . $arguments[$i] . "\1";
      return $delete . $replacement;

      // skip over references to sub-expressions
    }
    else {
      $i += $pattern[self::LENGTH];
    }
  }
}