/** * Parses an argument list and returns the keys and values in an associative * array. * * @param string $tagArgs * @param string $tag * @return array */ public function parseTagArgs($tagArgs, $tag) { // replace strings $tagArgs = $this->replaceQuotes($tagArgs); // validate tag arguments if (!preg_match('~^(?:\s+\w+\s*=\s*[^=]*(?=\s|$))*$~s', $tagArgs)) { throw new SystemException($this->formatSyntaxError('syntax error in tag {'.$tag.'}', $this->currentIdentifier, $this->currentLineNo)); } // parse tag arguments $matches = array(); // find all variables preg_match_all('~\s+(\w+)\s*=\s*([^=]*)(?=\s|$)~s', $tagArgs, $matches); $args = array(); for ($i = 0, $j = count($matches[1]); $i < $j; $i++) { $name = $matches[1][$i]; $string = $this->compileVariableTag($matches[2][$i], false); // reinserts strings foreach (StringStack::getStack('singleQuote') as $hash => $value) { if (StringUtil::indexOf($string, $hash) !== false) { $string = StringUtil::replace($hash, $value, $string); } } foreach (StringStack::getStack('doubleQuote') as $hash => $value) { if (StringUtil::indexOf($string, $hash) !== false) { $string = StringUtil::replace($hash, $value, $string); } } $args[$name] = $string; } // clear stack $this->reinsertQuotes(''); return $args; }