protected function parseParameterValue($value, $locals, $isFinalPass = false) { $dataparam = null; // $deferable = false; if (substr($value, 0, 1) == '%' && substr($value, -1) == '%' && strpos(substr($value, 1, -1), '%') === false) { $paramval = 'Data:' . substr($value, 1, -1); $dataparam = substr($value, 1, -1); } else { $paramval = $value; if (strpos($paramval, 'Data:') === 0) { $dataparam = substr($paramval, 5); } elseif (strpos($paramval, 'Global:') === 0) { $dataparam = substr($paramval, 7); if (!$isFinalPass) { throw new DeferralException('Deferred condition due to parameter: ' . $value); } //$deferable = true; } } if (strlen($dataparam) >= 3 && strpos($dataparam, '%') !== false) { $dataparam = $this->parseFormatVariables($dataparam, $locals, $isFinalPass); } if ($dataparam != null) { if (array_key_exists($dataparam, $locals)) { return $locals[$dataparam]; } elseif (array_key_exists($dataparam, $this->getConstants())) { return $this->getConstant($dataparam); } elseif (substr($value, 0, 6) == 'Random') { return rand(1, intVal(substr($value, 6))); } elseif (strpos($dataparam, '.') !== false) { $parts = explode('.', $dataparam); if (!empty($parts)) { $broken = true; $array = $locals; foreach ($parts as $name) { if (isset($array[$name])) { $array = $array[$name]; $broken = false; } else { $broken = true; break; } } if (!$broken) { return $array; } // else if(!$isFinalPass && $deferable) { // throw new DeferralException('Deferred condition due to parameter: '.$value); // } } } // elseif(!$isFinalPass && $deferable) // defer me // throw new DeferralException('Deferred condition due to parameter: '.$value); return ''; } if (count($split = explode('?', $value, 2)) == 2) { list($method, $args) = $split; $nvps = explode('&', html_entity_decode($args, ENT_QUOTES)); foreach ($nvps as $param) { $split = explode('=', $param, 2); if ($split === FALSE || count($split) == 1) { throw new Exception('Bad NVP in condition: ' . $value); } list($name, $v) = $split; $params[$name] = $this->parseParameterValue($v, $locals, $isFinalPass); } return $this->handleFilter($method, $params, $locals); } $val = StringUtils::trimOnce($value, "'"); if (strlen($val) >= 4 && strpos($val, '%') !== false) { $val = $this->parseFormatVariables($val, $locals, $isFinalPass); } return $val; //return trim_once($value, "'"); }