コード例 #1
0
 public function templateData($context, $context_2 = '')
 {
     $ret = RsmlOut::templateData($context);
     if (!$this->hasAttribute('replace')) {
         if ($context == RsmlNode::CTX_TEMPLATE) {
             $ret = '<span id="' . $this->idAttribute(RsmlNode::CTX_PLAIN) . '">' . $ret . '</span>';
         } else {
             if ($context == RsmlNode::CTX_FUNCTION_ARGUMENT) {
                 $ret = '\'<span id="' . $this->idAttribute(RsmlNode::CTX_PLAIN) . '">\'.' . $ret . '.\'</span>\'';
             } else {
                 if ($context == RsmlNode::CTX_INLINE && $context_2 != RsmlNode::CTX_ARRAY_ARGUMENT) {
                     $ret = '<span id="' . $this->idAttribute(RsmlNode::CTX_PLAIN) . '">' . $ret . '</span>';
                 }
             }
         }
     }
     return $ret;
 }
コード例 #2
0
 /**
  * Get an attribute, processing it for the given context if necessary
  */
 public function attribute($name, $context = RsmlNode::CTX_PLAIN)
 {
     $keys = array_keys($this->attributes);
     $cont = '';
     foreach ($keys as $key => $el) {
         if ($el == $name || $el == 'out:' . $name) {
             $cont = $el;
         }
     }
     if (!$cont) {
         throw new InvalidAttributeException('Tried to get non-existent attribute: ' . $name . ' in RsmlNode');
     }
     $split = explode(':', $cont);
     if (count($split) > 1) {
         if ($split[0] != 'out') {
             throw new InvalidAttributeException('The only supported namespace tag in RSML is out');
         }
         $data = $this->attributes[$cont];
         $node = new RsmlOut(array(), $data);
         $value = $node->templateData($context);
         $name = $split[1];
     } else {
         $value = $this->attributes[$cont];
         $name = $cont;
         if ($context == RsmlNode::CTX_FUNCTION_ARGUMENT || $context == RsmlNode::CTX_ARRAY_ARGUMENT) {
             $value = '\'' . $value . '\'';
         }
     }
     switch ($context) {
         case RsmlNode::CTX_TEMPLATE:
         case RsmlNode::CTX_INLINE:
             $ret = $name . '="' . $value . '"';
             break;
         case RsmlNode::CTX_PLAIN:
         case RsmlNode::CTX_FUNCTION_ARGUMENT:
             $ret = $value;
             break;
         case RsmlNode::CTX_ARRAY_ARGUMENT:
             $ret = '\'' . $name . '\' => ' . $value;
             break;
     }
     return $ret;
 }