public function ParseMaster::add in Advanced CSS/JS Aggregation 6
Same name and namespace in other branches
- 8.4 advagg_js_minify/jspacker.inc \ParseMaster::add()
- 8.2 advagg_js_minify/jspacker.inc \ParseMaster::add()
- 8.3 advagg_js_minify/jspacker.inc \ParseMaster::add()
- 7.2 advagg_js_compress/jspacker.inc \ParseMaster::add()
- 7 advagg_js_compress/jspacker.inc \ParseMaster::add()
File
- advagg_js_compress/
jspacker.inc, line 579
Class
Code
public function add($expression, $replacement = '') {
// count the number of sub-expressions
// - add one because each pattern is itself a sub-expression
$length = 1 + preg_match_all($this->GROUPS, $this
->_internalEscape((string) $expression), $out);
// treat only strings $replacement
if (is_string($replacement)) {
// does the pattern deal with sub-expressions?
if (preg_match($this->SUB_REPLACE, $replacement)) {
// a simple lookup? (e.g. "$2")
if (preg_match($this->INDEXED, $replacement)) {
// store the index (used for fast retrieval of matched strings)
$replacement = (int) substr($replacement, 1) - 1;
}
else {
// a complicated lookup (e.g. "Hello $2 $1")
// build a function to do the lookup
$quote = preg_match($this->QUOTE, $this
->_internalEscape($replacement)) ? '"' : "'";
$replacement = array(
'fn' => '_backReferences',
'data' => array(
'replacement' => $replacement,
'length' => $length,
'quote' => $quote,
),
);
}
}
}
// pass the modified arguments
if (!empty($expression)) {
$this
->_add($expression, $replacement, $length);
}
else {
$this
->_add('/^$/', $replacement, $length);
}
}