/** * Adds the escaping formula to the specified expression using the current escaping * rules: * * 1. The $status variable. * 2. The current template settings. * 3. The OPT settings. * * @param char $modifier The modifier used to escape the expression. * @param string $expression The PHP expression to be escaped. * @param string $format The format of the expression. * @param boolean $status The status of escaping for this expression or NULL, if not set. * @return string The expression with the escaping formula added, if necessary. */ public function escape($modifier, $expression, $format, $status = null) { // OPT Configuration $escape = $this->_tpl->escape; // Template configuration if ($this->get('escaping') !== null) { $escape = $this->get('escaping') == true ? true : false; } // Expression settings if ($status !== null) { $escape = $status == true ? true : false; } // Apply the escaping subroutine defined by the modifier. if (!array_key_exists($modifier, $this->_modifiers)) { throw new Opt_InvalidExpressionModifier_Exception($modifier, $expression); } if ($escape && !empty($this->_modifiers[$modifier])) { return $this->_modifiers[$modifier] . '(' . Opt_Compiler_Utils::cast($this->_cdfManager, $expression, $format, 'Scalar') . ')'; } return $expression; }
/** * Processes an unary operator for a single expression. * * @param string $operator The PHP operator * @param SplFixedArray $expr The expression * @param int $weight The operator weight * @return SplFixedArray */ public function _unaryOperator($operator, SplFixedArray $expr, $weight) { $expr[0] = $operator . Opt_Compiler_Utils::cast($this->_manager, $expr[0], $expr[2], 'Scalar'); $expr[1] += $weight; $expr[3] = 0; return $expr; }