Esempio n. 1
0
 /**
  * Processes the opt:dtd node.
  * @internal
  * @param Opt_Xml_Node $node The recognized node.
  */
 public function processNode(Opt_Xml_Node $node)
 {
     $params = array('template' => array(0 => self::OPTIONAL, self::ID, null));
     $this->_extractAttributes($node, $params);
     // TODO: Hmmm... now we have to invent, how to deal with THAT!
     if (is_null($params['template'])) {
         Opt_Compiler_Utils::removeCdata($node, false);
         $this->_process($node);
     } else {
         $root = $node;
         while (is_object($tmp = $root->getParent())) {
             $root = $tmp;
         }
         $node->set('nophp', true);
         $node->set('hidden', false);
         // Use one of the predefined DTD templates for various markup languages
         switch ($params['template']) {
             case 'xhtml10strict':
                 $dtd = new Opt_Xml_Dtd('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
                 break;
             case 'xhtml10transitional':
                 $dtd = new Opt_Xml_Dtd('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
                 break;
             case 'xhtml10frameset':
                 $dtd = new Opt_Xml_Dtd('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">');
                 break;
             case 'xhtml11':
                 $dtd = new Opt_Xml_Dtd('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">');
                 break;
             case 'html40':
             case 'html4':
                 $dtd = new Opt_Xml_Dtd('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
                 break;
             case 'html5':
                 $dtd = new Opt_Xml_Dtd('<!DOCTYPE html>');
                 break;
             default:
                 throw new Opt_InvalidValue_Exception('opt:dtd template attribute: ' . $params['template']);
         }
         if (isset($dtd)) {
             $root->setDtd($dtd);
         }
     }
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * Used on a node, it looks for the CDATA elements and disables the
  * CDATA flag on them. Moreover, it allows to disable the text entitizing.
  *
  * Note: this function is deprecated. Use Opt_Compiler_Utils::removeCdata()
  * instead.
  *
  * @deprecated
  * @param Opt_Xml_Node $node The scanned node
  * @param Boolean $noEntitize optional The entitizing flag.
  */
 public function disableCDATA(Opt_Xml_Node $node, $noEntitize = false)
 {
     Opt_Compiler_Utils::removeCdata($node, !$noEntitize);
 }